aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2023-11-14 14:38:11 +0100
committerJo-Philipp Wich <jo@mein.io>2023-11-14 14:38:11 +0100
commit842932a63d8993150ff339f11f0cd0d5dc45e6cc (patch)
tree5dcaf446c7440558da648fb828b684164b52f456
parent51bb178824f937b1f1988c9351e3586f81c18b74 (diff)
downloadupstream-842932a63d8993150ff339f11f0cd0d5dc45e6cc.tar.gz
upstream-842932a63d8993150ff339f11f0cd0d5dc45e6cc.tar.bz2
upstream-842932a63d8993150ff339f11f0cd0d5dc45e6cc.zip
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: https://github.com/openwrt/netifd/issues/17 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--package/network/config/netifd/Makefile2
-rw-r--r--package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch32
2 files changed, 33 insertions, 1 deletions
diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
index 826889aca6..d237ed181f 100644
--- a/package/network/config/netifd/Makefile
+++ b/package/network/config/netifd/Makefile
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=netifd
-PKG_RELEASE:=1
+PKG_RELEASE:=1.1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
diff --git a/package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch b/package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch
new file mode 100644
index 0000000000..dd9374a83c
--- /dev/null
+++ b/package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch
@@ -0,0 +1,32 @@
+From 8587c074f1eb2064c42adb0a6aa5073f695ab89d Mon Sep 17 00:00:00 2001
+From: Jo-Philipp Wich <jo@mein.io>
+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 <jo@mein.io>
+---
+ 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
+