IPv6: Use source-routing to allow multi-wan
[project/netifd.git] / system-linux.c
index ebab09c..4401f78 100644 (file)
@@ -2,6 +2,7 @@
  * netifd - network interface daemon
  * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
  * Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2013 Steven Barth <steven@midlink.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2
@@ -580,6 +581,10 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
        system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_snooping",
                bridge->ifname, cfg->igmp_snoop ? "1" : "0");
 
+       args[0] = BRCTL_SET_BRIDGE_PRIORITY;
+       args[1] = cfg->priority;
+       system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+
        if (cfg->flags & BRIDGE_OPT_AGEING_TIME) {
                args[0] = BRCTL_SET_AGEING_TIME;
                args[1] = sec_to_jiffies(cfg->ageing_time);
@@ -960,7 +965,8 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd)
        unsigned char scope = (cmd == RTM_DELROUTE) ? RT_SCOPE_NOWHERE :
                        (have_gw) ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK;
 
-       unsigned int table = (route->flags & DEVROUTE_TABLE) ? route->table : RT_TABLE_MAIN;
+       unsigned int table = (route->flags & (DEVROUTE_TABLE | DEVROUTE_SRCTABLE))
+                       ? route->table : RT_TABLE_MAIN;
 
        struct rtmsg rtm = {
                .rtm_family = (alen == 4) ? AF_INET : AF_INET6,
@@ -1148,6 +1154,8 @@ static int system_iprule(struct iprule *rule, int cmd)
 
        if (rule->flags & IPRULE_PRIORITY)
                nla_put_u32(msg, FRA_PRIORITY, rule->priority);
+       else if (cmd == RTM_NEWRULE)
+               nla_put_u32(msg, FRA_PRIORITY, rule->order);
 
        if (rule->flags & IPRULE_FWMARK)
                nla_put_u32(msg, FRA_FWMARK, rule->fwmark);