[OpenWrt-Devel] [PATCH 4/4] netifd: Add igmpversion config support

2014-12-03 Thread Hans Dedecker
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
@@ 

Re: [OpenWrt-Devel] [PATCH 4/4] netifd: Add igmpversion config support

2014-12-03 Thread Felix Fietkau
On 2014-12-03 11:15, Hans Dedecker wrote:
 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
I'd prefer to leave out support for the igmpvX strings to simplify the
configuration format.

- Felix
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 4/4] netifd: Add igmpversion config support

2014-12-03 Thread Steven Barth

On 03.12.2014 11:15, Hans Dedecker wrote:

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



Thanks Hans.

However, I don't really see the point of the string logic, it seems a 
bit bloated and the simple integer 1 2 or 3 should suffice imo.


Also I'm wondering if this should set MLD version too (i.e. 1 if IGMP is 
2 and 2 if IGMP is 3).


Cheers,

Steven
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 4/4] netifd: Add igmpversion config support

2014-12-03 Thread Hans Dedecker
On Wed, Dec 3, 2014 at 11:23 AM, Steven Barth cy...@openwrt.org wrote:

 On 03.12.2014 11:15, Hans Dedecker wrote:

 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



 Thanks Hans.

 However, I don't really see the point of the string logic, it seems a bit
 bloated and the simple integer 1 2 or 3 should suffice imo.

 Also I'm wondering if this should set MLD version too (i.e. 1 if IGMP is 2
 and 2 if IGMP is 3).

 Cheers,

 Steven

I will simplify the configuration format and restrict it to the numerical
format as requested by you and Felix.
Regarding the MLD version wouldn't it be preferable to have this as a
different UCI parameter as I could imagine different versions in use for
MLD and IGMP. Quite a lot of ISP's are still stuck to IGMPv2 in their
network while they're using MLDv2 for IPV6.

Hans
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 4/4] netifd: Add igmpversion config support

2014-12-03 Thread Steven Barth


On 03.12.2014 11:39, Hans Dedecker wrote:


Regarding the MLD version wouldn't it be preferable to have this as a 
different UCI parameter as I could imagine different versions in use 
for MLD and IGMP. Quite a lot of ISP's are still stuck to IGMPv2 in 
their network while they're using MLDv2 for IPV6.

Okay, makes sense, thanks again.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel