Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+11 -30
+3 -9
include/net/ip_fib.h
··· 106 106 unsigned char nh_sel; 107 107 unsigned char type; 108 108 unsigned char scope; 109 + u32 tclassid; 109 110 struct fib_info *fi; 110 111 struct fib_table *table; 111 112 struct list_head *fa_head; 112 - #ifdef CONFIG_IP_MULTIPLE_TABLES 113 - struct fib_rule *r; 114 - #endif 115 113 }; 116 114 117 115 struct fib_result_nl { ··· 213 215 extern int __net_init fib4_rules_init(struct net *net); 214 216 extern void __net_exit fib4_rules_exit(struct net *net); 215 217 216 - #ifdef CONFIG_IP_ROUTE_CLASSID 217 - extern u32 fib_rules_tclass(const struct fib_result *res); 218 - #endif 219 - 220 218 extern struct fib_table *fib_new_table(struct net *net, u32 id); 221 219 extern struct fib_table *fib_get_table(struct net *net, u32 id); 222 220 ··· 223 229 struct fib_result *res) 224 230 { 225 231 if (!net->ipv4.fib_has_custom_rules) { 226 - res->r = NULL; 232 + res->tclassid = 0; 227 233 if (net->ipv4.fib_local && 228 234 !fib_table_lookup(net->ipv4.fib_local, flp, res, 229 235 FIB_LOOKUP_NOREF)) ··· 283 289 #endif 284 290 *itag = FIB_RES_NH(*res).nh_tclassid<<16; 285 291 #ifdef CONFIG_IP_MULTIPLE_TABLES 286 - rtag = fib_rules_tclass(res); 292 + rtag = res->tclassid; 287 293 if (*itag == 0) 288 294 *itag = (rtag<<16); 289 295 *itag |= (rtag>>16);
-8
net/ipv4/fib_frontend.c
··· 169 169 if (ipv4_is_multicast(addr)) 170 170 return RTN_MULTICAST; 171 171 172 - #ifdef CONFIG_IP_MULTIPLE_TABLES 173 - res.r = NULL; 174 - #endif 175 - 176 172 local_table = fib_get_table(net, RT_TABLE_LOCAL); 177 173 if (local_table) { 178 174 ret = RTN_UNICAST; ··· 929 933 .flowi4_tos = frn->fl_tos, 930 934 .flowi4_scope = frn->fl_scope, 931 935 }; 932 - 933 - #ifdef CONFIG_IP_MULTIPLE_TABLES 934 - res.r = NULL; 935 - #endif 936 936 937 937 frn->err = -ENOENT; 938 938 if (tb) {
+6 -9
net/ipv4/fib_rules.c
··· 47 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 50 int __fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res) 58 51 { 59 52 struct fib_lookup_arg arg = { ··· 56 63 int err; 57 64 58 65 err = fib_rules_lookup(net->ipv4.rules_ops, flowi4_to_flowi(flp), 0, &arg); 59 - res->r = arg.rule; 60 - 66 + #ifdef CONFIG_IP_ROUTE_CLASSID 67 + if (arg.rule) 68 + res->tclassid = ((struct fib4_rule *)arg.rule)->tclassid; 69 + else 70 + res->tclassid = 0; 71 + #endif 61 72 return err; 62 73 } 63 74 EXPORT_SYMBOL_GPL(__fib_lookup);
+2 -4
net/ipv4/route.c
··· 1735 1735 1736 1736 #ifdef CONFIG_IP_ROUTE_CLASSID 1737 1737 #ifdef CONFIG_IP_MULTIPLE_TABLES 1738 - set_class_tag(rt, fib_rules_tclass(res)); 1738 + set_class_tag(rt, res->tclassid); 1739 1739 #endif 1740 1740 set_class_tag(rt, itag); 1741 1741 #endif ··· 2353 2353 __be32 orig_saddr; 2354 2354 int orig_oif; 2355 2355 2356 + res.tclassid = 0; 2356 2357 res.fi = NULL; 2357 2358 res.table = NULL; 2358 - #ifdef CONFIG_IP_MULTIPLE_TABLES 2359 - res.r = NULL; 2360 - #endif 2361 2359 2362 2360 orig_daddr = fl4->daddr; 2363 2361 orig_saddr = fl4->saddr;