]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ipaddress: do not add IFA_FLAGS when not necessary
authorWANG Cong <xiyou.wangcong@gmail.com>
Fri, 4 Apr 2014 17:07:20 +0000 (10:07 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Sat, 12 Apr 2014 00:44:57 +0000 (17:44 -0700)
commit 37c9b94ed21d5779acc23d89a4 (add support for extended ifa_flags)
introduced a regression:

        # ./ip/ip addr add 192.168.0.1/24 dev eth0
        RTNETLINK answers: Invalid argument

This is due to old kernels don't support IFA_FLAGS flag, we should not
use it if we don't use the flags beyond old .ifa_flags.

Cc: Jiri Pirko <jiri@resnulli.us>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
ip/ipaddress.c

index 14d17200defe2eafe4c05a30dff674d122fbb967..e3be5b228e2ea83f0d2bd98f6f5e7fac82ada6ca 100644 (file)
@@ -1398,8 +1398,10 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
                }
                argc--; argv++;
        }
-       req.ifa.ifa_flags = ifa_flags;
-       addattr32(&req.n, sizeof(req), IFA_FLAGS, ifa_flags);
+       if (ifa_flags <= 0xff)
+               req.ifa.ifa_flags = ifa_flags;
+       else
+               addattr32(&req.n, sizeof(req), IFA_FLAGS, ifa_flags);
 
        if (d == NULL) {
                fprintf(stderr, "Not enough information: \"dev\" argument is required.\n");