Skip to content

Commit eab9a2d

Browse files
committed
Merge branch 'mlxsw-IPv6-and-reference-counting-fixes'
Ido Schimmel says: ==================== mlxsw: IPv6 and reference counting fixes The first three patches fix a mismatch between the new IPv6 behavior introduced in commit f34436a ("net/ipv6: Simplify route replace and appending into multipath route") and mlxsw. The patches allow the driver to support multipathing in IPv6 overlays with GRE tunnel devices. A selftest will be submitted when net-next opens. The last patch fixes a reference count problem of the port_vlan struct. I plan to simplify the code in net-next, so that reference counting is not necessary anymore. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 41f9ba6 + 9e25826 commit eab9a2d

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,12 +4756,6 @@ static void mlxsw_sp_rt6_destroy(struct mlxsw_sp_rt6 *mlxsw_sp_rt6)
47564756
kfree(mlxsw_sp_rt6);
47574757
}
47584758

4759-
static bool mlxsw_sp_fib6_rt_can_mp(const struct fib6_info *rt)
4760-
{
4761-
/* RTF_CACHE routes are ignored */
4762-
return (rt->fib6_flags & (RTF_GATEWAY | RTF_ADDRCONF)) == RTF_GATEWAY;
4763-
}
4764-
47654759
static struct fib6_info *
47664760
mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
47674761
{
@@ -4771,11 +4765,11 @@ mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
47714765

47724766
static struct mlxsw_sp_fib6_entry *
47734767
mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
4774-
const struct fib6_info *nrt, bool replace)
4768+
const struct fib6_info *nrt, bool append)
47754769
{
47764770
struct mlxsw_sp_fib6_entry *fib6_entry;
47774771

4778-
if (!mlxsw_sp_fib6_rt_can_mp(nrt) || replace)
4772+
if (!append)
47794773
return NULL;
47804774

47814775
list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
@@ -4790,8 +4784,7 @@ mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
47904784
break;
47914785
if (rt->fib6_metric < nrt->fib6_metric)
47924786
continue;
4793-
if (rt->fib6_metric == nrt->fib6_metric &&
4794-
mlxsw_sp_fib6_rt_can_mp(rt))
4787+
if (rt->fib6_metric == nrt->fib6_metric)
47954788
return fib6_entry;
47964789
if (rt->fib6_metric > nrt->fib6_metric)
47974790
break;
@@ -5170,7 +5163,7 @@ static struct mlxsw_sp_fib6_entry *
51705163
mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,
51715164
const struct fib6_info *nrt, bool replace)
51725165
{
5173-
struct mlxsw_sp_fib6_entry *fib6_entry, *fallback = NULL;
5166+
struct mlxsw_sp_fib6_entry *fib6_entry;
51745167

51755168
list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
51765169
struct fib6_info *rt = mlxsw_sp_fib6_entry_rt(fib6_entry);
@@ -5179,18 +5172,13 @@ mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,
51795172
continue;
51805173
if (rt->fib6_table->tb6_id != nrt->fib6_table->tb6_id)
51815174
break;
5182-
if (replace && rt->fib6_metric == nrt->fib6_metric) {
5183-
if (mlxsw_sp_fib6_rt_can_mp(rt) ==
5184-
mlxsw_sp_fib6_rt_can_mp(nrt))
5185-
return fib6_entry;
5186-
if (mlxsw_sp_fib6_rt_can_mp(nrt))
5187-
fallback = fallback ?: fib6_entry;
5188-
}
5175+
if (replace && rt->fib6_metric == nrt->fib6_metric)
5176+
return fib6_entry;
51895177
if (rt->fib6_metric > nrt->fib6_metric)
5190-
return fallback ?: fib6_entry;
5178+
return fib6_entry;
51915179
}
51925180

5193-
return fallback;
5181+
return NULL;
51945182
}
51955183

51965184
static int
@@ -5316,7 +5304,8 @@ static void mlxsw_sp_fib6_entry_replace(struct mlxsw_sp *mlxsw_sp,
53165304
}
53175305

