]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/ipv4/fib_semantics.c
ipv4: Cache source address in nexthop entries.
[mv-sheeva.git] / net / ipv4 / fib_semantics.c
index 6349a21692ec430930fb6dbf889fc58437991157..952c737f2a274ab42257f8f4b2e3419e2fdafb7d 100644 (file)
@@ -853,6 +853,12 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
                                goto err_inval;
        }
 
+       change_nexthops(fi) {
+               nexthop_nh->nh_saddr = inet_select_addr(nexthop_nh->nh_dev,
+                                                       nexthop_nh->nh_gw,
+                                                       nexthop_nh->nh_scope);
+       } endfor_nexthops(fi)
+
 link_it:
        ofi = fib_find_info(fi);
        if (ofi) {
@@ -898,13 +904,6 @@ failure:
        return ERR_PTR(err);
 }
 
-/* Find appropriate source address to this destination */
-
-__be32 __fib_res_prefsrc(struct fib_result *res)
-{
-       return inet_select_addr(FIB_RES_DEV(*res), FIB_RES_GW(*res), res->scope);
-}
-
 int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
                  u32 tb_id, u8 type, u8 scope, __be32 dst, int dst_len, u8 tos,
                  struct fib_info *fi, unsigned int flags)
@@ -1128,6 +1127,24 @@ out:
        return;
 }
 
+void fib_update_nh_saddrs(struct net_device *dev)
+{
+       struct hlist_head *head;
+       struct hlist_node *node;
+       struct fib_nh *nh;
+       unsigned int hash;
+
+       hash = fib_devindex_hashfn(dev->ifindex);
+       head = &fib_info_devhash[hash];
+       hlist_for_each_entry(nh, node, head, nh_hash) {
+               if (nh->nh_dev != dev)
+                       continue;
+               nh->nh_saddr = inet_select_addr(nh->nh_dev,
+                                               nh->nh_gw,
+                                               nh->nh_scope);
+       }
+}
+
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 
 /*