]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink: fix incorrect any address handling for ip tunnels
authorHangbin Liu <liuhangbin@gmail.com>
Tue, 18 Sep 2018 09:48:40 +0000 (17:48 +0800)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 21 Sep 2018 18:28:33 +0000 (11:28 -0700)
After commit d42c7891d26e4 ("utils: Do not reset family for default, any,
all addresses"), when call get_addr() for any/all addresses, we will set
addr->flags to ADDRTYPE_INET_UNSPEC if family is AF_INET/AF_INET6, which
makes is_addrtype_inet() checking passed and assigns incorrect address
to kernel. The ip link cmd will return error like:

]# ip link add ipip1 type ipip local any remote 1.1.1.1
RTNETLINK answers: Numerical result out of range

Fix it by using is_addrtype_inet_not_unspec() to avoid unspec addresses.

geneve, vxlan are not affected as they use AF_UNSPEC family when call
get_addr()

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: d42c7891d26e4 ("utils: Do not reset family for default, any, all addresses")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/link_gre.c
ip/link_gre6.c
ip/link_ip6tnl.c
ip/link_iptnl.c
ip/link_vti.c
ip/link_vti6.c

index ede761b23a8c1e5c0c21c4620f7de2dcaa7bc1fd..1ee7ee13ab6cdcc90132efff8c353e22266faaac 100644 (file)
@@ -395,9 +395,9 @@ get_failed:
        addattr32(n, 1024, IFLA_GRE_OKEY, okey);
        addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
        addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
-       if (is_addrtype_inet(&saddr))
+       if (is_addrtype_inet_not_unspec(&saddr))
                addattr_l(n, 1024, IFLA_GRE_LOCAL, saddr.data, saddr.bytelen);
-       if (is_addrtype_inet(&daddr))
+       if (is_addrtype_inet_not_unspec(&daddr))
                addattr_l(n, 1024, IFLA_GRE_REMOTE, daddr.data, daddr.bytelen);
        addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
        if (ignore_df)
index 181b2eae808b11dc02442c38f33c95b3177fda41..20f930596027972d23d4798cebb167e9c54d7d32 100644 (file)
@@ -424,9 +424,9 @@ get_failed:
        addattr32(n, 1024, IFLA_GRE_OKEY, okey);
        addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
        addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
-       if (is_addrtype_inet(&saddr))
+       if (is_addrtype_inet_not_unspec(&saddr))
                addattr_l(n, 1024, IFLA_GRE_LOCAL, saddr.data, saddr.bytelen);
-       if (is_addrtype_inet(&daddr))
+       if (is_addrtype_inet_not_unspec(&daddr))
                addattr_l(n, 1024, IFLA_GRE_REMOTE, daddr.data, daddr.bytelen);
        if (link)
                addattr32(n, 1024, IFLA_GRE_LINK, link);
index c7fef2e0366010e18fd09032cd8c43c138d7f51d..cfe2c5aa372422f9e1ff40cc6cd4b577e207fadc 100644 (file)
@@ -320,11 +320,11 @@ get_failed:
                return 0;
        }
 
-       if (is_addrtype_inet(&saddr)) {
+       if (is_addrtype_inet_not_unspec(&saddr)) {
                addattr_l(n, 1024, IFLA_IPTUN_LOCAL,
                          saddr.data, saddr.bytelen);
        }
-       if (is_addrtype_inet(&daddr)) {
+       if (is_addrtype_inet_not_unspec(&daddr)) {
                addattr_l(n, 1024, IFLA_IPTUN_REMOTE,
                          daddr.data, daddr.bytelen);
        }
index 57f4d0c7a8731b073551ccffd633441e6be4c464..7ec1594d071679440df26218b78a968418497ae0 100644 (file)
@@ -325,11 +325,11 @@ get_failed:
                return 0;
        }
 
-       if (is_addrtype_inet(&saddr)) {
+       if (is_addrtype_inet_not_unspec(&saddr)) {
                addattr_l(n, 1024, IFLA_IPTUN_LOCAL,
                          saddr.data, saddr.bytelen);
        }
-       if (is_addrtype_inet(&daddr)) {
+       if (is_addrtype_inet_not_unspec(&daddr)) {
                addattr_l(n, 1024, IFLA_IPTUN_REMOTE,
                          daddr.data, daddr.bytelen);
        }
index 6196a1c9e2f37a1da34d2ae5408d53ad929884b2..3fff4417de11b1158ec5768cccef77afaf929f85 100644 (file)
@@ -157,9 +157,9 @@ get_failed:
 
        addattr32(n, 1024, IFLA_VTI_IKEY, ikey);
        addattr32(n, 1024, IFLA_VTI_OKEY, okey);
-       if (is_addrtype_inet(&saddr))
+       if (is_addrtype_inet_not_unspec(&saddr))
                addattr_l(n, 1024, IFLA_VTI_LOCAL, saddr.data, saddr.bytelen);
-       if (is_addrtype_inet(&daddr))
+       if (is_addrtype_inet_not_unspec(&daddr))
                addattr_l(n, 1024, IFLA_VTI_REMOTE, daddr.data, daddr.bytelen);
        addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark);
        if (link)
index 4263615b2aecfaf3a3370441deeb0e6a6a93e8e1..f5a267a81d9de8c6fe5ebfca3a57da3e19090068 100644 (file)
@@ -159,9 +159,9 @@ get_failed:
 
        addattr32(n, 1024, IFLA_VTI_IKEY, ikey);
        addattr32(n, 1024, IFLA_VTI_OKEY, okey);
-       if (is_addrtype_inet(&saddr))
+       if (is_addrtype_inet_not_unspec(&saddr))
                addattr_l(n, 1024, IFLA_VTI_LOCAL, saddr.data, saddr.bytelen);
-       if (is_addrtype_inet(&daddr))
+       if (is_addrtype_inet_not_unspec(&daddr))
                addattr_l(n, 1024, IFLA_VTI_REMOTE, daddr.data, daddr.bytelen);
        addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark);
        if (link)