diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-13 11:21:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-13 11:21:29 -0400 |
commit | 85b91b0339e764f7e56ff5968fa10d85451378b4 (patch) | |
tree | 539c368948900b35ee8d474829724a796b482d44 | |
parent | d01cb20711e3c2df41677ee270d6bdeff24e9902 (diff) |
ipv4: Don't store a rule pointer in fib_result.
We only use it to fetch the rule's tclassid, so just store the
tclassid there instead.
This also decreases the size of fib_result by a full 8 bytes on
64-bit. On 32-bits it's a wash.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/ip_fib.h | 12 | ||||
-rw-r--r-- | net/ipv4/fib_frontend.c | 8 | ||||
-rw-r--r-- | net/ipv4/fib_rules.c | 15 | ||||
-rw-r--r-- | net/ipv4/route.c | 6 |
4 files changed, 11 insertions, 30 deletions
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index e91fedd22db2..5697acefeba3 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h | |||
@@ -106,12 +106,10 @@ struct fib_result { | |||
106 | unsigned char nh_sel; | 106 | unsigned char nh_sel; |
107 | unsigned char type; | 107 | unsigned char type; |
108 | unsigned char scope; | 108 | unsigned char scope; |
109 | u32 tclassid; | ||
109 | struct fib_info *fi; | 110 | struct fib_info *fi; |
110 | struct fib_table *table; | 111 | struct fib_table *table; |
111 | struct list_head *fa_head; | 112 | struct list_head *fa_head; |
112 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
113 | struct fib_rule *r; | ||
114 | #endif | ||
115 | }; | 113 | }; |
116 | 114 | ||
117 | struct fib_result_nl { | 115 | struct fib_result_nl { |
@@ -215,10 +213,6 @@ static inline int fib_lookup(struct net *net, const struct flowi4 *flp, | |||
215 | extern int __net_init fib4_rules_init(struct net *net); | 213 | extern int __net_init fib4_rules_init(struct net *net); |
216 | extern void __net_exit fib4_rules_exit(struct net *net); | 214 | extern void __net_exit fib4_rules_exit(struct net *net); |
217 | 215 | ||
218 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
219 | extern u32 fib_rules_tclass(const struct fib_result *res); | ||
220 | #endif | ||
221 | |||
222 | extern struct fib_table *fib_new_table(struct net *net, u32 id); | 216 | extern struct fib_table *fib_new_table(struct net *net, u32 id); |
223 | extern struct fib_table *fib_get_table(struct net *net, u32 id); | 217 | extern struct fib_table *fib_get_table(struct net *net, u32 id); |
224 | 218 | ||
@@ -229,7 +223,7 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp, | |||
229 | struct fib_result *res) | 223 | struct fib_result *res) |
230 | { | 224 | { |
231 | if (!net->ipv4.fib_has_custom_rules) { | 225 | if (!net->ipv4.fib_has_custom_rules) { |
232 | res->r = NULL; | 226 | res->tclassid = 0; |
233 | if (net->ipv4.fib_local && | 227 | if (net->ipv4.fib_local && |
234 | !fib_table_lookup(net->ipv4.fib_local, flp, res, | 228 | !fib_table_lookup(net->ipv4.fib_local, flp, res, |
235 | FIB_LOOKUP_NOREF)) | 229 | FIB_LOOKUP_NOREF)) |
@@ -289,7 +283,7 @@ static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) | |||
289 | #endif | 283 | #endif |
290 | *itag = FIB_RES_NH(*res).nh_tclassid<<16; | 284 | *itag = FIB_RES_NH(*res).nh_tclassid<<16; |
291 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 285 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
292 | rtag = fib_rules_tclass(res); | 286 | rtag = res->tclassid; |
293 | if (*itag == 0) | 287 | if (*itag == 0) |
294 | *itag = (rtag<<16); | 288 | *itag = (rtag<<16); |
295 | *itag |= (rtag>>16); | 289 | *itag |= (rtag>>16); |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 81f85716a894..7a31194ec633 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -169,10 +169,6 @@ static inline unsigned int __inet_dev_addr_type(struct net *net, | |||
169 | if (ipv4_is_multicast(addr)) | 169 | if (ipv4_is_multicast(addr)) |
170 | return RTN_MULTICAST; | 170 | return RTN_MULTICAST; |
171 | 171 | ||
172 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
173 | res.r = NULL; | ||
174 | #endif | ||
175 | |||
176 | local_table = fib_get_table(net, RT_TABLE_LOCAL); | 172 | local_table = fib_get_table(net, RT_TABLE_LOCAL); |
177 | if (local_table) { | 173 | if (local_table) { |
178 | ret = RTN_UNICAST; | 174 | ret = RTN_UNICAST; |
@@ -934,10 +930,6 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb) | |||
934 | .flowi4_scope = frn->fl_scope, | 930 | .flowi4_scope = frn->fl_scope, |
935 | }; | 931 | }; |
936 | 932 | ||
937 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
938 | res.r = NULL; | ||
939 | #endif | ||
940 | |||
941 | frn->err = -ENOENT; | 933 | frn->err = -ENOENT; |
942 | if (tb) { | 934 | if (tb) { |
943 | local_bh_disable(); | 935 | local_bh_disable(); |
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index c06da93b0b70..a83d74e498d2 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c | |||
@@ -47,13 +47,6 @@ struct fib4_rule { | |||
47 | #endif | 47 | #endif |
48 | }; | 48 | }; |
49 | 49 | ||
50 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
51 | u32 fib_rules_tclass(const struct fib_result *res) | ||
52 | { | ||
53 | return res->r ? ((struct fib4_rule *) res->r)->tclassid : 0; | ||
54 | } | ||
55 | #endif | ||
56 | |||
57 | int __fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res) | 50 | int __fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res) |
58 | { | 51 | { |
59 | struct fib_lookup_arg arg = { | 52 | struct fib_lookup_arg arg = { |
@@ -63,8 +56,12 @@ int __fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res) | |||
63 | int err; | 56 | int err; |
64 | 57 | ||
65 | err = fib_rules_lookup(net->ipv4.rules_ops, flowi4_to_flowi(flp), 0, &arg); | 58 | err = fib_rules_lookup(net->ipv4.rules_ops, flowi4_to_flowi(flp), 0, &arg); |
66 | res->r = arg.rule; | 59 | #ifdef CONFIG_IP_ROUTE_CLASSID |
67 | 60 | if (arg.rule) | |
61 | res->tclassid = ((struct fib4_rule *)arg.rule)->tclassid; | ||
62 | else | ||
63 | res->tclassid = 0; | ||
64 | #endif | ||
68 | return err; | 65 | return err; |
69 | } | 66 | } |
70 | EXPORT_SYMBOL_GPL(__fib_lookup); | 67 | EXPORT_SYMBOL_GPL(__fib_lookup); |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 9319bf1f8354..aad21819316d 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1735,7 +1735,7 @@ static void rt_set_nexthop(struct rtable *rt, const struct flowi4 *fl4, | |||
1735 | 1735 | ||
1736 | #ifdef CONFIG_IP_ROUTE_CLASSID | 1736 | #ifdef CONFIG_IP_ROUTE_CLASSID |
1737 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 1737 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
1738 | set_class_tag(rt, fib_rules_tclass(res)); | 1738 | set_class_tag(rt, res->tclassid); |
1739 | #endif | 1739 | #endif |
1740 | set_class_tag(rt, itag); | 1740 | set_class_tag(rt, itag); |
1741 | #endif | 1741 | #endif |
@@ -2353,11 +2353,9 @@ static struct rtable *ip_route_output_slow(struct net *net, struct flowi4 *fl4) | |||
2353 | __be32 orig_saddr; | 2353 | __be32 orig_saddr; |
2354 | int orig_oif; | 2354 | int orig_oif; |
2355 | 2355 | ||
2356 | res.tclassid = 0; | ||
2356 | res.fi = NULL; | 2357 | res.fi = NULL; |
2357 | res.table = NULL; | 2358 | res.table = NULL; |
2358 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
2359 | res.r = NULL; | ||
2360 | #endif | ||
2361 | 2359 | ||
2362 | orig_daddr = fl4->daddr; | 2360 | orig_daddr = fl4->daddr; |
2363 | orig_saddr = fl4->saddr; | 2361 | orig_saddr = fl4->saddr; |