]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iprule: Allow option dsfield in 'ip rule show'
authorGuillaume Nault <gnault@redhat.com>
Mon, 31 Jan 2022 11:02:13 +0000 (12:02 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 1 Feb 2022 20:56:30 +0000 (12:56 -0800)
When the dsfield option was added to ip rule, it only worked for add
and delete operations. For consistency, allow it when dumping rules
too.

Fixes: dec01609dc62 ("iproute2: Add dsfield as alias for tos for ip rules")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iprule.c
testsuite/tests/ip/rule/dsfield.t [new file with mode: 0755]

index 4166073c0ddd129ebd3be1c95b21d83a0c6a2719..2d39e01bcd3f1e44499c9366ff7ca79578c55b08 100644 (file)
@@ -592,7 +592,8 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
                        filter.prefmask = 1;
                } else if (strcmp(*argv, "not") == 0) {
                        filter.not = 1;
-               } else if (strcmp(*argv, "tos") == 0) {
+               } else if (strcmp(*argv, "tos") == 0 ||
+                          strcmp(*argv, "dsfield") == 0) {
                        __u32 tos;
 
                        NEXT_ARG();
diff --git a/testsuite/tests/ip/rule/dsfield.t b/testsuite/tests/ip/rule/dsfield.t
new file mode 100755 (executable)
index 0000000..79ad4e2
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+. lib/generic.sh
+
+ts_log "[Testing rule with option dsfield/tos]"
+
+ts_ip "$0" "Add IPv4 rule with dsfield 0x10" -4 rule add dsfield 0x10
+ts_ip "$0" "Show IPv4 rule with dsfield 0x10" -4 rule show dsfield 0x10
+test_on "tos 0x10"
+test_lines_count 1
+ts_ip "$0" "Delete IPv4 rule with dsfield 0x10" -4 rule del dsfield 0x10
+
+ts_ip "$0" "Add IPv4 rule with tos 0x10" -4 rule add tos 0x10
+ts_ip "$0" "Show IPv4 rule with tos 0x10" -4 rule show tos 0x10
+test_on "tos 0x10"
+test_lines_count 1
+ts_ip "$0" "Delete IPv4 rule with tos 0x10" -4 rule del tos 0x10
+
+ts_ip "$0" "Add IPv6 rule with dsfield 0x10" -6 rule add dsfield 0x10
+ts_ip "$0" "Show IPv6 rule with dsfield 0x10" -6 rule show dsfield 0x10
+test_on "tos 0x10"
+test_lines_count 1
+ts_ip "$0" "Delete IPv6 rule with dsfield 0x10" -6 rule del dsfield 0x10
+
+ts_ip "$0" "Add IPv6 rule with tos 0x10" -6 rule add tos 0x10
+ts_ip "$0" "Show IPv6 rule with tos 0x10" -6 rule show tos 0x10
+test_on "tos 0x10"
+test_lines_count 1
+ts_ip "$0" "Delete IPv6 rule with tos 0x10" -6 rule del tos 0x10