Skip to content

Commit

Permalink
mptcp: cleanup error path in subflow_check_data_avail()
Browse files Browse the repository at this point in the history
Move fallback code out of the main loop and adds some
branch prediction annotations.

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Paolo Abeni authored and matttbe committed May 6, 2021
1 parent 43ae18d commit c30f4b4
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions net/mptcp/subflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() */
Expand All @@ -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)
Expand Down

0 comments on commit c30f4b4

Please sign in to comment.