diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-10-19 00:51:10 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-10-19 00:51:10 +0200 |
commit | 53f8ed2cdcf986389b605c79d273f08b5a687636 (patch) | |
tree | c100e34df6594a748fb3034f2bc1feb771a97339 | |
parent | 296a10e3eed1dfd5b5a96eea1309246ac34733d7 (diff) |
disable ipv6 for bridge member interfaces
-rw-r--r-- | system-linux.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/system-linux.c b/system-linux.c index 867af0f..2425445 100644 --- a/system-linux.c +++ b/system-linux.c @@ -87,6 +87,26 @@ static void handler_rtnl_event(struct uloop_fd *u, unsigned int events) nl_recvmsgs(sock_rtnl_event, nl_cb_rtnl_event); } +static void system_set_sysctl(const char *path, const char *val) +{ + int fd; + + fd = open(path, O_WRONLY); + if (fd < 0) + return; + + write(fd, val, strlen(val)); + close(fd); +} + +static void system_set_disable_ipv6(struct device *dev, const char *val) +{ + char buf[256]; + + snprintf(buf, sizeof(buf), "/proc/sys/net/ipv6/conf/%s/disable_ipv6", dev->ifname); + system_set_sysctl(buf, "0"); +} + // Evaluate netlink messages static int cb_rtnl_event(struct nl_msg *msg, void *arg) { @@ -138,11 +158,13 @@ static int system_bridge_if(const char *bridge, struct device *dev, int cmd, voi int system_bridge_addif(struct device *bridge, struct device *dev) { + system_set_disable_ipv6(dev, "1"); return system_bridge_if(bridge->ifname, dev, SIOCBRADDIF, NULL); } int system_bridge_delif(struct device *bridge, struct device *dev) { + system_set_disable_ipv6(dev, "0"); return system_bridge_if(bridge->ifname, dev, SIOCBRDELIF, NULL); } @@ -365,6 +387,7 @@ void system_if_clear_state(struct device *dev) system_if_clear_entries(dev, RTM_GETADDR, AF_INET); system_if_clear_entries(dev, RTM_GETROUTE, AF_INET6); system_if_clear_entries(dev, RTM_GETADDR, AF_INET6); + system_set_disable_ipv6(dev, "0"); } static inline unsigned long |