summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorAlin Năstac <alin.nastac@gmail.com>2016-05-24 17:02:20 +0200
committerJo-Philipp Wich <jo@mein.io>2016-06-01 15:47:36 +0200
commitfef10041f3a495d79f03f99bdf416a68a0ee91aa (patch)
treea0bf145eaad59089d12bea4a541c7cd9439bdad6 /system-linux.c
parenta0e96d0bdad7e39590ffc8dcb46935f35ee55284 (diff)
netifd: Add option to configure gc_stale_time for each device
The UCI parameter neighgcstaletime allows to control how much time will STALE entries be kept in the neighbour table for both IPv4 and IPv6. Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/system-linux.c b/system-linux.c
index 621f99b..90b0775 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -306,6 +306,16 @@ static void system_set_neigh6reachabletime(struct device *dev, const char *val)
system_set_dev_sysctl("/proc/sys/net/ipv6/neigh/%s/base_reachable_time_ms", dev->ifname, val);
}
+static void system_set_neigh4gcstaletime(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/proc/sys/net/ipv4/neigh/%s/gc_stale_time", dev->ifname, val);
+}
+
+static void system_set_neigh6gcstaletime(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/proc/sys/net/ipv6/neigh/%s/gc_stale_time", dev->ifname, val);
+}
+
static void system_set_dadtransmits(struct device *dev, const char *val)
{
system_set_dev_sysctl("/proc/sys/net/ipv6/conf/%s/dad_transmits", dev->ifname, val);
@@ -452,6 +462,18 @@ static int system_get_neigh6reachabletime(struct device *dev, char *buf, const s
dev->ifname, buf, buf_sz);
}
+static int system_get_neigh4gcstaletime(struct device *dev, char *buf, const size_t buf_sz)
+{
+ return system_get_dev_sysctl("/proc/sys/net/ipv4/neigh/%s/gc_stale_time",
+ dev->ifname, buf, buf_sz);
+}
+
+static int system_get_neigh6gcstaletime(struct device *dev, char *buf, const size_t buf_sz)
+{
+ return system_get_dev_sysctl("/proc/sys/net/ipv6/neigh/%s/gc_stale_time",
+ dev->ifname, buf, buf_sz);
+}
+
static int system_get_dadtransmits(struct device *dev, char *buf, const size_t buf_sz)
{
return system_get_dev_sysctl("/proc/sys/net/ipv6/conf/%s/dad_transmits",
@@ -1243,6 +1265,16 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
s->flags |= DEV_OPT_NEIGHREACHABLETIME;
}
+ if (!system_get_neigh4gcstaletime(dev, buf, sizeof(buf))) {
+ s->neigh4gcstaletime = strtoul(buf, NULL, 0);
+ s->flags |= DEV_OPT_NEIGHGCSTALETIME;
+ }
+
+ if (!system_get_neigh6gcstaletime(dev, buf, sizeof(buf))) {
+ s->neigh6gcstaletime = strtoul(buf, NULL, 0);
+ s->flags |= DEV_OPT_NEIGHGCSTALETIME;
+ }
+
if (!system_get_dadtransmits(dev, buf, sizeof(buf))) {
s->dadtransmits = strtoul(buf, NULL, 0);
s->flags |= DEV_OPT_DADTRANSMITS;
@@ -1337,6 +1369,12 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
snprintf(buf, sizeof(buf), "%d", s->neigh6reachabletime);
system_set_neigh6reachabletime(dev, buf);
}
+ if (s->flags & DEV_OPT_NEIGHGCSTALETIME & apply_mask) {
+ snprintf(buf, sizeof(buf), "%d", s->neigh4gcstaletime);
+ system_set_neigh4gcstaletime(dev, buf);
+ snprintf(buf, sizeof(buf), "%d", s->neigh6gcstaletime);
+ system_set_neigh6gcstaletime(dev, buf);
+ }
if (s->flags & DEV_OPT_DADTRANSMITS & apply_mask) {
snprintf(buf, sizeof(buf), "%d", s->dadtransmits);
system_set_dadtransmits(dev, buf);