Config support to force the IGMP host version on device level; possible values
are:
1|igmpv1: IGMP version 1
2|igmpv2: IGMP version 2
3|igmpv3: IGMP version 3
Signed-off-by: Hans Dedecker dedec...@gmail.com
---
device.c | 11 +++
device.h | 3 +++
system-dummy.c | 6 ++
system-linux.c | 46 ++
system.h | 1 +
5 files changed, 67 insertions(+)
diff --git a/device.c b/device.c
index aa5818f..6d33f69 100644
--- a/device.c
+++ b/device.c
@@ -41,6 +41,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX]
= {
[DEV_ATTR_PROMISC] = { .name = promisc, .type = BLOBMSG_TYPE_BOOL },
[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_STRING },
};
const struct uci_blob_param_list device_attr_list = {
@@ -158,6 +159,7 @@ device_merge_settings(struct device *dev, struct
device_settings *n)
n-promisc = s-flags DEV_OPT_PROMISC ? s-promisc : os-promisc;
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-flags = s-flags | os-flags;
}
@@ -213,6 +215,13 @@ device_init_settings(struct device *dev, struct blob_attr
**tb)
s-flags |= DEV_OPT_ACCEPTLOCAL;
}
+ if ((cur = tb[DEV_ATTR_IGMPVERSION])) {
+ if (system_resolve_igmpversion(blobmsg_data(cur),
s-igmpversion))
+ s-flags |= DEV_OPT_IGMPVERSION;
+ else
+ DPRINTF(Failed to resolve igmpversion: %s\n, (char *)
blobmsg_data(cur));
+ }
+
device_set_disabled(dev, disabled);
}
@@ -754,6 +763,8 @@ device_dump_status(struct blob_buf *b, struct device *dev)
blobmsg_add_u32(b, rpfilter, st.rpfilter);
if (st.flags DEV_OPT_ACCEPTLOCAL)
blobmsg_add_u8(b, acceptlocal, st.acceptlocal);
+ if (st.flags DEV_OPT_IGMPVERSION)
+ blobmsg_add_u32(b, igmpversion, st.igmpversion);
}
s = blobmsg_open_table(b, statistics);
diff --git a/device.h b/device.h
index 8569be7..a83cac8 100644
--- a/device.h
+++ b/device.h
@@ -35,6 +35,7 @@ enum {
DEV_ATTR_PROMISC,
DEV_ATTR_RPFILTER,
DEV_ATTR_ACCEPTLOCAL,
+ DEV_ATTR_IGMPVERSION,
__DEV_ATTR_MAX,
};
@@ -70,6 +71,7 @@ enum {
DEV_OPT_PROMISC = (1 4),
DEV_OPT_RPFILTER= (1 5),
DEV_OPT_ACCEPTLOCAL = (1 6),
+ DEV_OPT_IGMPVERSION = (1 7),
};
/* events broadcasted to all users of a device */
@@ -119,6 +121,7 @@ struct device_settings {
bool promisc;
unsigned int rpfilter;
bool acceptlocal;
+ unsigned int igmpversion;
};
/*
diff --git a/system-dummy.c b/system-dummy.c
index 76c6ffa..247b083 100644
--- a/system-dummy.c
+++ b/system-dummy.c
@@ -215,6 +215,12 @@ bool system_resolve_rpfilter(const char *filter, unsigned
int *id)
return true;
}
+bool system_resolve_igmpversion(const char *version, unsigned int *id)
+{
+ *id = 0;
+ return true;
+}
+
int system_add_iprule(struct iprule *rule)
{
return 0;
diff --git a/system-linux.c b/system-linux.c
index 4662bf8..776676a 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -275,6 +275,11 @@ static void system_set_acceptlocal(struct device *dev,
const char *val)
system_set_dev_sysctl(/proc/sys/net/ipv4/conf/%s/accept_local,
dev-ifname, val);
}
+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 int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
@@ -321,6 +326,12 @@ static int system_get_acceptlocal(struct device *dev, char
*buf, const size_t bu
dev-ifname, buf, buf_sz);
}
+static int system_get_igmpversion(struct device *dev, char *buf, const size_t
buf_sz)
+{
+ return
system_get_dev_sysctl(/proc/sys/net/ipv4/conf/%s/force_igmp_version,
+ dev-ifname, buf, buf_sz);
+}
+
// Evaluate netlink messages
static int cb_rtnl_event(struct nl_msg *msg, void *arg)
{
@@ -985,6 +996,11 @@ system_if_get_settings(struct device *dev, struct
device_settings *s)
s-acceptlocal = strtoul(buf, NULL, 0);
s-flags |= DEV_OPT_ACCEPTLOCAL;
}
+
+ if (!system_get_igmpversion(dev, buf, sizeof(buf))) {
+ s-igmpversion = strtoul(buf, NULL, 0);
+ s-flags |= DEV_OPT_IGMPVERSION;
+ }
}
void
@@