router: skip parse_routes when ra_default > 1
authorStijn Tintel <stijn@linux-ipv6.be>
Sun, 14 Aug 2016 17:22:57 +0000 (20:22 +0300)
committerStijn Tintel <stijn@linux-ipv6.be>
Tue, 27 Dec 2016 08:36:51 +0000 (09:36 +0100)
It does not make sense to scan the entire routing table if the decision
will be overridden afterwards.

This makes it possible to use odhcpd on a router with full IPv6 BGP
table, by setting ra_default to 2. Without this change, odhcpd is
constantly busy reading /proc/net/ipv6_route, and doesn't respond to
router solicitations in time.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
src/router.c

index 971197530918776d1f185dae9cab8a255fac5474..f964a82a813368a100eb2f888add88b6b40816fa 100644 (file)
@@ -257,10 +257,10 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                memcpy(addrs, iface->ia_addr, ipcnt * sizeof(*addrs));
 
                // Check default route
-               if (parse_routes(addrs, ipcnt))
-                       adv.h.nd_ra_router_lifetime = htons(1);
                if (iface->default_router > 1)
                        adv.h.nd_ra_router_lifetime = htons(iface->default_router);
+               else if (parse_routes(addrs, ipcnt))
+                       adv.h.nd_ra_router_lifetime = htons(1);
        }
 
        // Construct Prefix Information options