History

bonding: export slave's actor_oper_port_state via sysfs and netlink

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.

Nikolay Aleksandrov committed 11 years ago

Commit 254cb6d1 parent 4d367963 files · +26 −1Browse files

Unified · Split

3 files
  1. drivers/net/bonding/bond_netlink.c +9 −1
  2. drivers/net/bonding/bond_sysfs_slave.c +16 −0
  3. include/uapi/linux/if_link.h +1 −0
drivers/net/bonding/bond_netlink.c+9−1
@@ -28,6 +28,7 @@ static size_t bond_get_slave_size(const struct net_device *bond_dev, · 27 unmodified lines
2828 nla_total_size(MAX_ADDR_LEN) + /* IFLA_BOND_SLAVE_PERM_HWADDR */
2929 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_QUEUE_ID */
3030 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_AD_AGGREGATOR_ID */
31+ nla_total_size(sizeof(u8)) + /* IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE */
3132 0;
3233 }
3334
@@ -56,12 +57,19 @@ static int bond_fill_slave_info(struct sk_buff *skb, · 22 unmodified lines
5657
5758 if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
5859 const struct aggregator *agg;
60+ const struct port *ad_port;
5961
62+ ad_port = &SLAVE_AD_INFO(slave)->port;
6063 agg = SLAVE_AD_INFO(slave)->port.aggregator;
61− if (agg)
64+ if (agg) {
6265 if (nla_put_u16(skb, IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
6366 agg->aggregator_identifier))
6467 goto nla_put_failure;
68+ if (nla_put_u8(skb,
69+ IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
70+ ad_port->actor_oper_port_state))
71+ goto nla_put_failure;
72+ }
6573 }
6674
6775 return 0;
drivers/net/bonding/bond_sysfs_slave.c+16−0
@@ -80,6 +80,21 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf) · 79 unmodified lines
8080 }
8181 static SLAVE_ATTR_RO(ad_aggregator_id);
8282
83+static ssize_t ad_actor_oper_port_state_show(struct slave *slave, char *buf)
84+{
85+ const struct port *ad_port;
86+
87+ if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
88+ ad_port = &SLAVE_AD_INFO(slave)->port;
89+ if (ad_port->aggregator)
90+ return sprintf(buf, "%u\n",
91+ ad_port->actor_oper_port_state);
92+ }
93+
94+ return sprintf(buf, "N/A\n");
95+}
96+static SLAVE_ATTR_RO(ad_actor_oper_port_state);
97+
8398 static const struct slave_attribute *slave_attrs[] = {
8499 &slave_attr_state,
85100 &slave_attr_mii_status,
@@ -87,6 +102,7 @@ static const struct slave_attribute *slave_attrs[] = { · 1 unmodified line
87102 &slave_attr_perm_hwaddr,
88103 &slave_attr_queue_id,
89104 &slave_attr_ad_aggregator_id,
105+ &slave_attr_ad_actor_oper_port_state,
90106 NULL
91107 };
92108
include/uapi/linux/if_link.h+1−0
@@ -456,6 +456,7 @@ enum { · 455 unmodified lines
456456 IFLA_BOND_SLAVE_PERM_HWADDR,
457457 IFLA_BOND_SLAVE_QUEUE_ID,
458458 IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
459+ IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
459460 __IFLA_BOND_SLAVE_MAX,
460461 };
461462