Skip to content

Commit dd19f83

Browse files
scottfeldmandavem330
authored andcommitted
rocker: hook ndo_neigh_destroy to cleanup neigh refs in driver
Rocker driver tracks arp_tbl neighs to resolve IPv4 route nexthops. The driver uses NETEVENT_NEIGH_UPDATE for neigh adds and updates, but there is no event when the neigh is removed from the device (such as when the device goes admin down). This patches hooks ndo_neigh_destroy so the driver can know when a neigh is removed from the device. In response, the driver will purge the neigh entry from its internal tbl. I didn't find an in-tree users of ndo_neigh_destroy, so I'm not sure if this ndo is vestigial or if there are out-of-tree users. In any case, it does what I need here. An alternative design would be to generate NETEVENT_NEIGH_UPDATE event when neigh is being destroyed, setting state to NUD_NONE so driver knows neigh entry is dead. Signed-off-by: Scott Feldman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c8beb5b commit dd19f83

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Documentation/networking/switchdev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,5 @@ driver's rocker_port_ipv4_resolve() for an example.
367367

368368
The driver can monitor for updates to arp_tbl using the netevent notifier
369369
NETEVENT_NEIGH_UPDATE. The device can be programmed with resolved nexthops
370-
for the routes as arp_tbl updates.
370+
for the routes as arp_tbl updates. The driver implements ndo_neigh_destroy
371+
to know when arp_tbl neighbor entries are purged from the port.

drivers/net/ethernet/rocker/rocker.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4264,6 +4264,16 @@ static int rocker_port_change_proto_down(struct net_device *dev,
42644264
return 0;
42654265
}
42664266

4267+
static void rocker_port_neigh_destroy(struct neighbour *n)
4268+
{
4269+
struct rocker_port *rocker_port = netdev_priv(n->dev);
4270+
int flags = ROCKER_OP_FLAG_REMOVE | ROCKER_OP_FLAG_NOWAIT;
4271+
__be32 ip_addr = *(__be32 *)n->primary_key;
4272+
4273+
rocker_port_ipv4_neigh(rocker_port, SWITCHDEV_TRANS_NONE,
4274+
flags, ip_addr, n->ha);
4275+
}
4276+
42674277
static const struct net_device_ops rocker_port_netdev_ops = {
42684278
.ndo_open = rocker_port_open,
42694279
.ndo_stop = rocker_port_stop,
@@ -4278,6 +4288,7 @@ static const struct net_device_ops rocker_port_netdev_ops = {
42784288
.ndo_fdb_dump = switchdev_port_fdb_dump,
42794289
.ndo_get_phys_port_name = rocker_port_get_phys_port_name,
42804290
.ndo_change_proto_down = rocker_port_change_proto_down,
4291+
.ndo_neigh_destroy = rocker_port_neigh_destroy,
42814292
};
42824293

42834294
/********************

0 commit comments

Comments
 (0)