Netdev List
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add and use neigh_parms_lookup_dev()
@ 2026-07-01  8:15 Paritosh Potukuchi
  2026-07-01  8:15 ` [PATCH v2 1/2] net: neighbour: add neigh_parms_lookup_dev() helper Paritosh Potukuchi
  2026-07-01  8:16 ` [PATCH v2 2/2] bonding: reuse neigh_setup from slave neigh_parms Paritosh Potukuchi
  0 siblings, 2 replies; 3+ messages in thread
From: Paritosh Potukuchi @ 2026-07-01  8:15 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, Paritosh Potukuchi

This series follows up on a previous submission where it was suggested
that neigh_parms_lookup_dev() be accompanied by its users.

Patch 1 adds neigh_parms_lookup_dev() to expose per-device
neigh_parms lookup outside of the neighbour subsystem.

Patch 2 updates bonding to reuse an existing neigh_setup()
callback from the slave's neigh_parms when available, while
preserving the existing ndo_neigh_setup() fallback path.

v2:
 - Convert the previous submission into a patch series
 - Add bonding user of neigh_parms_lookup_dev() as requested.

Previous post's link:
https://lore.kernel.org/netdev/CAAVpQUBf+asQukcRw7sJz6vS2VdeNO5+Q5ucoCxf4JgK25nZ7g@mail.gmail.com/T/#t


Paritosh Potukuchi (2):
  net: neighbour: add neigh_parms_lookup_dev() helper
  bonding: reuse neigh_setup from slave neigh_parms

 drivers/net/bonding/bond_main.c | 10 +++++++++-
 include/net/neighbour.h         |  2 ++
 net/core/neighbour.c            |  8 ++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] net: neighbour: add neigh_parms_lookup_dev() helper
  2026-07-01  8:15 [PATCH v2 0/2] Add and use neigh_parms_lookup_dev() Paritosh Potukuchi
@ 2026-07-01  8:15 ` Paritosh Potukuchi
  2026-07-01  8:16 ` [PATCH v2 2/2] bonding: reuse neigh_setup from slave neigh_parms Paritosh Potukuchi
  1 sibling, 0 replies; 3+ messages in thread
From: Paritosh Potukuchi @ 2026-07-01  8:15 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Paritosh Potukuchi, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Kuniyuki Iwashima,
	Ido Schimmel, Petr Machata

Provide a helper to lookup neigh_parms associated
with a given (neigh_table, net_device) pair.

The existing lookup_neigh_parms() helper is internal to the
neighbour subsystem and cannot be used by other subsystems.
Some stacked/virtual devices like bond require access to the
underlying device's neigh_parms.

neigh_parms_lookup_dev() is designed to be a wrapper around
lookup_neigh_parms(). The function provides controlled access
to per device neigh_parms.

The caller is expected to hold rcu_read_lock().

This does not break any existing functionality.

Signed-off-by: Paritosh Potukuchi <paritosh.potukuchi@amd.com>
---
 include/net/neighbour.h | 2 ++
 net/core/neighbour.c    | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 8860cc2175fc..1b3b06eda886 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -438,6 +438,8 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
 			  proc_handler *proc_handler);
 void neigh_sysctl_unregister(struct neigh_parms *p);
 
+struct neigh_parms *neigh_parms_lookup_dev(struct neigh_table *tbl, struct net_device *dev);
+
 static inline void __neigh_parms_put(struct neigh_parms *parms)
 {
 	refcount_dec(&parms->refcnt);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 1349c0eedb64..6d32c2668af3 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1757,6 +1757,14 @@ static inline struct neigh_parms *lookup_neigh_parms(struct neigh_table *tbl,
 	return NULL;
 }
 
+/* Caller must hold rcu_read_lock()*/
+
+struct neigh_parms *neigh_parms_lookup_dev(struct neigh_table *tbl, struct net_device *dev)
+{
+	return lookup_neigh_parms(tbl, dev_net(dev), dev->ifindex);
+}
+EXPORT_SYMBOL(neigh_parms_lookup_dev);
+
 struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
 				      struct neigh_table *tbl)
 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] bonding: reuse neigh_setup from slave neigh_parms
  2026-07-01  8:15 [PATCH v2 0/2] Add and use neigh_parms_lookup_dev() Paritosh Potukuchi
  2026-07-01  8:15 ` [PATCH v2 1/2] net: neighbour: add neigh_parms_lookup_dev() helper Paritosh Potukuchi
@ 2026-07-01  8:16 ` Paritosh Potukuchi
  1 sibling, 0 replies; 3+ messages in thread
From: Paritosh Potukuchi @ 2026-07-01  8:16 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Paritosh Potukuchi, Jay Vosburgh, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni

bond_neigh_init() currently relies on the slave device's
ndo_neigh_setup() callback to obtain a neigh_setup() handler.

When an initialized neigh_parms instance already exists for the
slave device, reuse the neigh_setup() callback stored in it instead
of invoking ndo_neigh_setup() again.

If no neigh_parms instance is found, or no neigh_setup() callback is
present, retain the existing ndo_neigh_setup() fallback path.

This avoids unnecessary ndo_neigh_setup() invocations while preserving
existing behaviour.

Signed-off-by: Paritosh Potukuchi <paritosh.potukuchi@amd.com>
---
 drivers/net/bonding/bond_main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e044fc733b8c..d2e4dae4e97c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4719,7 +4719,7 @@ static int bond_neigh_init(struct neighbour *n)
 {
 	struct bonding *bond = netdev_priv(n->dev);
 	const struct net_device_ops *slave_ops;
-	struct neigh_parms parms;
+	struct neigh_parms parms, *p;
 	struct slave *slave;
 	int ret = 0;
 
@@ -4727,6 +4727,14 @@ static int bond_neigh_init(struct neighbour *n)
 	slave = bond_first_slave_rcu(bond);
 	if (!slave)
 		goto out;
+
+	p = neigh_parms_lookup_dev(n->tbl, slave->dev);
+
+	if (p && p->neigh_setup) {
+		ret = p->neigh_setup(n);
+		goto out;
+	}
+
 	slave_ops = slave->dev->netdev_ops;
 	if (!slave_ops->ndo_neigh_setup)
 		goto out;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-01  8:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01  8:15 [PATCH v2 0/2] Add and use neigh_parms_lookup_dev() Paritosh Potukuchi
2026-07-01  8:15 ` [PATCH v2 1/2] net: neighbour: add neigh_parms_lookup_dev() helper Paritosh Potukuchi
2026-07-01  8:16 ` [PATCH v2 2/2] bonding: reuse neigh_setup from slave neigh_parms Paritosh Potukuchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox