udp6: allow SO_MARK ctrl msg to affect routing
Subsystems (4)
Jakub Kicinski
maintainercover udp6: allow SO_MARK ctrl msg to affect routing
Hi!
Looks like SO_MARK from cmsg does not affect routing policy. This seems accidental.
I opted for net because of the discrepancy between IPv4 and IPv6, but it never worked and doesn't cause crashes..
Jakub Kicinski (2):
udp6: allow SO_MARK ctrl msg to affect routing
selftests: udp: test for passing SO_MARK as cmsg
net/ipv6/udp.c | 2 +- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/cmsg_so_mark.c | 67 +++++++++++++++++++++ tools/testing/selftests/net/cmsg_so_mark.sh | 61 +++++++++++++++++++ 5 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/net/cmsg_so_mark.c create mode 100755 tools/testing/selftests/net/cmsg_so_mark.sh
base-commit: 6de6e46d27ef386feecdbea56b3bfd6c3b3bc1f9
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 1/2 udp6: allow SO_MARK ctrl msg to affect routing
Commit c6af0c227a22 ("ip: support SO_MARK cmsg") added propagation of SO_MARK from cmsg to skb->mark. For IPv4 and raw sockets the mark also affects route lookup, but in case of IPv6 the flow info is initialized before cmsg is parsed.
--- net/ipv6/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/udp.c +1 -1
@@ -1435,7 +1435,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)if (!fl6.flowi6_oif) fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex; - fl6.flowi6_mark = ipc6.sockc.mark; fl6.flowi6_uid = sk->sk_uid;if (msg->msg_controllen) {
@@ -1471,6 +1470,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) ipc6.opt = opt; fl6.flowi6_proto = sk->sk_protocol; + fl6.flowi6_mark = ipc6.sockc.mark; fl6.daddr = *daddr;if (ipv6_addr_any (&fl6.saddr) && !ipv6_addr_any (&np->saddr)) fl6.saddr = np->saddr;
Signature · 1 line
2.31.1
Quoted 6 lines · Jakub Kicinski
Commit
c6af0c227a22("ip: supportSO_MARKcmsg") added propagation ofSO_MARKfrom cmsg toskb->mark. For IPv4 and raw sockets the mark also affects route lookup, but in case of IPv6 the flow info is initialized before cmsg is parsed.
Quoted 7 lines
Fixes c6af0c227a22 ("ip: support SO_MARK cmsg")Reported-and-tested-by Xintong Hu <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>--- net/ipv6/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines · David Ahern
Quoted 6 lines · Jakub Kicinski
Commit
c6af0c227a22("ip: supportSO_MARKcmsg") added propagation ofSO_MARKfrom cmsg toskb->mark. For IPv4 and raw sockets the mark also affects route lookup, but in case of IPv6 the flow info is initialized before cmsg is parsed.Quoted 7 lines
Fixes c6af0c227a22 ("ip: support SO_MARK cmsg")Reported-and-tested-by Xintong Hu <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>--- net/ipv6/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line
Reviewed-by David Ahern <[email protected]>
Thanks!
Jakub Kicinski
maintainerPATCH 2/2 selftests: udp: test for passing SO_MARK as cmsg
In reply to Jakub KicinskiBefore fix:
| Case IPv6 rejection returned 0, expected 1
|FAIL - 1/4 cases failed
With the fix:
| OK
--
CC: [email protected]
CC: [email protected]
--- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/cmsg_so_mark.c | 67 +++++++++++++++++++++ tools/testing/selftests/net/cmsg_so_mark.sh | 61 +++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 tools/testing/selftests/net/cmsg_so_mark.c create mode 100755 tools/testing/selftests/net/cmsg_so_mark.sh
tools/testing/selftests/net/.gitignore +1 -0
@@ -35,3 +35,4 @@ test_unix_oob gro ioam6_parser toeplitz +cmsg_so_mark
tools/testing/selftests/net/Makefile +2 -0
@@ -28,6 +28,7 @@ TEST_PROGS += veth.sh TEST_PROGS += ioam6.sh TEST_PROGS += gro.sh TEST_PROGS += gre_gso.sh +TEST_PROGS += cmsg_so_mark.sh TEST_PROGS_EXTENDED := in_netns.sh TEST_GEN_FILES = socket nettest TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
@@ -44,6 +45,7 @@ TEST_GEN_FILES += gro TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls TEST_GEN_FILES += toeplitz +TEST_GEN_FILES += cmsg_so_mark TEST_FILES := settings
tools/testing/selftests/net/cmsg_so_mark.c new file +67 -0
67 lines not on this page · raw message
tools/testing/selftests/net/cmsg_so_mark.sh new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH net 2/2] selftests: udp: test for passing SO_MARK as cmsg
Quoted 11 lines · Jakub Kicinski
Before fix:
| Case IPv6 rejection returned 0, expected 1
|FAIL - 1/4 cases failedWith the fix:
| OKSigned-off-by Jakub Kicinski <[email protected]>--
CC: [email protected]
CC: [email protected]
Quoted 9 lines
--- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/cmsg_so_mark.c | 67 +++++++++++++++++++++ tools/testing/selftests/net/cmsg_so_mark.sh | 61 +++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 tools/testing/selftests/net/cmsg_so_mark.c create mode 100755 tools/testing/selftests/net/cmsg_so_mark.sh
Re: [PATCH net 2/2] selftests: udp: test for passing SO_MARK as cmsg
Quoted 22 lines · David Ahern
Quoted 11 lines · Jakub Kicinski
Before fix:
| Case IPv6 rejection returned 0, expected 1
|FAIL - 1/4 cases failedWith the fix:
| OKSigned-off-by Jakub Kicinski <[email protected]>--
CC: [email protected]
CC: [email protected]Quoted 9 lines
--- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/cmsg_so_mark.c | 67 +++++++++++++++++++++ tools/testing/selftests/net/cmsg_so_mark.sh | 61 +++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 tools/testing/selftests/net/cmsg_so_mark.c create mode 100755 tools/testing/selftests/net/cmsg_so_mark.sh
Quoted 1 line
Reviewed-by David Ahern <[email protected]>
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Quoted 9 lines · On Fri, 29 Oct 2021 08:51:33 -0700 you wrote:
Hi!
Looks like
SO_MARKfrom cmsg does not affect routing policy. This seems accidental.I opted for net because of the discrepancy between IPv4 and IPv6, but it never worked and doesn't cause crashes..
[...]
Here is the summary with links:
- [net,1/2] udp6: allow SO_MARK ctrl msg to affect routing
https://git.kernel.org/netdev/net/c/42dcfd850e51 - [net,2/2] selftests: udp: test for passing SO_MARK as cmsg https://git.kernel.org/netdev/net/c/b0ced8f290fb
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html