summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--device.c14
-rw-r--r--device.h4
-rw-r--r--system-linux.c38
3 files changed, 56 insertions, 0 deletions
diff --git a/device.c b/device.c
index 0e07615..06c4820 100644
--- a/device.c
+++ b/device.c
@@ -45,6 +45,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_IGMPVERSION] = { .name = "igmpversion", .type = BLOBMSG_TYPE_INT32 },
[DEV_ATTR_MLDVERSION] = { .name = "mldversion", .type = BLOBMSG_TYPE_INT32 },
[DEV_ATTR_NEIGHREACHABLETIME] = { .name = "neighreachabletime", .type = BLOBMSG_TYPE_INT32 },
+ [DEV_ATTR_NEIGHGCSTALETIME] = { .name = "neighgcstaletime", .type = BLOBMSG_TYPE_INT32 },
[DEV_ATTR_RPS] = { .name = "rps", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_XPS] = { .name = "xps", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_DADTRANSMITS] = { .name = "dadtransmits", .type = BLOBMSG_TYPE_INT32 },
@@ -173,6 +174,10 @@ device_merge_settings(struct device *dev, struct device_settings *n)
s->neigh4reachabletime : os->neigh4reachabletime;
n->neigh6reachabletime = s->flags & DEV_OPT_NEIGHREACHABLETIME ?
s->neigh6reachabletime : os->neigh6reachabletime;
+ n->neigh4gcstaletime = s->flags & DEV_OPT_NEIGHGCSTALETIME ?
+ s->neigh4gcstaletime : os->neigh4gcstaletime;
+ n->neigh6gcstaletime = s->flags & DEV_OPT_NEIGHGCSTALETIME ?
+ s->neigh6gcstaletime : os->neigh6gcstaletime;
n->dadtransmits = s->flags & DEV_OPT_DADTRANSMITS ?
s->dadtransmits : os->dadtransmits;
n->multicast = s->flags & DEV_OPT_MULTICAST ?
@@ -262,6 +267,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
s->flags |= DEV_OPT_NEIGHREACHABLETIME;
}
+ if ((cur = tb[DEV_ATTR_NEIGHGCSTALETIME])) {
+ s->neigh6gcstaletime = s->neigh4gcstaletime = blobmsg_get_u32(cur);
+ s->flags |= DEV_OPT_NEIGHGCSTALETIME;
+ }
+
if ((cur = tb[DEV_ATTR_RPS])) {
s->rps = blobmsg_get_bool(cur);
s->flags |= DEV_OPT_RPS;
@@ -945,6 +955,10 @@ device_dump_status(struct blob_buf *b, struct device *dev)
blobmsg_add_u32(b, "neigh4reachabletime", st.neigh4reachabletime);
blobmsg_add_u32(b, "neigh6reachabletime", st.neigh6reachabletime);
}
+ if (st.flags & DEV_OPT_NEIGHGCSTALETIME) {
+ blobmsg_add_u32(b, "neigh4gcstaletime", st.neigh4gcstaletime);
+ blobmsg_add_u32(b, "neigh6gcstaletime", st.neigh6gcstaletime);
+ }
if (st.flags & DEV_OPT_DADTRANSMITS)
blobmsg_add_u32(b, "dadtransmits", st.dadtransmits);
if (st.flags & DEV_OPT_MULTICAST_TO_UNICAST)
diff --git a/device.h b/device.h
index 4a88c05..77a2fef 100644
--- a/device.h
+++ b/device.h
@@ -47,6 +47,7 @@ enum {
DEV_ATTR_MULTICAST,
DEV_ATTR_LEARNING,
DEV_ATTR_UNICAST_FLOOD,
+ DEV_ATTR_NEIGHGCSTALETIME,
__DEV_ATTR_MAX,
};
@@ -92,6 +93,7 @@ enum {
DEV_OPT_MULTICAST = (1 << 16),
DEV_OPT_LEARNING = (1 << 17),
DEV_OPT_UNICAST_FLOOD = (1 << 18),
+ DEV_OPT_NEIGHGCSTALETIME = (1 << 19),
};
/* events broadcasted to all users of a device */
@@ -147,6 +149,8 @@ struct device_settings {
unsigned int mldversion;
unsigned int neigh4reachabletime;
unsigned int neigh6reachabletime;
+ unsigned int neigh4gcstaletime;
+ unsigned int neigh6gcstaletime;
bool rps;
bool xps;
unsigned int dadtransmits;
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);