naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/iproute2-3.10.0-fix-ip-tunnel-command-for-vti-tunnels-with-io-key-gi.patch

a4b897
From ac525bc5be98547620bc8d9df9e040438f60f2a8 Mon Sep 17 00:00:00 2001
a4b897
From: Phil Sutter <psutter@redhat.com>
a4b897
Date: Fri, 7 Aug 2015 13:18:13 +0200
a4b897
Subject: [PATCH] fix ip tunnel command for vti tunnels with [io]key given
a4b897
a4b897
This patch folds five upstream commits:
a4b897
- 30d07e9 iproute2: spelling: noptmudisc -> nopmtudisc
a4b897
- 1c28bd5 iptunnel: Allow GRE_KEY for vti interface
a4b897
- 0612519 Remove trailing whitespace
a4b897
- 0cb6bb5 do not exit silently when link is not found
a4b897
- 23d526c fix ip tunnel for vti tunnels with ikey
a4b897
---
a4b897
 ip/ipaddress.c    |  2 +-
a4b897
 ip/ipaddrlabel.c  |  2 +-
a4b897
 ip/iplink_vxlan.c |  5 ++++-
a4b897
 ip/iproute.c      |  2 +-
a4b897
 ip/iptunnel.c     | 36 ++++++++++++++++++++----------------
a4b897
 ip/ipxfrm.c       |  4 ++--
a4b897
 ip/link_gre.c     |  7 +++++--
a4b897
 ip/link_gre6.c    |  5 ++++-
a4b897
 ip/link_iptnl.c   |  2 +-
a4b897
 ip/link_vti.c     |  5 ++++-
a4b897
 ip/tunnel.c       |  2 +-
a4b897
 ip/xfrm_state.c   |  2 +-
a4b897
 12 files changed, 45 insertions(+), 29 deletions(-)
a4b897
a4b897
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
a4b897
index c99a078..4650a2e 100644
a4b897
--- a/ip/ipaddress.c
a4b897
+++ b/ip/ipaddress.c
a4b897
@@ -126,7 +126,7 @@ static void print_link_flags(FILE *fp, unsigned flags, unsigned mdown)
a4b897
 }
a4b897
 
a4b897
 static const char *oper_states[] = {
a4b897
-	"UNKNOWN", "NOTPRESENT", "DOWN", "LOWERLAYERDOWN", 
a4b897
+	"UNKNOWN", "NOTPRESENT", "DOWN", "LOWERLAYERDOWN",
a4b897
 	"TESTING", "DORMANT",	 "UP"
a4b897
 };
a4b897
 
a4b897
diff --git a/ip/ipaddrlabel.c b/ip/ipaddrlabel.c
a4b897
index 1789d9c..301074b 100644
a4b897
--- a/ip/ipaddrlabel.c
a4b897
+++ b/ip/ipaddrlabel.c
a4b897
@@ -134,7 +134,7 @@ static int ipaddrlabel_modify(int cmd, int argc, char **argv)
a4b897
 	inet_prefix prefix;
a4b897
 	uint32_t label = 0xffffffffUL;
a4b897
 	char *p = NULL;
a4b897
-	char *l = NULL;        
a4b897
+	char *l = NULL;
a4b897
 
a4b897
 	memset(&req, 0, sizeof(req));
a4b897
 	memset(&prefix, 0, sizeof(prefix));
a4b897
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
a4b897
index 43b8abc..2f3a84c 100644
a4b897
--- a/ip/iplink_vxlan.c
a4b897
+++ b/ip/iplink_vxlan.c
a4b897
@@ -104,8 +104,11 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
a4b897
 		} else if (!matches(*argv, "dev")) {
a4b897
 			NEXT_ARG();
a4b897
 			link = if_nametoindex(*argv);
a4b897
-			if (link == 0)
a4b897
+			if (link == 0) {
a4b897
+				fprintf(stderr, "Cannot find device \"%s\"\n",
a4b897
+					*argv);
a4b897
 				exit(-1);
a4b897
+			}
a4b897
 		} else if (!matches(*argv, "ttl") ||
a4b897
 			   !matches(*argv, "hoplimit")) {
a4b897
 			unsigned uval;
a4b897
diff --git a/ip/iproute.c b/ip/iproute.c
a4b897
index 984d970..207301c 100644
a4b897
--- a/ip/iproute.c
a4b897
+++ b/ip/iproute.c
a4b897
@@ -837,7 +837,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
a4b897
 			}
