[PATCH net-next 0/2] bonding: extend the 3ad exported attributes

STALE4067d

6 messages, 3 authors, 2015-06-15 · open the first message on its own page

[PATCH net-next 0/2] bonding: extend the 3ad exported attributes

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: 2015-06-14 13:36:45

Hi,
These are two small patches that export actor_oper_port_state and
partner_oper_port_state via netlink and sysfs, until now they were only
exported via bond's proc entry. If this set gets accepted I have an iproute2
patch prepared that will export them with which I tested these changes.

Best regards,
 Nikolay Aleksandrov

Nikolay Aleksandrov (2):
  bonding: export slave's actor_oper_port_state via sysfs and netlink
  bonding: export slave's partner_oper_port_state via sysfs and netlink

 drivers/net/bonding/bond_netlink.c     | 15 ++++++++++++++-
 drivers/net/bonding/bond_sysfs_slave.c | 32 ++++++++++++++++++++++++++++++++
 include/uapi/linux/if_link.h           |  2 ++
 3 files changed, 48 insertions(+), 1 deletion(-)

-- 
2.4.3

[PATCH net-next 1/2] bonding: export slave's actor_oper_port_state via sysfs and netlink

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: 2015-06-14 13:36:47

Export the actor_oper_port_state of each port via sysfs and netlink.
In 802.3ad mode it is valuable for the user to be able to check the
actor_oper state, it is already exported via bond's proc entry.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
 drivers/net/bonding/bond_netlink.c     | 10 +++++++++-
 drivers/net/bonding/bond_sysfs_slave.c | 16 ++++++++++++++++
 include/uapi/linux/if_link.h           |  1 +
 3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index f7015eb4f8db..a0e600db4236 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -28,6 +28,7 @@ static size_t bond_get_slave_size(const struct net_device *bond_dev,
 		nla_total_size(MAX_ADDR_LEN) +	/* IFLA_BOND_SLAVE_PERM_HWADDR */
 		nla_total_size(sizeof(u16)) +	/* IFLA_BOND_SLAVE_QUEUE_ID */
 		nla_total_size(sizeof(u16)) +	/* IFLA_BOND_SLAVE_AD_AGGREGATOR_ID */
+		nla_total_size(sizeof(u8)) +	/* IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE */
 		0;
 }
 
@@ -56,12 +57,19 @@ static int bond_fill_slave_info(struct sk_buff *skb,
 
 	if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
 		const struct aggregator *agg;
+		const struct port *ad_port;
 
+		ad_port = &SLAVE_AD_INFO(slave)->port;
 		agg = SLAVE_AD_INFO(slave)->port.aggregator;
-		if (agg)
+		if (agg) {
 			if (nla_put_u16(skb, IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
 					agg->aggregator_identifier))
 				goto nla_put_failure;
+			if (nla_put_u8(skb,
+				       IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
+				       ad_port->actor_oper_port_state))
+				goto nla_put_failure;
+		}
 	}
 
 	return 0;
diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
index 23618a831612..f6c197cee669 100644
--- a/drivers/net/bonding/bond_sysfs_slave.c
+++ b/drivers/net/bonding/bond_sysfs_slave.c
@@ -80,6 +80,21 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf)
 }
 static SLAVE_ATTR_RO(ad_aggregator_id);
 
+static ssize_t ad_actor_oper_port_state_show(struct slave *slave, char *buf)
+{
+	const struct port *ad_port;
+
+	if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
+		ad_port = &SLAVE_AD_INFO(slave)->port;
+		if (ad_port->aggregator)
+			return sprintf(buf, "%u\n",
+				       ad_port->actor_oper_port_state);
+	}
+
+	return sprintf(buf, "N/A\n");
+}
+static SLAVE_ATTR_RO(ad_actor_oper_port_state);
+
 static const struct slave_attribute *slave_attrs[] = {
 	&slave_attr_state,
 	&slave_attr_mii_status,
@@ -87,6 +102,7 @@ static const struct slave_attribute *slave_attrs[] = {
 	&slave_attr_perm_hwaddr,
 	&slave_attr_queue_id,
 	&slave_attr_ad_aggregator_id,
+	&slave_attr_ad_actor_oper_port_state,
 	NULL
 };
 
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 1737b7a8272b..1b3e357223f2 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -456,6 +456,7 @@ enum {
 	IFLA_BOND_SLAVE_PERM_HWADDR,
 	IFLA_BOND_SLAVE_QUEUE_ID,
 	IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
+	IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
 	__IFLA_BOND_SLAVE_MAX,
 };
 
-- 
2.4.3

[PATCH net-next 2/2] bonding: export slave's partner_oper_port_state via sysfs and netlink

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: 2015-06-14 13:36:48

Export the partner_oper_port_state of each port via sysfs and netlink.
In 802.3ad mode it is valuable for the user to be able to check the
partner_oper state, it is already exported via bond's proc entry.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
Note: There's one line that's > 80 chars, but it's an IFLA name and can't
      be broken in a sane way.

 drivers/net/bonding/bond_netlink.c     |  5 +++++
 drivers/net/bonding/bond_sysfs_slave.c | 16 ++++++++++++++++
 include/uapi/linux/if_link.h           |  1 +
 3 files changed, 22 insertions(+)
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index a0e600db4236..5580fcde738f 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -29,6 +29,7 @@ static size_t bond_get_slave_size(const struct net_device *bond_dev,
 		nla_total_size(sizeof(u16)) +	/* IFLA_BOND_SLAVE_QUEUE_ID */
 		nla_total_size(sizeof(u16)) +	/* IFLA_BOND_SLAVE_AD_AGGREGATOR_ID */
 		nla_total_size(sizeof(u8)) +	/* IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE */
+		nla_total_size(sizeof(u16)) +	/* IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE */
 		0;
 }
 
@@ -69,6 +70,10 @@ static int bond_fill_slave_info(struct sk_buff *skb,
 				       IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
 				       ad_port->actor_oper_port_state))
 				goto nla_put_failure;
