From: Steven Barth Date: Mon, 13 May 2013 16:41:00 +0000 (+0200) Subject: IPv6: Set loopback-policy for output traffic X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=bc4a4bb127622c76085ecec7fd20448aad7bafaf;p=project%2Fnetifd.git IPv6: Set loopback-policy for output traffic Signed-off-by: Steven Barth --- diff --git a/interface-ip.c b/interface-ip.c index 31842c4..e265563 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -103,6 +103,18 @@ static int set_ipv6_source_policy(bool add, const union if_addr *addr, uint8_t m return (add) ? system_add_iprule(&rule) : system_del_iprule(&rule); } +static int set_ipv6_lo_policy(bool add, int ifindex) +{ + struct iprule rule = { + .flags = IPRULE_INET6 | IPRULE_IN | IPRULE_LOOKUP | IPRULE_PRIORITY, + .priority = 65535, + .lookup = interface_ip_resolve_v6_rtable(ifindex), + .in_dev = "lo" + }; + + return (add) ? system_add_iprule(&rule) : system_del_iprule(&rule); +} + static bool __find_ip_addr_target(struct interface_ip_settings *ip, union if_addr *a, bool v6) { @@ -1028,6 +1040,8 @@ void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled) list_for_each_entry(a, &c->assignments, head) if (!strcmp(a->name, ip->iface->name)) interface_set_prefix_address(a, c, ip->iface, enabled); + + set_ipv6_lo_policy(enabled, dev->ifindex); } void