bonding: add ad_info attribute netlink support
authorsfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com>
Fri, 3 Jan 2014 22:18:56 +0000 (14:18 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 4 Jan 2014 02:03:21 +0000 (21:03 -0500)
Add nested IFLA_BOND_AD_INFO for bonding 802.3ad info.

Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_netlink.c
include/uapi/linux/if_link.h

index df66dd8c08b56e40c46cbb9d1fd4dc4e3bc12f5d..1b4013b5f2300d36da1e7817225ed3e5a853f081 100644 (file)
@@ -45,6 +45,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
        [IFLA_BOND_PACKETS_PER_SLAVE]   = { .type = NLA_U32 },
        [IFLA_BOND_AD_LACP_RATE]        = { .type = NLA_U8 },
        [IFLA_BOND_AD_SELECT]           = { .type = NLA_U8 },
+       [IFLA_BOND_AD_INFO]             = { .type = NLA_NESTED },
 };
 
 static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -310,6 +311,12 @@ static size_t bond_get_size(const struct net_device *bond_dev)
                nla_total_size(sizeof(u32)) +  /* IFLA_BOND_PACKETS_PER_SLAVE */
                nla_total_size(sizeof(u8)) +    /* IFLA_BOND_AD_LACP_RATE */
                nla_total_size(sizeof(u8)) +    /* IFLA_BOND_AD_SELECT */
+               nla_total_size(sizeof(struct nlattr)) + /* IFLA_BOND_AD_INFO */
+               nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_AGGREGATOR */
+               nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_NUM_PORTS */
+               nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_ACTOR_KEY */
+               nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_PARTNER_KEY*/
+               nla_total_size(ETH_ALEN) +    /* IFLA_BOND_AD_INFO_PARTNER_MAC*/
                0;
 }
 
@@ -423,6 +430,37 @@ static int bond_fill_info(struct sk_buff *skb,
                       bond->params.ad_select))
                goto nla_put_failure;
 
+       if (bond->params.mode == BOND_MODE_8023AD) {
+               struct ad_info info;
+
+               if (!bond_3ad_get_active_agg_info(bond, &info)) {
+                       struct nlattr *nest;
+
+                       nest = nla_nest_start(skb, IFLA_BOND_AD_INFO);
+                       if (!nest)
+                               goto nla_put_failure;
+
+                       if (nla_put_u16(skb, IFLA_BOND_AD_INFO_AGGREGATOR,
+                                       info.aggregator_id))
+                               goto nla_put_failure;
+                       if (nla_put_u16(skb, IFLA_BOND_AD_INFO_NUM_PORTS,
+                                       info.ports))
+                               goto nla_put_failure;
+                       if (nla_put_u16(skb, IFLA_BOND_AD_INFO_ACTOR_KEY,
+                                       info.actor_key))
+                               goto nla_put_failure;
+                       if (nla_put_u16(skb, IFLA_BOND_AD_INFO_PARTNER_KEY,
+                                       info.partner_key))
+                               goto nla_put_failure;
+                       if (nla_put(skb, IFLA_BOND_AD_INFO_PARTNER_MAC,
+                                   sizeof(info.partner_system),
+                                   &info.partner_system))
+                               goto nla_put_failure;
+
+                       nla_nest_end(skb, nest);
+               }
+       }
+
        return 0;
 
 nla_put_failure:
index 0fbb01824dd30dd0c7595e92987e5677054c23a2..3e6bd3c7445dd3b16b193a0ea67cc41ed4ef78c1 100644 (file)
@@ -351,11 +351,23 @@ enum {
        IFLA_BOND_PACKETS_PER_SLAVE,
        IFLA_BOND_AD_LACP_RATE,
        IFLA_BOND_AD_SELECT,
+       IFLA_BOND_AD_INFO,
        __IFLA_BOND_MAX,
 };
 
 #define IFLA_BOND_MAX  (__IFLA_BOND_MAX - 1)
 
+enum {
+       IFLA_BOND_AD_INFO_AGGREGATOR,
+       IFLA_BOND_AD_INFO_NUM_PORTS,
+       IFLA_BOND_AD_INFO_ACTOR_KEY,
+       IFLA_BOND_AD_INFO_PARTNER_KEY,
+       IFLA_BOND_AD_INFO_PARTNER_MAC,
+       __IFLA_BOND_AD_INFO_MAX,
+};
+
+#define IFLA_BOND_AD_INFO_MAX  (__IFLA_BOND_AD_INFO_MAX - 1)
+
 /* SR-IOV virtual function management section */
 
 enum {