naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

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

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