diff options
author | David S. Miller <davem@davemloft.net> | 2011-01-28 17:05:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-28 17:05:05 -0500 |
commit | 725d1e1b457dc2bbebb337677e73efe7c6d14da5 (patch) | |
tree | b001a08feeff741963d8232ecb26e5c1a75efb92 | |
parent | 9c150e82ac50a611237bbebd508d17f6347d577c (diff) |
ipv4: Attach FIB info to dst_default_metrics when possible
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>
-rw-r--r-- | include/net/dst.h | 1 | ||||
-rw-r--r-- | net/core/dst.c | 2 | ||||
-rw-r--r-- | net/ipv4/fib_semantics.c | 12 |
3 files changed, 10 insertions, 5 deletions
diff --git a/include/net/dst.h b/include/net/dst.h index 94a8c234ea2a..484f80b69ada 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -97,6 +97,7 @@ struct dst_entry { | |||
97 | #ifdef __KERNEL__ | 97 | #ifdef __KERNEL__ |
98 | 98 | ||
99 | extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old); | 99 | extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old); |
100 | extern const u32 dst_default_metrics[RTAX_MAX]; | ||
100 | 101 | ||
101 | #define DST_METRICS_READ_ONLY 0x1UL | 102 | #define DST_METRICS_READ_ONLY 0x1UL |
102 | #define __DST_METRICS_PTR(Y) \ | 103 | #define __DST_METRICS_PTR(Y) \ |
diff --git a/net/core/dst.c b/net/core/dst.c index 578893505702..c1674fde827d 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
@@ -164,7 +164,7 @@ int dst_discard(struct sk_buff *skb) | |||
164 | } | 164 | } |
165 | EXPORT_SYMBOL(dst_discard); | 165 | EXPORT_SYMBOL(dst_discard); |
166 | 166 | ||
167 | static const u32 dst_default_metrics[RTAX_MAX]; | 167 | const u32 dst_default_metrics[RTAX_MAX]; |
168 | 168 | ||
169 | void *dst_alloc(struct dst_ops *ops) | 169 | void *dst_alloc(struct dst_ops *ops) |
170 | { | 170 | { |
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 363ec39228d3..48e93a560077 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -152,7 +152,8 @@ static void free_fib_info_rcu(struct rcu_head *head) | |||
152 | { | 152 | { |
153 | struct fib_info *fi = container_of(head, struct fib_info, rcu); | 153 | struct fib_info *fi = container_of(head, struct fib_info, rcu); |
154 | 154 | ||
155 | kfree(fi->fib_metrics); | 155 | if (fi->fib_metrics != (u32 *) dst_default_metrics) |
156 | kfree(fi->fib_metrics); | ||
156 | kfree(fi); | 157 | kfree(fi); |
157 | } | 158 | } |
158 | 159 | ||
@@ -743,9 +744,12 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
743 | fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); | 744 | fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); |
744 | if (fi == NULL) | 745 | if (fi == NULL) |
745 | goto failure; | 746 | goto failure; |
746 | fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL); | 747 | if (cfg->fc_mx) { |
747 | if (!fi->fib_metrics) | 748 | fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL); |
748 | goto failure; | 749 | if (!fi->fib_metrics) |
750 | goto failure; | ||
751 | } else | ||
752 | fi->fib_metrics = (u32 *) dst_default_metrics; | ||
749 | fib_info_cnt++; | 753 | fib_info_cnt++; |
750 | 754 | ||
751 | fi->fib_net = hold_net(net); | 755 | fi->fib_net = hold_net(net); |