bonding: add arp_ip_target netlink support
Subsystems (3)
PATCH v2 6/8 bonding: add arp_ip_target netlink support
Add IFLA_BOND_ARP_IP_TARGET to allow get/set of bonding parameter arp_ip_target via netlink.
Signed-off-by Scott Feldman <[email protected]>
--- drivers/net/bonding/bond_netlink.c | 36 ++++++++++ drivers/net/bonding/bond_options.c | 130 ++++++++++++++++++++++++++++++++++++ drivers/net/bonding/bond_sysfs.c | 84 ++++------------------- drivers/net/bonding/bonding.h | 4 + include/uapi/linux/if_link.h | 1 5 files changed, 187 insertions(+), 68 deletions(-)
drivers/net/bonding/bond_netlink.c +36 -0
@@ -29,6 +29,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_DOWNDELAY] = { .type = NLA_U32 }, [IFLA_BOND_USE_CARRIER] = { .type = NLA_U8 }, [IFLA_BOND_ARP_INTERVAL] = { .type = NLA_U32 }, + [IFLA_BOND_ARP_IP_TARGET] = { .type = NLA_NESTED }, };static int bond_validate (struct nlattr *tb[],struct nlattr *data[])
@@ -116,6 +117,20 @@ static int bond_changelink(struct net_device *bond_dev,if (err)return err; } +if (data[IFLA_BOND_ARP_IP_TARGET ]) { +__be32 targets[BOND_MAX_ARP_TARGETS ] = {0 , }; +struct nlattr *attr; +int i =0 , rem; + +nla_for_each_nested (attr, data[IFLA_BOND_ARP_IP_TARGET ], rem) { +__be32 target =nla_get_u32 (attr); + targets[i++] = target; + } + + err =bond_option_arp_ip_targets_set (bond, targets, i); +if (err) +return err; + }return 0 ; }
@@ -140,6 +155,8 @@ static size_t bond_get_size(const struct net_device *bond_dev)nla_total_size (sizeof (u32)) +/* IFLA_BOND_DOWNDELAY */ nla_total_size (sizeof (u8)) +/* IFLA_BOND_USE_CARRIER */ nla_total_size (sizeof (u32)) +/* IFLA_BOND_ARP_INTERVAL */ +/* IFLA_BOND_ARP_IP_TARGET */ +nla_total_size (sizeof (u32)) *BOND_MAX_ARP_TARGETS +0 ; }
@@ -148,6 +165,8 @@ static int bond_fill_info(struct sk_buff *skb, {struct bonding *bond =netdev_priv (bond_dev);struct net_device *slave_dev =bond_option_active_slave_get (bond); +struct nlattr *targets; +int i, targets_added;if (nla_put_u8 (skb,IFLA_BOND_MODE , bond->params.mode)) goto nla_put_failure;
@@ -173,6 +192,23 @@ static int bond_fill_info(struct sk_buff *skb,if (nla_put_u32 (skb,IFLA_BOND_ARP_INTERVAL , bond->params.arp_interval)) goto nla_put_failure; + targets =nla_nest_start (skb,IFLA_BOND_ARP_IP_TARGET ); +if (!targets) + goto nla_put_failure; + + targets_added =0 ; +for (i =0 ; i <BOND_MAX_ARP_TARGETS ; i++) { +if (bond->params.arp_targets[i]) { +nla_put_u32 (skb, i, bond->params.arp_targets[i]); + targets_added =1 ; + } + } + +if (targets_added) +nla_nest_end (skb, targets); +else +nla_nest_cancel (skb, targets); +return 0 ; nla_put_failure:
drivers/net/bonding/bond_options.c +130 -0
133 lines not on this page · raw message
drivers/net/bonding/bond_sysfs.c +16 -68
97 lines not on this page · raw message
drivers/net/bonding/bonding.h +4 -0
@@ -444,6 +444,10 @@ int bond_option_updelay_set(struct bonding *bond, int updelay);int bond_option_downdelay_set (struct bonding *bond,int downdelay);int bond_option_use_carrier_set (struct bonding *bond,int use_carrier);int bond_option_arp_interval_set (struct bonding *bond,int arp_interval); +int bond_option_arp_ip_targets_set (struct bonding *bond,__be32 *targets, +int count); +int bond_option_arp_ip_target_add (struct bonding *bond,__be32 target); +int bond_option_arp_ip_target_rem (struct bonding *bond,__be32 target);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
@@ -336,6 +336,7 @@ enum {IFLA_BOND_DOWNDELAY ,IFLA_BOND_USE_CARRIER ,IFLA_BOND_ARP_INTERVAL , +IFLA_BOND_ARP_IP_TARGET , __IFLA_BOND_MAX, };
Quoted 4 lines · Thu, Dec 12, 2013 at 11:10:31PM CET, [email protected] wrote:
Add
IFLA_BOND_ARP_IP_TARGETto allow get/set of bonding parameterarp_ip_targetvia netlink.Signed-off-by Scott Feldman <[email protected]>
Signed-off-by Jiri Pirko <[email protected]>
Quoted 8 lines
---
drivers/net/bonding/bond_netlink.c | 36 ++++++++++ drivers/net/bonding/bond_options.c | 130 ++++++++++++++++++++++++++++++++++++ drivers/net/bonding/bond_sysfs.c | 84 ++++------------------- drivers/net/bonding/bonding.h | 4 + include/uapi/linux/if_link.h | 1 5 files changed, 187 insertions(+), 68 deletions(-)