bonding: add primary attribute netlink support
Subsystems (3)
PATCH 1/5 bonding: add primary attribute netlink support
Add IFLA_BOND_PRIMARY to allow get/set of bonding parameter primary via netlink.
Signed-off-by Scott Feldman <[email protected]>
--- drivers/net/bonding/bond_netlink.c | 20 ++++++++++++++ drivers/net/bonding/bond_options.c | 52 ++++++++++++++++++++++++++++++++++++ drivers/net/bonding/bond_sysfs.c | 52 ++++++------------------------------ drivers/net/bonding/bonding.h | 1 + include/uapi/linux/if_link.h | 1 + 5 files changed, 83 insertions(+), 43 deletions(-)
drivers/net/bonding/bond_netlink.c +20 -0
@@ -32,6 +32,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_ARP_IP_TARGET] = { .type = NLA_NESTED }, [IFLA_BOND_ARP_VALIDATE] = { .type = NLA_U32 }, [IFLA_BOND_ARP_ALL_TARGETS] = { .type = NLA_U32 }, + [IFLA_BOND_PRIMARY] = { .type = NLA_U32 }, };static int bond_validate (struct nlattr *tb[],struct nlattr *data[])
@@ -154,6 +155,19 @@ static int bond_changelink(struct net_device *bond_dev,if (err)return err; } +if (data[IFLA_BOND_PRIMARY ]) { +int ifindex =nla_get_u32 (data[IFLA_BOND_PRIMARY ]); +struct net_device *dev; +char *primary ="" ; + + dev =__dev_get_by_index (dev_net (bond_dev), ifindex); +if (dev) + primary = dev->name; + + err =bond_option_primary_set (bond, primary); +if (err) +return err; + }return 0 ; }
@@ -182,6 +196,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)nla_total_size (sizeof (u32)) *BOND_MAX_ARP_TARGETS +nla_total_size (sizeof (u32)) +/* IFLA_BOND_ARP_VALIDATE */ nla_total_size (sizeof (u32)) +/* IFLA_BOND_ARP_ALL_TARGETS */ +nla_total_size (sizeof (u32)) +/* IFLA_BOND_PRIMARY */ 0 ; }
@@ -241,6 +256,11 @@ static int bond_fill_info(struct sk_buff *skb, bond->params.arp_all_targets)) goto nla_put_failure; +if (bond->primary_slave && +nla_put_u32 (skb,IFLA_BOND_PRIMARY , + bond->primary_slave->dev->ifindex)) + goto nla_put_failure; +return 0 ; nla_put_failure:
drivers/net/bonding/bond_options.c +52 -0
55 lines not on this page · raw message
drivers/net/bonding/bond_sysfs.c +9 -43
65 lines not on this page · raw message
drivers/net/bonding/bonding.h +1 -0
@@ -454,6 +454,7 @@ int bond_option_arp_ip_target_add(struct bonding *bond, __be32 target);int bond_option_arp_ip_target_rem (struct bonding *bond,__be32 target);int bond_option_arp_validate_set (struct bonding *bond,int arp_validate);int bond_option_arp_all_targets_set (struct bonding *bond,int arp_all_targets); +int bond_option_primary_set (struct bonding *bond,const char *primary);struct net_device *bond_option_active_slave_get_rcu (struct bonding *bond);struct net_device *bond_option_active_slave_get (struct bonding *bond);
include/uapi/linux/if_link.h +1 -0
@@ -339,6 +339,7 @@ enum {IFLA_BOND_ARP_IP_TARGET ,IFLA_BOND_ARP_VALIDATE ,IFLA_BOND_ARP_ALL_TARGETS , +IFLA_BOND_PRIMARY , __IFLA_BOND_MAX, };