]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/net: Add test coverage for UDP GSO software fallback
authorJakub Sitnicki <jakub@cloudflare.com>
Wed, 26 Jun 2024 17:51:27 +0000 (19:51 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 29 Jun 2024 01:13:00 +0000 (18:13 -0700)
Extend the existing test to exercise UDP GSO egress through devices with
various offload capabilities, including lack of checksum offload, which is
the default case for TUN/TAP devices.

Test against a dummy device because it is simpler to set up then TUN/TAP.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20240626-linux-udpgso-v2-2-422dfcbd6b48@cloudflare.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/udpgso.c
tools/testing/selftests/net/udpgso.sh

index 85b3baa3f7f34112ea95239c8819a2b1d834e22a..3e74cfa1a2bfec6bc8bea1a704e7bc074ad794a5 100644 (file)
@@ -53,6 +53,7 @@ static bool           cfg_do_ipv6;
 static bool            cfg_do_connected;
 static bool            cfg_do_connectionless;
 static bool            cfg_do_msgmore;
+static bool            cfg_do_recv = true;
 static bool            cfg_do_setsockopt;
 static int             cfg_specific_test_id = -1;
 
@@ -414,6 +415,9 @@ static void run_one(struct testcase *test, int fdt, int fdr,
        if (!sent)
                return;
 
+       if (!cfg_do_recv)
+               return;
+
        if (test->gso_len)
                mss = test->gso_len;
        else
@@ -464,8 +468,10 @@ static void run_test(struct sockaddr *addr, socklen_t alen)
        if (fdr == -1)
                error(1, errno, "socket r");
 
-       if (bind(fdr, addr, alen))
-               error(1, errno, "bind");
+       if (cfg_do_recv) {
+               if (bind(fdr, addr, alen))
+                       error(1, errno, "bind");
+       }
 
        /* Have tests fail quickly instead of hang */
        if (setsockopt(fdr, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)))
@@ -524,7 +530,7 @@ static void parse_opts(int argc, char **argv)
 {
        int c;
 
-       while ((c = getopt(argc, argv, "46cCmst:")) != -1) {
+       while ((c = getopt(argc, argv, "46cCmRst:")) != -1) {
                switch (c) {
                case '4':
                        cfg_do_ipv4 = true;
@@ -541,6 +547,9 @@ static void parse_opts(int argc, char **argv)
                case 'm':
                        cfg_do_msgmore = true;
                        break;
+               case 'R':
+                       cfg_do_recv = false;
+                       break;
                case 's':
                        cfg_do_setsockopt = true;
                        break;
index 6c63178086b0227ae58b755527a9194d85da136f..85d1fa3c1ff7858bf9d0de0e976b5f4e42b780a0 100755 (executable)
@@ -27,6 +27,31 @@ test_route_mtu() {
        ip route add local fd00::1/128 table local dev lo mtu 1500
 }
 
+setup_dummy_sink() {
+       ip link add name sink mtu 1500 type dummy
+       ip addr add dev sink 10.0.0.0/24
+       ip addr add dev sink fd00::2/64 nodad
+       ip link set dev sink up
+}
+
+test_hw_gso_hw_csum() {
+       setup_dummy_sink
+       ethtool -K sink tx-checksum-ip-generic on >/dev/null
+       ethtool -K sink tx-udp-segmentation on >/dev/null
+}
+
+test_sw_gso_hw_csum() {
+       setup_dummy_sink
+       ethtool -K sink tx-checksum-ip-generic on >/dev/null
+       ethtool -K sink tx-udp-segmentation off >/dev/null
+}
+
+test_sw_gso_sw_csum() {
+       setup_dummy_sink
+       ethtool -K sink tx-checksum-ip-generic off >/dev/null
+       ethtool -K sink tx-udp-segmentation off >/dev/null
+}
+
 if [ "$#" -gt 0 ]; then
        "$1"
        shift 2 # pop "test_*" arg and "--" delimiter
@@ -56,3 +81,21 @@ echo "ipv4 msg_more"
 
 echo "ipv6 msg_more"
 ./in_netns.sh "$0" test_dev_mtu -- ./udpgso -6 -C -m
+
+echo "ipv4 hw-gso hw-csum"
+./in_netns.sh "$0" test_hw_gso_hw_csum -- ./udpgso -4 -C -R
+
+echo "ipv6 hw-gso hw-csum"
+./in_netns.sh "$0" test_hw_gso_hw_csum -- ./udpgso -6 -C -R
+
+echo "ipv4 sw-gso hw-csum"
+./in_netns.sh "$0" test_sw_gso_hw_csum -- ./udpgso -4 -C -R
+
+echo "ipv6 sw-gso hw-csum"
+./in_netns.sh "$0" test_sw_gso_hw_csum -- ./udpgso -6 -C -R
+
+echo "ipv4 sw-gso sw-csum"
+./in_netns.sh "$0" test_sw_gso_sw_csum -- ./udpgso -4 -C -R
+
+echo "ipv6 sw-gso sw-csum"
+./in_netns.sh "$0" test_sw_gso_sw_csum -- ./udpgso -6 -C -R