aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-01-28 17:01:25 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-28 17:01:25 -0500
commit9c150e82ac50a611237bbebd508d17f6347d577c (patch)
tree7c79c013857cc13570595e805de0dbdb8f00332e
parenta4daad6b0923030fbd3b00a01f570e4c3eef446b (diff)
ipv4: Allocate fib metrics dynamically.
This is the initial gateway towards super-sharing metrics if they are all set to zero for a route. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ip_fib.h2
-rw-r--r--net/ipv4/fib_semantics.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 65d1fcdbc63b..2c0508a6e07c 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -77,7 +77,7 @@ struct fib_info {
77 int fib_protocol; 77 int fib_protocol;
78 __be32 fib_prefsrc; 78 __be32 fib_prefsrc;
79 u32 fib_priority; 79 u32 fib_priority;
80 u32 fib_metrics[RTAX_MAX]; 80 u32 *fib_metrics;
81#define fib_mtu fib_metrics[RTAX_MTU-1] 81#define fib_mtu fib_metrics[RTAX_MTU-1]
82#define fib_window fib_metrics[RTAX_WINDOW-1] 82#define fib_window fib_metrics[RTAX_WINDOW-1]
83#define fib_rtt fib_metrics[RTAX_RTT-1] 83#define fib_rtt fib_metrics[RTAX_RTT-1]
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 9aff11d7278f..363ec39228d3 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -152,6 +152,7 @@ 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 kfree(fi); 156 kfree(fi);
156} 157}
157 158
@@ -742,6 +743,9 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
742 fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); 743 fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
743 if (fi == NULL) 744 if (fi == NULL)
744 goto failure; 745 goto failure;
746 fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL);
747 if (!fi->fib_metrics)
748 goto failure;
745 fib_info_cnt++; 749 fib_info_cnt++;
746 750
747 fi->fib_net = hold_net(net); 751 fi->fib_net = hold_net(net);