netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event()
@ 2017-05-25 15:31 Vladislav Yasevich
  2017-05-25 15:31 ` [PATCH V5 1/2] rtnl: Add support for netdev event to link messages Vladislav Yasevich
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Vladislav Yasevich @ 2017-05-25 15:31 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, roopa, jiri, vfalico, andy, Vladislav Yasevich

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

First is the patch to add IFLA_EVENT attribute to the netlink message.  It
supports only 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.

Second, I remove duplicate messages that a result of a change to bonding
options.  If netlink is used to configure bonding options, 2 messages
are generated, one as a result NETDEV_CHANGEINFODATA event triggered by
bonding code and one a result of device state changes triggered by
netdev_state_change (called from do_setlink).


V5: Rebased.  Added iproute2 patch to the series.
V4:
  * Removed the patch the removed NETDEV_CHANGENAME from event whitelist.
    It doesn't trigger duplicate messages since name changes can only be
    done while device is down and netdev_state_change() doesn't report
    changes while device is down.
  * Added a patch to clean-up duplicate messages on bonding option changes.

V3: Rebased.  Cleaned-up duplicate event.

V2: Added missed events (from David Ahern)

Vladislav Yasevich (2):
  rtnl: Add support for netdev event to link messages
  bonding: Prevent duplicate userspace notification

 drivers/net/bonding/bond_main.c    |  3 +-
 drivers/net/bonding/bond_options.c | 27 +++++++++++++++--
 include/linux/rtnetlink.h          |  3 +-
 include/net/bond_options.h         |  2 ++
 include/uapi/linux/if_link.h       | 11 +++++++
 net/core/dev.c                     |  2 +-
 net/core/rtnetlink.c               | 62 ++++++++++++++++++++++++++++++++------
 7 files changed, 96 insertions(+), 14 deletions(-)

-- 
2.7.4

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

* [PATCH V5 1/2] rtnl: Add support for netdev event to link messages
  2017-05-25 15:31 [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() Vladislav Yasevich
@ 2017-05-25 15:31 ` Vladislav Yasevich
  2017-05-26 19:40   ` David Ahern
  2017-05-25 15:31 ` [PATCH V5 2/2] bonding: Prevent duplicate userspace notification Vladislav Yasevich
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Vladislav Yasevich @ 2017-05-25 15:31 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, roopa, jiri, vfalico, andy, 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.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
 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(-)

diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 57e5484..0459018 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -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);
 
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 15ac203..8779ab7 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -157,6 +157,7 @@ enum {
 	IFLA_GSO_MAX_SIZE,
 	IFLA_PAD,
 	IFLA_XDP,
+	IFLA_EVENT,
 	__IFLA_MAX
 };
 
@@ -911,4 +912,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 */
diff --git a/net/core/dev.c b/net/core/dev.c
index 3d98fbf..06e0a74 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7084,7 +7084,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);
 
 		/*
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index dab2834..96eb392 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -941,6 +941,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
 	       + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_SWITCH_ID */
 	       + nla_total_size(IFNAMSIZ) /* IFLA_PHYS_PORT_NAME */
 	       + rtnl_xdp_size() /* IFLA_XDP */
+	       + nla_total_size(4)  /* IFLA_EVENT */
 	       + nla_total_size(1); /* IFLA_PROTO_DOWN */
 
 }
@@ -1282,9 +1283,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:
+		return 0;
+	}
+
+	return nla_put_u32(skb, IFLA_EVENT, rtnl_event);
+}
+
 static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 			    int type, u32 pid, u32 seq, u32 change,
-			    unsigned int flags, u32 ext_filter_mask)
+			    unsigned int flags, u32 ext_filter_mask,
+			    unsigned long event)
 {
 	struct ifinfomsg *ifm;
 	struct nlmsghdr *nlh;
@@ -1333,6 +1365,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 	    nla_put_u8(skb, IFLA_PROTO_DOWN, dev->proto_down))
 		goto nla_put_failure;
 
