From: Guillaume Nault Date: Mon, 31 Jan 2022 11:02:13 +0000 (+0100) Subject: iprule: Allow option dsfield in 'ip rule show' X-Git-Tag: v5.17.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29da83f89f6e1fe528c59131a01f5d43bcd0a000;p=thirdparty%2Fiproute2.git iprule: Allow option dsfield in 'ip rule show' 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 Signed-off-by: Stephen Hemminger --- diff --git a/ip/iprule.c b/ip/iprule.c index 4166073c0..2d39e01bc 100644 --- a/ip/iprule.c +++ b/ip/iprule.c @@ -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 index 000000000..79ad4e2bf --- /dev/null +++ b/testsuite/tests/ip/rule/dsfield.t @@ -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