Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bonding: export slave's partner_oper_port_state via sysfs and netlink

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 <gospo@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Nikolay Aleksandrov and committed by
David S. Miller
46ea297e 254cb6db

+22
+5
drivers/net/bonding/bond_netlink.c
··· 29 29 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_QUEUE_ID */ 30 30 nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_AD_AGGREGATOR_ID */ 31 31 nla_total_size(sizeof(u8)) + /* IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE */ 32 + nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE */ 32 33 0; 33 34 } 34 35 ··· 69 68 if (nla_put_u8(skb, 70 69 IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE, 71 70 ad_port->actor_oper_port_state)) 71 + goto nla_put_failure; 72 + if (nla_put_u16(skb, 73 + IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE, 74 + ad_port->partner_oper.port_state)) 72 75 goto nla_put_failure; 73 76 } 74 77 }
+16
drivers/net/bonding/bond_sysfs_slave.c
··· 95 95 } 96 96 static SLAVE_ATTR_RO(ad_actor_oper_port_state); 97 97 98 + static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf) 99 + { 100 + const struct port *ad_port; 101 + 102 + if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) { 103 + ad_port = &SLAVE_AD_INFO(slave)->port; 104 + if (ad_port->aggregator) 105 + return sprintf(buf, "%u\n", 106 + ad_port->partner_oper.port_state); 107 + } 108 + 109 + return sprintf(buf, "N/A\n"); 110 + } 111 + static SLAVE_ATTR_RO(ad_partner_oper_port_state); 112 + 98 113 static const struct slave_attribute *slave_attrs[] = { 99 114 &slave_attr_state, 100 115 &slave_attr_mii_status, ··· 118 103 &slave_attr_queue_id, 119 104 &slave_attr_ad_aggregator_id, 120 105 &slave_attr_ad_actor_oper_port_state, 106 + &slave_attr_ad_partner_oper_port_state, 121 107 NULL 122 108 }; 123 109
+1
include/uapi/linux/if_link.h
··· 457 457 IFLA_BOND_SLAVE_QUEUE_ID, 458 458 IFLA_BOND_SLAVE_AD_AGGREGATOR_ID, 459 459 IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE, 460 + IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE, 460 461 __IFLA_BOND_SLAVE_MAX, 461 462 }; 462 463