* [patch net] mlxsw: spectrum_router: Don't offload routes next in list
@ 2017-07-21 16:04 Jiri Pirko
2017-07-24 21:15 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Pirko @ 2017-07-21 16:04 UTC (permalink / raw)
To: netdev; +Cc: davem, idosch, mlxsw
From: Ido Schimmel <idosch@mellanox.com>
Each FIB node holds a linked list of routes sharing the same prefix and
length. In the case of IPv4 it's ordered according to table ID, metric
and TOS and only the first route in the list is actually programmed to
the device.
In case a gatewayed route is added somewhere in the list, then after its
nexthop group will be refreshed and become valid (due to the resolution
of its gateway), it'll mistakenly overwrite the existing entry.
Example:
192.168.200.0/24 dev enp3s0np3 scope link metric 1000 offload
192.168.200.0/24 via 192.168.100.1 dev enp3s0np3 metric 1000 offload
Both routes are marked as offloaded despite the fact only the first one
should actually be present in the device's table.
When refreshing the nexthop group, don't write the route to the device's
table unless it's the first in its node.
Fixes: 9aecce1c7d97 ("mlxsw: spectrum_router: Correctly handle identical routes")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 383fef5a..4b2e0fd 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -1512,6 +1512,10 @@ mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp *mlxsw_sp,
static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_fib_entry *fib_entry);
+static bool
+mlxsw_sp_fib_node_entry_is_first(const struct mlxsw_sp_fib_node *fib_node,
+ const struct mlxsw_sp_fib_entry *fib_entry);
+
static int
mlxsw_sp_nexthop_fib_entries_update(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_nexthop_group *nh_grp)
@@ -1520,6 +1524,9 @@ mlxsw_sp_nexthop_fib_entries_update(struct mlxsw_sp *mlxsw_sp,
int err;
list_for_each_entry(fib_entry, &nh_grp->fib_list, nexthop_group_node) {
+ if (!mlxsw_sp_fib_node_entry_is_first(fib_entry->fib_node,
+ fib_entry))
+ continue;
err = mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry);
if (err)
return err;
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [patch net] mlxsw: spectrum_router: Don't offload routes next in list
2017-07-21 16:04 [patch net] mlxsw: spectrum_router: Don't offload routes next in list Jiri Pirko
@ 2017-07-24 21:15 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-07-24 21:15 UTC (permalink / raw)
To: jiri; +Cc: netdev, idosch, mlxsw
From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 21 Jul 2017 18:04:28 +0200
> From: Ido Schimmel <idosch@mellanox.com>
>
> Each FIB node holds a linked list of routes sharing the same prefix and
> length. In the case of IPv4 it's ordered according to table ID, metric
> and TOS and only the first route in the list is actually programmed to
> the device.
>
> In case a gatewayed route is added somewhere in the list, then after its
> nexthop group will be refreshed and become valid (due to the resolution
> of its gateway), it'll mistakenly overwrite the existing entry.
>
> Example:
> 192.168.200.0/24 dev enp3s0np3 scope link metric 1000 offload
> 192.168.200.0/24 via 192.168.100.1 dev enp3s0np3 metric 1000 offload
>
> Both routes are marked as offloaded despite the fact only the first one
> should actually be present in the device's table.
>
> When refreshing the nexthop group, don't write the route to the device's
> table unless it's the first in its node.
>
> Fixes: 9aecce1c7d97 ("mlxsw: spectrum_router: Correctly handle identical routes")
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-24 21:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-21 16:04 [patch net] mlxsw: spectrum_router: Don't offload routes next in list Jiri Pirko
2017-07-24 21:15 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).