From: Florian Westphal <fw@strlen.de>
To: <mptcp@lists.linux.dev>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH mptcp-next 2/4] tcp: add mptcp join demultiplex hooks
Date: Thu, 24 Feb 2022 16:50:08 +0100 [thread overview]
Message-ID: <20220224155010.23676-3-fw@strlen.de> (raw)
In-Reply-To: <20220224155010.23676-1-fw@strlen.de>
Split from the next patch to make core tcp changes more obvious:
add a dummy function that gets called after tcp socket demux came up
empty.
This will be used by mptcp to check if a tcp syn contains an mptcp
join option with a valid token (connection id).
If so, a hidden pernet mptcp listener socket is returned and packet
resumes normally.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/net/mptcp.h | 12 ++++++++++++
net/ipv4/tcp_ipv4.c | 7 +++++++
net/ipv6/tcp_ipv6.c | 7 +++++++
3 files changed, 26 insertions(+)
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index 8b1afd6f5cc4..b914e63afc13 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -197,6 +197,11 @@ static inline __be32 mptcp_reset_option(const struct sk_buff *skb)
return htonl(0u);
}
+
+static inline struct sock *mptcp_handle_join4(struct sk_buff *skb)
+{
+ return NULL;
+}
#else
static inline void mptcp_init(void)
@@ -274,14 +279,21 @@ static inline int mptcp_subflow_init_cookie_req(struct request_sock *req,
}
static inline __be32 mptcp_reset_option(const struct sk_buff *skb) { return htonl(0u); }
+static inline struct sock *mptcp_handle_join4(struct sk_buff *skb) { return NULL; }
#endif /* CONFIG_MPTCP */
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
int mptcpv6_init(void);
void mptcpv6_handle_mapped(struct sock *sk, bool mapped);
+
+static inline struct sock *mptcp_handle_join6(struct sk_buff *skb)
+{
+ return NULL;
+}
#elif IS_ENABLED(CONFIG_IPV6)
static inline int mptcpv6_init(void) { return 0; }
static inline void mptcpv6_handle_mapped(struct sock *sk, bool mapped) { }
+static inline struct sock *mptcp_handle_join6(struct sk_buff *skb) { return NULL; }
#endif
#endif /* __NET_MPTCP_H */
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index d42824aedc36..feb779d1fd21 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2155,6 +2155,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
goto discard_it;
+ sk = mptcp_handle_join4(skb);
+ if (sk)
+ goto process;
+
tcp_v4_fill_cb(skb, iph, th);
if (tcp_checksum_complete(skb)) {
@@ -2201,6 +2205,9 @@ int tcp_v4_rcv(struct sk_buff *skb)
iph->daddr, th->dest,
inet_iif(skb),
sdif);
+ if (!sk2)
+ sk2 = mptcp_handle_join4(skb);
+
if (sk2) {
inet_twsk_deschedule_put(inet_twsk(sk));
sk = sk2;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 749de8529c83..2f7a621aa24d 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1800,6 +1800,10 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
goto discard_it;
+ sk = mptcp_handle_join6(skb);
+ if (sk)
+ goto process;
+
tcp_v6_fill_cb(skb, hdr, th);
if (tcp_checksum_complete(skb)) {
@@ -1849,6 +1853,9 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
ntohs(th->dest),
tcp_v6_iif_l3_slave(skb),
sdif);
+ if (!sk2)
+ sk2 = mptcp_handle_join6(skb);
+
if (sk2) {
struct inet_timewait_sock *tw = inet_twsk(sk);
inet_twsk_deschedule_put(tw);
--
2.34.1
next prev parent reply other threads:[~2022-02-24 15:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 15:50 [PATCH mptcp-next v4 0/4] mptcp: replace per-addr listener sockets Florian Westphal
2022-02-24 15:50 ` [PATCH mptcp-next 1/4] mptcp: prefer ip address in syn skb instead of listen sk bound address Florian Westphal
2022-02-24 15:50 ` Florian Westphal [this message]
2022-02-24 15:50 ` [PATCH mptcp-next 3/4] mptcp: handle join requests via pernet listen socket Florian Westphal
2022-03-04 7:36 ` Kishen Maloor
2022-03-08 18:45 ` Florian Westphal
2022-03-08 23:00 ` Kishen Maloor
2022-03-09 12:53 ` Florian Westphal
2022-03-09 17:40 ` Kishen Maloor
2022-03-09 21:37 ` Florian Westphal
2022-03-09 23:40 ` Kishen Maloor
2022-03-10 0:37 ` Mat Martineau
2022-03-10 1:27 ` Kishen Maloor
2022-03-11 1:16 ` Mat Martineau
2022-02-24 15:50 ` [PATCH mptcp-next 4/4] mptcp: remove per-address listening sockets Florian Westphal
2022-02-24 17:23 ` mptcp: remove per-address listening sockets: Tests Results MPTCP CI
2022-03-02 9:45 ` [PATCH mptcp 5/4] mptcp: handle join requests early Florian Westphal
2022-03-03 1:33 ` Mat Martineau
2022-03-03 16:28 ` Florian Westphal
-- strict thread matches above, loose matches on Subject: below --
2022-02-10 15:29 [PATCH mptcp-next 0/4] mptcp: replace per-addr listener sockets Florian Westphal
2022-02-10 15:29 ` [PATCH mptcp-next 2/4] tcp: add mptcp join demultiplex hooks Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220224155010.23676-3-fw@strlen.de \
--to=fw@strlen.de \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.