]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
ipv4: Attach FIB info to dst_default_metrics when possible
authorDavid S. Miller <davem@davemloft.net>
Fri, 28 Jan 2011 22:05:05 +0000 (14:05 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Jan 2011 22:05:05 +0000 (14:05 -0800)
If there are no explicit metrics attached to a route, hook
fi->fib_info up to dst_default_metrics.

Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dst.h
net/core/dst.c
net/ipv4/fib_semantics.c

index 94a8c234ea2a24488443d6f1f4d664da839e9ad4..484f80b69adaf4b40a1560d23e345afc7a1f22f6 100644 (file)
@@ -97,6 +97,7 @@ struct dst_entry {
 #ifdef __KERNEL__
 
 extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
+extern const u32 dst_default_metrics[RTAX_MAX];
 
 #define DST_METRICS_READ_ONLY  0x1UL
 #define __DST_METRICS_PTR(Y)   \
index 578893505702fd13aec07c5ea5c0c1b335e2a834..c1674fde827d78c30293961ec6760f20b0570d08 100644 (file)
@@ -164,7 +164,7 @@ int dst_discard(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(dst_discard);
 
-static const u32 dst_default_metrics[RTAX_MAX];
+const u32 dst_default_metrics[RTAX_MAX];
 
 void *dst_alloc(struct dst_ops *ops)
 {
index 363ec39228d347901660807897b5d74683d7ed41..48e93a56007708c7d346c2b8ffaed23354466435 100644 (file)
@@ -152,7 +152,8 @@ static void free_fib_info_rcu(struct rcu_head *head)
 {
        struct fib_info *fi = container_of(head, struct fib_info, rcu);
 
-       kfree(fi->fib_metrics);
+       if (fi->fib_metrics != (u32 *) dst_default_metrics)
+               kfree(fi->fib_metrics);
        kfree(fi);
 }
 
@@ -743,9 +744,12 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
        fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
        if (fi == NULL)
                goto failure;
-       fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL);
-       if (!fi->fib_metrics)
-               goto failure;
+       if (cfg->fc_mx) {
+               fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL);
+               if (!fi->fib_metrics)
+                       goto failure;
+       } else
+               fi->fib_metrics = (u32 *) dst_default_metrics;
        fib_info_cnt++;
 
        fi->fib_net = hold_net(net);