mptcp: fix for ipv6-related oops
Subsystems (3)
Paolo Abeni
cover mptcp: fix for ipv6-related oops
We need to allocate a larger struct sock for mptcp v6 master sockets, otherwise inet6_sk() will access mptcp related data instead of struct ipv6_pinfo.
This should fix the crash reported by Matt.
The protocol.c code changes are split in 2 patches to simplify the squashing.
(yep, I know we somewhat agreed to big giant rebase, but this specific should be trivial).
Additionally adds some fixlet for the ipv6 tests
v1 -> v2:
- address Matt feedback on patches 1 && 2
- add missing mptcp_v6 proto registration (I don't know why the previous iteration of these patches did not explode without that!!! :(((
Paolo Abeni (3):
selftests: fixup for IPv6 tests
mptcp: use ipv6-specific proto struct
mptcp/ipv6: mptcp_v6_prot needs costom destroy.
net/mptcp/protocol.c | 24 +++++++++++-- .../selftests/net/mptcp/mptcp_connect.sh | 34 ++++++------------- 2 files changed, 33 insertions(+), 25 deletions(-)
Signature · 1 line
2.21.0
Paolo Abeni
PATCH 1/3 selftests: fixup for IPv6 tests
Add '-6' to ping argument to deal with older ping version. Additionally, setting 'noadad' on ipv6 addresses will avoid explicit waits later
v1 -> v2:
- ping6 -> ping -6 (Matt)
- drop show_all_ipv6, too (Matt)
Squash-to: "mptcp: add basic kselftest for mptcp"
Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
--- .../selftests/net/mptcp/mptcp_connect.sh | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +11 -23
@@ -124,18 +124,18 @@ ip link add ns2eth3 netns "$ns2" type veth peer name ns3eth2 netns "$ns3" ip link add ns3eth4 netns "$ns3" type veth peer name ns4eth3 netns "$ns4" ip -net "$ns1" addr add 10.0.1.1/24 dev ns1eth2 -ip -net "$ns1" addr add dead:beef:1::1/64 dev ns1eth2 +ip -net "$ns1" addr add dead:beef:1::1/64 dev ns1eth2 nodad ip -net "$ns1" link set ns1eth2 up ip -net "$ns1" route add default via 10.0.1.2 ip -net "$ns1" route add default via dead:beef:1::2 ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1 -ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 +ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad ip -net "$ns2" link set ns2eth1 up ip -net "$ns2" addr add 10.0.2.1/24 dev ns2eth3 -ip -net "$ns2" addr add dead:beef:2::1/64 dev ns2eth3 +ip -net "$ns2" addr add dead:beef:2::1/64 dev ns2eth3 nodad ip -net "$ns2" link set ns2eth3 up ip -net "$ns2" route add default via 10.0.2.2 ip -net "$ns2" route add default via dead:beef:2::2
@@ -143,11 +143,11 @@ ip netns exec "$ns2" sysctl -q net.ipv4.ip_forward=1 ip netns exec "$ns2" sysctl -q net.ipv6.conf.all.forwarding=1 ip -net "$ns3" addr add 10.0.2.2/24 dev ns3eth2 -ip -net "$ns3" addr add dead:beef:2::2/64 dev ns3eth2 +ip -net "$ns3" addr add dead:beef:2::2/64 dev ns3eth2 nodad ip -net "$ns3" link set ns3eth2 up ip -net "$ns3" addr add 10.0.3.2/24 dev ns3eth4 -ip -net "$ns3" addr add dead:beef:3::2/64 dev ns3eth4 +ip -net "$ns3" addr add dead:beef:3::2/64 dev ns3eth4 nodad ip -net "$ns3" link set ns3eth4 up ip -net "$ns3" route add default via 10.0.2.1 ip -net "$ns3" route add default via dead:beef:2::1
@@ -155,7 +155,7 @@ ip netns exec "$ns3" sysctl -q net.ipv4.ip_forward=1 ip netns exec "$ns3" sysctl -q net.ipv6.conf.all.forwarding=1 ip -net "$ns4" addr add 10.0.3.1/24 dev ns4eth3 -ip -net "$ns4" addr add dead:beef:3::1/64 dev ns4eth3 +ip -net "$ns4" addr add dead:beef:3::1/64 dev ns4eth3 nodad ip -net "$ns4" link set ns4eth3 up ip -net "$ns4" route add default via 10.0.3.2 ip -net "$ns4" route add default via dead:beef:3::2
@@ -277,12 +277,14 @@ do_ping() local listener_ns="$1" local connector_ns="$2" local connect_addr="$3" + local ping_args="-q -c 1" - if ! $ipv6 && is_v6 "${connect_addr}"; then - return 0 + if is_v6 "${connect_addr}"; then + $ipv6 || return 0 + ping_args="${ping_args} -6" fi - ip netns exec ${connector_ns} ping -q -c 1 $connect_addr >/dev/null + ip netns exec ${connector_ns} ping ${ping_args} $connect_addr >/dev/null if [ $? -ne 0 ] ; then echo "$listener_ns -> $connect_addr connectivity [ FAIL ]" 1>&2 ret=1
@@ -485,20 +487,6 @@ check_mptcp_disabled check_mptcp_ulp_setsockopt -show_all_ipv6() -{ - local ns - for ns in "$ns1" "$ns2" "$ns3" "$ns4"; do - ip -net "${ns}" -6 addr show scope global - done -} - -# Allow DAD to finish -for dad in $(seq 20); do - show_all_ipv6 | grep -q -e tentative -e temporary || break - sleep 0.1 -done - echo "INFO: validating network environment with pings" for sender in "$ns1" "$ns2" "$ns3" "$ns4";do do_ping "$ns1" $sender 10.0.1.1
Signature · 1 line
2.21.0
Paolo Abeni
PATCH 2/3 mptcp: use ipv6-specific proto struct
In reply to Paolo AbeniBecause it needs a different (greater) obj_size.
v1 -> v2:
- TCPv6 -> MPTCPv6 (Matt)
- need to cleat slab and do proper proto_register()
Squash-to: "mptcp: Add MPTCP socket stubs"
Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
--- net/mptcp/protocol.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +15 -2
@@ -689,7 +689,7 @@ static struct proto mptcp_prot = { .unhash = inet_unhash, .get_port = mptcp_get_port, .obj_size = sizeof(struct mptcp_sock), - .no_autobind = 1, + .no_autobind = true, };static struct socket *mptcp_socket_create_get (struct mptcp_sock *msk)
@@ -972,11 +972,12 @@ void mptcp_proto_init(void)#if IS_ENABLED (CONFIG_MPTCP_IPV6 )static struct proto_ops mptcp_v6_stream_ops; +static struct proto mptcp_v6_prot;static struct inet_protosw mptcp_v6_protosw = { .type =SOCK_STREAM , .protocol =IPPROTO_MPTCP , - .prot = &mptcp_prot, + .prot = &mptcp_v6_prot, .ops = &mptcp_v6_stream_ops, .flags =INET_PROTOSW_ICSK , };
@@ -985,6 +986,16 @@ int mptcp_proto_v6_init(void) {int err; + mptcp_v6_prot = mptcp_prot; +strcpy (mptcp_v6_prot.name,"MPTCPv6" ); + mptcp_v6_prot.slab =NULL ; + mptcp_v6_prot.obj_size =sizeof (struct mptcp_sock ) + +sizeof (struct ipv6_pinfo ); + + err =proto_register (&mptcp_v6_prot,1 ); +if (err) +return err; + mptcp_v6_stream_ops = inet6_stream_ops; mptcp_v6_stream_ops.bind = mptcp_bind; mptcp_v6_stream_ops.connect = mptcp_stream_connect;
@@ -995,6 +1006,8 @@ int mptcp_proto_v6_init(void) mptcp_v6_stream_ops.shutdown = mptcp_shutdown; err =inet6_register_protosw (&mptcp_v6_protosw); +if (err) +proto_unregister (&mptcp_v6_prot);return err; }
Signature · 1 line
2.21.0
Paolo Abeni
PATCH 3/3 mptcp/ipv6: mptcp_v6_prot needs costom destroy.
In reply to Paolo AbeniOtherwise we can leak memory on close, if user space does some setsockopt before connectiong/accepting.
Note: the squash tag points to the commit currently introducing mptcp_destroy, but we likely want to move such function in another one - it's currently added as empty
Squash-to: "mptcp: Add key generation and token tree"
Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
--- net/mptcp/protocol.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/mptcp/protocol.c +7 -0
@@ -974,6 +974,12 @@ void mptcp_proto_init(void)static struct proto_ops mptcp_v6_stream_ops;static struct proto mptcp_v6_prot; +static void mptcp_v6_destroy (struct sock *sk) +{ +mptcp_destroy (sk); +inet6_destroy_sock (sk); +} +static struct inet_protosw mptcp_v6_protosw = { .type =SOCK_STREAM , .protocol =IPPROTO_MPTCP ,
@@ -989,6 +995,7 @@ int mptcp_proto_v6_init(void) mptcp_v6_prot = mptcp_prot;strcpy (mptcp_v6_prot.name,"MPTCPv6" ); mptcp_v6_prot.slab =NULL ; + mptcp_v6_prot.destroy = mptcp_v6_destroy; mptcp_v6_prot.obj_size =sizeof (struct mptcp_sock ) +sizeof (struct ipv6_pinfo );
Signature · 1 line
2.21.0
Matthieu Baerts
Hi Paolo,
Quoted 11 lines · Paolo Abeni
We need to allocate a larger struct sock for mptcp v6 master sockets, otherwise
inet6_sk()will access mptcp related data instead of structipv6_pinfo.This should fix the crash reported by Matt.
The
protocol.ccode changes are split in 2 patches to simplify the squashing.
(yep, I know we somewhat agreed to big giant rebase, but this specific should be trivial).
Quoted 6 lines
Additionally adds some fixlet for the ipv6 tests
v1 -> v2:
- address Matt feedback on patches 1 && 2
- add missingmptcp_v6proto registration (I don't know why the previousiteration of these patches did not explode without that!!! :(((
Thank you for the new version and good catch for the proto registration!
The new version looks good to me. I am going to apply it if there is no objections (post fixes are still possible of course).
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
Matthieu Baerts
Hi Paolo,
Quoted 22 lines · Matthieu Baerts
Hi Paolo,
Quoted 11 lines · Paolo Abeni
We need to allocate a larger struct sock for mptcp v6 master sockets, otherwise
inet6_sk()will access mptcp related data instead of structipv6_pinfo.This should fix the crash reported by Matt.
The
protocol.ccode changes are split in 2 patches to simplify the squashing.
(yep, I know we somewhat agreed to big giant rebase, but this specific should be trivial).Quoted 7 lines
Additionally adds some fixlet for the ipv6 tests
v1 -> v2:
- address Matt feedback on patches 1 && 2
- add missingmptcp_v6proto registration (I don't know why the previous
iteration of these patches did not explode without that!!! :(((
Quoted 4 lines
Thank you for the new version and good catch for the proto registration!
The new version looks good to me. I am going to apply it if there is no objections (post fixes are still possible of course).
Again thank you for the patches!
- 2a2dd30dbd33: "squashed" patch 1/3 in "mptcp: add basic kselftest for mptcp"
- 39d0ec7ab1eb..432a009dc917: result
- 4bf7842874f1: "squashed" patch 2/3 in "mptcp: Add MPTCP socket stubs"
- 3d4407546cc9: conflict in t/mptcp-Associate-MPTCP-context-with-TCP-socket
- 432a009dc917..458c883a09f8: result
- 972a3aab48ac: "squashed" patch 3/3 in "mptcp: Add key generation and token tree"
- 458c883a09f8..9dde928ded79: result
Tests are now OK again! Thanks for the fix!
Cheers,
Matt
Signature · 5 lines
Matthieu Baerts | R&D Engineer matthieu.baerts(a)tessares.net Tessares SA | Hybrid Access Solutions www.tessares.net 1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium