router: filter route information option
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 2 Jan 2019 18:23:11 +0000 (19:23 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 2 Jan 2019 19:38:04 +0000 (20:38 +0100)
Commit 750e457e3000187b85906814a2529ede24775325 added the capability
to filter out prefixes in RAs; however routes were not filtered out
based on the prefixes. This commit fixes this by taking into account
the prefix_filter when constructing the RA route info option

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/router.c

index f8a83a6437d0ddb3d58a32160bb9b17007a6d52a..c71575753df4a2a0aa6c11d7daf3bbc1f3060ce4 100644 (file)
@@ -597,7 +597,12 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
        for (ssize_t i = 0; i < ipcnt; ++i) {
                struct odhcpd_ipaddr *addr = &addrs[i];
                if (addr->dprefix > 64 || addr->dprefix == 0 || addr->valid <= (uint32_t)now)
-                       continue; // Address not suitable
+                       continue; /* Address not suitable */
+
+               if (odhcpd_bmemcmp(&addr->addr, &iface->pio_filter_addr,
+                               iface->pio_filter_length) != 0 ||
+                               addr->prefix < iface->pio_filter_length)
+                       continue; /* RIO filtered out of this RA */
 
                if (addr->dprefix > 32) {
                        addr->addr.in6.s6_addr32[1] &= htonl(~((1U << (64 - addr->dprefix)) - 1));