[LEDE-DEV] [PATCHv2] netifd: allow negative neighlocktime values

Alin Nastac alin.nastac at gmail.com
Thu Aug 17 05:12:05 PDT 2017


When -1 is written in /proc/sys/net/ipv4/neigh/<iface>/locktime,
kernel disables ARP trashing protection. A value of 0 does not completely
disable this protection, a second ARP update being discarded if it
is processed during the same jiffie as the first update.

Signed-off-by: Alin Nastac <alin.nastac at gmail.com>
---
 device.h       | 2 +-
 system-linux.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/device.h b/device.h
index 74d20d6..7ad733e 100644
--- a/device.h
+++ b/device.h
@@ -162,7 +162,7 @@ struct device_settings {
 	unsigned int neigh6reachabletime;
 	unsigned int neigh4gcstaletime;
 	unsigned int neigh6gcstaletime;
-	unsigned int neigh4locktime;
+	int neigh4locktime;
 	bool rps;
 	bool xps;
 	unsigned int dadtransmits;
diff --git a/system-linux.c b/system-linux.c
index 483a98d..0480b56 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -1362,7 +1362,7 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
 	}
 
 	if (!system_get_neigh4locktime(dev, buf, sizeof(buf))) {
-		s->neigh4locktime = strtoul(buf, NULL, 0);
+		s->neigh4locktime = strtol(buf, NULL, 0);
 		s->flags |= DEV_OPT_NEIGHLOCKTIME;
 	}
 
@@ -1476,7 +1476,7 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
 		system_set_neigh6reachabletime(dev, buf);
 	}
 	if (s->flags & DEV_OPT_NEIGHLOCKTIME & apply_mask) {
-		snprintf(buf, sizeof(buf), "%u", s->neigh4locktime);
+		snprintf(buf, sizeof(buf), "%d", s->neigh4locktime);
 		system_set_neigh4locktime(dev, buf);
 	}
 	if (s->flags & DEV_OPT_NEIGHGCSTALETIME & apply_mask) {
-- 
2.7.4




More information about the Lede-dev mailing list