a4b897
 			if (get_time_rtt(&rtt, *argv, &raw))
a4b897
 				invarg("\"rtt\" value is invalid\n", *argv);
a4b897
-			rta_addattr32(mxrta, sizeof(mxbuf), RTAX_RTT, 
a4b897
+			rta_addattr32(mxrta, sizeof(mxbuf), RTAX_RTT,
a4b897
 				(raw) ? rtt : rtt * 8);
a4b897
 		} else if (strcmp(*argv, "rto_min") == 0) {
a4b897
 			unsigned rto_min;
a4b897
diff --git a/ip/iptunnel.c b/ip/iptunnel.c
a4b897
index 9099503..29188c4 100644
a4b897
--- a/ip/iptunnel.c
a4b897
+++ b/ip/iptunnel.c
a4b897
@@ -240,8 +240,9 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
a4b897
 		}
a4b897
 	}
a4b897
 
a4b897
-	if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) {
a4b897
-		if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
a4b897
+	if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
a4b897
+		if (!(p->i_flags & VTI_ISVTI) &&
a4b897
+		    (p->iph.protocol != IPPROTO_GRE)) {
a4b897
 			fprintf(stderr, "Keys are not allowed with ipip and sit tunnels\n");
a4b897
 			return -1;
a4b897
 		}
a4b897
@@ -249,8 +250,11 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
a4b897
 
a4b897
 	if (medium[0]) {
a4b897
 		p->link = if_nametoindex(medium);
a4b897
-		if (p->link == 0)
a4b897
+		if (p->link == 0) {
a4b897
+			fprintf(stderr, "Cannot find device \"%s\"\n",
a4b897
+				medium);
a4b897
 			return -1;
a4b897
+		}
a4b897
 	}
a4b897
 
a4b897
 	if (p->i_key == 0 && IN_MULTICAST(ntohl(p->iph.daddr))) {
a4b897
@@ -280,16 +284,16 @@ static int do_add(int cmd, int argc, char **argv)
a4b897
 		return -1;
a4b897
 
a4b897
 	if (p.iph.ttl && p.iph.frag_off == 0) {
a4b897
-		fprintf(stderr, "ttl != 0 and noptmudisc are incompatible\n");
a4b897
+		fprintf(stderr, "ttl != 0 and nopmtudisc are incompatible\n");
a4b897
 		return -1;
a4b897
 	}
a4b897
 
a4b897
 	switch (p.iph.protocol) {
a4b897
 	case IPPROTO_IPIP:
a4b897
-		if (p.i_flags != VTI_ISVTI)
a4b897
-			return tnl_add_ioctl(cmd, "tunl0", p.name, &p);
a4b897
-		else
a4b897
+		if (p.i_flags & VTI_ISVTI)
a4b897
 			return tnl_add_ioctl(cmd, "ip_vti0", p.name, &p);
a4b897
+		else
a4b897
+			return tnl_add_ioctl(cmd, "tunl0", p.name, &p);
a4b897
 	case IPPROTO_GRE:
a4b897
 		return tnl_add_ioctl(cmd, "gre0", p.name, &p);
a4b897
 	case IPPROTO_IPV6:
a4b897
@@ -310,10 +314,10 @@ static int do_del(int argc, char **argv)
a4b897
 
a4b897
 	switch (p.iph.protocol) {
a4b897
 	case IPPROTO_IPIP:
a4b897
-		if (p.i_flags != VTI_ISVTI)
a4b897
-			return tnl_del_ioctl("tunl0", p.name, &p);
a4b897
-		else
a4b897
+		if (p.i_flags & VTI_ISVTI)
a4b897
 			return tnl_del_ioctl("ip_vti0", p.name, &p);
a4b897
+		else
a4b897
+			return tnl_del_ioctl("tunl0", p.name, &p);
a4b897
 	case IPPROTO_GRE:
a4b897
 		return tnl_del_ioctl("gre0", p.name, &p);
a4b897
 	case IPPROTO_IPV6:
a4b897
@@ -344,16 +348,16 @@ static void print_tunnel(struct ip_tunnel_parm *p)
a4b897
 	if (p->iph.protocol == IPPROTO_IPV6 && (p->i_flags & SIT_ISATAP)) {
a4b897
 		struct ip_tunnel_prl prl[16];
a4b897
 		int i;
a4b897
-		
a4b897
+
a4b897
 		memset(prl, 0, sizeof(prl));
a4b897
 		prl[0].datalen = sizeof(prl) - sizeof(prl[0]);
a4b897
 		prl[0].addr = htonl(INADDR_ANY);
a4b897
-	
a4b897
+
a4b897
 		if (!tnl_prl_ioctl(SIOCGETPRL, p->name, prl))
a4b897
 			for (i = 1; i < sizeof(prl) / sizeof(prl[0]); i++)
a4b897
 		{
a4b897
 			if (prl[i].addr != htonl(INADDR_ANY)) {
a4b897
-				printf(" %s %s ", 
a4b897
+				printf(" %s %s ",
a4b897
 					(prl[i].flags & PRL_DEFAULT) ? "pdr" : "pr",
a4b897
 					format_host(AF_INET, 4, &prl[i].addr, s1, sizeof(s1)));
a4b897
 			}
a4b897
@@ -502,10 +506,10 @@ static int do_show(int argc, char **argv)
a4b897
 
a4b897
 	switch (p.iph.protocol) {
a4b897
 	case IPPROTO_IPIP:
a4b897
-		if (p.i_flags != VTI_ISVTI)
a4b897
-			err = tnl_get_ioctl(p.name[0] ? p.name : "tunl0", &p);
a4b897
-		else
a4b897
+		if (p.i_flags & VTI_ISVTI)
a4b897
 			err = tnl_get_ioctl(p.name[0] ? p.name : "ip_vti0", &p);
a4b897
+		else
a4b897
+			err = tnl_get_ioctl(p.name[0] ? p.name : "tunl0", &p);
a4b897
 		break;
a4b897
 	case IPPROTO_GRE:
a4b897
 		err = tnl_get_ioctl(p.name[0] ? p.name : "gre0", &p);
a4b897
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
a4b897
index 020159c..a6ec4cf 100644
a4b897
--- a/ip/ipxfrm.c
a4b897
+++ b/ip/ipxfrm.c
a4b897
@@ -358,7 +358,7 @@ void xfrm_stats_print(struct xfrm_stats *s, FILE *fp, const char *prefix)
a4b897
 
a4b897
 	if (prefix)
a4b897
 		fputs(prefix, fp);
a4b897
-	fprintf(fp, "  replay-window %u replay %u failed %u%s", 
a4b897
+	fprintf(fp, "  replay-window %u replay %u failed %u%s",
a4b897
 		s->replay_window, s->replay, s->integrity_failed, _SL_);
a4b897
 }
a4b897
 
a4b897
@@ -409,7 +409,7 @@ void xfrm_lifetime_print(struct xfrm_lifetime_cfg *cfg,
a4b897
 
a4b897
 		if (prefix)
a4b897
 			fputs(prefix, fp);
a4b897
-		fprintf(fp, "  expire add: soft %llu(sec), hard %llu(sec)%s", 
a4b897
+		fprintf(fp, "  expire add: soft %llu(sec), hard %llu(sec)%s",
a4b897
 			(unsigned long long) cfg->soft_add_expires_seconds,
a4b897
 			(unsigned long long) cfg->hard_add_expires_seconds,
a4b897
 			_SL_);
a4b897
diff --git a/ip/link_gre.c b/ip/link_gre.c
a4b897
index 7e0b896..fda84d8 100644
a4b897
--- a/ip/link_gre.c
a4b897
+++ b/ip/link_gre.c
a4b897
@@ -207,8 +207,11 @@ get_failed:
a4b897
 		} else if (!matches(*argv, "dev")) {
a4b897
 			NEXT_ARG();
a4b897
 			link = if_nametoindex(*argv);
a4b897
-			if (link == 0)
a4b897
+			if (link == 0) {
a4b897
+				fprintf(stderr, "Cannot find device \"%s\"\n",
a4b897
+					*argv);
a4b897
 				exit(-1);
a4b897
+			}
a4b897
 		} else if (!matches(*argv, "ttl") ||
a4b897
 			   !matches(*argv, "hoplimit")) {
a4b897
 			unsigned uval;
a4b897
@@ -233,7 +236,7 @@ get_failed:
a4b897
 				tos = uval;
a4b897
 			} else
a4b897
 				tos = 1;
a4b897
-		} else 
a4b897
+		} else
a4b897
 			usage();
a4b897
 		argc--; argv++;
a4b897
 	}
a4b897
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
a4b897
index 4c9c536..c7183e2 100644
a4b897
--- a/ip/link_gre6.c
a4b897
+++ b/ip/link_gre6.c
a4b897
@@ -225,8 +225,11 @@ get_failed:
a4b897
 		} else if (!matches(*argv, "dev")) {
a4b897
 			NEXT_ARG();
a4b897
 			link = if_nametoindex(*argv);
a4b897
-			if (link == 0)
a4b897
+			if (link == 0) {
a4b897
+				fprintf(stderr, "Cannot find device \"%s\"\n",
a4b897
+					*argv);
a4b897
 				exit(-1);
a4b897
+			}
a4b897
 		} else if (!matches(*argv, "ttl") ||
a4b897
 			   !matches(*argv, "hoplimit")) {
a4b897
 			__u8 uval;
a4b897
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
a4b897
index b00d8d9..768c4ef 100644
a4b897
--- a/ip/link_iptnl.c
a4b897
+++ b/ip/link_iptnl.c
a4b897
@@ -212,7 +212,7 @@ get_failed:
a4b897
 	}
a4b897
 
a4b897
 	if (ttl && pmtudisc == 0) {
a4b897
-		fprintf(stderr, "ttl != 0 and noptmudisc are incompatible\n");
a4b897
+		fprintf(stderr, "ttl != 0 and nopmtudisc are incompatible\n");
a4b897
 		exit(-1);
a4b897
 	}
a4b897
 
a4b897
diff --git a/ip/link_vti.c b/ip/link_vti.c
a4b897
index 77a7482..6274c83 100644
a4b897
--- a/ip/link_vti.c
a4b897
+++ b/ip/link_vti.c
a4b897
@@ -171,8 +171,11 @@ get_failed:
a4b897
 		} else if (!matches(*argv, "dev")) {
a4b897
 			NEXT_ARG();
a4b897
 			link = if_nametoindex(*argv);
a4b897
-			if (link == 0)
a4b897
+			if (link == 0) {
a4b897
+				fprintf(stderr, "Cannot find device \"%s\"\n",
a4b897
+					*argv);
a4b897
 				exit(-1);
a4b897
+			}
a4b897
 		} else
a4b897
 			usage();
a4b897
 		argc--; argv++;
a4b897
diff --git a/ip/tunnel.c b/ip/tunnel.c
a4b897
index a6a2846..a1a7660 100644
a4b897
--- a/ip/tunnel.c
a4b897
+++ b/ip/tunnel.c
a4b897
@@ -122,7 +122,7 @@ int tnl_del_ioctl(const char *basedev, const char *name, void *p)
a4b897
 	return err;
a4b897
 }
a4b897
 
a4b897
-static int tnl_gen_ioctl(int cmd, const char *name, 
a4b897
+static int tnl_gen_ioctl(int cmd, const char *name,
a4b897
 			 void *p, int skiperr)
a4b897
 {
a4b897
 	struct ifreq ifr;
a4b897
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
a4b897
index 160ab32..208c49c 100644
a4b897
--- a/ip/xfrm_state.c
a4b897
+++ b/ip/xfrm_state.c
a4b897
@@ -1193,7 +1193,7 @@ static int print_sadinfo(struct nlmsghdr *n, void *arg)
a4b897
 				fprintf(fp,"BAD SAD length returned\n");
a4b897
 				return -1;
a4b897
 			}
a4b897
-				
a4b897
+
a4b897
 			si = RTA_DATA(tb[XFRMA_SAD_HINFO]);
a4b897
 			fprintf(fp," (buckets ");
a4b897
 			fprintf(fp,"count %d", si->sadhcnt);
a4b897
-- 
a4b897
1.8.3.1
a4b897