bonding: add miimon netlink support
Subsystems (3)
PATCH v2 1/8 bonding: add miimon netlink support
Add IFLA_BOND_MIIMON to allow get/set of bonding parameter miimon via netlink.
Signed-off-by Scott Feldman <[email protected]>
--- drivers/net/bonding/bond_netlink.c | 32 ++++++++++++++++++---- drivers/net/bonding/bond_options.c | 42 +++++++++++++++++++++++++++++ drivers/net/bonding/bond_sysfs.c | 53 +++++++----------------------------- drivers/net/bonding/bonding.h | 1 + include/uapi/linux/if_link.h | 1 + 5 files changed, 80 insertions(+), 49 deletions(-)
drivers/net/bonding/bond_netlink.c +26 -6
@@ -1,6 +1,7 @@/* * drivers/net/bond/bond_netlink.c - Netlink interface for bonding * Copyright (c) 2013 Jiri Pirko <[email protected]> +* Copyright (c) 2013 Scott Feldman <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -23,6 +24,7 @@static const struct nla_policy bond_policy[IFLA_BOND_MAX +1 ] = { [IFLA_BOND_MODE ] = { .type =NLA_U8 }, [IFLA_BOND_ACTIVE_SLAVE ] = { .type =NLA_U32 }, + [IFLA_BOND_MIIMON ] = { .type =NLA_U32 }, };static int bond_validate (struct nlattr *tb[],struct nlattr *data[])
@@ -42,14 +44,17 @@ static int bond_changelink(struct net_device *bond_dev,struct bonding *bond =netdev_priv (bond_dev);int err; -if (data && data[IFLA_BOND_MODE ]) { +if (!data) +return 0 ; + +if (data[IFLA_BOND_MODE ]) {int mode =nla_get_u8 (data[IFLA_BOND_MODE ]); err =bond_option_mode_set (bond, mode);if (err)return err; } -if (data && data[IFLA_BOND_ACTIVE_SLAVE ]) { +if (data[IFLA_BOND_ACTIVE_SLAVE ]) {int ifindex =nla_get_u32 (data[IFLA_BOND_ACTIVE_SLAVE ]);struct net_device *slave_dev;
@@ -65,6 +70,13 @@ static int bond_changelink(struct net_device *bond_dev,if (err)return err; } +if (data[IFLA_BOND_MIIMON ]) { +int miimon =nla_get_u32 (data[IFLA_BOND_MIIMON ]); + + err =bond_option_miimon_set (bond, miimon); +if (err) +return err; + }return 0 ; }
@@ -83,7 +95,9 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev,static size_t bond_get_size (const struct net_device *bond_dev) {return nla_total_size (sizeof (u8)) +/* IFLA_BOND_MODE */ -nla_total_size (sizeof (u32));/* IFLA_BOND_ACTIVE_SLAVE */ +nla_total_size (sizeof (u32)) +/* IFLA_BOND_ACTIVE_SLAVE */ +nla_total_size (sizeof (u32)) +/* IFLA_BOND_MIIMON */ +0 ; } static int bond_fill_info(struct sk_buff *skb,
@@ -92,10 +106,16 @@ 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); -if (nla_put_u8 (skb,IFLA_BOND_MODE , bond->params.mode) || - (slave_dev && -nla_put_u32 (skb,IFLA_BOND_ACTIVE_SLAVE , slave_dev->ifindex))) +if (nla_put_u8 (skb,IFLA_BOND_MODE , bond->params.mode)) goto nla_put_failure; + +if (slave_dev && +nla_put_u32 (skb,IFLA_BOND_ACTIVE_SLAVE , slave_dev->ifindex)) + goto nla_put_failure; + +if (nla_put_u32 (skb,IFLA_BOND_MIIMON , bond->params.miimon)) + goto nla_put_failure; +return 0 ; nla_put_failure:
drivers/net/bonding/bond_options.c +42 -0
51 lines not on this page · raw message
drivers/net/bonding/bond_sysfs.c +10 -43
65 lines not on this page · raw message
drivers/net/bonding/bonding.h +1 -0
@@ -439,6 +439,7 @@ int bond_netlink_init(void);void bond_netlink_fini (void );int bond_option_mode_set (struct bonding *bond,int mode);int bond_option_active_slave_set (struct bonding *bond,struct net_device *slave_dev); +int bond_option_miimon_set (struct bonding *bond,int miimon);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
@@ -331,6 +331,7 @@ enum {IFLA_BOND_UNSPEC ,IFLA_BOND_MODE ,IFLA_BOND_ACTIVE_SLAVE , +IFLA_BOND_MIIMON , __IFLA_BOND_MAX, };
Quoted 4 lines · Thu, Dec 12, 2013 at 11:09:55PM CET, [email protected] wrote:
Add
IFLA_BOND_MIIMONto allow get/set of bonding parameter miimon via netlink.Signed-off-by Scott Feldman <[email protected]>
Signed-off-by Jiri Pirko <[email protected]>
Quoted 8 lines
---
drivers/net/bonding/bond_netlink.c | 32 ++++++++++++++++++---- drivers/net/bonding/bond_options.c | 42 +++++++++++++++++++++++++++++ drivers/net/bonding/bond_sysfs.c | 53 +++++++----------------------------- drivers/net/bonding/bonding.h | 1 + include/uapi/linux/if_link.h | 1 + 5 files changed, 80 insertions(+), 49 deletions(-)