]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip-xfrm: Fix help messages
authorAndrea Claudi <aclaudi@redhat.com>
Wed, 29 Jan 2020 14:56:40 +0000 (15:56 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 29 Jan 2020 18:11:14 +0000 (10:11 -0800)
After commit 8589eb4efdf2a ("treewide: refactor help messages") help
messages for xfrm state and policy are broken, printing many times the
same protocol in UPSPEC section:

$ ip xfrm state help
[...]
UPSPEC := proto { { tcp | tcp | tcp | tcp } [ sport PORT ] [ dport PORT ] |
                  { icmp | icmp | icmp } [ type NUMBER ] [ code NUMBER ] |
                  gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }

This happens because strxf_proto function is non-reentrant and gets called
multiple times in the same fprintf instruction.

This commit fix the issue avoiding calls to strxf_proto() with a constant
param, just hardcoding strings for protocol names.

Fixes: 8589eb4efdf2a ("treewide: refactor help messages")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/xfrm_policy.c
ip/xfrm_state.c

index 7c0233c182902cb710e44df7bfbfa649b9b6e4c0..d3c706d3225f0e7ea967f256f68419a17e9b1f0b 100644 (file)
@@ -66,24 +66,9 @@ static void usage(void)
                "Usage: ip xfrm policy count\n"
                "Usage: ip xfrm policy set [ hthresh4 LBITS RBITS ] [ hthresh6 LBITS RBITS ]\n"
                "SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
-               "UPSPEC := proto { { ");
-       fprintf(stderr, "%s | %s | %s | %s } ",
-               strxf_proto(IPPROTO_TCP),
-               strxf_proto(IPPROTO_UDP),
-               strxf_proto(IPPROTO_SCTP),
-               strxf_proto(IPPROTO_DCCP));
-       fprintf(stderr,
-               "[ sport PORT ] [ dport PORT ] |\n"
-               "                  { %s | %s | %s } ",
-               strxf_proto(IPPROTO_ICMP),
-               strxf_proto(IPPROTO_ICMPV6),
-               strxf_proto(IPPROTO_MH));
-       fprintf(stderr,
-               "[ type NUMBER ] [ code NUMBER ] |\n"
-               "                  %s",
-               strxf_proto(IPPROTO_GRE));
-       fprintf(stderr,
-               " [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
+               "UPSPEC := proto { { tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |\n"
+               "                  { icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code NUMBER ] |\n"
+               "                  gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
                "DIR := in | out | fwd\n"
                "PTYPE := main | sub\n"
                "ACTION := allow | block\n"
index df2d50c3843bd58f22e29ed3f0c0bc052911a52d..16ff1931b156df0b86235eb8fad94f23a223eaba 100644 (file)
@@ -106,27 +106,9 @@ static void usage(void)
                "EXTRA-FLAG-LIST := [ EXTRA-FLAG-LIST ] EXTRA-FLAG\n"
                "EXTRA-FLAG := dont-encap-dscp\n"
                "SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
-               "UPSPEC := proto { { ");
-       fprintf(stderr,
-               "%s | %s | %s | %s",
-               strxf_proto(IPPROTO_TCP),
-               strxf_proto(IPPROTO_UDP),
-               strxf_proto(IPPROTO_SCTP),
-               strxf_proto(IPPROTO_DCCP));
-       fprintf(stderr,
-               " } [ sport PORT ] [ dport PORT ] |\n"
-               "                  { ");
-       fprintf(stderr,
-               "%s | %s | %s",
-               strxf_proto(IPPROTO_ICMP),
-               strxf_proto(IPPROTO_ICMPV6),
-               strxf_proto(IPPROTO_MH));
-       fprintf(stderr,
-               " } [ type NUMBER ] [ code NUMBER ] |\n");
-       fprintf(stderr,
-               "                  %s", strxf_proto(IPPROTO_GRE));
-       fprintf(stderr,
-               " [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
+               "UPSPEC := proto { { tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |\n"
+               "                  { icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code NUMBER ] |\n"
+               "                  gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
                "LIMIT-LIST := [ LIMIT-LIST ] limit LIMIT\n"
                "LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard } SECONDS |\n"
                "         { byte-soft | byte-hard } SIZE | { packet-soft | packet-hard } COUNT\n"