Skip to contentSkip to conversation

bonding: add sysfs interface for broadcast_neighbor

PATCH In review Yafang Shao 3 participants 10 messages Jun 10 – Jun 11

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: add sysfs interface for broadcast_neighbor

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
---
 drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +12 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,
 };
 
Signature · 1 line
2.52.0
#1 lore raw
Quoted 62 lines · Yafang Shao

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
---
  drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +11 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 7 lines
drivers/net/bonding/bond_sysfs.c +1 -0
@@ -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,
  };
 

Then update your iproute2 package, sysfs use for options is discouraged and is not being extended on purpose. Move to netlink.

Cheers,
Nik

#2 lore raw
Quoted 65 lines · Nikolay Aleksandrov
Quoted 63 lines · Yafang Shao

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
---
  drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +11 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,
Quoted 8 lines

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 6 lines
drivers/net/bonding/bond_sysfs.c +1 -0
      &dev_attr_ad_user_port_key.attr,
      &dev_attr_arp_missed_max.attr,
+     &dev_attr_broadcast_neighbor.attr,
      NULL,
  };
 

Then update your iproute2 package, sysfs use for options is discouraged

Could you please explain in detail why this is discouraged?

Quoted 1 line

and is not being extended on purpose. Move to netlink.

Signature · 2 lines
Regards
Yafang
#3 lore raw
Quoted 75 lines · Yafang Shao
Quoted 65 lines · Nikolay Aleksandrov
Quoted 63 lines · Yafang Shao

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
---
   drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
   1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +11 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,
Quoted 8 lines

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 6 lines
drivers/net/bonding/bond_sysfs.c +1 -0
       &dev_attr_ad_user_port_key.attr,
       &dev_attr_arp_missed_max.attr,
+     &dev_attr_broadcast_neighbor.attr,
       NULL,
   };
 

Then update your iproute2 package, sysfs use for options is discouraged

Quoted 4 lines

Could you please explain in detail why this is discouraged?

Quoted 1 line

and is not being extended on purpose. Move to netlink.

Networking has been moving to netlink-only options for awhile now. Check for example:
1e16f382ae0b ("net: bridge: add warning comments to avoid extending sysfs")

The preferred way to configure device types is via iproute2/netlink.

#4 lore raw
Quoted 79 lines · Nikolay Aleksandrov
Quoted 77 lines · Yafang Shao
Quoted 65 lines · Nikolay Aleksandrov
Quoted 63 lines · Yafang Shao

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
---
   drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
   1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +11 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,
Quoted 8 lines

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 6 lines
drivers/net/bonding/bond_sysfs.c +1 -0
       &dev_attr_ad_user_port_key.attr,
       &dev_attr_arp_missed_max.attr,
+     &dev_attr_broadcast_neighbor.attr,
       NULL,
   };
 

Then update your iproute2 package, sysfs use for options is discouraged

Could you please explain in detail why this is discouraged?

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

and is not being extended on purpose. Move to netlink.

Networking has been moving to netlink-only options for awhile now. Check for example:
1e16f382ae0b ("net: bridge: add warning comments to avoid extending sysfs")

The preferred way to configure device types is via iproute2/netlink.

Thanks for your explanation, but I still don't understand the benefit of it. Could you elaborate further?

Signature · 2 lines
Regards
Yafang
#5 lore raw
Quoted 83 lines · Yafang Shao
Quoted 82 lines · Nikolay Aleksandrov
Quoted 79 lines · Yafang Shao
Quoted 65 lines · Nikolay Aleksandrov
Quoted 63 lines · Yafang Shao

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
---
    drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
    1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +11 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,
Quoted 8 lines

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 6 lines
drivers/net/bonding/bond_sysfs.c +1 -0
        &dev_attr_ad_user_port_key.attr,
        &dev_attr_arp_missed_max.attr,
+     &dev_attr_broadcast_neighbor.attr,
        NULL,
    };
 

Then update your iproute2 package, sysfs use for options is discouraged

Could you please explain in detail why this is discouraged?

Quoted 1 line

and is not being extended on purpose. Move to netlink.

Quoted 9 lines
Quoted 5 lines

Networking has been moving to netlink-only options for awhile now. Check for example:
1e16f382ae0b ("net: bridge: add warning comments to avoid extending sysfs")

The preferred way to configure device types is via iproute2/netlink.

Thanks for your explanation, but I still don't understand the benefit of it. Could you elaborate further?

The benefits of netlink over sysfs?? There are so many.. it will help if you
look into how netlink vs sysfs operate. Netlink is structured, transactional,
typed, easily extendable, you can dump, do specific queries, it is less calls and it supports notifications. I'm sure I'm missing, but in a nutshell it's preferred. :)

#6 lore raw
Quoted 95 lines · Nikolay Aleksandrov
Quoted 83 lines · Yafang Shao
Quoted 82 lines · Nikolay Aleksandrov
Quoted 79 lines · Yafang Shao
Quoted 65 lines · Nikolay Aleksandrov
Quoted 63 lines · Yafang Shao

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
---
    drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
    1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +11 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,
Quoted 8 lines

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 6 lines
drivers/net/bonding/bond_sysfs.c +1 -0
        &dev_attr_ad_user_port_key.attr,
        &dev_attr_arp_missed_max.attr,
+     &dev_attr_broadcast_neighbor.attr,
        NULL,
    };
 

