Skip to content

Commit 0d876f2

Browse files
dsaherndavem330
authored andcommitted
net/ipv4: Simplify fib_select_path
If flow oif is set and it is not an l3mdev, then fib_select_path can jump to the source address check. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3174a94 commit 0d876f2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

net/ipv4/fib_semantics.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,13 +1760,11 @@ void fib_select_multipath(struct fib_result *res, int hash)
17601760
void fib_select_path(struct net *net, struct fib_result *res,
17611761
struct flowi4 *fl4, const struct sk_buff *skb)
17621762
{
1763-
bool oif_check;
1764-
1765-
oif_check = (fl4->flowi4_oif == 0 ||
1766-
fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF);
1763+
if (fl4->flowi4_oif && !(fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF))
1764+
goto check_saddr;
17671765

17681766
#ifdef CONFIG_IP_ROUTE_MULTIPATH
1769-
if (res->fi->fib_nhs > 1 && oif_check) {
1767+
if (res->fi->fib_nhs > 1) {
17701768
int h = fib_multipath_hash(res->fi, fl4, skb);
17711769

17721770
fib_select_multipath(res, h);
@@ -1775,9 +1773,10 @@ void fib_select_path(struct net *net, struct fib_result *res,
17751773
#endif
17761774
if (!res->prefixlen &&
17771775
res->table->tb_num_default > 1 &&
1778-
res->type == RTN_UNICAST && oif_check)
1776+
res->type == RTN_UNICAST)
17791777
fib_select_default(fl4, res);
17801778

1779+
check_saddr:
17811780
if (!fl4->saddr)
17821781
fl4->saddr = FIB_RES_PREFSRC(net, *res);
17831782
}

0 commit comments

Comments
 (0)