netifd: allow negative neighlocktime values
authorAlin Năstac <alin.nastac@gmail.com>
Thu, 17 Aug 2017 12:12:05 +0000 (14:12 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 17 Aug 2017 16:35:51 +0000 (18:35 +0200)
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@gmail.com>
device.h
system-linux.c

index 74d20d65cd11c740ec225e516b7f1ff4c15f928e..7ad733eaf5cd1a64d10de5631d5ac9804023d0f3 100644 (file)
--- 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;
index f38aaed584ead695df6ca139174a1585690db552..02faa328262faf94ed09d93c4ae68c8ada1fa71b 100644 (file)
@@ -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) {