Then update your iproute2 package, sysfs use for options is discouraged

Could you please explain in detail why this is discouraged?

Quoted 1 line

and is not being extended on purpose. Move to netlink.

Quoted 9 lines
Quoted 5 lines

Networking has been moving to netlink-only options for awhile now. Check for example:
1e16f382ae0b ("net: bridge: add warning comments to avoid extending sysfs")

The preferred way to configure device types is via iproute2/netlink.

Thanks for your explanation, but I still don't understand the benefit of it. Could you elaborate further?

Quoted 5 lines

The benefits of netlink over sysfs?? There are so many.. it will help if you look into how netlink vs sysfs operate. Netlink is structured, transactional, typed, easily extendable, you can dump, do specific queries, it is less calls and it supports notifications. I'm sure I'm missing, but in a nutshell it's preferred. :)

Thank you for the explanation. Requesting package upgrades on production servers is often challenging, particularly when additional library updates are required. Consequently, sysadmins prefer utilizing native shell commands, such as echo, to avoid these dependencies;-)

Honestly, if a feature needs userspace tools to be upgraded, it will take years to see it in production... ;-)

Signature · 2 lines
Regards
Yafang
#7 lore raw
In reply to Nikolay Aleksandrov
Quoted 79 lines · Nikolay Aleksandrov
Quoted 78 lines · Yafang Shao
Quoted 66 lines · Nikolay Aleksandrov
Quoted 64 lines · Yafang Shao

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

---
   drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++

   1 file changed, 12 insertions(+)
drivers/net/bonding/bond_sysfs.c +11 -0
index eaba44c76a5e..24eb23634d98 100644
@@ -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,

drivers/net/bonding/bond_sysfs.c +0 -0
@@ -789,6 +800,7 @@ static struct attribute *per_bond_attrs[] = {
        &dev_attr_ad_actor_system.attr,
Quoted 8 lines

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 6 lines
drivers/net/bonding/bond_sysfs.c +1 -0
        &dev_attr_ad_user_port_key.attr,
        &dev_attr_arp_missed_max.attr,
+     &dev_attr_broadcast_neighbor.attr,
        NULL,
    };
 

Then update your iproute2 package, sysfs use for options is discouraged

Could you please explain in detail why this is discouraged?

Quoted 9 lines
Quoted 2 lines
Quoted 1 line

and is not being extended on purpose. Move to netlink.

Networking has been moving to netlink-only options for awhile now. Check for example:
1e16f382ae0b ("net: bridge: add warning comments to avoid extending sysfs")

The preferred way to configure device types is via iproute2/netlink.

The author of this option also had sysfs initially in his patch-set and then removed it, here's my comment at that time:
https://lore.kernel.org/all/[email protected]/

and also Jay's confirmation that sysfs shouldn't be extended:
https://lore.kernel.org/all/1319073.1747143053@vermin/

Cheers,
Nik

#8 lore raw
Quoted 94 lines · Nikolay Aleksandrov
Quoted 81 lines · Nikolay Aleksandrov
Quoted 80 lines · Yafang Shao
Quoted 68 lines · Nikolay Aleksandrov
Quoted 66 lines · Yafang Shao

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
---
   drivers/net/bonding/bond_sysfs.c | 12 ++++++++++++
   1 file changed, 12 insertions(+)
drivers/net/bonding/ renamed from drivers/net/bonding/bond_sysfs.c +0 -0

bond_sysfs.c
index eaba44c76a5e..24eb23634d98 100644

drivers/net/bonding/bond_sysfs.c +11 -0
@@ -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,

drivers/net/bonding/bond_sysfs.c +0 -0
@@ -789,6 +800,7 @@ static struct attribute *per_bond_attrs[] = {
       &dev_attr_ad_actor_system.attr,
Quoted 8 lines

drivers/net/bonding/bond_sysfs.c static struct attribute *per_bond_attrs[] = { · line 806

Quoted 6 lines
drivers/net/bonding/bond_sysfs.c +1 -0
       &dev_attr_ad_user_port_key.attr,
       &dev_attr_arp_missed_max.attr,
+     &dev_attr_broadcast_neighbor.attr,
       NULL,
   };
 

Then update your iproute2 package, sysfs use for options is discouraged

Could you please explain in detail why this is discouraged?

Quoted 10 lines
Quoted 2 lines
Quoted 1 line

and is not being extended on purpose. Move to netlink.

Networking has been moving to netlink-only options for awhile now. Check for example:
1e16f382ae0b ("net: bridge: add warning comments to avoid extending sysfs")

The preferred way to configure device types is via iproute2/netlink.

Quoted 6 lines

The author of this option also had sysfs initially in his patch-set and then removed it, here's my comment at that time:
https://lore.kernel.org/all/[email protected]/

and also Jay's confirmation that sysfs shouldn't be extended:
https://lore.kernel.org/all/1319073.1747143053@vermin/

Understood. So we'll have to keep this patch in our local kernel. The production environment is complex enough as it is... ;-)

Signature · 2 lines
Regards
Yafang
maintainer
#9 lore raw
In reply to Nikolay Aleksandrov
Quoted 2 lines · On Wed, 10 Jun 2026 15:30:11 +0300 Nikolay Aleksandrov wrote:

Then update your iproute2 package, sysfs use for options is discouraged and is not being extended on purpose. Move to netlink.

FWIW -- ynl also supports rtnl and bonding options, so even less of a reason for sysfs these days.