mlxsw: spectrum_router: Extract a helper to schedule neighbour work

This will come in handy for neighbour replay.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Petr Machata 2023-07-19 13:01:20 +02:00 committed by David S. Miller
parent 6bbc9ca6a3
commit 96c3e45c01
1 changed files with 16 additions and 9 deletions

View File

@ -2872,6 +2872,21 @@ static bool mlxsw_sp_dev_lower_is_port(struct net_device *dev)
return !!mlxsw_sp_port; return !!mlxsw_sp_port;
} }
static int mlxsw_sp_router_schedule_neigh_work(struct mlxsw_sp_router *router,
struct neighbour *n)
{
struct net *net;
net = neigh_parms_net(n->parms);
/* Take a reference to ensure the neighbour won't be destructed until we
* drop the reference in delayed work.
*/
neigh_clone(n);
return mlxsw_sp_router_schedule_work(net, router, n,
mlxsw_sp_router_neigh_event_work);
}
static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, static int mlxsw_sp_router_netevent_event(struct notifier_block *nb,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
@ -2879,7 +2894,6 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb,
unsigned long interval; unsigned long interval;
struct neigh_parms *p; struct neigh_parms *p;
struct neighbour *n; struct neighbour *n;
struct net *net;
router = container_of(nb, struct mlxsw_sp_router, netevent_nb); router = container_of(nb, struct mlxsw_sp_router, netevent_nb);
@ -2903,7 +2917,6 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb,
break; break;
case NETEVENT_NEIGH_UPDATE: case NETEVENT_NEIGH_UPDATE:
n = ptr; n = ptr;
net = neigh_parms_net(n->parms);
if (n->tbl->family != AF_INET && n->tbl->family != AF_INET6) if (n->tbl->family != AF_INET && n->tbl->family != AF_INET6)
return NOTIFY_DONE; return NOTIFY_DONE;
@ -2911,13 +2924,7 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb,
if (!mlxsw_sp_dev_lower_is_port(n->dev)) if (!mlxsw_sp_dev_lower_is_port(n->dev))
return NOTIFY_DONE; return NOTIFY_DONE;
/* Take a reference to ensure the neighbour won't be return mlxsw_sp_router_schedule_neigh_work(router, n);
* destructed until we drop the reference in delayed
* work.
*/
neigh_clone(n);
return mlxsw_sp_router_schedule_work(net, router, n,
mlxsw_sp_router_neigh_event_work);
case NETEVENT_IPV4_MPATH_HASH_UPDATE: case NETEVENT_IPV4_MPATH_HASH_UPDATE:
case NETEVENT_IPV6_MPATH_HASH_UPDATE: case NETEVENT_IPV6_MPATH_HASH_UPDATE: