summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2023-11-14 13:01:44 +0000
committerJo-Philipp Wich2023-11-14 13:32:53 +0000
commit8587c074f1eb2064c42adb0a6aa5073f695ab89d (patch)
tree3533b9ed54e34335822ec8e3dcb1d63d613935a4
parentc739dee0a37bc593aaed7ae3f0a61e3d7c1fb1ac (diff)
downloadnetifd-8587c074f1eb2064c42adb0a6aa5073f695ab89d.tar.gz
interface-ip: fix IPv4 route target masking
A previous commit supposed to mask out excess host bits in route targets failed to correctly calculate the mask value, causing it to produce improper results for certain mask lengths. Fixes: #17 Fixes: 76eb342 ("interface-ip: mask out host bits in IPv4 route targets") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--interface-ip.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/interface-ip.c b/interface-ip.c
index d2fe385..28e7106 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -448,7 +448,7 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6)
/* Mask out IPv4 host bits to avoid "Invalid prefix for given prefix length" */
if (af == AF_INET && route->mask < 32)
- route->addr.in.s_addr &= ((1u << route->mask) - 1);
+ clear_if_addr(&route->addr, route->mask);
}
if ((cur = tb[ROUTE_GATEWAY]) != NULL) {