+	if (rtnl_fill_link_event(skb, event))
+		goto nla_put_failure;
+
 	if (rtnl_fill_link_ifmap(skb, dev))
 		goto nla_put_failure;
 
@@ -1467,6 +1502,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
 	[IFLA_LINK_NETNSID]	= { .type = NLA_S32 },
 	[IFLA_PROTO_DOWN]	= { .type = NLA_U8 },
 	[IFLA_XDP]		= { .type = NLA_NESTED },
+	[IFLA_EVENT]		= { .type = NLA_U32 },
 };
 
 static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
@@ -1626,7 +1662,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 					       NETLINK_CB(cb->skb).portid,
 					       cb->nlh->nlmsg_seq, 0,
 					       flags,
-					       ext_filter_mask);
+					       ext_filter_mask, 0);
 
 			if (err < 0) {
 				if (likely(skb->len))
@@ -2736,7 +2772,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 		return -ENOBUFS;
 
 	err = rtnl_fill_ifinfo(nskb, dev, RTM_NEWLINK, NETLINK_CB(skb).portid,
-			       nlh->nlmsg_seq, 0, 0, ext_filter_mask);
+			       nlh->nlmsg_seq, 0, 0, ext_filter_mask, 0);
 	if (err < 0) {
 		/* -EMSGSIZE implies BUG in if_nlmsg_size */
 		WARN_ON(err == -EMSGSIZE);
@@ -2808,7 +2844,8 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
 }
 
 struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
-				       unsigned int change, gfp_t flags)
+				       unsigned int change,
+				       unsigned long event, gfp_t flags)
 {
 	struct net *net = dev_net(dev);
 	struct sk_buff *skb;
@@ -2819,7 +2856,7 @@ struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
 	if (skb == NULL)
 		goto errout;
 
-	err = rtnl_fill_ifinfo(skb, dev, type, 0, 0, change, 0, 0);
+	err = rtnl_fill_ifinfo(skb, dev, type, 0, 0, change, 0, 0, event);
 	if (err < 0) {
 		/* -EMSGSIZE implies BUG in if_nlmsg_size() */
 		WARN_ON(err == -EMSGSIZE);
@@ -2840,18 +2877,25 @@ void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev, gfp_t flags)
 	rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, flags);
 }
 
-void rtmsg_ifinfo(int type, struct net_device *dev, unsigned int change,
-		  gfp_t flags)
+static void rtmsg_ifinfo_event(int type, struct net_device *dev,
+			       unsigned int change, unsigned long event,
+			       gfp_t flags)
 {
 	struct sk_buff *skb;
 
 	if (dev->reg_state != NETREG_REGISTERED)
 		return;
 
-	skb = rtmsg_ifinfo_build_skb(type, dev, change, flags);
+	skb = rtmsg_ifinfo_build_skb(type, dev, change, event, flags);
 	if (skb)
 		rtmsg_ifinfo_send(skb, dev, flags);
 }
