From c30f4b417683f141d03a20d17a6b172d1ea996cc Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Tue, 4 May 2021 23:42:05 +0200 Subject: [PATCH] mptcp: cleanup error path in subflow_check_data_avail() Move fallback code out of the main loop and adds some branch prediction annotations. Reviewed-by: Mat Martineau Signed-off-by: Paolo Abeni --- net/mptcp/subflow.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index bdf461caa4f2d..331a24ae6a6f0 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1109,21 +1109,12 @@ static bool subflow_check_data_avail(struct sock *ssk) status = get_mapping_status(ssk, msk); trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue)); - if (status == MAPPING_INVALID) { + if (unlikely(status == MAPPING_INVALID)) { ssk->sk_err = EBADMSG; goto fatal; } - if (status == MAPPING_DUMMY) { - __mptcp_do_fallback(msk); - skb = skb_peek(&ssk->sk_receive_queue); - subflow->map_valid = 1; - subflow->map_seq = READ_ONCE(msk->ack_seq); - subflow->map_data_len = skb->len; - subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - - subflow->ssn_offset; - subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; - return true; - } + if (unlikely(status == MAPPING_DUMMY)) + goto fallback; if (status != MAPPING_OK) goto no_data; @@ -1167,6 +1158,7 @@ static bool subflow_check_data_avail(struct sock *ssk) no_data: subflow_sched_work_if_closed(msk, ssk); return false; + fatal: /* fatal protocol error, close the socket */ /* This barrier is coupled with smp_rmb() in tcp_poll() */ @@ -1178,6 +1170,16 @@ static bool subflow_check_data_avail(struct sock *ssk) tcp_send_active_reset(ssk, GFP_ATOMIC); subflow->data_avail = 0; return false; + +fallback: + __mptcp_do_fallback(msk); + skb = skb_peek(&ssk->sk_receive_queue); + subflow->map_valid = 1; + subflow->map_seq = READ_ONCE(msk->ack_seq); + subflow->map_data_len = skb->len; + subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - subflow->ssn_offset; + subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; + return true; } bool mptcp_subflow_data_available(struct sock *sk)