@@ -42,6 +42,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_RPFILTER] = { .name = "rpfilter", .type = BLOBMSG_TYPE_STRING },
[DEV_ATTR_ACCEPTLOCAL] = { .name = "acceptlocal", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_IGMPVERSION] = { .name = "igmpversion", .type = BLOBMSG_TYPE_INT32 },
+ [DEV_ATTR_MLDVERSION] = { .name = "mldversion", .type = BLOBMSG_TYPE_INT32 },
};
const struct uci_blob_param_list device_attr_list = {
@@ -160,6 +161,7 @@ device_merge_settings(struct device *dev, struct device_settings *n)
n->rpfilter = s->flags & DEV_OPT_RPFILTER ? s->rpfilter : os->rpfilter;
n->acceptlocal = s->flags & DEV_OPT_ACCEPTLOCAL ? s->acceptlocal : os->acceptlocal;
n->igmpversion = s->flags & DEV_OPT_IGMPVERSION ? s->igmpversion : os->igmpversion;
+ n->mldversion = s->flags & DEV_OPT_MLDVERSION ? s->mldversion : os->mldversion;
n->flags = s->flags | os->flags;
}
@@ -222,6 +224,13 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
DPRINTF("Failed to resolve igmpversion: %d\n", blobmsg_get_u32(cur));
}
+ if ((cur = tb[DEV_ATTR_MLDVERSION])) {
+ if (system_resolve_mldversion(blobmsg_get_u32(cur), &s->mldversion))
+ s->flags |= DEV_OPT_MLDVERSION;
+ else
+ DPRINTF("Failed to resolve mldversion: %d\n", blobmsg_get_u32(cur));
+ }
+
device_set_disabled(dev, disabled);
}
@@ -765,6 +774,8 @@ device_dump_status(struct blob_buf *b, struct device *dev)
blobmsg_add_u8(b, "acceptlocal", st.acceptlocal);
if (st.flags & DEV_OPT_IGMPVERSION)
blobmsg_add_u32(b, "igmpversion", st.igmpversion);
+ if (st.flags & DEV_OPT_MLDVERSION)
+ blobmsg_add_u32(b, "mldversion", st.mldversion);
}
s = blobmsg_open_table(b, "statistics");
@@ -36,6 +36,7 @@ enum {
DEV_ATTR_RPFILTER,
DEV_ATTR_ACCEPTLOCAL,
DEV_ATTR_IGMPVERSION,
+ DEV_ATTR_MLDVERSION,
__DEV_ATTR_MAX,
};
@@ -72,6 +73,7 @@ enum {
DEV_OPT_RPFILTER = (1 << 5),
DEV_OPT_ACCEPTLOCAL = (1 << 6),
DEV_OPT_IGMPVERSION = (1 << 7),
+ DEV_OPT_MLDVERSION = (1 << 8),
};
/* events broadcasted to all users of a device */
@@ -122,6 +124,7 @@ struct device_settings {
unsigned int rpfilter;
bool acceptlocal;
unsigned int igmpversion;
+ unsigned int mldversion;
};
/*
@@ -221,6 +221,12 @@ bool system_resolve_igmpversion(const unsigned int version, unsigned int *id)
return true;
}
+bool system_resolve_mldversion(const unsigned int version, unsigned int *id)
+{
+ *id = 0;
+ return true;
+}
+
int system_add_iprule(struct iprule *rule)
{
return 0;
@@ -280,6 +280,11 @@ static void system_set_igmpversion(struct device *dev, const char *val)
system_set_dev_sysctl("/proc/sys/net/ipv4/conf/%s/force_igmp_version", dev->ifname, val);
}
+static void system_set_mldversion(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/proc/sys/net/ipv6/conf/%s/force_mld_version", dev->ifname, val);
+}
+
static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
@@ -332,6 +337,12 @@ static int system_get_igmpversion(struct device *dev, char *buf, const size_t bu
dev->ifname, buf, buf_sz);
}
+static int system_get_mldversion(struct device *dev, char *buf, const size_t buf_sz)
+{
+ return system_get_dev_sysctl("/proc/sys/net/ipv6/conf/%s/force_mld_version",
+ dev->ifname, buf, buf_sz);
+}
+
// Evaluate netlink messages
static int cb_rtnl_event(struct nl_msg *msg, void *arg)
{
@@ -1001,6 +1012,11 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
s->igmpversion = strtoul(buf, NULL, 0);
s->flags |= DEV_OPT_IGMPVERSION;
}
+
+ if (!system_get_mldversion(dev, buf, sizeof(buf))) {
+ s->mldversion = strtoul(buf, NULL, 0);
+ s->flags |= DEV_OPT_MLDVERSION;
+ }
}
void
@@ -1050,6 +1066,12 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
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);
+ }
}
int system_if_up(struct device *dev)
@@ -1609,6 +1631,18 @@ bool system_resolve_igmpversion(const unsigned int version, unsigned int *id)
return true;
}
+bool system_resolve_mldversion(const unsigned int version, unsigned int *id)
+{
+ if (!version || version > 2)
+ return false;
+
+ *id = version;
+ if (*id == 2)
+ *id = 0;
+
+ return true;
+}
+
static int system_iprule(struct iprule *rule, int cmd)
{
int alen = ((rule->flags & IPRULE_FAMILY) == IPRULE_INET4) ? 4 : 16;
@@ -137,6 +137,7 @@ bool system_resolve_rt_table(const char *name, unsigned int *id);
bool system_is_default_rt_table(unsigned int id);
bool system_resolve_rpfilter(const char *filter, unsigned int *id);
bool system_resolve_igmpversion(const unsigned int version, unsigned int *id);
+bool system_resolve_mldversion(const unsigned int version, unsigned int *id);
int system_del_ip_tunnel(const char *name, struct blob_attr *attr);
int system_add_ip_tunnel(const char *name, struct blob_attr *attr);
Config support to set the MLD host version on device level; possible values are : 1 : MLDv1 2 : MLDv2 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> --- device.c | 11 +++++++++++ device.h | 3 +++ system-dummy.c | 6 ++++++ system-linux.c | 34 ++++++++++++++++++++++++++++++++++ system.h | 1 + 5 files changed, 55 insertions(+)