+			if (nla_put_u16(skb,
+					IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
+					ad_port->partner_oper.port_state))
+				goto nla_put_failure;
 		}
 	}
 
diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
index f6c197cee669..7d16c51e6913 100644
--- a/drivers/net/bonding/bond_sysfs_slave.c
+++ b/drivers/net/bonding/bond_sysfs_slave.c
@@ -95,6 +95,21 @@ static ssize_t ad_actor_oper_port_state_show(struct slave *slave, char *buf)
 }
 static SLAVE_ATTR_RO(ad_actor_oper_port_state);
 
+static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf)
+{
+	const struct port *ad_port;
+
+	if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
+		ad_port = &SLAVE_AD_INFO(slave)->port;
+		if (ad_port->aggregator)
+			return sprintf(buf, "%u\n",
+				       ad_port->partner_oper.port_state);
+	}
+
+	return sprintf(buf, "N/A\n");
+}
+static SLAVE_ATTR_RO(ad_partner_oper_port_state);
+
 static const struct slave_attribute *slave_attrs[] = {
 	&slave_attr_state,
 	&slave_attr_mii_status,
@@ -103,6 +118,7 @@ static const struct slave_attribute *slave_attrs[] = {
 	&slave_attr_queue_id,
 	&slave_attr_ad_aggregator_id,
 	&slave_attr_ad_actor_oper_port_state,
+	&slave_attr_ad_partner_oper_port_state,
 	NULL
 };
 
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 1b3e357223f2..510efb360580 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -457,6 +457,7 @@ enum {
 	IFLA_BOND_SLAVE_QUEUE_ID,
 	IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
 	IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
+	IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
 	__IFLA_BOND_SLAVE_MAX,
 };
 
-- 
2.4.3

Re: [PATCH net-next 1/2] bonding: export slave's actor_oper_port_state via sysfs and netlink

From: Andy Gospodarek <hidden>
Date: 2015-06-15 14:09:33

On Sun, Jun 14, 2015 at 04:36:34PM +0300, Nikolay Aleksandrov wrote:
Export the actor_oper_port_state of each port via sysfs and netlink.
In 802.3ad mode it is valuable for the user to be able to check the
actor_oper state, it is already exported via bond's proc entry.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Andy Gospodarek <redacted>
---
 drivers/net/bonding/bond_netlink.c     | 10 +++++++++-
 drivers/net/bonding/bond_sysfs_slave.c | 16 ++++++++++++++++
 include/uapi/linux/if_link.h           |  1 +
 3 files changed, 26 insertions(+), 1 deletion(-)

Re: [PATCH net-next 2/2] bonding: export slave's partner_oper_port_state via sysfs and netlink

From: Andy Gospodarek <hidden>
Date: 2015-06-15 14:10:02

On Sun, Jun 14, 2015 at 04:36:35PM +0300, Nikolay Aleksandrov wrote:
Export the partner_oper_port_state of each port via sysfs and netlink.
In 802.3ad mode it is valuable for the user to be able to check the
partner_oper state, it is already exported via bond's proc entry.

Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Andy Gospodarek <redacted>
---
Note: There's one line that's > 80 chars, but it's an IFLA name and can't
      be broken in a sane way.

 drivers/net/bonding/bond_netlink.c     |  5 +++++
 drivers/net/bonding/bond_sysfs_slave.c | 16 ++++++++++++++++
 include/uapi/linux/if_link.h           |  1 +
 3 files changed, 22 insertions(+)

Re: [PATCH net-next 0/2] bonding: extend the 3ad exported attributes

From: David Miller <davem@davemloft.net>
Date: 2015-06-15 23:40:42

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: Sun, 14 Jun 2015 16:36:33 +0300
These are two small patches that export actor_oper_port_state and
partner_oper_port_state via netlink and sysfs, until now they were only
exported via bond's proc entry. If this set gets accepted I have an iproute2
patch prepared that will export them with which I tested these changes.
Series applied, thank you.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help