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
28 nla_total_size(MAX_ADDR_LEN) + /* IFLA_BOND_SLAVE_PERM_HWADDR */28 nla_total_size(MAX_ADDR_LEN) + /* IFLA_BOND_SLAVE_PERM_HWADDR */
29 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_QUEUE_ID */29 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_QUEUE_ID */
30 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_AD_AGGREGATOR_ID */30 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 */
31 0;32 0;
32}33}
33 34
@@ -56,12 +57,19 @@ static int bond_fill_slave_info(struct sk_buff *skb, · 22 unmodified lines
56 57
57 if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {58 if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
58 const struct aggregator *agg;59 const struct aggregator *agg;
60 const struct port *ad_port;
59 61
62 ad_port = &SLAVE_AD_INFO(slave)->port;
60 agg = SLAVE_AD_INFO(slave)->port.aggregator;63 agg = SLAVE_AD_INFO(slave)->port.aggregator;
61 if (agg)64 if (agg) {
62 if (nla_put_u16(skb, IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,65 if (nla_put_u16(skb, IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
63 agg->aggregator_identifier))66 agg->aggregator_identifier))
64 goto nla_put_failure;67 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 }
65 }73 }
66 74
67 return 0;75 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
80}80}
81static SLAVE_ATTR_RO(ad_aggregator_id);81static SLAVE_ATTR_RO(ad_aggregator_id);
82 82
83static 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}
96static SLAVE_ATTR_RO(ad_actor_oper_port_state);
97
83static const struct slave_attribute *slave_attrs[] = {98static const struct slave_attribute *slave_attrs[] = {
84 &slave_attr_state,99 &slave_attr_state,
85 &slave_attr_mii_status,100 &slave_attr_mii_status,
@@ -87,6 +102,7 @@ static const struct slave_attribute *slave_attrs[] = { · 1 unmodified line
87 &slave_attr_perm_hwaddr,102 &slave_attr_perm_hwaddr,
88 &slave_attr_queue_id,103 &slave_attr_queue_id,
89 &slave_attr_ad_aggregator_id,104 &slave_attr_ad_aggregator_id,
105 &slave_attr_ad_actor_oper_port_state,
90 NULL106 NULL
91};107};
92 108
include/uapi/linux/if_link.h+1−0
@@ -456,6 +456,7 @@ enum { · 455 unmodified lines
456 IFLA_BOND_SLAVE_PERM_HWADDR,456 IFLA_BOND_SLAVE_PERM_HWADDR,
457 IFLA_BOND_SLAVE_QUEUE_ID,457 IFLA_BOND_SLAVE_QUEUE_ID,
458 IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,458 IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
459 IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
459 __IFLA_BOND_SLAVE_MAX,460 __IFLA_BOND_SLAVE_MAX,
460};461};
461 462