Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d3ee88a authored by sfeldma@cumulusnetworks.com's avatar sfeldma@cumulusnetworks.com Committed by David S. Miller
Browse files

bonding: add netlink attributes to slave link dev



If link is IFF_SLAVE, extend link dev netlink attributes to include
slave attributes with new IFLA_SLAVE nest.  Add netlink notification
(RTM_NEWLINK) when slave status changes from backup to active, or
visa-versa.

Adds new ndo_get_slave op to net_device_ops to fill skb with IFLA_SLAVE
attributes.  Currently only used by bonding driver, but could be
used by other aggregating devices with slaves.

Signed-off-by: default avatarScott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 07699f9a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3883,6 +3883,7 @@ static const struct net_device_ops bond_netdev_ops = {
#endif
	.ndo_add_slave		= bond_enslave,
	.ndo_del_slave		= bond_release,
	.ndo_get_slave		= bond_get_slave,
	.ndo_fix_features	= bond_fix_features,
};

+36 −0
Original line number Diff line number Diff line
@@ -22,6 +22,42 @@
#include <linux/reciprocal_div.h>
#include "bonding.h"

int bond_get_slave(struct net_device *slave_dev, struct sk_buff *skb)
{
	struct slave *slave = bond_slave_get_rtnl(slave_dev);
	const struct aggregator *agg;

	if (nla_put_u8(skb, IFLA_SLAVE_STATE, bond_slave_state(slave)))
		goto nla_put_failure;

	if (nla_put_u8(skb, IFLA_SLAVE_MII_STATUS, slave->link))
		goto nla_put_failure;

	if (nla_put_u32(skb, IFLA_SLAVE_LINK_FAILURE_COUNT,
			slave->link_failure_count))
		goto nla_put_failure;

	if (nla_put(skb, IFLA_SLAVE_PERM_HWADDR,
		    slave_dev->addr_len, slave->perm_hwaddr))
		goto nla_put_failure;

	if (nla_put_u16(skb, IFLA_SLAVE_QUEUE_ID, slave->queue_id))
		goto nla_put_failure;

	if (slave->bond->params.mode == BOND_MODE_8023AD) {
		agg = SLAVE_AD_INFO(slave).port.aggregator;
		if (agg)
			if (nla_put_u16(skb, IFLA_SLAVE_AD_AGGREGATOR_ID,
					agg->aggregator_identifier))
				goto nla_put_failure;
	}

	return 0;

nla_put_failure:
	return -EMSGSIZE;
}

static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = {
	[IFLA_BOND_MODE]		= { .type = NLA_U8 },
	[IFLA_BOND_ACTIVE_SLAVE]	= { .type = NLA_U32 },
+9 −2
Original line number Diff line number Diff line
@@ -285,12 +285,18 @@ static inline bool bond_is_lb(const struct bonding *bond)

static inline void bond_set_active_slave(struct slave *slave)
{
	if (slave->backup) {
		slave->backup = 0;
		rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_KERNEL);
	}
}

static inline void bond_set_backup_slave(struct slave *slave)
{
	if (!slave->backup) {
		slave->backup = 1;
		rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_KERNEL);
	}
}

static inline int bond_slave_state(struct slave *slave)
@@ -426,6 +432,7 @@ int bond_sysfs_slave_add(struct slave *slave);
void bond_sysfs_slave_del(struct slave *slave);
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
int bond_get_slave(struct net_device *slave_dev, struct sk_buff *skb);
int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count);
int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl);
int bond_parm_tbl_lookup(int mode, const struct bond_parm_tbl *tbl);
+5 −0
Original line number Diff line number Diff line
@@ -921,6 +921,9 @@ struct netdev_phys_port_id {
 * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev);
 *	Called to release previously enslaved netdev.
 *
 * int (*ndo_get_slave)(struct net_device *slave_dev, struct sk_buff *skb);
 *	Called to fill netlink skb with slave info.
 *
 *      Feature/offload setting functions.
 * netdev_features_t (*ndo_fix_features)(struct net_device *dev,
 *		netdev_features_t features);
@@ -1093,6 +1096,8 @@ struct net_device_ops {
						 struct net_device *slave_dev);
	int			(*ndo_del_slave)(struct net_device *dev,
						 struct net_device *slave_dev);
	int			(*ndo_get_slave)(struct net_device *slave_dev,
						 struct sk_buff *skb);
	netdev_features_t	(*ndo_fix_features)(struct net_device *dev,
						    netdev_features_t features);
	int			(*ndo_set_features)(struct net_device *dev,
+13 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ enum {
	IFLA_NUM_RX_QUEUES,
	IFLA_CARRIER,
	IFLA_PHYS_PORT_ID,
	IFLA_SLAVE,
	__IFLA_MAX
};

@@ -368,6 +369,18 @@ enum {

#define IFLA_BOND_AD_INFO_MAX	(__IFLA_BOND_AD_INFO_MAX - 1)

enum {
	IFLA_SLAVE_STATE,
	IFLA_SLAVE_MII_STATUS,
	IFLA_SLAVE_LINK_FAILURE_COUNT,
	IFLA_SLAVE_PERM_HWADDR,
	IFLA_SLAVE_QUEUE_ID,
	IFLA_SLAVE_AD_AGGREGATOR_ID,
	__IFLA_SLAVE_MAX,
};

#define IFLA_SLAVE_MAX	(__IFLA_SLAVE_MAX - 1)

/* SR-IOV virtual function management section */

enum {
Loading