net: sched: Add sysfs_notify for /sys/class/net/*/carrier
diff mbox series

Message ID 20200213052111.19595-1-nobuta.keiya@fujitsu.com
State Changes Requested
Delegated to: David Miller
Headers show
Series
  • net: sched: Add sysfs_notify for /sys/class/net/*/carrier
Related show

Commit Message

Keiya Nobuta Feb. 13, 2020, 5:21 a.m. UTC
This patch makes /sys/class/<iface>/carrier pollable and allows
application to monitor current physical link state changes.

Signed-off-by: Keiya Nobuta <nobuta.keiya@fujitsu.com>
---
 net/sched/sch_generic.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jiri Pirko Feb. 13, 2020, 8:40 a.m. UTC | #1
Thu, Feb 13, 2020 at 06:21:11AM CET, nobuta.keiya@fujitsu.com wrote:
>This patch makes /sys/class/<iface>/carrier pollable and allows
>application to monitor current physical link state changes.
>
>Signed-off-by: Keiya Nobuta <nobuta.keiya@fujitsu.com>
>---
> net/sched/sch_generic.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
>index 6c9595f..67e4190 100644
>--- a/net/sched/sch_generic.c
>+++ b/net/sched/sch_generic.c
>@@ -493,6 +493,7 @@ void netif_carrier_on(struct net_device *dev)
> 		linkwatch_fire_event(dev);
> 		if (netif_running(dev))
> 			__netdev_watchdog_up(dev);
>+		sysfs_notify(&dev->dev.kobj, NULL, "carrier");

This would be the only use of sysfs notify in net. I wonder, what makes
the carrier different comparing to other attributes that might change
during runtime?

Also, in net, we have RTNETLINK that app can listen to and react.
Carrier change is propagated through that as well.


> 	}
> }
> EXPORT_SYMBOL(netif_carrier_on);
>@@ -510,6 +511,7 @@ void netif_carrier_off(struct net_device *dev)
> 			return;
> 		atomic_inc(&dev->carrier_down_count);
> 		linkwatch_fire_event(dev);
>+		sysfs_notify(&dev->dev.kobj, NULL, "carrier");
> 	}
> }
> EXPORT_SYMBOL(netif_carrier_off);
>-- 
>2.7.4
>

Patch
diff mbox series

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 6c9595f..67e4190 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -493,6 +493,7 @@  void netif_carrier_on(struct net_device *dev)
 		linkwatch_fire_event(dev);
 		if (netif_running(dev))
 			__netdev_watchdog_up(dev);
+		sysfs_notify(&dev->dev.kobj, NULL, "carrier");
 	}
 }
 EXPORT_SYMBOL(netif_carrier_on);
@@ -510,6 +511,7 @@  void netif_carrier_off(struct net_device *dev)
 			return;
 		atomic_inc(&dev->carrier_down_count);
 		linkwatch_fire_event(dev);
+		sysfs_notify(&dev->dev.kobj, NULL, "carrier");
 	}
 }
 EXPORT_SYMBOL(netif_carrier_off);