+
+void rtmsg_ifinfo(int type, struct net_device *dev, unsigned int change,
+		  gfp_t flags)
+{
+	rtmsg_ifinfo_event(type, dev, change, 0, flags);
+}
 EXPORT_SYMBOL(rtmsg_ifinfo);
 
 static int nlmsg_populate_fdb_fill(struct sk_buff *skb,
@@ -4165,7 +4209,7 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
 	case NETDEV_NOTIFY_PEERS:
 	case NETDEV_RESEND_IGMP:
 	case NETDEV_CHANGEINFODATA:
-		rtmsg_ifinfo(RTM_NEWLINK, dev, 0, GFP_KERNEL);
+		rtmsg_ifinfo_event(RTM_NEWLINK, dev, 0, event, GFP_KERNEL);
 		break;
 	default:
 		break;
-- 
2.7.4

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

* [PATCH V5 2/2] bonding: Prevent duplicate userspace notification
  2017-05-25 15:31 [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() Vladislav Yasevich
  2017-05-25 15:31 ` [PATCH V5 1/2] rtnl: Add support for netdev event to link messages Vladislav Yasevich
@ 2017-05-25 15:31 ` Vladislav Yasevich
  2017-05-26 19:46   ` David Ahern
  2017-05-25 15:31 ` [PATCH V5 iproute] ip: Add support for netdev events to monitor Vladislav Yasevich
  2017-05-26 18:30 ` [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() David Miller
  3 siblings, 1 reply; 9+ messages in thread
From: Vladislav Yasevich @ 2017-05-25 15:31 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, roopa, jiri, vfalico, andy, Vladislav Yasevich

Whenever a user changes bonding options, a NETDEV_CHANGEINFODATA
notificatin is generated which results in a rtnelink message to
be sent.  While runnig 'ip monitor', we can actually see 2 messages,
one a result of the event, and the other a result of state change
that is generated bo netdev_state_change().  However, this is not
always the case. If bonding changes were done via sysfs or ifenslave
(old ioctl interface), then only 1 message is seen.

This patch removes duplicate messages in the case of using netlink
to configure bonding.  It introduceds a separte function that
triggers a netdev event and uses that function in the syfs and ioctl
cases.

This was discovered while auditing all the different envents and
continues the effort of cleaning up duplicated netlink messages.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
 drivers/net/bonding/bond_main.c    |  3 ++-
 drivers/net/bonding/bond_options.c | 27 +++++++++++++++++++++++++--
 include/net/bond_options.h         |  2 ++
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7331331..d7aa137 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3481,7 +3481,8 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
 	case BOND_CHANGE_ACTIVE_OLD:
 	case SIOCBONDCHANGEACTIVE:
 		bond_opt_initstr(&newval, slave_dev->name);
-		res = __bond_opt_set(bond, BOND_OPT_ACTIVE_SLAVE, &newval);
+		res = __bond_opt_set_notify(bond, BOND_OPT_ACTIVE_SLAVE,
+					    &newval);
 		break;
 	default:
 		res = -EOPNOTSUPP;
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 1bcbb89..8ca6833 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -673,7 +673,30 @@ int __bond_opt_set(struct bonding *bond,
 out:
 	if (ret)
 		bond_opt_error_interpret(bond, opt, ret, val);
-	else if (bond->dev->reg_state == NETREG_REGISTERED)
+
+	return ret;
+}
+/**
+ * __bond_opt_set_notify - set a bonding option
+ * @bond: target bond device
+ * @option: option to set
+ * @val: value to set it to
+ *
+ * This function is used to change the bond's option value and trigger
+ * a notification to user sapce. It can be used for both enabling/changing
+ * an option and for disabling it. RTNL lock must be obtained before calling
+ * this function.
+ */
+int __bond_opt_set_notify(struct bonding *bond,
+			  unsigned int option, struct bond_opt_value *val)
+{
+	int ret = -ENOENT;
+
+	ASSERT_RTNL();
+
+	ret = __bond_opt_set(bond, option, val);
+
+	if (!ret && (bond->dev->reg_state == NETREG_REGISTERED))
 		call_netdevice_notifiers(NETDEV_CHANGEINFODATA, bond->dev);
 
 	return ret;
@@ -696,7 +719,7 @@ int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf)
 	if (!rtnl_trylock())
 		return restart_syscall();
 	bond_opt_initstr(&optval, buf);
-	ret = __bond_opt_set(bond, option, &optval);
+	ret = __bond_opt_set_notify(bond, option, &optval);
 	rtnl_unlock();
 
 	return ret;
diff --git a/include/net/bond_options.h b/include/net/bond_options.h
index 1797235..d79d28f 100644
--- a/include/net/bond_options.h
+++ b/include/net/bond_options.h
@@ -104,6 +104,8 @@ struct bond_option {
 
 int __bond_opt_set(struct bonding *bond, unsigned int option,
 		   struct bond_opt_value *val);
+int __bond_opt_set_notify(struct bonding *bond, unsigned int option,
+			  struct bond_opt_value *val);
 int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf);
 
 const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt,
-- 
2.7.4

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

* [PATCH V5 iproute] ip: Add support for netdev events to monitor
  2017-05-25 15:31 [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() Vladislav Yasevich
  2017-05-25 15:31 ` [PATCH V5 1/2] rtnl: Add support for netdev event to link messages Vladislav Yasevich
  2017-05-25 15:31 ` [PATCH V5 2/2] bonding: Prevent duplicate userspace notification Vladislav Yasevich
@ 2017-05-25 15:31 ` Vladislav Yasevich
  2017-05-26 18:30 ` [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() David Miller
  3 siblings, 0 replies; 9+ messages in thread
From: Vladislav Yasevich @ 2017-05-25 15:31 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, roopa, jiri, vfalico, andy, Vladislav Yasevich

Add IFLA_EVENT handling so that event types can be viewed with
'monitor' command.  This gives a little more information for why
a given message was receivied.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
 include/linux/if_link.h | 11 +++++++++++
 ip/ipaddress.c          | 21 +++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 5a3a048..7e10274 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -157,6 +157,7 @@ enum {
 	IFLA_GSO_MAX_SIZE,
 	IFLA_PAD,
 	IFLA_XDP,
+	IFLA_EVENT,
 	__IFLA_MAX
 };
 
@@ -909,4 +910,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 /* _LINUX_IF_LINK_H */
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index b8d9c7d..d37b4b2 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -753,6 +753,24 @@ int print_linkinfo_brief(const struct sockaddr_nl *who,
 	return 0;
 }
 
+static const char *netdev_events[] = {"UNKNOWN",
+				      "REBOOT",
+				      "FEATURE_CHANGE",
+				      "BONDING_FAILOVER",
+				      "NOTIFY_PEERS",
+				      "RESEND_IGMP",
+				      "CHANGE_INFO_DATA"};
+
+static void print_dev_event(FILE *f, __u32 event)
+{
+	if (event >= ARRAY_SIZE(netdev_events))
+		fprintf(f, "event %d ", event);
+	else {
+		if (event)
+			fprintf(f, "event %s ", netdev_events[event]);
+	}
+}
+
 int print_linkinfo(const struct sockaddr_nl *who,
 		   struct nlmsghdr *n, void *arg)
 {
@@ -858,6 +876,9 @@ int print_linkinfo(const struct sockaddr_nl *who,
 	if (filter.showqueue)
 		print_queuelen(fp, tb);
 
+	if (tb[IFLA_EVENT])
+		print_dev_event(fp, rta_getattr_u32(tb[IFLA_EVENT]));
+
 	if (!filter.family || filter.family == AF_PACKET || show_details) {
 		SPRINT_BUF(b1);
 		fprintf(fp, "%s", _SL_);
-- 
2.7.4

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

* Re: [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event()
  2017-05-25 15:31 [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() Vladislav Yasevich
                   ` (2 preceding siblings ...)
  2017-05-25 15:31 ` [PATCH V5 iproute] ip: Add support for netdev events to monitor Vladislav Yasevich
@ 2017-05-26 18:30 ` David Miller
  3 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2017-05-26 18:30 UTC (permalink / raw)
  To: vyasevich; +Cc: netdev, dsahern, roopa, jiri, vfalico, andy, vyasevic

From: Vladislav Yasevich <vyasevich@gmail.com>
Date: Thu, 25 May 2017 11:31:53 -0400

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

David Ahern, please review.

Thanks.

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

* Re: [PATCH V5 1/2] rtnl: Add support for netdev event to link messages
  2017-05-25 15:31 ` [PATCH V5 1/2] rtnl: Add support for netdev event to link messages Vladislav Yasevich
@ 2017-05-26 19:40   ` David Ahern
  2017-05-26 20:01     ` Vlad Yasevich
  0 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2017-05-26 19:40 UTC (permalink / raw)
  To: Vladislav Yasevich, netdev; +Cc: roopa, jiri, vfalico, andy, Vladislav Yasevich

On 5/25/17 9:31 AM, Vladislav Yasevich wrote:
> @@ -911,4 +912,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 */

I agree these are unique events that userspace might care about.

I'd prefer better names for the userspace api for a couple of those
along with a description in the header file so userspace knows why the
event was generated.

How about something like this:

enum {
	IFLA_EVENT_NONE,
	IFLA_EVENT_REBOOT,		/* internal reset / reboot */
	IFLA_EVENT_FEATURES,		/* change in offload features */
	IFLA_EVENT_BONDING_FAILOVER,	/* change in active slave */
	IFLA_EVENT_NOTIFY_PEERS,	/* re-sent grat. arp/ndisc */
	IFLA_EVENT_IGMP_RESEND,		/* re-sent IGMP JOIN */
	IFLA_EVENT_BONDING_OPTIONS,	/* change in bonding options */
};

Also, generically the IFLA_EVENT attribute should be considered
independent of NETDEV_ events.

For example, userspace should be notified if the speed / duplex for a
device changes, so we could have another one of these -- e.g.,
IFLA_EVENT_SPEED -- that does not correlate to NETDEV_SPEED since
nothing internal to the network stack cares about speed changes, or
perhaps more generically it is IFLA_EVENT_LINK_SETTING.

The rest of the patch looks ok to me.

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

* Re: [PATCH V5 2/2] bonding: Prevent duplicate userspace notification
  2017-05-25 15:31 ` [PATCH V5 2/2] bonding: Prevent duplicate userspace notification Vladislav Yasevich
@ 2017-05-26 19:46   ` David Ahern
  0 siblings, 0 replies; 9+ messages in thread
From: David Ahern @ 2017-05-26 19:46 UTC (permalink / raw)
  To: Vladislav Yasevich, netdev; +Cc: roopa, jiri, vfalico, andy, Vladislav Yasevich

On 5/25/17 9:31 AM, Vladislav Yasevich wrote:
> Whenever a user changes bonding options, a NETDEV_CHANGEINFODATA
> notificatin is generated which results in a rtnelink message to
> be sent.  While runnig 'ip monitor', we can actually see 2 messages,
> one a result of the event, and the other a result of state change
> that is generated bo netdev_state_change().  However, this is not
> always the case. If bonding changes were done via sysfs or ifenslave
> (old ioctl interface), then only 1 message is seen.
> 
> This patch removes duplicate messages in the case of using netlink
> to configure bonding.  It introduceds a separte function that
> triggers a netdev event and uses that function in the syfs and ioctl
> cases.
> 
> This was discovered while auditing all the different envents and
> continues the effort of cleaning up duplicated netlink messages.
> 
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> ---
>  drivers/net/bonding/bond_main.c    |  3 ++-
>  drivers/net/bonding/bond_options.c | 27 +++++++++++++++++++++++++--
>  include/net/bond_options.h         |  2 ++
>  3 files changed, 29 insertions(+), 3 deletions(-)

LGTM

Acked-by: David Ahern <dsahern@gmail.com>

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

* Re: [PATCH V5 1/2] rtnl: Add support for netdev event to link messages
  2017-05-26 19:40   ` David Ahern
@ 2017-05-26 20:01     ` Vlad Yasevich
  2017-05-26 20:04       ` David Ahern
  0 siblings, 1 reply; 9+ messages in thread
From: Vlad Yasevich @ 2017-05-26 20:01 UTC (permalink / raw)
  To: David Ahern, Vladislav Yasevich, netdev; +Cc: roopa, jiri, vfalico, andy

On 05/26/2017 03:40 PM, David Ahern wrote:
> On 5/25/17 9:31 AM, Vladislav Yasevich wrote:
>> @@ -911,4 +912,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 */
> 
> I agree these are unique events that userspace might care about.
> 
> I'd prefer better names for the userspace api for a couple of those
> along with a description in the header file so userspace knows why the
> event was generated.
> 
> How about something like this:
> 
> enum {
> 	IFLA_EVENT_NONE,
> 	IFLA_EVENT_REBOOT,		/* internal reset / reboot */
> 	IFLA_EVENT_FEATURES,		/* change in offload features */
> 	IFLA_EVENT_BONDING_FAILOVER,	/* change in active slave */
> 	IFLA_EVENT_NOTIFY_PEERS,	/* re-sent grat. arp/ndisc */
> 	IFLA_EVENT_IGMP_RESEND,		/* re-sent IGMP JOIN */
> 	IFLA_EVENT_BONDING_OPTIONS,	/* change in bonding options */
> };
> 

Ok.  I'll change and re-submit.

> Also, generically the IFLA_EVENT attribute should be considered
> independent of NETDEV_ events.
> 
> For example, userspace should be notified if the speed / duplex for a
> device changes, so we could have another one of these -- e.g.,
> IFLA_EVENT_SPEED -- that does not correlate to NETDEV_SPEED since
> nothing internal to the network stack cares about speed changes, or
> perhaps more generically it is IFLA_EVENT_LINK_SETTING.
> 

Ok.  We could do a translation between netdev event and IFLA_EVENT attribute value
earlier (say in rtnetlink_event) and pass that along.  This would allow calls
from other places, assuming proper IFLA_EVENT attribute value and translation
is defined.

Would that address your concerns?

> The rest of the patch looks ok to me.
> 

Thanks
-vlad

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

* Re: [PATCH V5 1/2] rtnl: Add support for netdev event to link messages
  2017-05-26 20:01     ` Vlad Yasevich
@ 2017-05-26 20:04       ` David Ahern
  0 siblings, 0 replies; 9+ messages in thread
From: David Ahern @ 2017-05-26 20:04 UTC (permalink / raw)
  To: vyasevic, Vladislav Yasevich, netdev; +Cc: roopa, jiri, vfalico, andy

On 5/26/17 2:01 PM, Vlad Yasevich wrote:
>> Also, generically the IFLA_EVENT attribute should be considered
>> independent of NETDEV_ events.
>>
>> For example, userspace should be notified if the speed / duplex for a
>> device changes, so we could have another one of these -- e.g.,
>> IFLA_EVENT_SPEED -- that does not correlate to NETDEV_SPEED since
>> nothing internal to the network stack cares about speed changes, or
>> perhaps more generically it is IFLA_EVENT_LINK_SETTING.
>>
> 
> Ok.  We could do a translation between netdev event and IFLA_EVENT attribute value
> earlier (say in rtnetlink_event) and pass that along.  This would allow calls
> from other places, assuming proper IFLA_EVENT attribute value and translation
> is defined.
> 
> Would that address your concerns?

yes. that code re-factoring can be done when it is needed.

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

end of thread, other threads:[~2017-05-26 20:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-25 15:31 [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() Vladislav Yasevich
2017-05-25 15:31 ` [PATCH V5 1/2] rtnl: Add support for netdev event to link messages Vladislav Yasevich
2017-05-26 19:40   ` David Ahern
2017-05-26 20:01     ` Vlad Yasevich
2017-05-26 20:04       ` David Ahern
2017-05-25 15:31 ` [PATCH V5 2/2] bonding: Prevent duplicate userspace notification Vladislav Yasevich
2017-05-26 19:46   ` David Ahern
2017-05-25 15:31 ` [PATCH V5 iproute] ip: Add support for netdev events to monitor Vladislav Yasevich
2017-05-26 18:30 ` [PATCH v5 net-next 0/2] rtnetlink: Updates to rtnetlink_event() David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).