diff options
| author | sfeldma@cumulusnetworks.com <sfeldma@cumulusnetworks.com> | 2013-12-12 17:10:16 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-12-14 01:07:31 -0500 |
| commit | 9f53e14e86c46a2300f17309f6308ad0dfbb53ff (patch) | |
| tree | bda5f3e1cbfbd344957aead32c7547091fb461ac | |
| parent | c7461f9bf5a11bf88fdbd05b26c6d55b77dcd46d (diff) | |
bonding: add use_carrier netlink support
Add IFLA_BOND_USE_CARRIER to allow get/set of bonding parameter
use_carrier via netlink.
Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/bonding/bond_netlink.c | 12 | ||||
| -rw-r--r-- | drivers/net/bonding/bond_options.c | 14 | ||||
| -rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 24 | ||||
| -rw-r--r-- | drivers/net/bonding/bonding.h | 1 | ||||
| -rw-r--r-- | include/uapi/linux/if_link.h | 1 |
5 files changed, 39 insertions, 13 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index a0a2e8c32fe5..7edf6399cea2 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
| @@ -27,6 +27,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { | |||
| 27 | [IFLA_BOND_MIIMON] = { .type = NLA_U32 }, | 27 | [IFLA_BOND_MIIMON] = { .type = NLA_U32 }, |
| 28 | [IFLA_BOND_UPDELAY] = { .type = NLA_U32 }, | 28 | [IFLA_BOND_UPDELAY] = { .type = NLA_U32 }, |
| 29 | [IFLA_BOND_DOWNDELAY] = { .type = NLA_U32 }, | 29 | [IFLA_BOND_DOWNDELAY] = { .type = NLA_U32 }, |
| 30 | [IFLA_BOND_USE_CARRIER] = { .type = NLA_U8 }, | ||
| 30 | }; | 31 | }; |
| 31 | 32 | ||
| 32 | static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) | 33 | static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) |
| @@ -93,6 +94,13 @@ static int bond_changelink(struct net_device *bond_dev, | |||
| 93 | if (err) | 94 | if (err) |
| 94 | return err; | 95 | return err; |
| 95 | } | 96 | } |
| 97 | if (data[IFLA_BOND_USE_CARRIER]) { | ||
| 98 | int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]); | ||
| 99 | |||
| 100 | err = bond_option_use_carrier_set(bond, use_carrier); | ||
| 101 | if (err) | ||
| 102 | return err; | ||
| 103 | } | ||
| 96 | return 0; | 104 | return 0; |
| 97 | } | 105 | } |
| 98 | 106 | ||
| @@ -115,6 +123,7 @@ static size_t bond_get_size(const struct net_device *bond_dev) | |||
| 115 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_MIIMON */ | 123 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_MIIMON */ |
| 116 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_UPDELAY */ | 124 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_UPDELAY */ |
| 117 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_DOWNDELAY */ | 125 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_DOWNDELAY */ |
| 126 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_USE_CARRIER */ | ||
| 118 | 0; | 127 | 0; |
| 119 | } | 128 | } |
| 120 | 129 | ||
| @@ -142,6 +151,9 @@ static int bond_fill_info(struct sk_buff *skb, | |||
| 142 | bond->params.downdelay * bond->params.miimon)) | 151 | bond->params.downdelay * bond->params.miimon)) |
| 143 | goto nla_put_failure; | 152 | goto nla_put_failure; |
| 144 | 153 | ||
| 154 | if (nla_put_u8(skb, IFLA_BOND_USE_CARRIER, bond->params.use_carrier)) | ||
| 155 | goto nla_put_failure; | ||
| 156 | |||
| 145 | return 0; | 157 | return 0; |
| 146 | 158 | ||
| 147 | nla_put_failure: | 159 | nla_put_failure: |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 2914d649ee34..6fc7bbf0b85f 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
| @@ -245,3 +245,17 @@ int bond_option_downdelay_set(struct bonding *bond, int downdelay) | |||
| 245 | 245 | ||
| 246 | return 0; | 246 | return 0; |
| 247 | } | 247 | } |
| 248 | |||
| 249 | int bond_option_use_carrier_set(struct bonding *bond, int use_carrier) | ||
| 250 | { | ||
| 251 | if ((use_carrier == 0) || (use_carrier == 1)) { | ||
| 252 | bond->params.use_carrier = use_carrier; | ||
| 253 | pr_info("%s: Setting use_carrier to %d.\n", | ||
| 254 | bond->dev->name, use_carrier); | ||
| 255 | } else { | ||
| 256 | pr_info("%s: Ignoring invalid use_carrier value %d.\n", | ||
| 257 | bond->dev->name, use_carrier); | ||
| 258 | } | ||
| 259 | |||
| 260 | return 0; | ||
| 261 | } | ||
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index bec20bc08d31..114760af9a6d 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
| @@ -1097,25 +1097,23 @@ static ssize_t bonding_store_carrier(struct device *d, | |||
| 1097 | struct device_attribute *attr, | 1097 | struct device_attribute *attr, |
| 1098 | const char *buf, size_t count) | 1098 | const char *buf, size_t count) |
| 1099 | { | 1099 | { |
| 1100 | int new_value, ret = count; | 1100 | int new_value, ret; |
| 1101 | struct bonding *bond = to_bond(d); | 1101 | struct bonding *bond = to_bond(d); |
| 1102 | 1102 | ||
| 1103 | |||
| 1104 | if (sscanf(buf, "%d", &new_value) != 1) { | 1103 | if (sscanf(buf, "%d", &new_value) != 1) { |
| 1105 | pr_err("%s: no use_carrier value specified.\n", | 1104 | pr_err("%s: no use_carrier value specified.\n", |
| 1106 | bond->dev->name); | 1105 | bond->dev->name); |
| 1107 | ret = -EINVAL; | 1106 | return -EINVAL; |
| 1108 | goto out; | ||
| 1109 | } | ||
| 1110 | if ((new_value == 0) || (new_value == 1)) { | ||
| 1111 | bond->params.use_carrier = new_value; | ||
| 1112 | pr_info("%s: Setting use_carrier to %d.\n", | ||
| 1113 | bond->dev->name, new_value); | ||
| 1114 | } else { | ||
| 1115 | pr_info("%s: Ignoring invalid use_carrier value %d.\n", | ||
| 1116 | bond->dev->name, new_value); | ||
| 1117 | } | 1107 | } |
| 1118 | out: | 1108 | |
| 1109 | if (!rtnl_trylock()) | ||
| 1110 | return restart_syscall(); | ||
| 1111 | |||
| 1112 | ret = bond_option_use_carrier_set(bond, new_value); | ||
| 1113 | if (!ret) | ||
| 1114 | ret = count; | ||
| 1115 | |||
| 1116 | rtnl_unlock(); | ||
| 1119 | return ret; | 1117 | return ret; |
| 1120 | } | 1118 | } |
| 1121 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, | 1119 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index f5749b18d168..df159da8db30 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
| @@ -442,6 +442,7 @@ int bond_option_active_slave_set(struct bonding *bond, struct net_device *slave_ | |||
| 442 | int bond_option_miimon_set(struct bonding *bond, int miimon); | 442 | int bond_option_miimon_set(struct bonding *bond, int miimon); |
| 443 | int bond_option_updelay_set(struct bonding *bond, int updelay); | 443 | int bond_option_updelay_set(struct bonding *bond, int updelay); |
| 444 | int bond_option_downdelay_set(struct bonding *bond, int downdelay); | 444 | int bond_option_downdelay_set(struct bonding *bond, int downdelay); |
| 445 | int bond_option_use_carrier_set(struct bonding *bond, int use_carrier); | ||
| 445 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); | 446 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); |
| 446 | struct net_device *bond_option_active_slave_get(struct bonding *bond); | 447 | struct net_device *bond_option_active_slave_get(struct bonding *bond); |
| 447 | 448 | ||
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index f95506777710..77c41bda36a4 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h | |||
| @@ -334,6 +334,7 @@ enum { | |||
| 334 | IFLA_BOND_MIIMON, | 334 | IFLA_BOND_MIIMON, |
| 335 | IFLA_BOND_UPDELAY, | 335 | IFLA_BOND_UPDELAY, |
| 336 | IFLA_BOND_DOWNDELAY, | 336 | IFLA_BOND_DOWNDELAY, |
| 337 | IFLA_BOND_USE_CARRIER, | ||
| 337 | __IFLA_BOND_MAX, | 338 | __IFLA_BOND_MAX, |
| 338 | }; | 339 | }; |
| 339 | 340 | ||
