History

mptcp: consolidate synack processing.

Currently the MPTCP code uses 2 hooks to process syn-ack packets, mptcp_rcv_synsent() and the sk_rx_dst_set() callback. We can drop the first, moving the relevant code into the latter, reducing the hooking into the TCP code. This is also needed by the next patch. v1 -> v2: - use local tcp sock ptr instead of casting the sk variable several times - DaveM

Paolo Abeni committed 6 years ago

Commit 263e1201 parent 30724cc4 files · +24 −29Browse files

Unified · Split

4 files
  1. include/net/mptcp.h +0 −1
  2. net/ipv4/tcp_input.c +0 −3
  3. net/mptcp/options.c +0 −22
  4. net/mptcp/subflow.c +24 −3
include/net/mptcp.h+0−1
@@ -72,7 +72,6 @@ void mptcp_parse_option(const struct sk_buff *skb, const unsigned char *ptr, · 71 unmodified lines
7272 int opsize, struct tcp_options_received *opt_rx);
7373 bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
7474 unsigned int *size, struct mptcp_out_options *opts);
75−void mptcp_rcv_synsent(struct sock *sk);
7675 bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
7776 struct mptcp_out_options *opts);
7877 bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
net/ipv4/tcp_input.c+0−3
@@ -5990,9 +5990,6 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, · 5989 unmodified lines
59905990 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
59915991 tcp_initialize_rcv_mss(sk);
59925992
5993− if (sk_is_mptcp(sk))
5994− mptcp_rcv_synsent(sk);
5995−
59965993 /* Remember, tcp_poll() does not lock socket!
59975994 * Change state from SYN-SENT only after copied_seq
59985995 * is initialized. */
net/mptcp/options.c+0−22
@@ -344,28 +344,6 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb, · 343 unmodified lines
344344 return false;
345345 }
346346
347−void mptcp_rcv_synsent(struct sock *sk)
348−{
349− struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
350− struct tcp_sock *tp = tcp_sk(sk);
351−
352− if (subflow->request_mptcp && tp->rx_opt.mptcp.mp_capable) {
353− subflow->mp_capable = 1;
354− subflow->can_ack = 1;
355− subflow->remote_key = tp->rx_opt.mptcp.sndr_key;
356− pr_debug("subflow=%p, remote_key=%llu", subflow,
357− subflow->remote_key);
358− } else if (subflow->request_join && tp->rx_opt.mptcp.mp_join) {
359− subflow->mp_join = 1;
360− subflow->thmac = tp->rx_opt.mptcp.thmac;
361− subflow->remote_nonce = tp->rx_opt.mptcp.nonce;
362− pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u", subflow,
363− subflow->thmac, subflow->remote_nonce);
364− } else if (subflow->request_mptcp) {
365− tcp_sk(sk)->is_mptcp = 0;
366− }
367−}
368−
369347 /* MP_JOIN client subflow must wait for 4th ack before sending any data:
370348 * TCP can't schedule delack timer before the subflow is fully established.
371349 * MPTCP uses the delack timer to do 3rd ack retransmissions
net/mptcp/subflow.c+24−3
@@ -222,6 +222,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) · 221 unmodified lines
222222 {
223223 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
224224 struct sock *parent = subflow->conn;
225+ struct tcp_sock *tp = tcp_sk(sk);
225226
226227 subflow->icsk_af_ops->sk_rx_dst_set(sk, skb);
227228
@@ -230,14 +231,35 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) · 2 unmodified lines
230231 parent->sk_state_change(parent);
231232 }
232233
233− if (subflow->conn_finished || !tcp_sk(sk)->is_mptcp)
234+ /* be sure no special action on any packet other than syn-ack */
235+ if (subflow->conn_finished)
236+ return;
237+
238+ subflow->conn_finished = 1;
239+
240+ if (subflow->request_mptcp && tp->rx_opt.mptcp.mp_capable) {
241+ subflow->mp_capable = 1;
242+ subflow->can_ack = 1;
243+ subflow->remote_key = tp->rx_opt.mptcp.sndr_key;
244+ pr_debug("subflow=%p, remote_key=%llu", subflow,
245+ subflow->remote_key);
246+ } else if (subflow->request_join && tp->rx_opt.mptcp.mp_join) {
247+ subflow->mp_join = 1;
248+ subflow->thmac = tp->rx_opt.mptcp.thmac;
249+ subflow->remote_nonce = tp->rx_opt.mptcp.nonce;
250+ pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u", subflow,
251+ subflow->thmac, subflow->remote_nonce);
252+ } else if (subflow->request_mptcp) {
253+ tp->is_mptcp = 0;
254+ }
255+
256+ if (!tp->is_mptcp)
234257 return;
235258
236259 if (subflow->mp_capable) {
237260 pr_debug("subflow=%p, remote_key=%llu", mptcp_subflow_ctx(sk),
238261 subflow->remote_key);
239262 mptcp_finish_connect(sk);
240− subflow->conn_finished = 1;
241263
242264 if (skb) {
243265 pr_debug("synack seq=%u", TCP_SKB_CB(skb)->seq);
@@ -264,7 +286,6 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) · 20 unmodified lines
264286 if (!mptcp_finish_join(sk))
265287 goto do_reset;
266288
267− subflow->conn_finished = 1;
268289 MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNACKRX);
269290 } else {
270291 do_reset: