Skip to contentSkip to conversation

rtnetlink: Updates to rtnetlink_event()

PATCH Superseded Vladislav Yasevich 5 participants 14 messages Apr 21, 2017 – May 2, 2017

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#1 lore raw

PATCH v3 1/2 rtnetlink: Disable notification for NETDEV_NAMECHANGE event

In reply to Vladislav Yasevich

The data signaling name change is already provided at the end of do_setlink(). This event handler just generates a duplicate announcement. Disable it.

---
 net/core/rtnetlink.c | 1 -
 1 file changed, 1 deletion(-)
net/core/rtnetlink.c +0 -1
index 0ee5479..e8e6816 100644
@@ -4123,7 +4123,6 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
 
 	switch (event) {
 	case NETDEV_REBOOT:
-	case NETDEV_CHANGENAME:
 	case NETDEV_FEAT_CHANGE:
 	case NETDEV_BONDING_FAILOVER:
 	case NETDEV_NOTIFY_PEERS:
Signature · 1 line
2.7.4
#0 lore raw

v3 cover rtnetlink: Updates to rtnetlink_event()

This is a version 3 series came out of the conversation that started as a result my first attempt to add netdevice event info to netlink messages.

First, let's clean-up the duplicate notifications for NETDEV_CHANGNAME event. We get a message from the event handler as well as a result of do_setlink(). The two messages are identical, so remove the event.

Second, update the original patch to add IFLA_EVENT attribute to the link message to only support currently white-listed events. Like before, this is just an attribute that gets added to the rtnetlink message only when the messaged was generated as a result of a netdev event. In my case, this is necessary since I want to trap NETDEV_NOTIFY_PEERS event (also possibly NETDEV_RESEND_IGMP event) and perform certain actions in user space. This is not possible since the messages generated as a result of netdev events do not usually contain any changed data. They are just notifications. This patch exposes this notification type to userspace.

I will also update my patch to iproute that will show this data through 'ip monitor'.

V3: Rebased. Cleaned-up duplicate event.

V2: Added missed events (from David Ahern)

Vladislav Yasevich (2):
rtnetlink: Convert rtnetlink_event to white list
rtnl: Add support for netdev event to link messages

 include/linux/rtnetlink.h    |   3 +-
 include/uapi/linux/if_link.h |  21 ++++++++
 net/core/dev.c               |   2 +-
 net/core/rtnetlink.c         | 121 +++++++++++++++++++++++++++++++++++--------
 4 files changed, 123 insertions(+), 24 deletions(-)
Signature · 15 lines
2.7.4


Vladislav Yasevich (2):
  rtnetlink: Disable notification for NETDEV_NAMECHANGE event
  rtnl: Add support for netdev event to link messages

 include/linux/rtnetlink.h    |  3 ++-
 include/uapi/linux/if_link.h | 11 ++++++++
 net/core/dev.c               |  2 +-
 net/core/rtnetlink.c         | 63 +++++++++++++++++++++++++++++++++++++-------
 4 files changed, 67 insertions(+), 12 deletions(-)

-- 
2.7.4
#2 lore raw

Re: [PATCH net-next 1/2] rtnetlink: Disable notification for NETDEV_NAMECHANGE event

In reply to Vladislav Yasevich
Quoted 16 lines · Vladislav Yasevich

The data signaling name change is already provided at the end of do_setlink(). This event handler just generates a duplicate announcement. Disable it.

---
 net/core/rtnetlink.c | 1 -
 1 file changed, 1 deletion(-)
net/core/rtnetlink.c +0 -0
index 0ee5479..e8e6816 100644

net/core/rtnetlink.c static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi · line 4128

Quoted 7 lines
net/core/rtnetlink.c +0 -1
@@ -4123,7 +4123,6 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
 
 	switch (event) {
 	case NETDEV_REBOOT:
-	case NETDEV_CHANGENAME:
 	case NETDEV_FEAT_CHANGE:
 	case NETDEV_BONDING_FAILOVER:
 	case NETDEV_NOTIFY_PEERS:

I only see one using the ip monitor.

$ ip li set foobar name fubar

generates these 3 messages:

[LINK]12: fubar: <BROADCAST,NOARP> mtu 1500 qdisc noqueue state DOWN group default

    link/ether 76:cd:72:dd:2a:cb brd ff:ff:ff:ff:ff:ff

Unknown message: type=0x00000051(81) flags=0x00000000(0)len=0x0000001c(28) [NETCONF]ipv4 dev dummy2 forwarding on rp_filter off mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off
Unknown message: type=0x00000051(81) flags=0x00000000(0)len=0x0000001c(28) [NETCONF]ipv6 dev dummy2 forwarding on mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off

do_setlink only sets DO_SETLINK_MODIFIED so a name change alone will not generate 2 messages.

#4 lore raw

PATCH v3 2/2 rtnl: Add support for netdev event attribute to link messages

In reply to Vladislav Yasevich

When netdev events happen, a rtnetlink_event() handler will send messages for every event in it's white list. These messages contain current information about a particular device, but they do not include the iformation about which event just happened. So, it is impossible to tell what just happend for these events.

This patch adds a new extension to RTM_NEWLINK message called IFLA_EVENT that would have an encoding of event that triggered this message. This would allow the the message consumer to easily determine if it needs to perform certain actions.

---
 include/linux/rtnetlink.h    |  3 ++-
 include/uapi/linux/if_link.h | 11 ++++++++
 net/core/dev.c               |  2 +-
 net/core/rtnetlink.c         | 62 +++++++++++++++++++++++++++++++++++++-------
 4 files changed, 67 insertions(+), 11 deletions(-)
include/linux/rtnetlink.h +2 -1
index 57e5484..0459018 100644
@@ -18,7 +18,8 @@ extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
 
 void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change, gfp_t flags);
 struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
-				       unsigned change, gfp_t flags);
+				       unsigned change, unsigned long event,
+				       gfp_t flags);
 void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev,
 		       gfp_t flags);
 
include/uapi/linux/if_link.h +11 -0
index 8b405af..aceb766 100644
@@ -157,6 +157,7 @@ enum {
 	IFLA_GSO_MAX_SIZE,
 	IFLA_PAD,
 	IFLA_XDP,
+	IFLA_EVENT,
 	__IFLA_MAX
 };
 
@@ -899,4 +900,14 @@ enum {
 
 #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1)
 
+enum {
+	IFLA_EVENT_UNSPEC,
+	IFLA_EVENT_REBOOT,
+	IFLA_EVENT_FEAT_CHANGE,
+	IFLA_EVENT_BONDING_FAILOVER,
+	IFLA_EVENT_NOTIFY_PEERS,
+	IFLA_EVENT_RESEND_IGMP,
+	IFLA_EVENT_CHANGE_INFO_DATA,
+};
+
 #endif /* _UAPI_LINUX_IF_LINK_H */
net/core/dev.c +1 -1
index ef9fe60e..7efb417 100644
@@ -6840,7 +6840,7 @@ static void rollback_registered_many(struct list_head *head)
 
 		if (!dev->rtnl_link_ops ||
 		    dev->rtnl_link_state == RTNL_LINK_INITIALIZED)
-			skb = rtmsg_ifinfo_build_skb(RTM_DELLINK, dev, ~0U,
+			skb = rtmsg_ifinfo_build_skb(RTM_DELLINK, dev, ~0U, 0,
 						     GFP_KERNEL);
 
 		/*
net/core/rtnetlink.c +53 -9

133 lines not on this page · raw message

Signature · 1 line
2.7.4
#5 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

Quoted 24 lines · Vladislav Yasevich
net/core/rtnetlink.c +20 -0
@@ -1276,9 +1277,40 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
 	return err;
 }
 
+static int rtnl_fill_link_event(struct sk_buff *skb, unsigned long event)
+{
+	u32 rtnl_event;
+
+	switch (event) {
+	case NETDEV_REBOOT:
+		rtnl_event = IFLA_EVENT_REBOOT;
+		break;
+	case NETDEV_FEAT_CHANGE:
+		rtnl_event = IFLA_EVENT_FEAT_CHANGE;
+		break;
+	case NETDEV_BONDING_FAILOVER:
+		rtnl_event = IFLA_EVENT_BONDING_FAILOVER;
+		break;
+	case NETDEV_NOTIFY_PEERS:
+		rtnl_event = IFLA_EVENT_NOTIFY_PEERS;
+		break;
+	case NETDEV_RESEND_IGMP:
+		rtnl_event = IFLA_EVENT_RESEND_IGMP;
+		break;

net/core/rtnetlink.c static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) · line 1309

Quoted 10 lines
net/core/rtnetlink.c +10 -0
+	case NETDEV_CHANGEINFODATA:
+		rtnl_event = IFLA_EVENT_CHANGE_INFO_DATA;
+		break;
+	default:
+		return 0;
+	}
+
+	return nla_put_u32(skb, IFLA_EVENT, rtnl_event);
+}
+

I still have doubts about encoding kernel events into a uapi.

For example, NETDEV_CHANGEINFODATA is only for bonds though nothing about the name suggests it is a bonding notification. This one was added specifically to notify userspace (d4261e5650004), yet seems to happen only during a changelink and that already generates a RTM_NEWLINK message via do_setlink. Since the rtnetlink_event message does not contain anything "NETDEV_CHANGEINFODATA" related what purpose does it really serve besides duplicating netlink messages to userspace.

The REBOOT, IGMP, FEAT_CHANGE and BONDING_FAILOVER seem to be unique messages (code analysis only) which I get for notifying userspace.

NETDEV_NOTIFY_PEERS is not so clear in how often it duplicates other messages.

#6 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

Quoted 30 lines · David Ahern
Quoted 28 lines · Vladislav Yasevich
net/core/rtnetlink.c +24 -0
@@ -1276,9 +1277,40 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
      return err;
 }
 
+static int rtnl_fill_link_event(struct sk_buff *skb, unsigned long event)
+{
+     u32 rtnl_event;
+
+     switch (event) {
+     case NETDEV_REBOOT:
+             rtnl_event = IFLA_EVENT_REBOOT;
+             break;
+     case NETDEV_FEAT_CHANGE:
+             rtnl_event = IFLA_EVENT_FEAT_CHANGE;
+             break;
+     case NETDEV_BONDING_FAILOVER:
+             rtnl_event = IFLA_EVENT_BONDING_FAILOVER;
+             break;
+     case NETDEV_NOTIFY_PEERS:
+             rtnl_event = IFLA_EVENT_NOTIFY_PEERS;
+             break;
+     case NETDEV_RESEND_IGMP:
+             rtnl_event = IFLA_EVENT_RESEND_IGMP;
+             break;
+     case NETDEV_CHANGEINFODATA:
+             rtnl_event = IFLA_EVENT_CHANGE_INFO_DATA;
+             break;
+     default:
Quoted 8 lines

net/core/rtnetlink.c static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) · line 1309

Quoted 6 lines
net/core/rtnetlink.c +6 -0
+             return 0;
+     }
+
+     return nla_put_u32(skb, IFLA_EVENT, rtnl_event);
+}
+

I still have doubts about encoding kernel events into a uapi.

agree. I don't see why user-space will need NETDEV_CHANGEINFODATA and others david listed.

My other concerns are, once we have this exposed to user-space and user-space starts relying on it, it will need accurate information and will expect to have this event information all the time. IIUC, we cannot cover multiple events in a single notification and not all link notifications will contain an IFLA_EVENT attribute. In other words, we will be telling user-space to not expect that the kernel will send IFLA_EVENT every time.

Quoted 14 lines

For example, NETDEV_CHANGEINFODATA is only for bonds though nothing about the name suggests it is a bonding notification. This one was added specifically to notify userspace (d4261e5650004), yet seems to happen only during a changelink and that already generates a RTM_NEWLINK message via do_setlink. Since the rtnetlink_event message does not contain anything "NETDEV_CHANGEINFODATA" related what purpose does it really serve besides duplicating netlink messages to userspace.

The REBOOT, IGMP, FEAT_CHANGE and BONDING_FAILOVER seem to be unique messages (code analysis only) which I get for notifying userspace.

NETDEV_NOTIFY_PEERS is not so clear in how often it duplicates other messages.

#3 lore raw

Re: [PATCH net-next 1/2] rtnetlink: Disable notification for NETDEV_NAMECHANGE event

In reply to David Ahern
Quoted 42 lines · David Ahern
Quoted 16 lines · Vladislav Yasevich

The data signaling name change is already provided at the end of do_setlink(). This event handler just generates a duplicate announcement. Disable it.

---
 net/core/rtnetlink.c | 1 -
 1 file changed, 1 deletion(-)
net/core/rtnetlink.c +0 -0
index 0ee5479..e8e6816 100644

net/core/rtnetlink.c static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi · line 4128

Quoted 7 lines
net/core/rtnetlink.c +0 -1
@@ -4123,7 +4123,6 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
 
 	switch (event) {
 	case NETDEV_REBOOT:
-	case NETDEV_CHANGENAME:
 	case NETDEV_FEAT_CHANGE:
 	case NETDEV_BONDING_FAILOVER:
 	case NETDEV_NOTIFY_PEERS:

I only see one using the ip monitor.

$ ip li set foobar name fubar

generates these 3 messages:

[LINK]12: fubar: <BROADCAST,NOARP> mtu 1500 qdisc noqueue state DOWN group default

    link/ether 76:cd:72:dd:2a:cb brd ff:ff:ff:ff:ff:ff

Unknown message: type=0x00000051(81) flags=0x00000000(0)len=0x0000001c(28) [NETCONF]ipv4 dev dummy2 forwarding on rp_filter off mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off
Unknown message: type=0x00000051(81) flags=0x00000000(0)len=0x0000001c(28) [NETCONF]ipv6 dev dummy2 forwarding on mc_forwarding off proxy_neigh off ignore_routes_with_linkdown off

Quoted 3 lines

do_setlink only sets DO_SETLINK_MODIFIED so a name change alone will not generate 2 messages.

Actually, it has nothing to do with above flag. Setting DO_SETLINK_MODIFIED will still generate notifications, but only if the device is UP. However, it looks like link name change can only be done when the link is down. As a result, netdev_state_change will not report it, so we only see the 'event' one.

So this is patch isn't needed, but only as a kind-of side-effect..

-vlad

#9 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

In reply to David Ahern
Quoted 38 lines · David Ahern
Quoted 24 lines · Vladislav Yasevich
net/core/rtnetlink.c +20 -0
@@ -1276,9 +1277,40 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
 	return err;
 }
 
+static int rtnl_fill_link_event(struct sk_buff *skb, unsigned long event)
+{
+	u32 rtnl_event;
+
+	switch (event) {
+	case NETDEV_REBOOT:
+		rtnl_event = IFLA_EVENT_REBOOT;
+		break;
+	case NETDEV_FEAT_CHANGE:
+		rtnl_event = IFLA_EVENT_FEAT_CHANGE;
+		break;
+	case NETDEV_BONDING_FAILOVER:
+		rtnl_event = IFLA_EVENT_BONDING_FAILOVER;
+		break;
+	case NETDEV_NOTIFY_PEERS:
+		rtnl_event = IFLA_EVENT_NOTIFY_PEERS;
+		break;
+	case NETDEV_RESEND_IGMP:
+		rtnl_event = IFLA_EVENT_RESEND_IGMP;
+		break;

net/core/rtnetlink.c static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) · line 1309

Quoted 10 lines
net/core/rtnetlink.c +10 -0
+	case NETDEV_CHANGEINFODATA:
+		rtnl_event = IFLA_EVENT_CHANGE_INFO_DATA;
+		break;
+	default:
+		return 0;
+	}
+
+	return nla_put_u32(skb, IFLA_EVENT, rtnl_event);
+}
+

I still have doubts about encoding kernel events into a uapi.

Quoted 8 lines

For example, NETDEV_CHANGEINFODATA is only for bonds though nothing about the name suggests it is a bonding notification. This one was added specifically to notify userspace (d4261e5650004), yet seems to happen only during a changelink and that already generates a RTM_NEWLINK message via do_setlink. Since the rtnetlink_event message does not contain anything "NETDEV_CHANGEINFODATA" related what purpose does it really serve besides duplicating netlink messages to userspace.

I am not sure about this one, but if you have an app trying to monitor for this event, it can't really since there is no info in the netlink message.

Quoted 6 lines

The REBOOT, IGMP, FEAT_CHANGE and BONDING_FAILOVER seem to be unique messages (code analysis only) which I get for notifying userspace.

NETDEV_NOTIFY_PEERS is not so clear in how often it duplicates other messages.

This one sometimes happens in addition to bonding failover, but not always (it depends on bonding mode).
For me, having access to this particular event is important as it will used to trigger a guest announcements.

-vlad

#7 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

In reply to Roopa Prabhu
Quoted 40 lines · Roopa Prabhu
Quoted 30 lines · David Ahern
Quoted 28 lines · Vladislav Yasevich
net/core/rtnetlink.c +24 -0
@@ -1276,9 +1277,40 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
      return err;
 }
 
+static int rtnl_fill_link_event(struct sk_buff *skb, unsigned long event)
+{
+     u32 rtnl_event;
+
+     switch (event) {
+     case NETDEV_REBOOT:
+             rtnl_event = IFLA_EVENT_REBOOT;
+             break;
+     case NETDEV_FEAT_CHANGE:
+             rtnl_event = IFLA_EVENT_FEAT_CHANGE;
+             break;
+     case NETDEV_BONDING_FAILOVER:
+             rtnl_event = IFLA_EVENT_BONDING_FAILOVER;
+             break;
+     case NETDEV_NOTIFY_PEERS:
+             rtnl_event = IFLA_EVENT_NOTIFY_PEERS;
+             break;
+     case NETDEV_RESEND_IGMP:
+             rtnl_event = IFLA_EVENT_RESEND_IGMP;
+             break;
+     case NETDEV_CHANGEINFODATA:
+             rtnl_event = IFLA_EVENT_CHANGE_INFO_DATA;
+             break;
+     default:
Quoted 8 lines

net/core/rtnetlink.c static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) · line 1309

Quoted 6 lines
net/core/rtnetlink.c +6 -0
+             return 0;
+     }
+
+     return nla_put_u32(skb, IFLA_EVENT, rtnl_event);
+}
+

I still have doubts about encoding kernel events into a uapi.

Quoted 3 lines

agree. I don't see why user-space will need NETDEV_CHANGEINFODATA and others david listed.

Well, I am not sure about CHANGEINFODATA as well, but I can see use cases for others.

Quoted 5 lines

My other concerns are, once we have this exposed to user-space and user-space starts relying on it, it will need accurate information and will expect to have this event information all the time. IIUC, we cannot cover multiple events in a single notification and not all link notifications will contain an IFLA_EVENT attribute.

Uhm... If the rtnetlink message was a result of an event, it will have an IFLA_EVENT. If a message is something else, then it will not have an event. That's the point. Not all netlink attributes are in every netlink message.

Quoted 4 lines

In other
words, we will be telling user-space to not expect that the kernel will send IFLA_EVENT every time.

No, we are telling the user that if it is interested in a specific event (let's say NOTIFY_PEERS or RESEND_IGMP), then it now can monitor netlink traffic for those events.
As things stand right now, that's not possible.

I've done this specifically for all events for which we currently generate a netlink message.

The only concern I have is that if in the future we remove a certain netdev event, it may impact applications. But we may be doing it right now as well, only silently, and the apps may have to find some ways to work around it.

There is also a potential to improve libnl caching and not invalidate the cached data for certain events.

-vlad

Quoted 16 lines
Quoted 16 lines

For example, NETDEV_CHANGEINFODATA is only for bonds though nothing about the name suggests it is a bonding notification. This one was added specifically to notify userspace (d4261e5650004), yet seems to happen only during a changelink and that already generates a RTM_NEWLINK message via do_setlink. Since the rtnetlink_event message does not contain anything "NETDEV_CHANGEINFODATA" related what purpose does it really serve besides duplicating netlink messages to userspace.

The REBOOT, IGMP, FEAT_CHANGE and BONDING_FAILOVER seem to be unique messages (code analysis only) which I get for notifying userspace.

NETDEV_NOTIFY_PEERS is not so clear in how often it duplicates other messages.

#10 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

In reply to Vlad Yasevich
Quoted 11 lines · Vlad Yasevich
Quoted 8 lines

For example, NETDEV_CHANGEINFODATA is only for bonds though nothing about the name suggests it is a bonding notification. This one was added specifically to notify userspace (d4261e5650004), yet seems to happen only during a changelink and that already generates a RTM_NEWLINK message via do_setlink. Since the rtnetlink_event message does not contain anything "NETDEV_CHANGEINFODATA" related what purpose does it really serve besides duplicating netlink messages to userspace.

I am not sure about this one, but if you have an app trying to monitor for this event, it can't really since there is no info in the netlink message.

I cc'ed Jiri on this thread hoping he would explain the intent.

I propose it gets removed.

#8 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

In reply to Vlad Yasevich
Quoted 69 lines · Vlad Yasevich
Quoted 40 lines · Roopa Prabhu
Quoted 30 lines · David Ahern
Quoted 28 lines · Vladislav Yasevich
net/core/rtnetlink.c +24 -0
@@ -1276,9 +1277,40 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev)
      return err;
 }
 
+static int rtnl_fill_link_event(struct sk_buff *skb, unsigned long event)
+{
+     u32 rtnl_event;
+
+     switch (event) {
+     case NETDEV_REBOOT:
+             rtnl_event = IFLA_EVENT_REBOOT;
+             break;
+     case NETDEV_FEAT_CHANGE:
+             rtnl_event = IFLA_EVENT_FEAT_CHANGE;
+             break;
+     case NETDEV_BONDING_FAILOVER:
+             rtnl_event = IFLA_EVENT_BONDING_FAILOVER;
+             break;
+     case NETDEV_NOTIFY_PEERS:
+             rtnl_event = IFLA_EVENT_NOTIFY_PEERS;
+             break;
+     case NETDEV_RESEND_IGMP:
+             rtnl_event = IFLA_EVENT_RESEND_IGMP;
+             break;
+     case NETDEV_CHANGEINFODATA:
+             rtnl_event = IFLA_EVENT_CHANGE_INFO_DATA;
+             break;
+     default:
Quoted 8 lines

net/core/rtnetlink.c static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) · line 1309

Quoted 6 lines
net/core/rtnetlink.c +6 -0
+             return 0;
+     }
+
+     return nla_put_u32(skb, IFLA_EVENT, rtnl_event);
+}
+

I still have doubts about encoding kernel events into a uapi.

Quoted 3 lines

agree. I don't see why user-space will need NETDEV_CHANGEINFODATA and others david listed.

Well, I am not sure about CHANGEINFODATA as well, but I can see use cases for others.

Quoted 5 lines

My other concerns are, once we have this exposed to user-space and user-space starts relying on it, it will need accurate information and will expect to have this event information all the time. IIUC, we cannot cover multiple events in a single notification and not all link notifications will contain an IFLA_EVENT attribute.

Uhm... If the rtnetlink message was a result of an event, it will have an IFLA_EVENT. If a message is something else, then it will not have an event. That's the point. Not all netlink attributes are in every netlink message.

Quoted 4 lines

In other
words, we will be telling user-space to not expect that the kernel will send IFLA_EVENT every time.

No, we are telling the user that if it is interested in a specific event (let's say NOTIFY_PEERS or RESEND_IGMP), then it now can monitor netlink traffic for those events.
As things stand right now, that's not possible.

Quoted 7 lines

I've done this specifically for all events for which we currently generate a netlink message.

The only concern I have is that if in the future we remove a certain netdev event, it may impact applications. But we may be doing it right now as well, only silently, and the apps may have to find some ways to work around it.

ok, fair enough. it might be ok then....except for the specific attributes that user-space may not be interested like CHANGEINFODATA.

#11 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

In reply to David Ahern
Quoted 10 lines · Thu, Apr 27, 2017 at 09:59:38PM CEST, [email protected] wrote:
Quoted 9 lines · Vlad Yasevich
Quoted 8 lines

For example, NETDEV_CHANGEINFODATA is only for bonds though nothing about the name suggests it is a bonding notification. This one was added specifically to notify userspace (d4261e5650004), yet seems to happen only during a changelink and that already generates a RTM_NEWLINK message via do_setlink. Since the rtnetlink_event message does not contain anything "NETDEV_CHANGEINFODATA" related what purpose does it really serve besides duplicating netlink messages to userspace.

Quoted 6 lines
Quoted 2 lines

I am not sure about this one, but if you have an app trying to monitor for this event, it can't really since there is no info in the netlink message.

I cc'ed Jiri on this thread hoping he would explain the intent.

I propose it gets removed.

Hmm, I don't really recall. But looking at it now, I agree it is redundant.

#12 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

Quoted 14 lines · Jiri Pirko
Quoted 13 lines · Thu, Apr 27, 2017 at 09:59:38PM CEST, [email protected] wrote:
Quoted 11 lines · Vlad Yasevich
Quoted 8 lines

For example, NETDEV_CHANGEINFODATA is only for bonds though nothing about the name suggests it is a bonding notification. This one was added specifically to notify userspace (d4261e5650004), yet seems to happen only during a changelink and that already generates a RTM_NEWLINK message via do_setlink. Since the rtnetlink_event message does not contain anything "NETDEV_CHANGEINFODATA" related what purpose does it really serve besides duplicating netlink messages to userspace.

I am not sure about this one, but if you have an app trying to monitor for this event, it can't really since there is no info in the netlink message.

Quoted 7 lines
Quoted 3 lines

I cc'ed Jiri on this thread hoping he would explain the intent.

I propose it gets removed.

Hmm, I don't really recall. But looking at it now, I agree it is redundant.

So, it looks like the notifier might be there to account for the ioctl/sysfs interfaces.

Additionally, the message is not generated from do_setlink() if the devices is down, so notifier accounts for that as well.

I guess, basic question is whether data carried in NETDEV_CHANGEINFODATA is useful to user space? If yes (I can possibly see some managements apps that might be interested in it), then we shouldn't just remove it. Possible solutions to eliminate duplicates would be to move the notifier call into non-rtnl code paths...

Also, may be netdev_state_change() should call rtmsg_ifinfo() unconditionally?

-vlad

#13 lore raw

Re: [PATCH net-next V3 2/2] rtnl: Add support for netdev event attribute to link messages

Quoted 2 lines · Vlad Yasevich

So, it looks like the notifier might be there to account for the ioctl/sysfs interfaces.

hmmm... I guess we have to leave it then.

Quoted 10 lines

Additionally, the message is not generated from do_setlink() if the devices is down, so notifier accounts for that as well.

I guess, basic question is whether data carried in NETDEV_CHANGEINFODATA is useful to user space? If yes (I can possibly see some managements apps that might be interested in it), then we shouldn't just remove it. Possible solutions to eliminate duplicates would be to move the notifier call into non-rtnl code paths...

Also, may be netdev_state_change() should call rtmsg_ifinfo() unconditionally?

Link up will generate a message, so userspace gets notified at some point.