Blame SOURCES/0006-ip-xfrm-Fix-help-messages.patch

07a51b
From 028ce3bafd9c8415a0cd72ff135f9498d833db21 Mon Sep 17 00:00:00 2001
07a51b
From: Andrea Claudi <aclaudi@redhat.com>
07a51b
Date: Wed, 15 Apr 2020 19:09:48 +0200
07a51b
Subject: [PATCH] ip-xfrm: Fix help messages
07a51b
07a51b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1796045
07a51b
Upstream Status: iproute2.git commit 38dd041bfe773
07a51b
07a51b
commit 38dd041bfe773e481ebf9c8250e49c665af2e215
07a51b
Author: Andrea Claudi <aclaudi@redhat.com>
07a51b
Date:   Wed Jan 29 15:56:40 2020 +0100
07a51b
07a51b
    ip-xfrm: Fix help messages
07a51b
07a51b
    After commit 8589eb4efdf2a ("treewide: refactor help messages") help
07a51b
    messages for xfrm state and policy are broken, printing many times the
07a51b
    same protocol in UPSPEC section:
07a51b
07a51b
    $ ip xfrm state help
07a51b
    [...]
07a51b
    UPSPEC := proto { { tcp | tcp | tcp | tcp } [ sport PORT ] [ dport PORT ] |
07a51b
                      { icmp | icmp | icmp } [ type NUMBER ] [ code NUMBER ] |
07a51b
                      gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }
07a51b
07a51b
    This happens because strxf_proto function is non-reentrant and gets called
07a51b
    multiple times in the same fprintf instruction.
07a51b
07a51b
    This commit fix the issue avoiding calls to strxf_proto() with a constant
07a51b
    param, just hardcoding strings for protocol names.
07a51b
07a51b
    Fixes: 8589eb4efdf2a ("treewide: refactor help messages")
07a51b
    Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
07a51b
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
07a51b
---
07a51b
 ip/xfrm_policy.c | 21 +++------------------
07a51b
 ip/xfrm_state.c  | 24 +++---------------------
07a51b
 2 files changed, 6 insertions(+), 39 deletions(-)
07a51b
07a51b
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
07a51b
index 7c0233c182902..d3c706d3225f0 100644
07a51b
--- a/ip/xfrm_policy.c
07a51b
+++ b/ip/xfrm_policy.c
07a51b
@@ -66,24 +66,9 @@ static void usage(void)
07a51b
 		"Usage: ip xfrm policy count\n"
07a51b
 		"Usage: ip xfrm policy set [ hthresh4 LBITS RBITS ] [ hthresh6 LBITS RBITS ]\n"
07a51b
 		"SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
07a51b
-		"UPSPEC := proto { { ");
07a51b
-	fprintf(stderr, "%s | %s | %s | %s } ",
07a51b
-		strxf_proto(IPPROTO_TCP),
07a51b
-		strxf_proto(IPPROTO_UDP),
07a51b
-		strxf_proto(IPPROTO_SCTP),
07a51b
-		strxf_proto(IPPROTO_DCCP));
07a51b
-	fprintf(stderr,
07a51b
-		"[ sport PORT ] [ dport PORT ] |\n"
07a51b
-		"                  { %s | %s | %s } ",
07a51b
-		strxf_proto(IPPROTO_ICMP),
07a51b
-		strxf_proto(IPPROTO_ICMPV6),
07a51b
-		strxf_proto(IPPROTO_MH));
07a51b
-	fprintf(stderr,
07a51b
-		"[ type NUMBER ] [ code NUMBER ] |\n"
07a51b
-		"                  %s",
07a51b
-		strxf_proto(IPPROTO_GRE));
07a51b
-	fprintf(stderr,
07a51b
-		" [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
07a51b
+		"UPSPEC := proto { { tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |\n"
07a51b
+		"                  { icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code NUMBER ] |\n"
07a51b
+		"                  gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
07a51b
 		"DIR := in | out | fwd\n"
07a51b
 		"PTYPE := main | sub\n"
07a51b
 		"ACTION := allow | block\n"
07a51b
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
07a51b
index b03ccc5807e90..7b413cd9b9a22 100644
07a51b
--- a/ip/xfrm_state.c
07a51b
+++ b/ip/xfrm_state.c
07a51b
@@ -106,27 +106,9 @@ static void usage(void)
07a51b
 		"EXTRA-FLAG-LIST := [ EXTRA-FLAG-LIST ] EXTRA-FLAG\n"
07a51b
 		"EXTRA-FLAG := dont-encap-dscp\n"
07a51b
 		"SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
07a51b
-		"UPSPEC := proto { { ");
07a51b
-	fprintf(stderr,
07a51b
-		"%s | %s | %s | %s",
07a51b
-		strxf_proto(IPPROTO_TCP),
07a51b
-		strxf_proto(IPPROTO_UDP),
07a51b
-		strxf_proto(IPPROTO_SCTP),
07a51b
-		strxf_proto(IPPROTO_DCCP));
07a51b
-	fprintf(stderr,
07a51b
-		" } [ sport PORT ] [ dport PORT ] |\n"
07a51b
-		"                  { ");
07a51b
-	fprintf(stderr,
07a51b
-		"%s | %s | %s",
07a51b
-		strxf_proto(IPPROTO_ICMP),
07a51b
-		strxf_proto(IPPROTO_ICMPV6),
07a51b
-		strxf_proto(IPPROTO_MH));
07a51b
-	fprintf(stderr,
07a51b
-		" } [ type NUMBER ] [ code NUMBER ] |\n");
07a51b
-	fprintf(stderr,
07a51b
-		"                  %s", strxf_proto(IPPROTO_GRE));
07a51b
-	fprintf(stderr,
07a51b
-		" [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
07a51b
+		"UPSPEC := proto { { tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |\n"
07a51b
+		"                  { icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code NUMBER ] |\n"
07a51b
+		"                  gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
07a51b
 		"LIMIT-LIST := [ LIMIT-LIST ] limit LIMIT\n"
07a51b
 		"LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard } SECONDS |\n"
07a51b
 		"         { byte-soft | byte-hard } SIZE | { packet-soft | packet-hard } COUNT\n"
07a51b
-- 
07a51b
2.25.4
07a51b