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>
Cleaned up and simplified.
Signed-off-by: Steven Barth <steven@midlink.org>
[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 = {
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;
}
}
if ((cur = tb[DEV_ATTR_IGMPVERSION])) {
- if (system_resolve_igmpversion(blobmsg_get_u32(cur), &s->igmpversion))
+ s->igmpversion = blobmsg_get_u32(cur);
+ if (s->igmpversion >= 1 && s->igmpversion <= 3)
s->flags |= DEV_OPT_IGMPVERSION;
else
DPRINTF("Failed to resolve igmpversion: %d\n", blobmsg_get_u32(cur));
}
+ if ((cur = tb[DEV_ATTR_MLDVERSION])) {
+ s->mldversion = blobmsg_get_u32(cur);
+ if (s->mldversion >= 1 && s->mldversion <= 2)
+ s->flags |= DEV_OPT_MLDVERSION;
+ else
+ DPRINTF("Failed to resolve mldversion: %d\n", blobmsg_get_u32(cur));
+ }
+
device_set_disabled(dev, disabled);
}
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");
DEV_ATTR_RPFILTER,
DEV_ATTR_ACCEPTLOCAL,
DEV_ATTR_IGMPVERSION,
+ DEV_ATTR_MLDVERSION,
__DEV_ATTR_MAX,
};
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 */
unsigned int rpfilter;
bool acceptlocal;
unsigned int igmpversion;
+ unsigned int mldversion;
};
/*
return true;
}
-bool system_resolve_igmpversion(const unsigned int version, unsigned int *id)
-{
- *id = 0;
- return true;
-}
-
int system_add_iprule(struct iprule *rule)
{
return 0;
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;
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)
{
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
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)
return true;
}
-bool system_resolve_igmpversion(const unsigned int version, unsigned int *id)
-{
- if (!version || version > 3)
- return false;
-
- *id = version;
- if (*id == 3)
- *id = 0;
-
- return true;
-}
-
static int system_iprule(struct iprule *rule, int cmd)
{
int alen = ((rule->flags & IPRULE_FAMILY) == IPRULE_INET4) ? 4 : 16;
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);
int system_del_ip_tunnel(const char *name, struct blob_attr *attr);
int system_add_ip_tunnel(const char *name, struct blob_attr *attr);