From 21adee5a295830d43ea85dbbe6e3dc11c08115db Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 28 Jan 2011 14:05:05 -0800 Subject: [PATCH] --- yaml --- r: 236799 b: refs/heads/master c: 725d1e1b457dc2bbebb337677e73efe7c6d14da5 h: refs/heads/master i: 236797: 4e8e6766231ee6a7e3d6231aad9b637fa25cc290 236795: 1138a5b570cdadd2fe84b32ae20ae27eb28bad51 236791: 2dfd66b24d1f77f1cb8ca07aa343599785ab8178 236783: cd014c8a9d986dbab042b756b78fac05b7008466 236767: d89b2330ec6ed0fe8ac2b5fb3c6b394137e0c5c2 236735: e16fb19437e275e5c387c243257dfbdc1a6b9a1b 236671: 5655514a6102bb8308659f8be529a802bb2a4ff1 236543: a1a39cb76461a6521435b3bdf047684a93c29226 v: v3 --- [refs] | 2 +- trunk/include/net/dst.h | 1 + trunk/net/core/dst.c | 2 +- trunk/net/ipv4/fib_semantics.c | 12 ++++++++---- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 830d94a7e4b5..0594e8655306 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9c150e82ac50a611237bbebd508d17f6347d577c +refs/heads/master: 725d1e1b457dc2bbebb337677e73efe7c6d14da5 diff --git a/trunk/include/net/dst.h b/trunk/include/net/dst.h index 94a8c234ea2a..484f80b69ada 100644 --- a/trunk/include/net/dst.h +++ b/trunk/include/net/dst.h @@ -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) \ diff --git a/trunk/net/core/dst.c b/trunk/net/core/dst.c index 578893505702..c1674fde827d 100644 --- a/trunk/net/core/dst.c +++ b/trunk/net/core/dst.c @@ -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) { diff --git a/trunk/net/ipv4/fib_semantics.c b/trunk/net/ipv4/fib_semantics.c index 363ec39228d3..48e93a560077 100644 --- a/trunk/net/ipv4/fib_semantics.c +++ b/trunk/net/ipv4/fib_semantics.c @@ -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);