summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--device.c12
-rw-r--r--device.h5
-rw-r--r--system-linux.c29
3 files changed, 36 insertions, 10 deletions
diff --git a/device.c b/device.c
index 1265c86..fec5bce 100644
--- a/device.c
+++ b/device.c
@@ -47,6 +47,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_NEIGHREACHABLETIME] = { .name = "neighreachabletime", .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 },
};
const struct uci_blob_param_list device_attr_list = {
@@ -170,7 +171,9 @@ device_merge_settings(struct device *dev, struct device_settings *n)
n->neigh4reachabletime = s->flags & DEV_OPT_NEIGHREACHABLETIME ?
s->neigh4reachabletime : os->neigh4reachabletime;
n->neigh6reachabletime = s->flags & DEV_OPT_NEIGHREACHABLETIME ?
- s->neigh6reachabletime : os->neigh6reachabletime;
+ s->neigh6reachabletime : os->neigh6reachabletime;
+ n->dadtransmits = s->flags & DEV_OPT_DADTRANSMITS ?
+ s->dadtransmits : os->dadtransmits;
n->flags = s->flags | os->flags;
}
@@ -266,6 +269,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
else
s->xps = default_ps;
+ if ((cur = tb[DEV_ATTR_DADTRANSMITS])) {
+ s->dadtransmits = blobmsg_get_u32(cur);
+ s->flags |= DEV_OPT_DADTRANSMITS;
+ }
+
device_set_disabled(dev, disabled);
}
@@ -872,6 +880,8 @@ 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_DADTRANSMITS)
+ blobmsg_add_u32(b, "dadtransmits", st.dadtransmits);
}
s = blobmsg_open_table(b, "statistics");
diff --git a/device.h b/device.h
index 4d84d80..ce135ba 100644
--- a/device.h
+++ b/device.h
@@ -41,6 +41,7 @@ enum {
DEV_ATTR_NEIGHREACHABLETIME,
DEV_ATTR_RPS,
DEV_ATTR_XPS,
+ DEV_ATTR_DADTRANSMITS,
__DEV_ATTR_MAX,
};
@@ -81,7 +82,8 @@ enum {
DEV_OPT_NEIGHREACHABLETIME = (1 << 9),
DEV_OPT_RPS = (1 << 10),
DEV_OPT_XPS = (1 << 11),
- DEV_OPT_MTU6 = (1 << 12),
+ DEV_OPT_MTU6 = (1 << 12),
+ DEV_OPT_DADTRANSMITS = (1 << 13),
};
/* events broadcasted to all users of a device */
@@ -138,6 +140,7 @@ struct device_settings {
unsigned int neigh6reachabletime;
bool rps;
bool xps;
+ unsigned int dadtransmits;
};
/*
diff --git a/system-linux.c b/system-linux.c
index b44eb76..9ba13fd 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -310,6 +310,11 @@ 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_dadtransmits(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/proc/sys/net/ipv6/conf/%s/dad_transmits", dev->ifname, val);
+}
+
static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
@@ -380,6 +385,12 @@ static int system_get_neigh6reachabletime(struct device *dev, char *buf, const s
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",
+ dev->ifname, buf, buf_sz);
+}
+
// Evaluate netlink messages
static int cb_rtnl_event(struct nl_msg *msg, void *arg)
{
@@ -1072,6 +1083,11 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
s->neigh6reachabletime = strtoul(buf, NULL, 0);
s->flags |= DEV_OPT_NEIGHREACHABLETIME;
}
+
+ if (!system_get_dadtransmits(dev, buf, sizeof(buf))) {
+ s->dadtransmits = strtoul(buf, NULL, 0);
+ s->flags |= DEV_OPT_DADTRANSMITS;
+ }
}
static void
@@ -1110,6 +1126,7 @@ void
system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned int apply_mask)
{
struct ifreq ifr;
+ char buf[12];
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name));
@@ -1140,33 +1157,29 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
s->flags &= ~DEV_OPT_PROMISC;
}
if (s->flags & DEV_OPT_RPFILTER & apply_mask) {
- char buf[2];
-
snprintf(buf, sizeof(buf), "%d", s->rpfilter);
system_set_rpfilter(dev, buf);
}
if (s->flags & DEV_OPT_ACCEPTLOCAL & apply_mask)
system_set_acceptlocal(dev, s->acceptlocal ? "1" : "0");
if (s->flags & DEV_OPT_IGMPVERSION & apply_mask) {
- char buf[2];
-
snprintf(buf, sizeof(buf), "%d", s->igmpversion);
system_set_igmpversion(dev, buf);
}
if (s->flags & DEV_OPT_MLDVERSION & apply_mask) {
- char buf[2];
-
snprintf(buf, sizeof(buf), "%d", s->mldversion);
system_set_mldversion(dev, buf);
}
if (s->flags & DEV_OPT_NEIGHREACHABLETIME & apply_mask) {
- char buf[12];
-
snprintf(buf, sizeof(buf), "%d", s->neigh4reachabletime);
system_set_neigh4reachabletime(dev, buf);
snprintf(buf, sizeof(buf), "%d", s->neigh6reachabletime);
system_set_neigh6reachabletime(dev, buf);
}
+ if (s->flags & DEV_OPT_DADTRANSMITS & apply_mask) {
+ snprintf(buf, sizeof(buf), "%d", s->dadtransmits);
+ system_set_dadtransmits(dev, buf);
+ }
system_if_apply_rps_xps(dev, s);
}