Skip to content

Commit 03cf786

Browse files
xemulDavid S. Miller
authored andcommitted
[IPV4]: Explicitly call fib_get_table() in fib_frontend.c
In case the "multiple tables" config option is y, the ip_fib_local_table is not a variable, but a macro, that calls fib_get_table(RT_TABLE_LOCAL). Some code uses this "variable" *3* times in one place, thus implicitly making 3 calls. Fix it. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f0fe91d commit 03cf786

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎net/ipv4/fib_frontend.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,14 @@ struct net_device * ip_dev_find(__be32 addr)
128128
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } };
129129
struct fib_result res;
130130
struct net_device *dev = NULL;
131+
struct fib_table *local_table;
131132

132133
#ifdef CONFIG_IP_MULTIPLE_TABLES
133134
res.r = NULL;
134135
#endif
135136

136-
if (!ip_fib_local_table ||
137-
ip_fib_local_table->tb_lookup(ip_fib_local_table, &fl, &res))
137+
local_table = fib_get_table(RT_TABLE_LOCAL);
138+
if (!local_table || local_table->tb_lookup(local_table, &fl, &res))
138139
return NULL;
139140
if (res.type != RTN_LOCAL)
140141
goto out;
@@ -152,6 +153,7 @@ unsigned inet_addr_type(__be32 addr)
152153
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } };
153154
struct fib_result res;
154155
unsigned ret = RTN_BROADCAST;
156+
struct fib_table *local_table;
155157

156158
if (ZERONET(addr) || BADCLASS(addr))
157159
return RTN_BROADCAST;
@@ -162,10 +164,10 @@ unsigned inet_addr_type(__be32 addr)
162164
res.r = NULL;
163165
#endif
164166

165-
if (ip_fib_local_table) {
167+
local_table = fib_get_table(RT_TABLE_LOCAL);
168+
if (local_table) {
166169
ret = RTN_UNICAST;
167-
if (!ip_fib_local_table->tb_lookup(ip_fib_local_table,
168-
&fl, &res)) {
170+
if (!local_table->tb_lookup(local_table, &fl, &res)) {
169171
ret = res.type;
170172
fib_res_put(&res);
171173
}

0 commit comments

Comments
 (0)