Skip to contentSkip to conversation

mptcp: honor net namespace when creating subflow sk

PATCH In review Florian Westphal 2 participants 2 messages Apr 26, 2019 – Apr 27, 2019

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author
#0 lore raw

PATCH 1/1 mptcp: honor net namespace when creating subflow sk

Otherwise, even loopback communication doesn't work when program is run from non-init_netns.

Signed-off-by Florian Westphal <fw(a)strlen.de>

---
Could be squashed with
'mptcp: Make connection_list a real list of subflows'.

 net/mptcp/protocol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +2 -2
index 1e73e307a6d2..1fbddbcb1164 100644
@@ -703,12 +703,12 @@ static struct proto mptcp_prot = {
 static int mptcp_subflow_create(struct sock *sk)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
+	struct net *net = sock_net(sk);
 	struct socket *sf;
 	int err;
 
 	pr_debug("msk=%p", msk);
-	err = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, IPPROTO_TCP,
-			       &sf);
+	err = sock_create_kern(net, PF_INET, SOCK_STREAM, IPPROTO_TCP, &sf);
 	if (!err) {
 		lock_sock(sf->sk);
 		err = tcp_set_ulp(sf->sk, "mptcp");
Signature · 1 line
2.21.0
#1 lore raw
Quoted 7 lines · Florian Westphal

Otherwise, even loopback communication doesn't work when program is run from non-init_netns.

Signed-off-by Florian Westphal <fw(a)strlen.de>

---
Could be squashed with
'mptcp: Make connection_list a real list of subflows'.

Thanks Florian. I'll squash it earlier in the series, where the sock_create_kern() call is added.

Mat

Quoted 25 lines

net/mptcp/protocol.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +2 -2
index 1e73e307a6d2..1fbddbcb1164 100644
@@ -703,12 +703,12 @@ static struct proto mptcp_prot = {
 static int mptcp_subflow_create(struct sock *sk)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
+	struct net *net = sock_net(sk);
 	struct socket *sf;
 	int err;
 
 	pr_debug("msk=%p", msk);
-	err = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, IPPROTO_TCP,
-			       &sf);
+	err = sock_create_kern(net, PF_INET, SOCK_STREAM, IPPROTO_TCP, &sf);
 	if (!err) {
 		lock_sock(sf->sk);
 		err = tcp_set_ulp(sf->sk, "mptcp");
Signature · 1 line
2.21.0

--
Mat Martineau
Intel