net/ipv6: Revert attempt to simplify route replace and append
Subsystems (5)
[email protected]
maintainerPATCH v2 1/1 net/ipv6: Revert attempt to simplify route replace and append
From: David Ahern <[email protected]>
NetworkManager likes to manage linklocal prefix routes and does so with the NLM_F_APPEND flag, breaking attempts to simplify the IPv6 route code and by extension enable multipath routes with device only nexthops.
Revert f34436a43092 and these followup patches:6eba08c3626b ("ipv6: Only emit append events for appended routes"). ce45bded6435 ("mlxsw: spectrum_router: Align with new route replace logic") 53b562df8c20 ("mlxsw: spectrum_router: Allow appending to dev-only routes")
Update the fib_tests cases to reflect the old behavior.
---
The gre_multipath tests only exist in net-next. Those will need to be updated separately.
.../net/ethernet/mellanox/mlxsw/spectrum_router.c | 48 +++---- include/net/ip6_route.h | 6 + net/ipv6/ip6_fib.c | 156 ++++++++++++--------- net/ipv6/route.c | 3 +- tools/testing/selftests/net/fib_tests.sh | 41 ------ 5 files changed, 117 insertions(+), 137 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +24 -24
@@ -4756,6 +4756,12 @@ static void mlxsw_sp_rt6_destroy(struct mlxsw_sp_rt6 *mlxsw_sp_rt6)kfree (mlxsw_sp_rt6); } +static bool mlxsw_sp_fib6_rt_can_mp (const struct fib6_info *rt) +{ +/* RTF_CACHE routes are ignored */ +return (rt->fib6_flags & (RTF_GATEWAY |RTF_ADDRCONF )) ==RTF_GATEWAY ; +} +static struct fib6_info *mlxsw_sp_fib6_entry_rt (const struct mlxsw_sp_fib6_entry *fib6_entry) {
@@ -4765,11 +4771,11 @@ mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)static struct mlxsw_sp_fib6_entry *mlxsw_sp_fib6_node_mp_entry_find (const struct mlxsw_sp_fib_node *fib_node, -const struct fib6_info *nrt,bool append) +const struct fib6_info *nrt,bool replace) {struct mlxsw_sp_fib6_entry *fib6_entry; -if (!append) +if (!mlxsw_sp_fib6_rt_can_mp (nrt) || replace)return NULL ;list_for_each_entry (fib6_entry, &fib_node->entry_list, common.list) {
@@ -4784,7 +4790,8 @@ mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,break ;if (rt->fib6_metric < nrt->fib6_metric)continue ; -if (rt->fib6_metric == nrt->fib6_metric) +if (rt->fib6_metric == nrt->fib6_metric && +mlxsw_sp_fib6_rt_can_mp (rt))return fib6_entry;if (rt->fib6_metric > nrt->fib6_metric)break ;
@@ -5163,7 +5170,7 @@ static struct mlxsw_sp_fib6_entry * mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node, const struct fib6_info *nrt, bool replace) { - struct mlxsw_sp_fib6_entry *fib6_entry; + struct mlxsw_sp_fib6_entry *fib6_entry, *fallback = NULL;list_for_each_entry (fib6_entry, &fib_node->entry_list, common.list) {struct fib6_info *rt =mlxsw_sp_fib6_entry_rt (fib6_entry);
@@ -5172,13 +5179,18 @@ mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,continue ;if (rt->fib6_table->tb6_id != nrt->fib6_table->tb6_id)break ; -if (replace && rt->fib6_metric == nrt->fib6_metric) -return fib6_entry; +if (replace && rt->fib6_metric == nrt->fib6_metric) { +if (mlxsw_sp_fib6_rt_can_mp (rt) == +mlxsw_sp_fib6_rt_can_mp (nrt)) +return fib6_entry; +if (mlxsw_sp_fib6_rt_can_mp (nrt)) + fallback = fallback ?: fib6_entry; + }if (rt->fib6_metric > nrt->fib6_metric) -return fib6_entry; +return fallback ?: fib6_entry; } -return NULL ; +return fallback; } static int
@@ -5304,8 +5316,7 @@ static void mlxsw_sp_fib6_entry_replace(struct mlxsw_sp *mlxsw_sp, }static int mlxsw_sp_router_fib6_add (struct mlxsw_sp *mlxsw_sp, -struct fib6_info *rt,bool replace, -bool append) +struct fib6_info *rt,bool replace) {struct mlxsw_sp_fib6_entry *fib6_entry;struct mlxsw_sp_fib_node *fib_node;
@@ -5331,7 +5342,7 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,/* Before creating a new entry, try to append route to an existing * multipath entry. */ - fib6_entry =mlxsw_sp_fib6_node_mp_entry_find (fib_node, rt, append); + fib6_entry =mlxsw_sp_fib6_node_mp_entry_find (fib_node, rt, replace);if (fib6_entry) { err =mlxsw_sp_fib6_entry_nexthop_add (mlxsw_sp, fib6_entry, rt);if (err)
@@ -5339,14 +5350,6 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,return 0 ; } -/* We received an append event, yet did not find any route to -* append to. -*/ -if (WARN_ON (append)) { - err = -EINVAL ; - goto err_fib6_entry_append; - } - fib6_entry =mlxsw_sp_fib6_entry_create (mlxsw_sp, fib_node, rt);if (IS_ERR (fib6_entry)) { err =PTR_ERR (fib6_entry);
@@ -5364,7 +5367,6 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp, err_fib6_node_entry_link:mlxsw_sp_fib6_entry_destroy (mlxsw_sp, fib6_entry); err_fib6_entry_create: -err_fib6_entry_append: err_fib6_entry_nexthop_add:mlxsw_sp_fib_node_put (mlxsw_sp, fib_node);return err;
@@ -5715,7 +5717,7 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)struct mlxsw_sp_fib_event_work *fib_work = container_of(work, struct mlxsw_sp_fib_event_work, work);struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp; -bool replace, append; +bool replace;int err;rtnl_lock ();
@@ -5726,10 +5728,8 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)case FIB_EVENT_ENTRY_APPEND :/* fall through */ case FIB_EVENT_ENTRY_ADD : replace = fib_work->event ==FIB_EVENT_ENTRY_REPLACE ; - append = fib_work->event ==FIB_EVENT_ENTRY_APPEND ; err =mlxsw_sp_router_fib6_add (mlxsw_sp, - fib_work->fen6_info.rt, replace, - append); + fib_work->fen6_info.rt, replace);if (err)mlxsw_sp_router_fib_abort (mlxsw_sp);mlxsw_sp_rt6_release (fib_work->fen6_info.rt);
include/net/ip6_route.h +6 -0
@@ -66,6 +66,12 @@ static inline bool rt6_need_strict(const struct in6_addr *daddr) (IPV6_ADDR_MULTICAST |IPV6_ADDR_LINKLOCAL |IPV6_ADDR_LOOPBACK ); } +static inline bool rt6_qualify_for_ecmp (const struct fib6_info *f6i) +{ +return (f6i->fib6_flags & (RTF_GATEWAY |RTF_ADDRCONF |RTF_DYNAMIC )) == +RTF_GATEWAY ; +} +void ip6_route_input (struct sk_buff *skb); struct dst_entry *ip6_route_input_lookup(struct net *net, struct net_device *dev,
net/ipv6/ip6_fib.c +86 -70
237 lines not on this page · raw message
net/ipv6/route.c +1 -2
@@ -3842,7 +3842,7 @@ static struct fib6_info *rt6_multipath_first_sibling(const struct fib6_info *rt) lockdep_is_held(&rt->fib6_table->tb6_lock));while (iter) {if (iter->fib6_metric == rt->fib6_metric && - iter->fib6_nsiblings) +rt6_qualify_for_ecmp (iter))return iter; iter =rcu_dereference_protected (iter->fib6_next,lockdep_is_held (&rt->fib6_table->tb6_lock));
@@ -4439,7 +4439,6 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,*/ cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |NLM_F_REPLACE ); - cfg->fc_nlinfo.nlh->nlmsg_flags |=NLM_F_APPEND ; nhn++; }
tools/testing/selftests/net/fib_tests.sh +0 -41
65 lines not on this page · raw message
Signature · 1 line
2.11.0
From: [email protected]
Date: Tue, 3 Jul 2018 14:36:21 -0700
Quoted 11 lines
From: David Ahern <[email protected]>
NetworkManager likes to manage linklocal prefix routes and does so with the
NLM_F_APPENDflag, breaking attempts to simplify the IPv6 route code and by extension enable multipath routes with device only nexthops.Revert
f34436a43092and these followup patches:6eba08c3626b("ipv6: Only emit append events for appended routes").ce45bded6435("mlxsw:spectrum_router: Align with new route replace logic")53b562df8c20("mlxsw:spectrum_router: Allow appending to dev-only routes")
Quoted 4 lines
Update the
fib_testscases to reflect the old behavior.Fixes f34436a43092 ("net/ipv6: Simplify route replace and appending into multipath route")Signed-off-by David Ahern <[email protected]>
Applied.
Quoted 2 lines
The
gre_multipathtests only exist in net-next. Those will need to be updated separately.
Ok, please send me the net-next update once this gets merged there.
Thanks.