2222
2323static const struct nla_policy bond_policy [IFLA_BOND_MAX + 1 ] = {
2424 [IFLA_BOND_MODE ] = { .type = NLA_U8 },
25+ [IFLA_BOND_ACTIVE_SLAVE ] = { .type = NLA_U32 },
2526};
2627
2728static int bond_validate (struct nlattr * tb [], struct nlattr * data [])
@@ -48,6 +49,22 @@ static int bond_changelink(struct net_device *bond_dev,
4849 if (err )
4950 return err ;
5051 }
52+ if (data && data [IFLA_BOND_ACTIVE_SLAVE ]) {
53+ int ifindex = nla_get_u32 (data [IFLA_BOND_ACTIVE_SLAVE ]);
54+ struct net_device * slave_dev ;
55+
56+ if (ifindex == 0 ) {
57+ slave_dev = NULL ;
58+ } else {
59+ slave_dev = __dev_get_by_index (dev_net (bond_dev ),
60+ ifindex );
61+ if (!slave_dev )
62+ return - ENODEV ;
63+ }
64+ err = bond_option_active_slave_set (bond , slave_dev );
65+ if (err )
66+ return err ;
67+ }
5168 return 0 ;
5269}
5370
@@ -66,14 +83,18 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev,
6683static size_t bond_get_size (const struct net_device * bond_dev )
6784{
6885 return nla_total_size (sizeof (u8 )); /* IFLA_BOND_MODE */
86+ + nla_total_size (sizeof (u32 )); /* IFLA_BOND_ACTIVE_SLAVE */
6987}
7088
7189static int bond_fill_info (struct sk_buff * skb ,
7290 const struct net_device * bond_dev )
7391{
7492 struct bonding * bond = netdev_priv (bond_dev );
93+ struct net_device * slave_dev = bond_option_active_slave_get (bond );
7594
76- if (nla_put_u8 (skb , IFLA_BOND_MODE , bond -> params .mode ))
95+ if (nla_put_u8 (skb , IFLA_BOND_MODE , bond -> params .mode ) ||
96+ (slave_dev &&
97+ nla_put_u32 (skb , IFLA_BOND_ACTIVE_SLAVE , slave_dev -> ifindex )))
7798 goto nla_put_failure ;
7899 return 0 ;
79100
0 commit comments