53185306
static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5319-
struct fib6_info *rt, bool replace)
5307+
struct fib6_info *rt, bool replace,
5308+
bool append)
53205309
{
53215310
struct mlxsw_sp_fib6_entry *fib6_entry;
53225311
struct mlxsw_sp_fib_node *fib_node;
@@ -5342,14 +5331,22 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
53425331
/* Before creating a new entry, try to append route to an existing
53435332
* multipath entry.
53445333
*/
5345-
fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, replace);
5334+
fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, append);
53465335
if (fib6_entry) {
53475336
err = mlxsw_sp_fib6_entry_nexthop_add(mlxsw_sp, fib6_entry, rt);
53485337
if (err)
53495338
goto err_fib6_entry_nexthop_add;
53505339
return 0;
53515340
}
53525341

5342+
/* We received an append event, yet did not find any route to
5343+
* append to.
5344+
*/
5345+
if (WARN_ON(append)) {
5346+
err = -EINVAL;
5347+
goto err_fib6_entry_append;
5348+
}
5349+
53535350
fib6_entry = mlxsw_sp_fib6_entry_create(mlxsw_sp, fib_node, rt);
53545351
if (IS_ERR(fib6_entry)) {
53555352
err = PTR_ERR(fib6_entry);
@@ -5367,6 +5364,7 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
53675364
err_fib6_node_entry_link:
53685365
mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry);
53695366
err_fib6_entry_create:
5367+
err_fib6_entry_append:
53705368
err_fib6_entry_nexthop_add:
53715369
mlxsw_sp_fib_node_put(mlxsw_sp, fib_node);
53725370
return err;
@@ -5717,7 +5715,7 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
57175715
struct mlxsw_sp_fib_event_work *fib_work =
57185716
container_of(work, struct mlxsw_sp_fib_event_work, work);
57195717
struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp;
5720-
bool replace;
5718+
bool replace, append;
57215719
int err;
57225720

57235721
rtnl_lock();
@@ -5728,8 +5726,10 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
57285726
case FIB_EVENT_ENTRY_APPEND: /* fall through */
57295727
case FIB_EVENT_ENTRY_ADD:
57305728
replace = fib_work->event == FIB_EVENT_ENTRY_REPLACE;
5729+
append = fib_work->event == FIB_EVENT_ENTRY_APPEND;
57315730
err = mlxsw_sp_router_fib6_add(mlxsw_sp,
5732-
fib_work->fen6_info.rt, replace);
5731+
fib_work->fen6_info.rt, replace,
5732+
append);
57335733
if (err)
57345734
mlxsw_sp_router_fib_abort(mlxsw_sp);
57355735
mlxsw_sp_rt6_release(fib_work->fen6_info.rt);

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,10 @@ mlxsw_sp_port_vlan_bridge_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
10181018
int err;
10191019

10201020
/* No need to continue if only VLAN flags were changed */
1021-
if (mlxsw_sp_port_vlan->bridge_port)
1021+
if (mlxsw_sp_port_vlan->bridge_port) {
1022+
mlxsw_sp_port_vlan_put(mlxsw_sp_port_vlan);
10221023
return 0;
1024+
}
10231025

10241026
err = mlxsw_sp_port_vlan_fid_join(mlxsw_sp_port_vlan, bridge_port);
10251027
if (err)

net/ipv6/ip6_fib.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
934934
{
935935
struct fib6_info *leaf = rcu_dereference_protected(fn->leaf,
936936
lockdep_is_held(&rt->fib6_table->tb6_lock));
937+
enum fib_event_type event = FIB_EVENT_ENTRY_ADD;
937938
struct fib6_info *iter = NULL, *match = NULL;
938939
struct fib6_info __rcu **ins;
939940
int replace = (info->nlh &&
@@ -1013,6 +1014,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
10131014
"Can not append to a REJECT route");
10141015
return -EINVAL;
10151016
}
1017+
event = FIB_EVENT_ENTRY_APPEND;
10161018
rt->fib6_nsiblings = match->fib6_nsiblings;
10171019
list_add_tail(&rt->fib6_siblings, &match->fib6_siblings);
10181020
match->fib6_nsiblings++;
@@ -1034,15 +1036,12 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
10341036
* insert node
10351037
*/
10361038
if (!replace) {
1037-
enum fib_event_type event;
1038-
10391039
if (!add)
10401040
pr_warn("NLM_F_CREATE should be set when creating new route\n");
10411041

10421042
add:
10431043
nlflags |= NLM_F_CREATE;
10441044

1045-
event = append ? FIB_EVENT_ENTRY_APPEND : FIB_EVENT_ENTRY_ADD;
10461045
err = call_fib6_entry_notifiers(info->nl_net, event, rt,
10471046
extack);
10481047
if (err)

0 commit comments

Comments
 (0)