* [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option.
@ 2023-05-11 14:39 Guillaume Nault
2023-05-11 14:39 ` [PATCH v2 net-next 1/4] selftests: Add SO_DONTROUTE option to nettest Guillaume Nault
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Guillaume Nault @ 2023-05-11 14:39 UTC (permalink / raw)
To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, David Ahern
The objective is to cover kernel paths that use the RTO_ONLINK flag
in .flowi4_tos. This way we'll be able to safely remove this flag in
the future by properly setting .flowi4_scope instead. With these
selftests in place, we can make sure this won't introduce regressions.
For more context, the final objective is to convert .flowi4_tos to
dscp_t, to ensure that ECN bits don't influence route and fib-rule
lookups (see commit a410a0cf9885 ("ipv6: Define dscp_t and stop taking
ECN bits into account in fib6-rules")).
These selftests only cover IPv4, as SO_DONTROUTE has no effect on IPv6
sockets.
v2:
- Use two different nettest options for setting SO_DONTROUTE either
on the server or on the client socket.
- Use the above feature to run a single 'nettest -B' instance per
test (instead of having two nettest processes for server and
client).
Guillaume Nault (4):
selftests: Add SO_DONTROUTE option to nettest.
selftests: fcnal: Test SO_DONTROUTE on TCP sockets.
selftests: fcnal: Test SO_DONTROUTE on UDP sockets.
selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets.
tools/testing/selftests/net/fcnal-test.sh | 87 +++++++++++++++++++++++
tools/testing/selftests/net/nettest.c | 46 +++++++++++-
2 files changed, 132 insertions(+), 1 deletion(-)
--
2.30.2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 net-next 1/4] selftests: Add SO_DONTROUTE option to nettest.
2023-05-11 14:39 [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option Guillaume Nault
@ 2023-05-11 14:39 ` Guillaume Nault
2023-05-11 15:00 ` David Ahern
2023-05-11 14:39 ` [PATCH v2 net-next 2/4] selftests: fcnal: Test SO_DONTROUTE on TCP sockets Guillaume Nault
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Nault @ 2023-05-11 14:39 UTC (permalink / raw)
To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, David Ahern
Add --client-dontroute and --server-dontroute options to nettest. They
allow to set the SO_DONTROUTE option to the client and server sockets
respectively. This will be used by the following patches to test
the SO_DONTROUTE kernel behaviour with TCP and UDP.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
v2: Use two different options for setting SO_DONTROUTE either on the
client or on the server socket.
tools/testing/selftests/net/nettest.c | 46 ++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/nettest.c b/tools/testing/selftests/net/nettest.c
index ee9a72982705..39a0e01f8554 100644
--- a/tools/testing/selftests/net/nettest.c
+++ b/tools/testing/selftests/net/nettest.c
@@ -76,7 +76,9 @@ struct sock_args {
has_grp:1,
has_expected_laddr:1,
has_expected_raddr:1,
- bind_test_only:1;
+ bind_test_only:1,
+ client_dontroute:1,
+ server_dontroute:1;
unsigned short port;
@@ -611,6 +613,18 @@ static int set_dsfield(int sd, int version, int dsfield)
return 0;
}
+static int set_dontroute(int sd)
+{
+ unsigned int one = 1;
+
+ if (setsockopt(sd, SOL_SOCKET, SO_DONTROUTE, &one, sizeof(one)) < 0) {
+ log_err_errno("setsockopt(SO_DONTROUTE)");
+ return -1;
+ }
+
+ return 0;
+}
+
static int str_to_uint(const char *str, int min, int max, unsigned int *value)
{
int number;
@@ -1351,6 +1365,14 @@ static int msock_init(struct sock_args *args, int server)
if (set_dsfield(sd, AF_INET, args->dsfield) != 0)
goto out_err;
+ if (server) {
+ if (args->server_dontroute && set_dontroute(sd) != 0)
+ goto out_err;
+ } else {
+ if (args->client_dontroute && set_dontroute(sd) != 0)
+ goto out_err;
+ }
+
if (args->dev && bind_to_device(sd, args->dev) != 0)
goto out_err;
else if (args->use_setsockopt &&
@@ -1482,6 +1504,9 @@ static int lsock_init(struct sock_args *args)
if (set_dsfield(sd, args->version, args->dsfield) != 0)
goto err;
+ if (args->server_dontroute && set_dontroute(sd) != 0)
+ goto err;
+
if (args->dev && bind_to_device(sd, args->dev) != 0)
goto err;
else if (args->use_setsockopt &&
@@ -1698,6 +1723,9 @@ static int connectsock(void *addr, socklen_t alen, struct sock_args *args)
if (set_dsfield(sd, args->version, args->dsfield) != 0)
goto err;
+ if (args->client_dontroute && set_dontroute(sd) != 0)
+ goto err;
+
if (args->dev && bind_to_device(sd, args->dev) != 0)
goto err;
else if (args->use_setsockopt &&
@@ -1905,10 +1933,14 @@ static int ipc_parent(int cpid, int fd, struct sock_args *args)
#define GETOPT_STR "sr:l:c:Q:p:t:g:P:DRn:M:X:m:d:I:BN:O:SUCi6xL:0:1:2:3:Fbqf"
#define OPT_FORCE_BIND_KEY_IFINDEX 1001
#define OPT_NO_BIND_KEY_IFINDEX 1002
+#define OPT_CLIENT_DONTROUTE 1003
+#define OPT_SERVER_DONTROUTE 1004
static struct option long_opts[] = {
{"force-bind-key-ifindex", 0, 0, OPT_FORCE_BIND_KEY_IFINDEX},
{"no-bind-key-ifindex", 0, 0, OPT_NO_BIND_KEY_IFINDEX},
+ {"client-dontroute", 0, 0, OPT_CLIENT_DONTROUTE},
+ {"server-dontroute", 0, 0, OPT_SERVER_DONTROUTE},
{0, 0, 0, 0}
};
@@ -1954,6 +1986,12 @@ static void print_usage(char *prog)
" --no-bind-key-ifindex: Force TCP_MD5SIG_FLAG_IFINDEX off\n"
" --force-bind-key-ifindex: Force TCP_MD5SIG_FLAG_IFINDEX on\n"
" (default: only if -I is passed)\n"
+ " --client-dontroute: don't use gateways for client socket: send\n"
+ " packets only if destination is on link (see\n"
+ " SO_DONTROUTE in socket(7))\n"
+ " --server-dontroute: don't use gateways for server socket: send\n"
+ " packets only if destination is on link (see\n"
+ " SO_DONTROUTE in socket(7))\n"
"\n"
" -g grp multicast group (e.g., 239.1.1.1)\n"
" -i interactive mode (default is echo and terminate)\n"
@@ -2076,6 +2114,12 @@ int main(int argc, char *argv[])
case OPT_NO_BIND_KEY_IFINDEX:
args.bind_key_ifindex = -1;
break;
+ case OPT_CLIENT_DONTROUTE:
+ args.client_dontroute = 1;
+ break;
+ case OPT_SERVER_DONTROUTE:
+ args.server_dontroute = 1;
+ break;
case 'X':
args.client_pw = optarg;
break;
--
2.30.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 net-next 2/4] selftests: fcnal: Test SO_DONTROUTE on TCP sockets.
2023-05-11 14:39 [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option Guillaume Nault
2023-05-11 14:39 ` [PATCH v2 net-next 1/4] selftests: Add SO_DONTROUTE option to nettest Guillaume Nault
@ 2023-05-11 14:39 ` Guillaume Nault
2023-05-11 15:02 ` David Ahern
2023-05-11 14:39 ` [PATCH v2 net-next 3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets Guillaume Nault
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Nault @ 2023-05-11 14:39 UTC (permalink / raw)
To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, David Ahern
Use nettest --{client,server}-dontroute to test the kernel behaviour
with TCP sockets having the SO_DONTROUTE option. Sending packets to a
neighbour (on link) host, should work. When the host is behind a
router, sending should fail.
Client and server sockets are tested independently, so that we can
cover different TCP kernel paths.
SO_DONTROUTE also affects the syncookies path. So ipv4_tcp_dontroute()
is made to work with or without syncookies, to cover both paths.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
v2: Use 'nettest -B' instead of invoking two nettest instances for
client and server.
tools/testing/selftests/net/fcnal-test.sh | 56 +++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
index 21ca91473c09..3a1f3051321f 100755
--- a/tools/testing/selftests/net/fcnal-test.sh
+++ b/tools/testing/selftests/net/fcnal-test.sh
@@ -1098,6 +1098,59 @@ test_ipv4_md5_vrf__global_server__bind_ifindex0()
set_sysctl net.ipv4.tcp_l3mdev_accept="$old_tcp_l3mdev_accept"
}
+ipv4_tcp_dontroute()
+{
+ local syncookies=$1
+ local nsa_syncookies
+ local nsb_syncookies
+ local a
+
+ #
+ # Link local connection tests (SO_DONTROUTE).
+ # Connections should succeed only when the remote IP address is
+ # on link (doesn't need to be routed through a gateway).
+ #
+
+ nsa_syncookies=$(ip netns exec "${NSA}" sysctl -n net.ipv4.tcp_syncookies)
+ nsb_syncookies=$(ip netns exec "${NSB}" sysctl -n net.ipv4.tcp_syncookies)
+ ip netns exec "${NSA}" sysctl -wq net.ipv4.tcp_syncookies=${syncookies}
+ ip netns exec "${NSB}" sysctl -wq net.ipv4.tcp_syncookies=${syncookies}
+
+ # Test with eth1 address (on link).
+
+ a=${NSB_IP}
+ log_start
+ do_run_cmd nettest -B -N "${NSA}" -O "${NSB}" -r ${a} --client-dontroute
+ log_test_addr ${a} $? 0 "SO_DONTROUTE client, syncookies=${syncookies}"
+
+ a=${NSB_IP}
+ log_start
+ do_run_cmd nettest -B -N "${NSA}" -O "${NSB}" -r ${a} --server-dontroute
+ log_test_addr ${a} $? 0 "SO_DONTROUTE server, syncookies=${syncookies}"
+
+ # Test with loopback address (routed).
+ #
+ # The client would use the eth1 address as source IP by default.
+ # Therefore, we need to use the -c option here, to force the use of the
+ # routed (loopback) address as source IP (so that the server will try
+ # to respond to a routed address and not a link local one).
+
+ a=${NSB_LO_IP}
+ log_start
+ show_hint "Should fail 'Network is unreachable' since server is not on link"
+ do_run_cmd nettest -B -N "${NSA}" -O "${NSB}" -c "${NSA_LO_IP}" -r ${a} --client-dontroute
+ log_test_addr ${a} $? 1 "SO_DONTROUTE client, syncookies=${syncookies}"
+
+ a=${NSB_LO_IP}
+ log_start
+ show_hint "Should timeout since server cannot respond (client is not on link)"
+ do_run_cmd nettest -B -N "${NSA}" -O "${NSB}" -c "${NSA_LO_IP}" -r ${a} --server-dontroute
+ log_test_addr ${a} $? 2 "SO_DONTROUTE server, syncookies=${syncookies}"
+
+ ip netns exec "${NSB}" sysctl -wq net.ipv4.tcp_syncookies=${nsb_syncookies}
+ ip netns exec "${NSA}" sysctl -wq net.ipv4.tcp_syncookies=${nsa_syncookies}
+}
+
ipv4_tcp_novrf()
{
local a
@@ -1217,6 +1270,9 @@ ipv4_tcp_novrf()
log_test_addr ${a} $? 1 "No server, device client, local conn"
ipv4_tcp_md5_novrf
+
+ ipv4_tcp_dontroute 0
+ ipv4_tcp_dontroute 2
}
ipv4_tcp_vrf()
--
2.30.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 net-next 3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets.
2023-05-11 14:39 [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option Guillaume Nault
2023-05-11 14:39 ` [PATCH v2 net-next 1/4] selftests: Add SO_DONTROUTE option to nettest Guillaume Nault
2023-05-11 14:39 ` [PATCH v2 net-next 2/4] selftests: fcnal: Test SO_DONTROUTE on TCP sockets Guillaume Nault
@ 2023-05-11 14:39 ` Guillaume Nault
2023-05-11 15:03 ` David Ahern
2023-05-11 14:39 ` [PATCH v2 net-next 4/4] selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets Guillaume Nault
2023-05-12 8:50 ` [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option patchwork-bot+netdevbpf
4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Nault @ 2023-05-11 14:39 UTC (permalink / raw)
To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, David Ahern
Use nettest --client-dontroute to test the kernel behaviour with UDP
sockets having the SO_DONTROUTE option. Sending packets to a neighbour
(on link) host, should work. When the host is behind a router, sending
should fail.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
v2: Use 'nettest -B' instead of invoking two nettest instances for
client and server.
tools/testing/selftests/net/fcnal-test.sh | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
index 3a1f3051321f..08b4b96cbd63 100755
--- a/tools/testing/selftests/net/fcnal-test.sh
+++ b/tools/testing/selftests/net/fcnal-test.sh
@@ -1641,6 +1641,23 @@ ipv4_udp_novrf()
log_start
run_cmd nettest -D -d ${NSA_DEV} -r ${a}
log_test_addr ${a} $? 2 "No server, device client, local conn"
+
+ #
+ # Link local connection tests (SO_DONTROUTE).
+ # Connections should succeed only when the remote IP address is
+ # on link (doesn't need to be routed through a gateway).
+ #
+
+ a=${NSB_IP}
+ log_start
+ do_run_cmd nettest -B -D -N "${NSA}" -O "${NSB}" -r ${a} --client-dontroute
+ log_test_addr ${a} $? 0 "SO_DONTROUTE client"
+
+ a=${NSB_LO_IP}
+ log_start
+ show_hint "Should fail 'Network is unreachable' since server is not on link"
+ do_run_cmd nettest -B -D -N "${NSA}" -O "${NSB}" -r ${a} --client-dontroute
+ log_test_addr ${a} $? 1 "SO_DONTROUTE client"
}
ipv4_udp_vrf()
--
2.30.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 net-next 4/4] selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets.
2023-05-11 14:39 [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option Guillaume Nault
` (2 preceding siblings ...)
2023-05-11 14:39 ` [PATCH v2 net-next 3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets Guillaume Nault
@ 2023-05-11 14:39 ` Guillaume Nault
2023-05-11 15:04 ` David Ahern
2023-05-12 8:50 ` [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option patchwork-bot+netdevbpf
4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Nault @ 2023-05-11 14:39 UTC (permalink / raw)
To: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, David Ahern
Use ping -r to test the kernel behaviour with raw and ping sockets
having the SO_DONTROUTE option.
Since ipv4_ping_novrf() is called with different values of
net.ipv4.ping_group_range, then it tests both raw and ping sockets
(ping uses ping sockets if its user ID belongs to ping_group_range
and raw sockets otherwise).
With both socket types, sending packets to a neighbour (on link) host,
should work. When the host is behind a router, sending should fail.
Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
tools/testing/selftests/net/fcnal-test.sh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
index 08b4b96cbd63..05b5c4af7a08 100755
--- a/tools/testing/selftests/net/fcnal-test.sh
+++ b/tools/testing/selftests/net/fcnal-test.sh
@@ -584,6 +584,20 @@ ipv4_ping_novrf()
log_test_addr ${a} $? 0 "ping out, address bind"
done
+ #
+ # out, but don't use gateway if peer is not on link
+ #
+ a=${NSB_IP}
+ log_start
+ run_cmd ping -c 1 -w 1 -r ${a}
+ log_test_addr ${a} $? 0 "ping out (don't route), peer on link"
+
+ a=${NSB_LO_IP}
+ log_start
+ show_hint "Fails since peer is not on link"
+ run_cmd ping -c 1 -w 1 -r ${a}
+ log_test_addr ${a} $? 1 "ping out (don't route), peer not on link"
+
#
# in
#
--
2.30.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 net-next 1/4] selftests: Add SO_DONTROUTE option to nettest.
2023-05-11 14:39 ` [PATCH v2 net-next 1/4] selftests: Add SO_DONTROUTE option to nettest Guillaume Nault
@ 2023-05-11 15:00 ` David Ahern
0 siblings, 0 replies; 11+ messages in thread
From: David Ahern @ 2023-05-11 15:00 UTC (permalink / raw)
To: Guillaume Nault, David Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: netdev
On 5/11/23 8:39 AM, Guillaume Nault wrote:
> Add --client-dontroute and --server-dontroute options to nettest. They
> allow to set the SO_DONTROUTE option to the client and server sockets
> respectively. This will be used by the following patches to test
> the SO_DONTROUTE kernel behaviour with TCP and UDP.
>
> Signed-off-by: Guillaume Nault <gnault@redhat.com>
> ---
> v2: Use two different options for setting SO_DONTROUTE either on the
> client or on the server socket.
>
> tools/testing/selftests/net/nettest.c | 46 ++++++++++++++++++++++++++-
> 1 file changed, 45 insertions(+), 1 deletion(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 net-next 2/4] selftests: fcnal: Test SO_DONTROUTE on TCP sockets.
2023-05-11 14:39 ` [PATCH v2 net-next 2/4] selftests: fcnal: Test SO_DONTROUTE on TCP sockets Guillaume Nault
@ 2023-05-11 15:02 ` David Ahern
0 siblings, 0 replies; 11+ messages in thread
From: David Ahern @ 2023-05-11 15:02 UTC (permalink / raw)
To: Guillaume Nault, David Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: netdev
On 5/11/23 8:39 AM, Guillaume Nault wrote:
> Use nettest --{client,server}-dontroute to test the kernel behaviour
> with TCP sockets having the SO_DONTROUTE option. Sending packets to a
> neighbour (on link) host, should work. When the host is behind a
> router, sending should fail.
>
> Client and server sockets are tested independently, so that we can
> cover different TCP kernel paths.
>
> SO_DONTROUTE also affects the syncookies path. So ipv4_tcp_dontroute()
> is made to work with or without syncookies, to cover both paths.
>
> Signed-off-by: Guillaume Nault <gnault@redhat.com>
> ---
> v2: Use 'nettest -B' instead of invoking two nettest instances for
> client and server.
>
> tools/testing/selftests/net/fcnal-test.sh | 56 +++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 net-next 3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets.
2023-05-11 14:39 ` [PATCH v2 net-next 3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets Guillaume Nault
@ 2023-05-11 15:03 ` David Ahern
2023-05-11 15:55 ` Guillaume Nault
0 siblings, 1 reply; 11+ messages in thread
From: David Ahern @ 2023-05-11 15:03 UTC (permalink / raw)
To: Guillaume Nault, David Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: netdev
On 5/11/23 8:39 AM, Guillaume Nault wrote:
> Use nettest --client-dontroute to test the kernel behaviour with UDP
> sockets having the SO_DONTROUTE option. Sending packets to a neighbour
> (on link) host, should work. When the host is behind a router, sending
> should fail.
>
> Signed-off-by: Guillaume Nault <gnault@redhat.com>
> ---
> v2: Use 'nettest -B' instead of invoking two nettest instances for
> client and server.
>
> tools/testing/selftests/net/fcnal-test.sh | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
> index 3a1f3051321f..08b4b96cbd63 100755
> --- a/tools/testing/selftests/net/fcnal-test.sh
> +++ b/tools/testing/selftests/net/fcnal-test.sh
> @@ -1641,6 +1641,23 @@ ipv4_udp_novrf()
> log_start
> run_cmd nettest -D -d ${NSA_DEV} -r ${a}
> log_test_addr ${a} $? 2 "No server, device client, local conn"
> +
> + #
> + # Link local connection tests (SO_DONTROUTE).
> + # Connections should succeed only when the remote IP address is
> + # on link (doesn't need to be routed through a gateway).
> + #
> +
> + a=${NSB_IP}
> + log_start
> + do_run_cmd nettest -B -D -N "${NSA}" -O "${NSB}" -r ${a} --client-dontroute
> + log_test_addr ${a} $? 0 "SO_DONTROUTE client"
> +
> + a=${NSB_LO_IP}
> + log_start
> + show_hint "Should fail 'Network is unreachable' since server is not on link"
> + do_run_cmd nettest -B -D -N "${NSA}" -O "${NSB}" -r ${a} --client-dontroute
> + log_test_addr ${a} $? 1 "SO_DONTROUTE client"
> }
>
> ipv4_udp_vrf()
Reviewed-by: David Ahern <dsahern@kernel.org>
Have you looked at test cases with VRF - both UDP and TCP?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 net-next 4/4] selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets.
2023-05-11 14:39 ` [PATCH v2 net-next 4/4] selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets Guillaume Nault
@ 2023-05-11 15:04 ` David Ahern
0 siblings, 0 replies; 11+ messages in thread
From: David Ahern @ 2023-05-11 15:04 UTC (permalink / raw)
To: Guillaume Nault, David Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: netdev
On 5/11/23 8:39 AM, Guillaume Nault wrote:
> Use ping -r to test the kernel behaviour with raw and ping sockets
> having the SO_DONTROUTE option.
>
> Since ipv4_ping_novrf() is called with different values of
> net.ipv4.ping_group_range, then it tests both raw and ping sockets
> (ping uses ping sockets if its user ID belongs to ping_group_range
> and raw sockets otherwise).
>
> With both socket types, sending packets to a neighbour (on link) host,
> should work. When the host is behind a router, sending should fail.
>
> Signed-off-by: Guillaume Nault <gnault@redhat.com>
> ---
> tools/testing/selftests/net/fcnal-test.sh | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 net-next 3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets.
2023-05-11 15:03 ` David Ahern
@ 2023-05-11 15:55 ` Guillaume Nault
0 siblings, 0 replies; 11+ messages in thread
From: Guillaume Nault @ 2023-05-11 15:55 UTC (permalink / raw)
To: David Ahern
Cc: David Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet, netdev
On Thu, May 11, 2023 at 09:03:44AM -0600, David Ahern wrote:
> On 5/11/23 8:39 AM, Guillaume Nault wrote:
> > Use nettest --client-dontroute to test the kernel behaviour with UDP
> > sockets having the SO_DONTROUTE option. Sending packets to a neighbour
> > (on link) host, should work. When the host is behind a router, sending
> > should fail.
> >
> > Signed-off-by: Guillaume Nault <gnault@redhat.com>
> > ---
> > v2: Use 'nettest -B' instead of invoking two nettest instances for
> > client and server.
> >
> > tools/testing/selftests/net/fcnal-test.sh | 17 +++++++++++++++++
> > 1 file changed, 17 insertions(+)
> >
> > diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
> > index 3a1f3051321f..08b4b96cbd63 100755
> > --- a/tools/testing/selftests/net/fcnal-test.sh
> > +++ b/tools/testing/selftests/net/fcnal-test.sh
> > @@ -1641,6 +1641,23 @@ ipv4_udp_novrf()
> > log_start
> > run_cmd nettest -D -d ${NSA_DEV} -r ${a}
> > log_test_addr ${a} $? 2 "No server, device client, local conn"
> > +
> > + #
> > + # Link local connection tests (SO_DONTROUTE).
> > + # Connections should succeed only when the remote IP address is
> > + # on link (doesn't need to be routed through a gateway).
> > + #
> > +
> > + a=${NSB_IP}
> > + log_start
> > + do_run_cmd nettest -B -D -N "${NSA}" -O "${NSB}" -r ${a} --client-dontroute
> > + log_test_addr ${a} $? 0 "SO_DONTROUTE client"
> > +
> > + a=${NSB_LO_IP}
> > + log_start
> > + show_hint "Should fail 'Network is unreachable' since server is not on link"
> > + do_run_cmd nettest -B -D -N "${NSA}" -O "${NSB}" -r ${a} --client-dontroute
> > + log_test_addr ${a} $? 1 "SO_DONTROUTE client"
> > }
> >
> > ipv4_udp_vrf()
>
> Reviewed-by: David Ahern <dsahern@kernel.org>
>
> Have you looked at test cases with VRF - both UDP and TCP?
I haven't looked at the VRF cases. I don't really see what kernel path
I could cover that isn't already covered by the non-vrf cases:
* From ns-B point of view, VRF_IP is just a routed IP, like NSA_LO_IP.
So testing SO_DONTROUTE on a socket belonging to ns-B wouldn't
cover any new kernel code path.
* From ns-A point of view, the routing table content is the same. It
just has to use table $VRF_TABLE instead of main. So the test would
just ensure that we jump to the right routing table, something that
SO_DONTROUTE doesn't influences. But the route lookup itself is
actually the same as for the non-vrf test (just using a different
table). Therefore I feel that adding vrf tests for SO_DONTROUTE
wouldn't bring much value.
But I may very well be missing some interesting points. If you have any
VRF test case in mind, I can add them.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option.
2023-05-11 14:39 [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option Guillaume Nault
` (3 preceding siblings ...)
2023-05-11 14:39 ` [PATCH v2 net-next 4/4] selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets Guillaume Nault
@ 2023-05-12 8:50 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-12 8:50 UTC (permalink / raw)
To: Guillaume Nault; +Cc: davem, kuba, pabeni, edumazet, netdev, dsahern
Hello:
This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 11 May 2023 16:39:19 +0200 you wrote:
> The objective is to cover kernel paths that use the RTO_ONLINK flag
> in .flowi4_tos. This way we'll be able to safely remove this flag in
> the future by properly setting .flowi4_scope instead. With these
> selftests in place, we can make sure this won't introduce regressions.
>
> For more context, the final objective is to convert .flowi4_tos to
> dscp_t, to ensure that ECN bits don't influence route and fib-rule
> lookups (see commit a410a0cf9885 ("ipv6: Define dscp_t and stop taking
> ECN bits into account in fib6-rules")).
>
> [...]
Here is the summary with links:
- [v2,net-next,1/4] selftests: Add SO_DONTROUTE option to nettest.
https://git.kernel.org/netdev/net-next/c/aeefbb574c38
- [v2,net-next,2/4] selftests: fcnal: Test SO_DONTROUTE on TCP sockets.
https://git.kernel.org/netdev/net-next/c/dd017c72dde6
- [v2,net-next,3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets.
https://git.kernel.org/netdev/net-next/c/a431327c4faa
- [v2,net-next,4/4] selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets.
https://git.kernel.org/netdev/net-next/c/ceec9f272432
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-05-12 8:50 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-11 14:39 [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option Guillaume Nault
2023-05-11 14:39 ` [PATCH v2 net-next 1/4] selftests: Add SO_DONTROUTE option to nettest Guillaume Nault
2023-05-11 15:00 ` David Ahern
2023-05-11 14:39 ` [PATCH v2 net-next 2/4] selftests: fcnal: Test SO_DONTROUTE on TCP sockets Guillaume Nault
2023-05-11 15:02 ` David Ahern
2023-05-11 14:39 ` [PATCH v2 net-next 3/4] selftests: fcnal: Test SO_DONTROUTE on UDP sockets Guillaume Nault
2023-05-11 15:03 ` David Ahern
2023-05-11 15:55 ` Guillaume Nault
2023-05-11 14:39 ` [PATCH v2 net-next 4/4] selftests: fcnal: Test SO_DONTROUTE on raw and ping sockets Guillaume Nault
2023-05-11 15:04 ` David Ahern
2023-05-12 8:50 ` [PATCH v2 net-next 0/4] selftests: fcnal: Test SO_DONTROUTE socket option patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).