]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
linux: use IFA_F_NOPREFIXROUTE for ipv4 addresses
authorRoy Marples <roy@marples.name>
Sun, 10 Dec 2017 18:49:20 +0000 (18:49 +0000)
committerRoy Marples <roy@marples.name>
Sun, 10 Dec 2017 18:51:13 +0000 (18:51 +0000)
src/if-linux.c

index 647e12617adb0c20e55fcd9d8afdb314039b0c59..f0be076e79649c0afd35c2a6b2183ec2574caa49 100644 (file)
@@ -1455,6 +1455,9 @@ if_address(unsigned char cmd, const struct ipv4_addr *addr)
 {
        struct nlma nlm;
        int retval = 0;
+#if defined(IFA_F_NOPREFIXROUTE)
+       uint32_t flags = 0;
+#endif
 
        memset(&nlm, 0, sizeof(nlm));
        nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
@@ -1477,6 +1480,13 @@ if_address(unsigned char cmd, const struct ipv4_addr *addr)
                add_attr_l(&nlm.hdr, sizeof(nlm), IFA_BROADCAST,
                    &addr->brd.s_addr, sizeof(addr->brd.s_addr));
 
+#ifdef IFA_F_NOPREFIXROUTE
+       if (nlm.ifa.ifa_prefixlen < 32)
+               flags |= IFA_F_NOPREFIXROUTE;
+       if (flags)
+               add_attr_32(&nlm.hdr, sizeof(nlm), IFA_FLAGS, flags);
+#endif
+
        if (send_netlink(addr->iface->ctx, NULL,
            NETLINK_ROUTE, &nlm.hdr, NULL) == -1)
                retval = -1;