naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0041-iplink-fix-incorrect-any-address-handling-for-ip-tun.patch

7e752c
From 6549ac61c997af9a96d13cb4ae94d1a7b1993762 Mon Sep 17 00:00:00 2001
7e752c
From: Phil Sutter <psutter@redhat.com>
7e752c
Date: Tue, 18 Dec 2018 17:34:35 +0100
7e752c
Subject: [PATCH] iplink: fix incorrect any address handling for ip tunnels
7e752c
7e752c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1626304
7e752c
Upstream Status: iproute2.git commit fa1e658e84ab2
7e752c
7e752c
commit fa1e658e84ab267bb98955e44774831bb36f3861
7e752c
Author: Hangbin Liu <liuhangbin@gmail.com>
7e752c
Date:   Tue Sep 18 17:48:40 2018 +0800
7e752c
7e752c
    iplink: fix incorrect any address handling for ip tunnels
7e752c
7e752c
    After commit d42c7891d26e4 ("utils: Do not reset family for default, any,
7e752c
    all addresses"), when call get_addr() for any/all addresses, we will set
7e752c
    addr->flags to ADDRTYPE_INET_UNSPEC if family is AF_INET/AF_INET6, which
7e752c
    makes is_addrtype_inet() checking passed and assigns incorrect address
7e752c
    to kernel. The ip link cmd will return error like:
7e752c
7e752c
    ]# ip link add ipip1 type ipip local any remote 1.1.1.1
7e752c
    RTNETLINK answers: Numerical result out of range
7e752c
7e752c
    Fix it by using is_addrtype_inet_not_unspec() to avoid unspec addresses.
7e752c
7e752c
    geneve, vxlan are not affected as they use AF_UNSPEC family when call
7e752c
    get_addr()
7e752c
7e752c
    Reported-by: Jianlin Shi <jishi@redhat.com>
7e752c
    Fixes: d42c7891d26e4 ("utils: Do not reset family for default, any, all addresses")
7e752c
    Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
7e752c
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
7e752c
---
7e752c
 ip/link_gre.c    | 4 ++--
7e752c
 ip/link_gre6.c   | 4 ++--
7e752c
 ip/link_ip6tnl.c | 4 ++--
7e752c
 ip/link_iptnl.c  | 4 ++--
7e752c
 ip/link_vti.c    | 4 ++--
7e752c
 ip/link_vti6.c   | 4 ++--
7e752c
 6 files changed, 12 insertions(+), 12 deletions(-)
7e752c
7e752c
diff --git a/ip/link_gre.c b/ip/link_gre.c
7e752c
index ede761b..1ee7ee1 100644
7e752c
--- a/ip/link_gre.c
7e752c
+++ b/ip/link_gre.c
7e752c
@@ -395,9 +395,9 @@ get_failed:
7e752c
 	addattr32(n, 1024, IFLA_GRE_OKEY, okey);
7e752c
 	addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
7e752c
 	addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
7e752c
-	if (is_addrtype_inet(&saddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&saddr))
7e752c
 		addattr_l(n, 1024, IFLA_GRE_LOCAL, saddr.data, saddr.bytelen);
7e752c
-	if (is_addrtype_inet(&daddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&daddr))
7e752c
 		addattr_l(n, 1024, IFLA_GRE_REMOTE, daddr.data, daddr.bytelen);
7e752c
 	addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
7e752c
 	if (ignore_df)
7e752c
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
7e752c
index 181b2ea..20f9305 100644
7e752c
--- a/ip/link_gre6.c
7e752c
+++ b/ip/link_gre6.c
7e752c
@@ -424,9 +424,9 @@ get_failed:
7e752c
 	addattr32(n, 1024, IFLA_GRE_OKEY, okey);
7e752c
 	addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
7e752c
 	addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
7e752c
-	if (is_addrtype_inet(&saddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&saddr))
7e752c
 		addattr_l(n, 1024, IFLA_GRE_LOCAL, saddr.data, saddr.bytelen);
7e752c
-	if (is_addrtype_inet(&daddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&daddr))
7e752c
 		addattr_l(n, 1024, IFLA_GRE_REMOTE, daddr.data, daddr.bytelen);
