- set_ipv6_source_policy(false, &a_old->addr, a_old->mask, dev->ifindex);
+ v6 = true;
+
+ //This is needed for source routing to work correctly. If a device
+ //has two connections to a network using the same subnet, adding
+ //only the network-rule will cause packets to be routed through the
+ //first matching network (source IP matches both masks).
+ set_ip_source_policy(false, v6, IPRULE_PRIORITY_ADDR, &a_old->addr,
+ (v6) ? 128 : 32, iface);
+ set_ip_source_policy(false, v6, IPRULE_PRIORITY_NW, &a_old->addr,
+ a_old->mask, iface);