-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netifd: 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: openwrt/netifd#17 Signed-off-by: Jo-Philipp Wich <[email protected]>
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From 8587c074f1eb2064c42adb0a6aa5073f695ab89d Mon Sep 17 00:00:00 2001 | ||
From: Jo-Philipp Wich <[email protected]> | ||
Date: Tue, 14 Nov 2023 14:01:44 +0100 | ||
Subject: [PATCH] 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 <[email protected]> | ||
--- | ||
interface-ip.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
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) { | ||
-- | ||
2.39.1 | ||
|