Skip to content

Commit

Permalink
net: Fix prefsrc lookups
Browse files Browse the repository at this point in the history
A bug report (https://bugzilla.kernel.org/show_bug.cgi?id=107071) noted
that the follwoing ip command is failing with v4.3:

    $ ip route add 10.248.5.0/24 dev bond0.250 table vlan_250 src 10.248.5.154
    RTNETLINK answers: Invalid argument

021dd3b changed the lookup of the given preferred source address to
use the table id passed in, but this assumes the local entries are in the
given table which is not necessarily true for non-VRF use cases. When
validating the preferred source fallback to the local table on failure.

Fixes: 021dd3b ("net: Add routes to the table associated with the device")
Signed-off-by: David Ahern <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
David Ahern authored and davem330 committed Nov 5, 2015
1 parent 87e9f03 commit e1b8d90
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/ipv4/fib_semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,14 +923,21 @@ static bool fib_valid_prefsrc(struct fib_config *cfg, __be32 fib_prefsrc)
if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||
fib_prefsrc != cfg->fc_dst) {
u32 tb_id = cfg->fc_table;
int rc;

if (tb_id == RT_TABLE_MAIN)
tb_id = RT_TABLE_LOCAL;

if (inet_addr_type_table(cfg->fc_nlinfo.nl_net,
fib_prefsrc, tb_id) != RTN_LOCAL) {
return false;
rc = inet_addr_type_table(cfg->fc_nlinfo.nl_net,
fib_prefsrc, tb_id);

if (rc != RTN_LOCAL && tb_id != RT_TABLE_LOCAL) {
rc = inet_addr_type_table(cfg->fc_nlinfo.nl_net,
fib_prefsrc, RT_TABLE_LOCAL);
}

if (rc != RTN_LOCAL)
return false;
}
return true;
}
Expand Down

0 comments on commit e1b8d90

Please sign in to comment.