bonding: export slave's actor_oper_port_state via sysfs and netlink
authorNikolay Aleksandrov <razor@blackwall.org>
Sun, 14 Jun 2015 13:36:34 +0000 (16:36 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Jun 2015 23:40:24 +0000 (16:40 -0700)
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 <gospo@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_netlink.c
drivers/net/bonding/bond_sysfs_slave.c
include/uapi/linux/if_link.h

index f7015eb4f8db69714e515100d00b8494fb93512d..a0e600db4236095a359747ef6cbc39028d3c33ca 100644 (file)
@@ -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;
index 23618a8316122e87c074c863b0dc687f7ed1dcea..f6c197cee669a2b00a9cc82f5003b7762753835d 100644 (file)
@@ -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
 };
 
index 1737b7a8272bbec19a195b27f68f6b363ad200d1..1b3e357223f2b7b15ac48fdb2835d3e653dd8714 100644 (file)
@@ -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,
 };