summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2014-12-04 12:07:18 +0000
committerSteven Barth <steven@midlink.org>2014-12-08 18:23:59 +0100
commit7c5d82806c11886bcc08821584fe51790a593feb (patch)
tree7c82070126191c13061e8880b1692c32b2e6f4da /system-linux.c
parentdb99fce3f59d1a9629ca5bc7ec8f8208acf02816 (diff)
netifd: Add igmpversion config support
Config support to set the IGMP host version on device level; possible values are : 1 : IGMPv1 2 : IGMPv2 3 : IGMPv3 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Cleand up and simplified Signed-off-by: Steven Barth <steven@midlink.org>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/system-linux.c b/system-linux.c
index 4662bf8..7beae09 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
@@ -1028,6 +1044,12 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
}
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);
+ }
}
int system_if_up(struct device *dev)
@@ -1575,6 +1597,18 @@ bool system_resolve_rpfilter(const char *filter, unsigned int *id)
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;