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

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