linux: more IPv6 onlink-route handling fixes / improvements
[project/netifd.git] / system-linux.c
index bfd623b..a6dde59 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/sockios.h>
 #include <linux/ip.h>
+#include <linux/if_addr.h>
 #include <linux/if_link.h>
 #include <linux/if_vlan.h>
 #include <linux/if_bridge.h>
@@ -1427,7 +1428,6 @@ static int system_addr(struct device *dev, struct device_addr *addr, int cmd)
                .ifa_family = (alen == 4) ? AF_INET : AF_INET6,
                .ifa_prefixlen = addr->mask,
                .ifa_index = dev->ifindex,
-               .ifa_flags = (addr->flags & DEVADDR_OFFLINK) ? IFA_F_NOPREFIXROUTE : 0,
        };
 
        struct nl_msg *msg;
@@ -1470,6 +1470,9 @@ static int system_addr(struct device *dev, struct device_addr *addr, int cmd)
                }
 
                nla_put(msg, IFA_CACHEINFO, sizeof(cinfo), &cinfo);
+
+               if (cmd == RTM_NEWADDR && (addr->flags & DEVADDR_OFFLINK))
+                       nla_put_u32(msg, IFA_FLAGS, IFA_F_NOPREFIXROUTE);
        }
 
        return system_rtnl_call(msg);