7e752c
 	if (link)
7e752c
 		addattr32(n, 1024, IFLA_GRE_LINK, link);
7e752c
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
7e752c
index c7fef2e..cfe2c5a 100644
7e752c
--- a/ip/link_ip6tnl.c
7e752c
+++ b/ip/link_ip6tnl.c
7e752c
@@ -320,11 +320,11 @@ get_failed:
7e752c
 		return 0;
7e752c
 	}
7e752c
 
7e752c
-	if (is_addrtype_inet(&saddr)) {
7e752c
+	if (is_addrtype_inet_not_unspec(&saddr)) {
7e752c
 		addattr_l(n, 1024, IFLA_IPTUN_LOCAL,
7e752c
 			  saddr.data, saddr.bytelen);
7e752c
 	}
7e752c
-	if (is_addrtype_inet(&daddr)) {
7e752c
+	if (is_addrtype_inet_not_unspec(&daddr)) {
7e752c
 		addattr_l(n, 1024, IFLA_IPTUN_REMOTE,
7e752c
 			  daddr.data, daddr.bytelen);
7e752c
 	}
7e752c
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
7e752c
index 57f4d0c..7ec1594 100644
7e752c
--- a/ip/link_iptnl.c
7e752c
+++ b/ip/link_iptnl.c
7e752c
@@ -325,11 +325,11 @@ get_failed:
7e752c
 		return 0;
7e752c
 	}
7e752c
 
7e752c
-	if (is_addrtype_inet(&saddr)) {
7e752c
+	if (is_addrtype_inet_not_unspec(&saddr)) {
7e752c
 		addattr_l(n, 1024, IFLA_IPTUN_LOCAL,
7e752c
 			  saddr.data, saddr.bytelen);
7e752c
 	}
7e752c
-	if (is_addrtype_inet(&daddr)) {
7e752c
+	if (is_addrtype_inet_not_unspec(&daddr)) {
7e752c
 		addattr_l(n, 1024, IFLA_IPTUN_REMOTE,
7e752c
 			  daddr.data, daddr.bytelen);
7e752c
 	}
7e752c
diff --git a/ip/link_vti.c b/ip/link_vti.c
7e752c
index 6196a1c..3fff441 100644
7e752c
--- a/ip/link_vti.c
7e752c
+++ b/ip/link_vti.c
7e752c
@@ -157,9 +157,9 @@ get_failed:
7e752c
 
7e752c
 	addattr32(n, 1024, IFLA_VTI_IKEY, ikey);
7e752c
 	addattr32(n, 1024, IFLA_VTI_OKEY, okey);
7e752c
-	if (is_addrtype_inet(&saddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&saddr))
7e752c
 		addattr_l(n, 1024, IFLA_VTI_LOCAL, saddr.data, saddr.bytelen);
7e752c
-	if (is_addrtype_inet(&daddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&daddr))
7e752c
 		addattr_l(n, 1024, IFLA_VTI_REMOTE, daddr.data, daddr.bytelen);
7e752c
 	addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark);
7e752c
 	if (link)
7e752c
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
7e752c
index 4263615..f5a267a 100644
7e752c
--- a/ip/link_vti6.c
7e752c
+++ b/ip/link_vti6.c
7e752c
@@ -159,9 +159,9 @@ get_failed:
7e752c
 
7e752c
 	addattr32(n, 1024, IFLA_VTI_IKEY, ikey);
7e752c
 	addattr32(n, 1024, IFLA_VTI_OKEY, okey);
7e752c
-	if (is_addrtype_inet(&saddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&saddr))
7e752c
 		addattr_l(n, 1024, IFLA_VTI_LOCAL, saddr.data, saddr.bytelen);
7e752c
-	if (is_addrtype_inet(&daddr))
7e752c
+	if (is_addrtype_inet_not_unspec(&daddr))
7e752c
 		addattr_l(n, 1024, IFLA_VTI_REMOTE, daddr.data, daddr.bytelen);
7e752c
 	addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark);
7e752c
 	if (link)
7e752c
-- 
7e752c
1.8.3.1
7e752c