Content-Type: multipart/mixed; boundary="===============2155223230304386564==" MIME-Version: 1.0 From: Florian Westphal To: mptcp at lists.01.org Subject: [MPTCP] [PATCH RFC 08/11] tcp: syncookies: keep mptcp option enabled Date: Tue, 14 Jul 2020 20:25:11 +0200 Message-ID: <20200714182514.25250-9-fw@strlen.de> In-Reply-To: 20200714182514.25250-1-fw@strlen.de X-Status: X-Keywords: X-UID: 5005 --===============2155223230304386564== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable If SYN packet contains MP_CAPABLE option, keep it enabled. The mptcp relevant code is changed to detect the new 'sycookie' flag in the request socket. If it is set, the socket isn't inserted into the token tree. This will only be done when the cookie ACK comes back. Signed-off-by: Florian Westphal --- net/ipv4/syncookies.c | 21 +++++++++++++++++---- net/ipv4/tcp_input.c | 4 +--- net/ipv6/syncookies.c | 17 ++++++++++++++--- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index ee17f55401ef..5da49dc126f9 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -289,6 +289,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk= _buff *skb) struct tcp_sock *tp =3D tcp_sk(sk); const struct tcphdr *th =3D tcp_hdr(skb); __u32 cookie =3D ntohl(th->ack_seq) - 1; + const struct request_sock_ops *ops; struct sock *ret =3D sk; struct request_sock *req; int mss; @@ -326,12 +327,27 @@ struct sock *cookie_v4_check(struct sock *sk, struct = sk_buff *skb) goto out; = ret =3D NULL; - req =3D inet_reqsk_alloc(&tcp_request_sock_ops, sk, false); /* for safety= */ + ops =3D &tcp_request_sock_ops; +#ifdef CONFIG_MPTCP + if (sk_is_mptcp(sk)) + ops =3D &mptcp_subflow_request_sock_ops; +#endif + + req =3D inet_reqsk_alloc(ops, sk, false); /* for safety */ if (!req) goto out; = ireq =3D inet_rsk(req); treq =3D tcp_rsk(req); + treq->is_mptcp =3D sk_is_mptcp(sk); + + if (treq->is_mptcp) { + int err =3D mptcp_subflow_init_cookie_req(req, sk, skb); + + if (err) + goto out_free; + } + treq->rcv_isn =3D ntohl(th->seq) - 1; treq->snt_isn =3D cookie; treq->ts_off =3D 0; @@ -350,9 +366,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk= _buff *skb) treq->snt_synack =3D 0; treq->tfo_listener =3D false; = - if (IS_ENABLED(CONFIG_MPTCP)) - treq->is_mptcp =3D 0; - if (IS_ENABLED(CONFIG_SMC)) ireq->smc_ok =3D 0; = diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index d8b9d09eb472..5ae612902806 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6669,6 +6669,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, #if IS_ENABLED(CONFIG_MPTCP) tcp_rsk(req)->is_mptcp =3D 0; #endif + tcp_rsk(req)->syncookie =3D want_cookie; = tcp_clear_options(&tmp_opt); tmp_opt.mss_clamp =3D af_ops->mss_clamp; @@ -6691,9 +6692,6 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, = af_ops->init_req(req, sk, skb); = - if (IS_ENABLED(CONFIG_MPTCP) && want_cookie) - tcp_rsk(req)->is_mptcp =3D 0; - if (security_inet_conn_request(sk, skb, req)) goto drop_and_free; = diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 13235a012388..0a05c3c1e776 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c @@ -134,6 +134,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk= _buff *skb) struct tcp_sock *tp =3D tcp_sk(sk); const struct tcphdr *th =3D tcp_hdr(skb); __u32 cookie =3D ntohl(th->ack_seq) - 1; + const struct request_sock_ops *ops; struct sock *ret =3D sk; struct request_sock *req; int mss; @@ -170,7 +171,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct s= k_buff *skb) goto out; = ret =3D NULL; - req =3D inet_reqsk_alloc(&tcp6_request_sock_ops, sk, false); + ops =3D &tcp6_request_sock_ops; +#ifdef CONFIG_MPTCP + if (sk_is_mptcp(sk)) + ops =3D &mptcp_subflow_request_sock_ops; +#endif + + req =3D inet_reqsk_alloc(ops, sk, false); if (!req) goto out; = @@ -178,8 +185,12 @@ struct sock *cookie_v6_check(struct sock *sk, struct s= k_buff *skb) treq =3D tcp_rsk(req); treq->tfo_listener =3D false; = - if (IS_ENABLED(CONFIG_MPTCP)) - treq->is_mptcp =3D 0; + if (treq->is_mptcp) { + int err =3D mptcp_subflow_init_cookie_req(req, sk, skb); + + if (err) + goto out_free; + } = if (security_inet_conn_request(sk, skb, req)) goto out_free; -- = 2.26.2 --===============2155223230304386564==--