Netdev List
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com>,
	Tonghao Zhang <tonghao@bamaicloud.com>
Subject: [PATCH net-next] bonding: add sysfs interface for broadcast_neighbor
Date: Wed, 10 Jun 2026 20:08:12 +0800	[thread overview]
Message-ID: <20260610120812.49054-1-laoar.shao@gmail.com> (raw)

The upstream kernel has supported broadcast_neighbor for 802.3ad mode since
commit ce7a381697cb ("net: bonding: add broadcast_neighbor option for 802.3ad").
When upgrading from our local kernel to 6.18.y stable, we switched from our
out-of-tree implementation to the upstream one.

However, the iproute2 package on our production servers is too old to
support the broadcast_neighbor option. To enable this feature, add a new
sysfs attribute at:

  /sys/class/net/<bond>/bonding/broadcast_neighbor

This allows enabling the feature by writing "1" to the sysfs file, matching
the interface we previously maintained in our local kernel.

The result is as follows,

- For 802.3ad mode

  $ ip link add bond0 type bond mode 802.3ad
  $ cat /sys/class/net/bond0/bonding/broadcast_neighbor
  0
  $ echo 1 > /sys/class/net/bond0/bonding/broadcast_neighbor
  $ cat /sys/class/net/bond0/bonding/broadcast_neighbor
  1

- For other modes

  $ ip link add bond1 type bond
  $ cat /sys/class/net/bond1/bonding/broadcast_neighbor
  0
  $ echo 1 > /sys/class/net/bond1/bonding/broadcast_neighbor
  bash: echo: write error: Permission denied

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Cc: Tonghao Zhang <tonghao@bamaicloud.com>
---
 drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index eaba44c76a5e..24eb23634d98 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -750,6 +750,17 @@ static ssize_t bonding_show_ad_user_port_key(struct device *d,
 static DEVICE_ATTR(ad_user_port_key, 0644,
 		   bonding_show_ad_user_port_key, bonding_sysfs_store_option);
 
+static ssize_t bonding_show_broadcast_neighbor(struct device *d,
+					       struct device_attribute *attr,
+					       char *buf)
+{
+	struct bonding *bond = to_bond(d);
+
+	return sysfs_emit(buf, "%d\n", bond->params.broadcast_neighbor);
+}
+static DEVICE_ATTR(broadcast_neighbor, 0644,
+		   bonding_show_broadcast_neighbor, bonding_sysfs_store_option);
+
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
 	&dev_attr_mode.attr,
@@ -789,6 +800,7 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_ad_actor_system.attr,
 	&dev_attr_ad_user_port_key.attr,
 	&dev_attr_arp_missed_max.attr,
+	&dev_attr_broadcast_neighbor.attr,
 	NULL,
 };
 
-- 
2.52.0


             reply	other threads:[~2026-06-10 12:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10 12:08 Yafang Shao [this message]
2026-06-10 12:30 ` [PATCH net-next] bonding: add sysfs interface for broadcast_neighbor Nikolay Aleksandrov
2026-06-10 12:39   ` Yafang Shao
2026-06-10 12:45     ` Nikolay Aleksandrov
2026-06-10 12:49       ` Yafang Shao
2026-06-10 13:00         ` Nikolay Aleksandrov
2026-06-10 13:09           ` Yafang Shao
2026-06-10 12:52       ` Nikolay Aleksandrov
2026-06-10 12:56         ` Yafang Shao
2026-06-11 20:42   ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260610120812.49054-1-laoar.shao@gmail.com \
    --to=laoar.shao@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jv@jvosburgh.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tonghao@bamaicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox