Content-Type: multipart/mixed; boundary="===============7265174242826335752==" MIME-Version: 1.0 From: Florian Westphal To: mptcp at lists.01.org Subject: [MPTCP] [RFC v2 mptcp-next 09/12] tcp: syncookies: create mptcp request socket for ACK cookies with MPTCP option Date: Tue, 21 Jul 2020 22:36:39 +0200 Message-ID: <20200721203642.32753-10-fw@strlen.de> In-Reply-To: 20200721203642.32753-1-fw@strlen.de X-Status: X-Keywords: X-UID: 5155 --===============7265174242826335752== 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. Syncokie validation and cookie-based socket creation is changed to instantiate an mptcp request sockets if the ACK contains an MPTCP connection request. Signed-off-by: Florian Westphal --- net/ipv4/syncookies.c | 21 +++++++++++++++++---- net/ipv4/tcp_input.c | 3 --- net/ipv6/syncookies.c | 17 ++++++++++++++--- 3 files changed, 31 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 17aa1c29d11c..7f4c21bca3b5 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6699,9 +6699,6 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, = af_ops->init_req(req, sk, skb, want_cookie); = - 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 --===============7265174242826335752==--