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>
[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_INT32 },
};
const struct uci_blob_param_list device_attr_list = {
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;
}
s->flags |= DEV_OPT_ACCEPTLOCAL;
}
+ if ((cur = tb[DEV_ATTR_IGMPVERSION])) {
+ if (system_resolve_igmpversion(blobmsg_get_u32(cur), &s->igmpversion))
+ s->flags |= DEV_OPT_IGMPVERSION;
+ else
+ DPRINTF("Failed to resolve igmpversion: %d\n", blobmsg_get_u32(cur));
+ }
+
device_set_disabled(dev, disabled);
}
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");
DEV_ATTR_PROMISC,
DEV_ATTR_RPFILTER,
DEV_ATTR_ACCEPTLOCAL,
+ DEV_ATTR_IGMPVERSION,
__DEV_ATTR_MAX,
};
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 */
bool promisc;
unsigned int rpfilter;
bool acceptlocal;
+ unsigned int igmpversion;
};
/*
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/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;
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)
{
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
}
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)
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);