Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright(c) 2004-2005 Intel Corporation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along |
| 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | * |
| 18 | * The full GNU General Public License is included in this distribution in the |
| 19 | * file called LICENSE. |
| 20 | * |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 21 | */ |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 22 | |
| 23 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 24 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 25 | #include <linux/kernel.h> |
| 26 | #include <linux/module.h> |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 27 | #include <linux/device.h> |
Alexey Dobriyan | d43c36d | 2009-10-07 17:09:06 +0400 | [diff] [blame] | 28 | #include <linux/sched.h> |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 29 | #include <linux/fs.h> |
| 30 | #include <linux/types.h> |
| 31 | #include <linux/string.h> |
| 32 | #include <linux/netdevice.h> |
| 33 | #include <linux/inetdevice.h> |
| 34 | #include <linux/in.h> |
| 35 | #include <linux/sysfs.h> |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 36 | #include <linux/ctype.h> |
| 37 | #include <linux/inet.h> |
| 38 | #include <linux/rtnetlink.h> |
Stephen Hemminger | 5c5129b | 2009-06-12 19:02:51 +0000 | [diff] [blame] | 39 | #include <linux/etherdevice.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 40 | #include <net/net_namespace.h> |
Eric W. Biederman | ec87fd3 | 2009-10-29 14:18:26 +0000 | [diff] [blame] | 41 | #include <net/netns/generic.h> |
| 42 | #include <linux/nsproxy.h> |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 43 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 44 | #include "bonding.h" |
Holger Eitzenberger | 5a03cdb | 2008-12-09 23:09:22 -0800 | [diff] [blame] | 45 | |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 46 | #define to_dev(obj) container_of(obj, struct device, kobj) |
Wang Chen | 454d7c9 | 2008-11-12 23:37:49 -0800 | [diff] [blame] | 47 | #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd)))) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 48 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 49 | /* |
| 50 | * "show" function for the bond_masters attribute. |
| 51 | * The class parameter is ignored. |
| 52 | */ |
Andi Kleen | 28812fe | 2010-01-05 12:48:07 +0100 | [diff] [blame] | 53 | static ssize_t bonding_show_bonds(struct class *cls, |
| 54 | struct class_attribute *attr, |
| 55 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 56 | { |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 57 | struct bond_net *bn = |
| 58 | container_of(attr, struct bond_net, class_attr_bonding_masters); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 59 | int res = 0; |
| 60 | struct bonding *bond; |
| 61 | |
Stephen Hemminger | 7e08384 | 2009-06-12 19:02:46 +0000 | [diff] [blame] | 62 | rtnl_lock(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 63 | |
Eric W. Biederman | ec87fd3 | 2009-10-29 14:18:26 +0000 | [diff] [blame] | 64 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 65 | if (res > (PAGE_SIZE - IFNAMSIZ)) { |
| 66 | /* not enough space for another interface name */ |
| 67 | if ((PAGE_SIZE - res) > 10) |
| 68 | res = PAGE_SIZE - 10; |
Wagner Ferenc | b884366 | 2007-12-06 23:40:30 -0800 | [diff] [blame] | 69 | res += sprintf(buf + res, "++more++ "); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 70 | break; |
| 71 | } |
Wagner Ferenc | b884366 | 2007-12-06 23:40:30 -0800 | [diff] [blame] | 72 | res += sprintf(buf + res, "%s ", bond->dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 73 | } |
Wagner Ferenc | 1dcdcd6 | 2007-12-06 23:40:31 -0800 | [diff] [blame] | 74 | if (res) |
| 75 | buf[res-1] = '\n'; /* eat the leftover space */ |
Stephen Hemminger | 7e08384 | 2009-06-12 19:02:46 +0000 | [diff] [blame] | 76 | |
| 77 | rtnl_unlock(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 78 | return res; |
| 79 | } |
| 80 | |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 81 | static struct net_device *bond_get_by_name(struct bond_net *bn, const char *ifname) |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 82 | { |
| 83 | struct bonding *bond; |
| 84 | |
Eric W. Biederman | ec87fd3 | 2009-10-29 14:18:26 +0000 | [diff] [blame] | 85 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 86 | if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0) |
| 87 | return bond->dev; |
| 88 | } |
| 89 | return NULL; |
| 90 | } |
| 91 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 92 | /* |
| 93 | * "store" function for the bond_masters attribute. This is what |
| 94 | * creates and deletes entire bonds. |
| 95 | * |
| 96 | * The class parameter is ignored. |
| 97 | * |
| 98 | */ |
| 99 | |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 100 | static ssize_t bonding_store_bonds(struct class *cls, |
Andi Kleen | 28812fe | 2010-01-05 12:48:07 +0100 | [diff] [blame] | 101 | struct class_attribute *attr, |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 102 | const char *buffer, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 103 | { |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 104 | struct bond_net *bn = |
| 105 | container_of(attr, struct bond_net, class_attr_bonding_masters); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 106 | char command[IFNAMSIZ + 1] = {0, }; |
| 107 | char *ifname; |
Jay Vosburgh | 027ea04 | 2008-01-17 16:25:02 -0800 | [diff] [blame] | 108 | int rv, res = count; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 109 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 110 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ |
| 111 | ifname = command + 1; |
| 112 | if ((strlen(command) <= 1) || |
| 113 | !dev_valid_name(ifname)) |
| 114 | goto err_no_cmd; |
| 115 | |
| 116 | if (command[0] == '+') { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 117 | pr_info("%s is being created...\n", ifname); |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 118 | rv = bond_create(bn->net, ifname); |
Jay Vosburgh | 027ea04 | 2008-01-17 16:25:02 -0800 | [diff] [blame] | 119 | if (rv) { |
Phil Oester | 5f86cad1 | 2011-03-14 06:22:06 +0000 | [diff] [blame] | 120 | if (rv == -EEXIST) |
| 121 | pr_info("%s already exists.\n", ifname); |
| 122 | else |
| 123 | pr_info("%s creation failed.\n", ifname); |
Jay Vosburgh | 027ea04 | 2008-01-17 16:25:02 -0800 | [diff] [blame] | 124 | res = rv; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 125 | } |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 126 | } else if (command[0] == '-') { |
| 127 | struct net_device *bond_dev; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 128 | |
Jay Vosburgh | 027ea04 | 2008-01-17 16:25:02 -0800 | [diff] [blame] | 129 | rtnl_lock(); |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 130 | bond_dev = bond_get_by_name(bn, ifname); |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 131 | if (bond_dev) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 132 | pr_info("%s is being deleted...\n", ifname); |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 133 | unregister_netdevice(bond_dev); |
| 134 | } else { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 135 | pr_err("unable to delete non-existent %s\n", ifname); |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 136 | res = -ENODEV; |
| 137 | } |
| 138 | rtnl_unlock(); |
| 139 | } else |
| 140 | goto err_no_cmd; |
Jay Vosburgh | 027ea04 | 2008-01-17 16:25:02 -0800 | [diff] [blame] | 141 | |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 142 | /* Always return either count or an error. If you return 0, you'll |
| 143 | * get called forever, which is bad. |
| 144 | */ |
| 145 | return res; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 146 | |
| 147 | err_no_cmd: |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 148 | pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n"); |
Jay Vosburgh | c4ebc66 | 2008-05-02 17:49:38 -0700 | [diff] [blame] | 149 | return -EPERM; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 150 | } |
Stephen Hemminger | 373500d | 2009-06-12 19:02:50 +0000 | [diff] [blame] | 151 | |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 152 | static const void *bonding_namespace(struct class *cls, |
| 153 | const struct class_attribute *attr) |
| 154 | { |
| 155 | const struct bond_net *bn = |
| 156 | container_of(attr, struct bond_net, class_attr_bonding_masters); |
| 157 | return bn->net; |
| 158 | } |
| 159 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 160 | /* class attribute for bond_masters file. This ends up in /sys/class/net */ |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 161 | static const struct class_attribute class_attr_bonding_masters = { |
| 162 | .attr = { |
| 163 | .name = "bonding_masters", |
| 164 | .mode = S_IWUSR | S_IRUGO, |
| 165 | }, |
| 166 | .show = bonding_show_bonds, |
| 167 | .store = bonding_store_bonds, |
| 168 | .namespace = bonding_namespace, |
| 169 | }; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 170 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 171 | /* |
| 172 | * Show the slaves in the current bond. |
| 173 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 174 | static ssize_t bonding_show_slaves(struct device *d, |
| 175 | struct device_attribute *attr, char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 176 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 177 | struct bonding *bond = to_bond(d); |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 178 | struct list_head *iter; |
nikolay@redhat.com | dec1e90 | 2013-08-01 16:54:47 +0200 | [diff] [blame] | 179 | struct slave *slave; |
| 180 | int res = 0; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 181 | |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 182 | if (!rtnl_trylock()) |
| 183 | return restart_syscall(); |
| 184 | |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 185 | bond_for_each_slave(bond, slave, iter) { |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 186 | if (res > (PAGE_SIZE - IFNAMSIZ)) { |
| 187 | /* not enough space for another interface name */ |
| 188 | if ((PAGE_SIZE - res) > 10) |
| 189 | res = PAGE_SIZE - 10; |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 190 | res += sprintf(buf + res, "++more++ "); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 191 | break; |
| 192 | } |
| 193 | res += sprintf(buf + res, "%s ", slave->dev->name); |
| 194 | } |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 195 | |
| 196 | rtnl_unlock(); |
| 197 | |
Wagner Ferenc | 1dcdcd6 | 2007-12-06 23:40:31 -0800 | [diff] [blame] | 198 | if (res) |
| 199 | buf[res-1] = '\n'; /* eat the leftover space */ |
nikolay@redhat.com | dec1e90 | 2013-08-01 16:54:47 +0200 | [diff] [blame] | 200 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 201 | return res; |
| 202 | } |
| 203 | |
| 204 | /* |
Veaceslav Falico | d6641cc | 2013-05-28 01:26:13 +0000 | [diff] [blame] | 205 | * Set the slaves in the current bond. |
Jiri Pirko | f9f3545 | 2010-05-18 05:46:39 +0000 | [diff] [blame] | 206 | * This is supposed to be only thin wrapper for bond_enslave and bond_release. |
| 207 | * All hard work should be done there. |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 208 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 209 | static ssize_t bonding_store_slaves(struct device *d, |
| 210 | struct device_attribute *attr, |
| 211 | const char *buffer, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 212 | { |
| 213 | char command[IFNAMSIZ + 1] = { 0, }; |
| 214 | char *ifname; |
Jiri Pirko | f9f3545 | 2010-05-18 05:46:39 +0000 | [diff] [blame] | 215 | int res, ret = count; |
| 216 | struct net_device *dev; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 217 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 218 | |
Eric W. Biederman | 496a60c | 2009-05-13 17:02:50 +0000 | [diff] [blame] | 219 | if (!rtnl_trylock()) |
| 220 | return restart_syscall(); |
Jay Vosburgh | 027ea04 | 2008-01-17 16:25:02 -0800 | [diff] [blame] | 221 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 222 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ |
| 223 | ifname = command + 1; |
| 224 | if ((strlen(command) <= 1) || |
| 225 | !dev_valid_name(ifname)) |
| 226 | goto err_no_cmd; |
| 227 | |
Jiri Pirko | f9f3545 | 2010-05-18 05:46:39 +0000 | [diff] [blame] | 228 | dev = __dev_get_by_name(dev_net(bond->dev), ifname); |
| 229 | if (!dev) { |
| 230 | pr_info("%s: Interface %s does not exist!\n", |
| 231 | bond->dev->name, ifname); |
| 232 | ret = -ENODEV; |
| 233 | goto out; |
| 234 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 235 | |
Jiri Pirko | f9f3545 | 2010-05-18 05:46:39 +0000 | [diff] [blame] | 236 | switch (command[0]) { |
| 237 | case '+': |
| 238 | pr_info("%s: Adding slave %s.\n", bond->dev->name, dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 239 | res = bond_enslave(bond->dev, dev); |
Jiri Pirko | f9f3545 | 2010-05-18 05:46:39 +0000 | [diff] [blame] | 240 | break; |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 241 | |
Jiri Pirko | f9f3545 | 2010-05-18 05:46:39 +0000 | [diff] [blame] | 242 | case '-': |
| 243 | pr_info("%s: Removing slave %s.\n", bond->dev->name, dev->name); |
| 244 | res = bond_release(bond->dev, dev); |
| 245 | break; |
| 246 | |
| 247 | default: |
| 248 | goto err_no_cmd; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Jiri Pirko | f9f3545 | 2010-05-18 05:46:39 +0000 | [diff] [blame] | 251 | if (res) |
| 252 | ret = res; |
| 253 | goto out; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 254 | |
| 255 | err_no_cmd: |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 256 | pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n", |
| 257 | bond->dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 258 | ret = -EPERM; |
| 259 | |
| 260 | out: |
Jay Vosburgh | 027ea04 | 2008-01-17 16:25:02 -0800 | [diff] [blame] | 261 | rtnl_unlock(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 262 | return ret; |
| 263 | } |
| 264 | |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 265 | static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, |
| 266 | bonding_store_slaves); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 267 | |
| 268 | /* |
| 269 | * Show and set the bonding mode. The bond interface must be down to |
| 270 | * change the mode. |
| 271 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 272 | static ssize_t bonding_show_mode(struct device *d, |
| 273 | struct device_attribute *attr, char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 274 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 275 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 276 | |
| 277 | return sprintf(buf, "%s %d\n", |
| 278 | bond_mode_tbl[bond->params.mode].modename, |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 279 | bond->params.mode); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 280 | } |
| 281 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 282 | static ssize_t bonding_store_mode(struct device *d, |
| 283 | struct device_attribute *attr, |
| 284 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 285 | { |
Jiri Pirko | 72be35f | 2013-10-18 17:43:34 +0200 | [diff] [blame] | 286 | int new_value, ret; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 287 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 288 | |
Jay Vosburgh | ece95f7 | 2008-01-17 16:25:01 -0800 | [diff] [blame] | 289 | new_value = bond_parse_parm(buf, bond_mode_tbl); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 290 | if (new_value < 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 291 | pr_err("%s: Ignoring invalid mode value %.*s.\n", |
| 292 | bond->dev->name, (int)strlen(buf) - 1, buf); |
Jiri Pirko | 72be35f | 2013-10-18 17:43:34 +0200 | [diff] [blame] | 293 | return -EINVAL; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 294 | } |
Jiri Pirko | 72be35f | 2013-10-18 17:43:34 +0200 | [diff] [blame] | 295 | if (!rtnl_trylock()) |
| 296 | return restart_syscall(); |
| 297 | |
| 298 | ret = bond_option_mode_set(bond, new_value); |
| 299 | if (!ret) { |
| 300 | pr_info("%s: setting mode to %s (%d).\n", |
| 301 | bond->dev->name, bond_mode_tbl[new_value].modename, |
| 302 | new_value); |
| 303 | ret = count; |
Andy Gospodarek | c5cb002 | 2010-07-28 15:13:56 +0000 | [diff] [blame] | 304 | } |
Andy Gospodarek | c5cb002 | 2010-07-28 15:13:56 +0000 | [diff] [blame] | 305 | |
nikolay@redhat.com | ea6836d | 2013-05-18 01:18:28 +0000 | [diff] [blame] | 306 | rtnl_unlock(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 307 | return ret; |
| 308 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 309 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, |
| 310 | bonding_show_mode, bonding_store_mode); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 311 | |
| 312 | /* |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 313 | * Show and set the bonding transmit hash method. |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 314 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 315 | static ssize_t bonding_show_xmit_hash(struct device *d, |
| 316 | struct device_attribute *attr, |
| 317 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 318 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 319 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 320 | |
Wagner Ferenc | 8e4b932 | 2007-12-06 23:40:32 -0800 | [diff] [blame] | 321 | return sprintf(buf, "%s %d\n", |
| 322 | xmit_hashtype_tbl[bond->params.xmit_policy].modename, |
| 323 | bond->params.xmit_policy); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 324 | } |
| 325 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 326 | static ssize_t bonding_store_xmit_hash(struct device *d, |
| 327 | struct device_attribute *attr, |
| 328 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 329 | { |
| 330 | int new_value, ret = count; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 331 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 332 | |
Jay Vosburgh | ece95f7 | 2008-01-17 16:25:01 -0800 | [diff] [blame] | 333 | new_value = bond_parse_parm(buf, xmit_hashtype_tbl); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 334 | if (new_value < 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 335 | pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 336 | bond->dev->name, |
| 337 | (int)strlen(buf) - 1, buf); |
| 338 | ret = -EINVAL; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 339 | } else { |
| 340 | bond->params.xmit_policy = new_value; |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 341 | pr_info("%s: setting xmit hash policy to %s (%d).\n", |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 342 | bond->dev->name, |
| 343 | xmit_hashtype_tbl[new_value].modename, new_value); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 344 | } |
Nikolay Aleksandrov | 53edee2 | 2013-05-24 00:59:47 +0000 | [diff] [blame] | 345 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 346 | return ret; |
| 347 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 348 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, |
| 349 | bonding_show_xmit_hash, bonding_store_xmit_hash); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 350 | |
| 351 | /* |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 352 | * Show and set arp_validate. |
| 353 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 354 | static ssize_t bonding_show_arp_validate(struct device *d, |
| 355 | struct device_attribute *attr, |
| 356 | char *buf) |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 357 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 358 | struct bonding *bond = to_bond(d); |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 359 | |
| 360 | return sprintf(buf, "%s %d\n", |
| 361 | arp_validate_tbl[bond->params.arp_validate].modename, |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 362 | bond->params.arp_validate); |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 365 | static ssize_t bonding_store_arp_validate(struct device *d, |
| 366 | struct device_attribute *attr, |
| 367 | const char *buf, size_t count) |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 368 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 369 | struct bonding *bond = to_bond(d); |
nikolay@redhat.com | 5bb9e0b | 2013-09-07 00:00:26 +0200 | [diff] [blame] | 370 | int new_value, ret = count; |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 371 | |
nikolay@redhat.com | 5c5038d | 2013-09-07 00:00:25 +0200 | [diff] [blame] | 372 | if (!rtnl_trylock()) |
| 373 | return restart_syscall(); |
Jay Vosburgh | ece95f7 | 2008-01-17 16:25:01 -0800 | [diff] [blame] | 374 | new_value = bond_parse_parm(buf, arp_validate_tbl); |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 375 | if (new_value < 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 376 | pr_err("%s: Ignoring invalid arp_validate value %s\n", |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 377 | bond->dev->name, buf); |
nikolay@redhat.com | 5c5038d | 2013-09-07 00:00:25 +0200 | [diff] [blame] | 378 | ret = -EINVAL; |
| 379 | goto out; |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 380 | } |
nikolay@redhat.com | 5bb9e0b | 2013-09-07 00:00:26 +0200 | [diff] [blame] | 381 | if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 382 | pr_err("%s: arp_validate only supported in active-backup mode.\n", |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 383 | bond->dev->name); |
nikolay@redhat.com | 5c5038d | 2013-09-07 00:00:25 +0200 | [diff] [blame] | 384 | ret = -EINVAL; |
| 385 | goto out; |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 386 | } |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 387 | pr_info("%s: setting arp_validate to %s (%d).\n", |
| 388 | bond->dev->name, arp_validate_tbl[new_value].modename, |
| 389 | new_value); |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 390 | |
nikolay@redhat.com | 5bb9e0b | 2013-09-07 00:00:26 +0200 | [diff] [blame] | 391 | if (bond->dev->flags & IFF_UP) { |
| 392 | if (!new_value) |
| 393 | bond->recv_probe = NULL; |
| 394 | else if (bond->params.arp_interval) |
| 395 | bond->recv_probe = bond_arp_rcv; |
| 396 | } |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 397 | bond->params.arp_validate = new_value; |
nikolay@redhat.com | 5c5038d | 2013-09-07 00:00:25 +0200 | [diff] [blame] | 398 | out: |
| 399 | rtnl_unlock(); |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 400 | |
nikolay@redhat.com | 5c5038d | 2013-09-07 00:00:25 +0200 | [diff] [blame] | 401 | return ret; |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 404 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, |
| 405 | bonding_store_arp_validate); |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 406 | /* |
| 407 | * Show and set arp_all_targets. |
| 408 | */ |
| 409 | static ssize_t bonding_show_arp_all_targets(struct device *d, |
| 410 | struct device_attribute *attr, |
| 411 | char *buf) |
| 412 | { |
| 413 | struct bonding *bond = to_bond(d); |
| 414 | int value = bond->params.arp_all_targets; |
| 415 | |
| 416 | return sprintf(buf, "%s %d\n", arp_all_targets_tbl[value].modename, |
| 417 | value); |
| 418 | } |
| 419 | |
| 420 | static ssize_t bonding_store_arp_all_targets(struct device *d, |
| 421 | struct device_attribute *attr, |
| 422 | const char *buf, size_t count) |
| 423 | { |
| 424 | struct bonding *bond = to_bond(d); |
| 425 | int new_value; |
| 426 | |
| 427 | new_value = bond_parse_parm(buf, arp_all_targets_tbl); |
| 428 | if (new_value < 0) { |
| 429 | pr_err("%s: Ignoring invalid arp_all_targets value %s\n", |
| 430 | bond->dev->name, buf); |
| 431 | return -EINVAL; |
| 432 | } |
| 433 | pr_info("%s: setting arp_all_targets to %s (%d).\n", |
| 434 | bond->dev->name, arp_all_targets_tbl[new_value].modename, |
| 435 | new_value); |
| 436 | |
| 437 | bond->params.arp_all_targets = new_value; |
| 438 | |
| 439 | return count; |
| 440 | } |
| 441 | |
| 442 | static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR, |
| 443 | bonding_show_arp_all_targets, bonding_store_arp_all_targets); |
Jay Vosburgh | f5b2b96 | 2006-09-22 21:54:53 -0700 | [diff] [blame] | 444 | |
| 445 | /* |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 446 | * Show and store fail_over_mac. User only allowed to change the |
| 447 | * value when there are no slaves. |
| 448 | */ |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 449 | static ssize_t bonding_show_fail_over_mac(struct device *d, |
| 450 | struct device_attribute *attr, |
| 451 | char *buf) |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 452 | { |
| 453 | struct bonding *bond = to_bond(d); |
| 454 | |
Jay Vosburgh | 3915c1e8 | 2008-05-17 21:10:14 -0700 | [diff] [blame] | 455 | return sprintf(buf, "%s %d\n", |
| 456 | fail_over_mac_tbl[bond->params.fail_over_mac].modename, |
| 457 | bond->params.fail_over_mac); |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 460 | static ssize_t bonding_store_fail_over_mac(struct device *d, |
| 461 | struct device_attribute *attr, |
| 462 | const char *buf, size_t count) |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 463 | { |
dingtianhong | 9402b74 | 2013-07-23 15:25:39 +0800 | [diff] [blame] | 464 | int new_value, ret = count; |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 465 | struct bonding *bond = to_bond(d); |
| 466 | |
dingtianhong | 9402b74 | 2013-07-23 15:25:39 +0800 | [diff] [blame] | 467 | if (!rtnl_trylock()) |
| 468 | return restart_syscall(); |
| 469 | |
Veaceslav Falico | 0965a1f | 2013-09-25 09:20:21 +0200 | [diff] [blame] | 470 | if (bond_has_slaves(bond)) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 471 | pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n", |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 472 | bond->dev->name); |
dingtianhong | 9402b74 | 2013-07-23 15:25:39 +0800 | [diff] [blame] | 473 | ret = -EPERM; |
| 474 | goto out; |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 475 | } |
| 476 | |
Jay Vosburgh | 3915c1e8 | 2008-05-17 21:10:14 -0700 | [diff] [blame] | 477 | new_value = bond_parse_parm(buf, fail_over_mac_tbl); |
| 478 | if (new_value < 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 479 | pr_err("%s: Ignoring invalid fail_over_mac value %s.\n", |
Jay Vosburgh | 3915c1e8 | 2008-05-17 21:10:14 -0700 | [diff] [blame] | 480 | bond->dev->name, buf); |
dingtianhong | 9402b74 | 2013-07-23 15:25:39 +0800 | [diff] [blame] | 481 | ret = -EINVAL; |
| 482 | goto out; |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Jay Vosburgh | 3915c1e8 | 2008-05-17 21:10:14 -0700 | [diff] [blame] | 485 | bond->params.fail_over_mac = new_value; |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 486 | pr_info("%s: Setting fail_over_mac to %s (%d).\n", |
| 487 | bond->dev->name, fail_over_mac_tbl[new_value].modename, |
| 488 | new_value); |
Jay Vosburgh | 3915c1e8 | 2008-05-17 21:10:14 -0700 | [diff] [blame] | 489 | |
dingtianhong | 9402b74 | 2013-07-23 15:25:39 +0800 | [diff] [blame] | 490 | out: |
| 491 | rtnl_unlock(); |
| 492 | return ret; |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 495 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, |
| 496 | bonding_show_fail_over_mac, bonding_store_fail_over_mac); |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 497 | |
| 498 | /* |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 499 | * Show and set the arp timer interval. There are two tricky bits |
| 500 | * here. First, if ARP monitoring is activated, then we must disable |
| 501 | * MII monitoring. Second, if the ARP timer isn't running, we must |
| 502 | * start it. |
| 503 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 504 | static ssize_t bonding_show_arp_interval(struct device *d, |
| 505 | struct device_attribute *attr, |
| 506 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 507 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 508 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 509 | |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 510 | return sprintf(buf, "%d\n", bond->params.arp_interval); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 511 | } |
| 512 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 513 | static ssize_t bonding_store_arp_interval(struct device *d, |
| 514 | struct device_attribute *attr, |
| 515 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 516 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 517 | struct bonding *bond = to_bond(d); |
nikolay@redhat.com | 5bb9e0b | 2013-09-07 00:00:26 +0200 | [diff] [blame] | 518 | int new_value, ret = count; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 519 | |
nikolay@redhat.com | fbb0c41 | 2012-11-29 01:31:31 +0000 | [diff] [blame] | 520 | if (!rtnl_trylock()) |
| 521 | return restart_syscall(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 522 | if (sscanf(buf, "%d", &new_value) != 1) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 523 | pr_err("%s: no arp_interval value specified.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 524 | bond->dev->name); |
| 525 | ret = -EINVAL; |
| 526 | goto out; |
| 527 | } |
| 528 | if (new_value < 0) { |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 529 | pr_err("%s: Invalid arp_interval value %d not in range 0-%d; rejected.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 530 | bond->dev->name, new_value, INT_MAX); |
| 531 | ret = -EINVAL; |
| 532 | goto out; |
| 533 | } |
Andy Gospodarek | c5cb002 | 2010-07-28 15:13:56 +0000 | [diff] [blame] | 534 | if (bond->params.mode == BOND_MODE_ALB || |
| 535 | bond->params.mode == BOND_MODE_TLB) { |
| 536 | pr_info("%s: ARP monitoring cannot be used with ALB/TLB. Only MII monitoring is supported on %s.\n", |
| 537 | bond->dev->name, bond->dev->name); |
| 538 | ret = -EINVAL; |
| 539 | goto out; |
| 540 | } |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 541 | pr_info("%s: Setting ARP monitoring interval to %d.\n", |
| 542 | bond->dev->name, new_value); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 543 | bond->params.arp_interval = new_value; |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 544 | if (new_value) { |
| 545 | if (bond->params.miimon) { |
| 546 | pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", |
| 547 | bond->dev->name, bond->dev->name); |
| 548 | bond->params.miimon = 0; |
| 549 | } |
| 550 | if (!bond->params.arp_targets[0]) |
| 551 | pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", |
| 552 | bond->dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 553 | } |
| 554 | if (bond->dev->flags & IFF_UP) { |
| 555 | /* If the interface is up, we may need to fire off |
| 556 | * the ARP timer. If the interface is down, the |
| 557 | * timer will get fired off when the open function |
| 558 | * is called. |
| 559 | */ |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 560 | if (!new_value) { |
nikolay@redhat.com | 5bb9e0b | 2013-09-07 00:00:26 +0200 | [diff] [blame] | 561 | if (bond->params.arp_validate) |
| 562 | bond->recv_probe = NULL; |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 563 | cancel_delayed_work_sync(&bond->arp_work); |
| 564 | } else { |
nikolay@redhat.com | 5bb9e0b | 2013-09-07 00:00:26 +0200 | [diff] [blame] | 565 | /* arp_validate can be set only in active-backup mode */ |
| 566 | if (bond->params.arp_validate) |
| 567 | bond->recv_probe = bond_arp_rcv; |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 568 | cancel_delayed_work_sync(&bond->mii_work); |
| 569 | queue_delayed_work(bond->wq, &bond->arp_work, 0); |
| 570 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 571 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 572 | out: |
nikolay@redhat.com | fbb0c41 | 2012-11-29 01:31:31 +0000 | [diff] [blame] | 573 | rtnl_unlock(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 574 | return ret; |
| 575 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 576 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, |
| 577 | bonding_show_arp_interval, bonding_store_arp_interval); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 578 | |
| 579 | /* |
| 580 | * Show and set the arp targets. |
| 581 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 582 | static ssize_t bonding_show_arp_targets(struct device *d, |
| 583 | struct device_attribute *attr, |
| 584 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 585 | { |
| 586 | int i, res = 0; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 587 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 588 | |
| 589 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { |
| 590 | if (bond->params.arp_targets[i]) |
Harvey Harrison | 6377943 | 2008-10-31 00:56:00 -0700 | [diff] [blame] | 591 | res += sprintf(buf + res, "%pI4 ", |
| 592 | &bond->params.arp_targets[i]); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 593 | } |
Wagner Ferenc | 1dcdcd6 | 2007-12-06 23:40:31 -0800 | [diff] [blame] | 594 | if (res) |
| 595 | buf[res-1] = '\n'; /* eat the leftover space */ |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 596 | return res; |
| 597 | } |
| 598 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 599 | static ssize_t bonding_store_arp_targets(struct device *d, |
| 600 | struct device_attribute *attr, |
| 601 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 602 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 603 | struct bonding *bond = to_bond(d); |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 604 | struct list_head *iter; |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 605 | struct slave *slave; |
| 606 | __be32 newtarget, *targets; |
| 607 | unsigned long *targets_rx; |
| 608 | int ind, i, j, ret = -EINVAL; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 609 | |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 610 | if (!rtnl_trylock()) |
| 611 | return restart_syscall(); |
| 612 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 613 | targets = bond->params.arp_targets; |
| 614 | newtarget = in_aton(buf + 1); |
| 615 | /* look for adds */ |
| 616 | if (buf[0] == '+') { |
Al Viro | d3bb52b | 2007-08-22 20:06:58 -0400 | [diff] [blame] | 617 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 618 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", |
Harvey Harrison | 6377943 | 2008-10-31 00:56:00 -0700 | [diff] [blame] | 619 | bond->dev->name, &newtarget); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 620 | goto out; |
| 621 | } |
| 622 | |
Veaceslav Falico | 87a7b84 | 2013-06-24 11:49:29 +0200 | [diff] [blame] | 623 | if (bond_get_targets_ip(targets, newtarget) != -1) { /* dup */ |
| 624 | pr_err("%s: ARP target %pI4 is already present\n", |
| 625 | bond->dev->name, &newtarget); |
| 626 | goto out; |
| 627 | } |
| 628 | |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 629 | ind = bond_get_targets_ip(targets, 0); /* first free slot */ |
| 630 | if (ind == -1) { |
Veaceslav Falico | 87a7b84 | 2013-06-24 11:49:29 +0200 | [diff] [blame] | 631 | pr_err("%s: ARP target table is full!\n", |
| 632 | bond->dev->name); |
| 633 | goto out; |
| 634 | } |
| 635 | |
| 636 | pr_info("%s: adding ARP target %pI4.\n", bond->dev->name, |
| 637 | &newtarget); |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 638 | /* not to race with bond_arp_rcv */ |
| 639 | write_lock_bh(&bond->lock); |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 640 | bond_for_each_slave(bond, slave, iter) |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 641 | slave->target_last_arp_rx[ind] = jiffies; |
| 642 | targets[ind] = newtarget; |
| 643 | write_unlock_bh(&bond->lock); |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 644 | } else if (buf[0] == '-') { |
Al Viro | d3bb52b | 2007-08-22 20:06:58 -0400 | [diff] [blame] | 645 | if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 646 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", |
Harvey Harrison | 6377943 | 2008-10-31 00:56:00 -0700 | [diff] [blame] | 647 | bond->dev->name, &newtarget); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 648 | goto out; |
| 649 | } |
| 650 | |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 651 | ind = bond_get_targets_ip(targets, newtarget); |
| 652 | if (ind == -1) { |
| 653 | pr_err("%s: unable to remove nonexistent ARP target %pI4.\n", |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 654 | bond->dev->name, &newtarget); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 655 | goto out; |
| 656 | } |
Veaceslav Falico | 87a7b84 | 2013-06-24 11:49:29 +0200 | [diff] [blame] | 657 | |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 658 | if (ind == 0 && !targets[1] && bond->params.arp_interval) |
| 659 | pr_warn("%s: removing last arp target with arp_interval on\n", |
| 660 | bond->dev->name); |
| 661 | |
Veaceslav Falico | 87a7b84 | 2013-06-24 11:49:29 +0200 | [diff] [blame] | 662 | pr_info("%s: removing ARP target %pI4.\n", bond->dev->name, |
| 663 | &newtarget); |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 664 | |
| 665 | write_lock_bh(&bond->lock); |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 666 | bond_for_each_slave(bond, slave, iter) { |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 667 | targets_rx = slave->target_last_arp_rx; |
| 668 | j = ind; |
| 669 | for (; (j < BOND_MAX_ARP_TARGETS-1) && targets[j+1]; j++) |
| 670 | targets_rx[j] = targets_rx[j+1]; |
| 671 | targets_rx[j] = 0; |
| 672 | } |
| 673 | for (i = ind; (i < BOND_MAX_ARP_TARGETS-1) && targets[i+1]; i++) |
Veaceslav Falico | 87a7b84 | 2013-06-24 11:49:29 +0200 | [diff] [blame] | 674 | targets[i] = targets[i+1]; |
| 675 | targets[i] = 0; |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 676 | write_unlock_bh(&bond->lock); |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 677 | } else { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 678 | pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", |
| 679 | bond->dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 680 | ret = -EPERM; |
| 681 | goto out; |
| 682 | } |
| 683 | |
Veaceslav Falico | 87a7b84 | 2013-06-24 11:49:29 +0200 | [diff] [blame] | 684 | ret = count; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 685 | out: |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 686 | rtnl_unlock(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 687 | return ret; |
| 688 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 689 | static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 690 | |
| 691 | /* |
| 692 | * Show and set the up and down delays. These must be multiples of the |
| 693 | * MII monitoring value, and are stored internally as the multiplier. |
| 694 | * Thus, we must translate to MS for the real world. |
| 695 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 696 | static ssize_t bonding_show_downdelay(struct device *d, |
| 697 | struct device_attribute *attr, |
| 698 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 699 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 700 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 701 | |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 702 | return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 703 | } |
| 704 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 705 | static ssize_t bonding_store_downdelay(struct device *d, |
| 706 | struct device_attribute *attr, |
| 707 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 708 | { |
| 709 | int new_value, ret = count; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 710 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 711 | |
| 712 | if (!(bond->params.miimon)) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 713 | pr_err("%s: Unable to set down delay as MII monitoring is disabled\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 714 | bond->dev->name); |
| 715 | ret = -EPERM; |
| 716 | goto out; |
| 717 | } |
| 718 | |
| 719 | if (sscanf(buf, "%d", &new_value) != 1) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 720 | pr_err("%s: no down delay value specified.\n", bond->dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 721 | ret = -EINVAL; |
| 722 | goto out; |
| 723 | } |
| 724 | if (new_value < 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 725 | pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n", |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 726 | bond->dev->name, new_value, 0, INT_MAX); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 727 | ret = -EINVAL; |
| 728 | goto out; |
| 729 | } else { |
| 730 | if ((new_value % bond->params.miimon) != 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 731 | pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n", |
Jiri Pirko | e5e2a8f | 2009-08-13 04:11:52 +0000 | [diff] [blame] | 732 | bond->dev->name, new_value, |
| 733 | bond->params.miimon, |
| 734 | (new_value / bond->params.miimon) * |
| 735 | bond->params.miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 736 | } |
| 737 | bond->params.downdelay = new_value / bond->params.miimon; |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 738 | pr_info("%s: Setting down delay to %d.\n", |
| 739 | bond->dev->name, |
| 740 | bond->params.downdelay * bond->params.miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 741 | |
| 742 | } |
| 743 | |
| 744 | out: |
| 745 | return ret; |
| 746 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 747 | static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR, |
| 748 | bonding_show_downdelay, bonding_store_downdelay); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 749 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 750 | static ssize_t bonding_show_updelay(struct device *d, |
| 751 | struct device_attribute *attr, |
| 752 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 753 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 754 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 755 | |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 756 | return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 757 | |
| 758 | } |
| 759 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 760 | static ssize_t bonding_store_updelay(struct device *d, |
| 761 | struct device_attribute *attr, |
| 762 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 763 | { |
| 764 | int new_value, ret = count; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 765 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 766 | |
| 767 | if (!(bond->params.miimon)) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 768 | pr_err("%s: Unable to set up delay as MII monitoring is disabled\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 769 | bond->dev->name); |
| 770 | ret = -EPERM; |
| 771 | goto out; |
| 772 | } |
| 773 | |
| 774 | if (sscanf(buf, "%d", &new_value) != 1) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 775 | pr_err("%s: no up delay value specified.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 776 | bond->dev->name); |
| 777 | ret = -EINVAL; |
| 778 | goto out; |
| 779 | } |
| 780 | if (new_value < 0) { |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 781 | pr_err("%s: Invalid up delay value %d not in range %d-%d; rejected.\n", |
| 782 | bond->dev->name, new_value, 0, INT_MAX); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 783 | ret = -EINVAL; |
| 784 | goto out; |
| 785 | } else { |
| 786 | if ((new_value % bond->params.miimon) != 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 787 | pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n", |
Jiri Pirko | e5e2a8f | 2009-08-13 04:11:52 +0000 | [diff] [blame] | 788 | bond->dev->name, new_value, |
| 789 | bond->params.miimon, |
| 790 | (new_value / bond->params.miimon) * |
| 791 | bond->params.miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 792 | } |
| 793 | bond->params.updelay = new_value / bond->params.miimon; |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 794 | pr_info("%s: Setting up delay to %d.\n", |
| 795 | bond->dev->name, |
| 796 | bond->params.updelay * bond->params.miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | out: |
| 800 | return ret; |
| 801 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 802 | static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR, |
| 803 | bonding_show_updelay, bonding_store_updelay); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 804 | |
| 805 | /* |
| 806 | * Show and set the LACP interval. Interface must be down, and the mode |
| 807 | * must be set to 802.3ad mode. |
| 808 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 809 | static ssize_t bonding_show_lacp(struct device *d, |
| 810 | struct device_attribute *attr, |
| 811 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 812 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 813 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 814 | |
| 815 | return sprintf(buf, "%s %d\n", |
| 816 | bond_lacp_tbl[bond->params.lacp_fast].modename, |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 817 | bond->params.lacp_fast); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 818 | } |
| 819 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 820 | static ssize_t bonding_store_lacp(struct device *d, |
| 821 | struct device_attribute *attr, |
| 822 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 823 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 824 | struct bonding *bond = to_bond(d); |
nikolay@redhat.com | c509316 | 2013-09-02 13:51:40 +0200 | [diff] [blame] | 825 | int new_value, ret = count; |
| 826 | |
| 827 | if (!rtnl_trylock()) |
| 828 | return restart_syscall(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 829 | |
| 830 | if (bond->dev->flags & IFF_UP) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 831 | pr_err("%s: Unable to update LACP rate because interface is up.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 832 | bond->dev->name); |
| 833 | ret = -EPERM; |
| 834 | goto out; |
| 835 | } |
| 836 | |
| 837 | if (bond->params.mode != BOND_MODE_8023AD) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 838 | pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 839 | bond->dev->name); |
| 840 | ret = -EPERM; |
| 841 | goto out; |
| 842 | } |
| 843 | |
Jay Vosburgh | ece95f7 | 2008-01-17 16:25:01 -0800 | [diff] [blame] | 844 | new_value = bond_parse_parm(buf, bond_lacp_tbl); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 845 | |
| 846 | if ((new_value == 1) || (new_value == 0)) { |
| 847 | bond->params.lacp_fast = new_value; |
Peter Pan(潘卫平) | ba824a8 | 2011-06-08 21:19:01 +0000 | [diff] [blame] | 848 | bond_3ad_update_lacp_rate(bond); |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 849 | pr_info("%s: Setting LACP rate to %s (%d).\n", |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 850 | bond->dev->name, bond_lacp_tbl[new_value].modename, |
| 851 | new_value); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 852 | } else { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 853 | pr_err("%s: Ignoring invalid LACP rate value %.*s.\n", |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 854 | bond->dev->name, (int)strlen(buf) - 1, buf); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 855 | ret = -EINVAL; |
| 856 | } |
| 857 | out: |
nikolay@redhat.com | c509316 | 2013-09-02 13:51:40 +0200 | [diff] [blame] | 858 | rtnl_unlock(); |
| 859 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 860 | return ret; |
| 861 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 862 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, |
| 863 | bonding_show_lacp, bonding_store_lacp); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 864 | |
stephen hemminger | 655f891 | 2011-06-22 09:54:39 +0000 | [diff] [blame] | 865 | static ssize_t bonding_show_min_links(struct device *d, |
| 866 | struct device_attribute *attr, |
| 867 | char *buf) |
| 868 | { |
| 869 | struct bonding *bond = to_bond(d); |
| 870 | |
| 871 | return sprintf(buf, "%d\n", bond->params.min_links); |
| 872 | } |
| 873 | |
| 874 | static ssize_t bonding_store_min_links(struct device *d, |
| 875 | struct device_attribute *attr, |
| 876 | const char *buf, size_t count) |
| 877 | { |
| 878 | struct bonding *bond = to_bond(d); |
| 879 | int ret; |
| 880 | unsigned int new_value; |
| 881 | |
| 882 | ret = kstrtouint(buf, 0, &new_value); |
| 883 | if (ret < 0) { |
| 884 | pr_err("%s: Ignoring invalid min links value %s.\n", |
| 885 | bond->dev->name, buf); |
| 886 | return ret; |
| 887 | } |
| 888 | |
| 889 | pr_info("%s: Setting min links value to %u\n", |
| 890 | bond->dev->name, new_value); |
| 891 | bond->params.min_links = new_value; |
| 892 | return count; |
| 893 | } |
| 894 | static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR, |
| 895 | bonding_show_min_links, bonding_store_min_links); |
| 896 | |
Jay Vosburgh | fd989c8 | 2008-11-04 17:51:16 -0800 | [diff] [blame] | 897 | static ssize_t bonding_show_ad_select(struct device *d, |
| 898 | struct device_attribute *attr, |
| 899 | char *buf) |
| 900 | { |
| 901 | struct bonding *bond = to_bond(d); |
| 902 | |
| 903 | return sprintf(buf, "%s %d\n", |
| 904 | ad_select_tbl[bond->params.ad_select].modename, |
| 905 | bond->params.ad_select); |
| 906 | } |
| 907 | |
| 908 | |
| 909 | static ssize_t bonding_store_ad_select(struct device *d, |
| 910 | struct device_attribute *attr, |
| 911 | const char *buf, size_t count) |
| 912 | { |
| 913 | int new_value, ret = count; |
| 914 | struct bonding *bond = to_bond(d); |
| 915 | |
| 916 | if (bond->dev->flags & IFF_UP) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 917 | pr_err("%s: Unable to update ad_select because interface is up.\n", |
| 918 | bond->dev->name); |
Jay Vosburgh | fd989c8 | 2008-11-04 17:51:16 -0800 | [diff] [blame] | 919 | ret = -EPERM; |
| 920 | goto out; |
| 921 | } |
| 922 | |
| 923 | new_value = bond_parse_parm(buf, ad_select_tbl); |
| 924 | |
| 925 | if (new_value != -1) { |
| 926 | bond->params.ad_select = new_value; |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 927 | pr_info("%s: Setting ad_select to %s (%d).\n", |
| 928 | bond->dev->name, ad_select_tbl[new_value].modename, |
| 929 | new_value); |
Jay Vosburgh | fd989c8 | 2008-11-04 17:51:16 -0800 | [diff] [blame] | 930 | } else { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 931 | pr_err("%s: Ignoring invalid ad_select value %.*s.\n", |
Jay Vosburgh | fd989c8 | 2008-11-04 17:51:16 -0800 | [diff] [blame] | 932 | bond->dev->name, (int)strlen(buf) - 1, buf); |
| 933 | ret = -EINVAL; |
| 934 | } |
| 935 | out: |
| 936 | return ret; |
| 937 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 938 | static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, |
| 939 | bonding_show_ad_select, bonding_store_ad_select); |
Jay Vosburgh | fd989c8 | 2008-11-04 17:51:16 -0800 | [diff] [blame] | 940 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 941 | /* |
Ben Hutchings | ad246c9 | 2011-04-26 15:25:52 +0000 | [diff] [blame] | 942 | * Show and set the number of peer notifications to send after a failover event. |
| 943 | */ |
| 944 | static ssize_t bonding_show_num_peer_notif(struct device *d, |
| 945 | struct device_attribute *attr, |
| 946 | char *buf) |
| 947 | { |
| 948 | struct bonding *bond = to_bond(d); |
| 949 | return sprintf(buf, "%d\n", bond->params.num_peer_notif); |
| 950 | } |
| 951 | |
| 952 | static ssize_t bonding_store_num_peer_notif(struct device *d, |
| 953 | struct device_attribute *attr, |
| 954 | const char *buf, size_t count) |
| 955 | { |
| 956 | struct bonding *bond = to_bond(d); |
| 957 | int err = kstrtou8(buf, 10, &bond->params.num_peer_notif); |
| 958 | return err ? err : count; |
| 959 | } |
| 960 | static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, |
| 961 | bonding_show_num_peer_notif, bonding_store_num_peer_notif); |
| 962 | static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, |
| 963 | bonding_show_num_peer_notif, bonding_store_num_peer_notif); |
| 964 | |
| 965 | /* |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 966 | * Show and set the MII monitor interval. There are two tricky bits |
| 967 | * here. First, if MII monitoring is activated, then we must disable |
| 968 | * ARP monitoring. Second, if the timer isn't running, we must |
| 969 | * start it. |
| 970 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 971 | static ssize_t bonding_show_miimon(struct device *d, |
| 972 | struct device_attribute *attr, |
| 973 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 974 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 975 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 976 | |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 977 | return sprintf(buf, "%d\n", bond->params.miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 978 | } |
| 979 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 980 | static ssize_t bonding_store_miimon(struct device *d, |
| 981 | struct device_attribute *attr, |
| 982 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 983 | { |
| 984 | int new_value, ret = count; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 985 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 986 | |
nikolay@redhat.com | fbb0c41 | 2012-11-29 01:31:31 +0000 | [diff] [blame] | 987 | if (!rtnl_trylock()) |
| 988 | return restart_syscall(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 989 | if (sscanf(buf, "%d", &new_value) != 1) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 990 | pr_err("%s: no miimon value specified.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 991 | bond->dev->name); |
| 992 | ret = -EINVAL; |
| 993 | goto out; |
| 994 | } |
| 995 | if (new_value < 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 996 | pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n", |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 997 | bond->dev->name, new_value, 0, INT_MAX); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 998 | ret = -EINVAL; |
| 999 | goto out; |
nikolay@redhat.com | 1bc7db1 | 2013-03-27 03:32:41 +0000 | [diff] [blame] | 1000 | } |
| 1001 | pr_info("%s: Setting MII monitoring interval to %d.\n", |
| 1002 | bond->dev->name, new_value); |
| 1003 | bond->params.miimon = new_value; |
| 1004 | if (bond->params.updelay) |
| 1005 | pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n", |
| 1006 | bond->dev->name, |
| 1007 | bond->params.updelay * bond->params.miimon); |
| 1008 | if (bond->params.downdelay) |
| 1009 | pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n", |
| 1010 | bond->dev->name, |
| 1011 | bond->params.downdelay * bond->params.miimon); |
| 1012 | if (new_value && bond->params.arp_interval) { |
| 1013 | pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", |
| 1014 | bond->dev->name); |
| 1015 | bond->params.arp_interval = 0; |
| 1016 | if (bond->params.arp_validate) |
| 1017 | bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; |
| 1018 | } |
| 1019 | if (bond->dev->flags & IFF_UP) { |
| 1020 | /* If the interface is up, we may need to fire off |
| 1021 | * the MII timer. If the interface is down, the |
| 1022 | * timer will get fired off when the open function |
| 1023 | * is called. |
| 1024 | */ |
| 1025 | if (!new_value) { |
| 1026 | cancel_delayed_work_sync(&bond->mii_work); |
| 1027 | } else { |
nikolay@redhat.com | fbb0c41 | 2012-11-29 01:31:31 +0000 | [diff] [blame] | 1028 | cancel_delayed_work_sync(&bond->arp_work); |
| 1029 | queue_delayed_work(bond->wq, &bond->mii_work, 0); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1030 | } |
| 1031 | } |
| 1032 | out: |
nikolay@redhat.com | fbb0c41 | 2012-11-29 01:31:31 +0000 | [diff] [blame] | 1033 | rtnl_unlock(); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1034 | return ret; |
| 1035 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1036 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, |
| 1037 | bonding_show_miimon, bonding_store_miimon); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1038 | |
| 1039 | /* |
| 1040 | * Show and set the primary slave. The store function is much |
| 1041 | * simpler than bonding_store_slaves function because it only needs to |
| 1042 | * handle one interface name. |
| 1043 | * The bond must be a mode that supports a primary for this be |
| 1044 | * set. |
| 1045 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1046 | static ssize_t bonding_show_primary(struct device *d, |
| 1047 | struct device_attribute *attr, |
| 1048 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1049 | { |
| 1050 | int count = 0; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1051 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1052 | |
| 1053 | if (bond->primary_slave) |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 1054 | count = sprintf(buf, "%s\n", bond->primary_slave->dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1055 | |
| 1056 | return count; |
| 1057 | } |
| 1058 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1059 | static ssize_t bonding_store_primary(struct device *d, |
| 1060 | struct device_attribute *attr, |
| 1061 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1062 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1063 | struct bonding *bond = to_bond(d); |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1064 | struct list_head *iter; |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1065 | char ifname[IFNAMSIZ]; |
nikolay@redhat.com | dec1e90 | 2013-08-01 16:54:47 +0200 | [diff] [blame] | 1066 | struct slave *slave; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1067 | |
Eric W. Biederman | 496a60c | 2009-05-13 17:02:50 +0000 | [diff] [blame] | 1068 | if (!rtnl_trylock()) |
| 1069 | return restart_syscall(); |
Neil Horman | e843fa5 | 2010-10-13 16:01:50 +0000 | [diff] [blame] | 1070 | block_netpoll_tx(); |
Jay Vosburgh | e934dd7 | 2008-01-17 16:24:57 -0800 | [diff] [blame] | 1071 | read_lock(&bond->lock); |
| 1072 | write_lock_bh(&bond->curr_slave_lock); |
| 1073 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1074 | if (!USES_PRIMARY(bond->params.mode)) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 1075 | pr_info("%s: Unable to set primary slave; %s is in mode %d\n", |
| 1076 | bond->dev->name, bond->dev->name, bond->params.mode); |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1077 | goto out; |
| 1078 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1079 | |
nikolay@redhat.com | eb6e98a | 2012-10-31 04:42:51 +0000 | [diff] [blame] | 1080 | sscanf(buf, "%15s", ifname); /* IFNAMSIZ */ |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1081 | |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1082 | /* check to see if we are clearing primary */ |
| 1083 | if (!strlen(ifname) || buf[0] == '\n') { |
| 1084 | pr_info("%s: Setting primary slave to None.\n", |
| 1085 | bond->dev->name); |
| 1086 | bond->primary_slave = NULL; |
Milos Vyletel | eb492f7 | 2013-01-29 09:59:00 +0000 | [diff] [blame] | 1087 | memset(bond->params.primary, 0, sizeof(bond->params.primary)); |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1088 | bond_select_active_slave(bond); |
| 1089 | goto out; |
| 1090 | } |
| 1091 | |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1092 | bond_for_each_slave(bond, slave, iter) { |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1093 | if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { |
| 1094 | pr_info("%s: Setting %s as primary slave.\n", |
| 1095 | bond->dev->name, slave->dev->name); |
| 1096 | bond->primary_slave = slave; |
| 1097 | strcpy(bond->params.primary, slave->dev->name); |
| 1098 | bond_select_active_slave(bond); |
| 1099 | goto out; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1100 | } |
| 1101 | } |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1102 | |
Weiping Pan | 8a93664 | 2012-06-10 23:00:20 +0000 | [diff] [blame] | 1103 | strncpy(bond->params.primary, ifname, IFNAMSIZ); |
| 1104 | bond->params.primary[IFNAMSIZ - 1] = 0; |
| 1105 | |
| 1106 | pr_info("%s: Recording %s as primary, " |
| 1107 | "but it has not been enslaved to %s yet.\n", |
| 1108 | bond->dev->name, ifname, bond->dev->name); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1109 | out: |
Jay Vosburgh | e934dd7 | 2008-01-17 16:24:57 -0800 | [diff] [blame] | 1110 | write_unlock_bh(&bond->curr_slave_lock); |
| 1111 | read_unlock(&bond->lock); |
Neil Horman | e843fa5 | 2010-10-13 16:01:50 +0000 | [diff] [blame] | 1112 | unblock_netpoll_tx(); |
Jay Vosburgh | 6603a6f | 2007-10-17 17:37:50 -0700 | [diff] [blame] | 1113 | rtnl_unlock(); |
| 1114 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1115 | return count; |
| 1116 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1117 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, |
| 1118 | bonding_show_primary, bonding_store_primary); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1119 | |
| 1120 | /* |
Jiri Pirko | a549952 | 2009-09-25 03:28:09 +0000 | [diff] [blame] | 1121 | * Show and set the primary_reselect flag. |
| 1122 | */ |
| 1123 | static ssize_t bonding_show_primary_reselect(struct device *d, |
| 1124 | struct device_attribute *attr, |
| 1125 | char *buf) |
| 1126 | { |
| 1127 | struct bonding *bond = to_bond(d); |
| 1128 | |
| 1129 | return sprintf(buf, "%s %d\n", |
| 1130 | pri_reselect_tbl[bond->params.primary_reselect].modename, |
| 1131 | bond->params.primary_reselect); |
| 1132 | } |
| 1133 | |
| 1134 | static ssize_t bonding_store_primary_reselect(struct device *d, |
| 1135 | struct device_attribute *attr, |
| 1136 | const char *buf, size_t count) |
| 1137 | { |
| 1138 | int new_value, ret = count; |
| 1139 | struct bonding *bond = to_bond(d); |
| 1140 | |
| 1141 | if (!rtnl_trylock()) |
| 1142 | return restart_syscall(); |
| 1143 | |
| 1144 | new_value = bond_parse_parm(buf, pri_reselect_tbl); |
| 1145 | if (new_value < 0) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 1146 | pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n", |
Jiri Pirko | a549952 | 2009-09-25 03:28:09 +0000 | [diff] [blame] | 1147 | bond->dev->name, |
| 1148 | (int) strlen(buf) - 1, buf); |
| 1149 | ret = -EINVAL; |
| 1150 | goto out; |
| 1151 | } |
| 1152 | |
| 1153 | bond->params.primary_reselect = new_value; |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 1154 | pr_info("%s: setting primary_reselect to %s (%d).\n", |
Jiri Pirko | a549952 | 2009-09-25 03:28:09 +0000 | [diff] [blame] | 1155 | bond->dev->name, pri_reselect_tbl[new_value].modename, |
| 1156 | new_value); |
| 1157 | |
Neil Horman | e843fa5 | 2010-10-13 16:01:50 +0000 | [diff] [blame] | 1158 | block_netpoll_tx(); |
Jiri Pirko | a549952 | 2009-09-25 03:28:09 +0000 | [diff] [blame] | 1159 | read_lock(&bond->lock); |
| 1160 | write_lock_bh(&bond->curr_slave_lock); |
| 1161 | bond_select_active_slave(bond); |
| 1162 | write_unlock_bh(&bond->curr_slave_lock); |
| 1163 | read_unlock(&bond->lock); |
Neil Horman | e843fa5 | 2010-10-13 16:01:50 +0000 | [diff] [blame] | 1164 | unblock_netpoll_tx(); |
Jiri Pirko | a549952 | 2009-09-25 03:28:09 +0000 | [diff] [blame] | 1165 | out: |
| 1166 | rtnl_unlock(); |
| 1167 | return ret; |
| 1168 | } |
| 1169 | static DEVICE_ATTR(primary_reselect, S_IRUGO | S_IWUSR, |
| 1170 | bonding_show_primary_reselect, |
| 1171 | bonding_store_primary_reselect); |
| 1172 | |
| 1173 | /* |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1174 | * Show and set the use_carrier flag. |
| 1175 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1176 | static ssize_t bonding_show_carrier(struct device *d, |
| 1177 | struct device_attribute *attr, |
| 1178 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1179 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1180 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1181 | |
Wagner Ferenc | 7bd4650 | 2007-12-06 23:40:28 -0800 | [diff] [blame] | 1182 | return sprintf(buf, "%d\n", bond->params.use_carrier); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1183 | } |
| 1184 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1185 | static ssize_t bonding_store_carrier(struct device *d, |
| 1186 | struct device_attribute *attr, |
| 1187 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1188 | { |
| 1189 | int new_value, ret = count; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1190 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1191 | |
| 1192 | |
| 1193 | if (sscanf(buf, "%d", &new_value) != 1) { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 1194 | pr_err("%s: no use_carrier value specified.\n", |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1195 | bond->dev->name); |
| 1196 | ret = -EINVAL; |
| 1197 | goto out; |
| 1198 | } |
| 1199 | if ((new_value == 0) || (new_value == 1)) { |
| 1200 | bond->params.use_carrier = new_value; |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 1201 | pr_info("%s: Setting use_carrier to %d.\n", |
| 1202 | bond->dev->name, new_value); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1203 | } else { |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 1204 | pr_info("%s: Ignoring invalid use_carrier value %d.\n", |
| 1205 | bond->dev->name, new_value); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1206 | } |
| 1207 | out: |
Jiri Pirko | 672bda3 | 2011-01-25 11:03:25 +0000 | [diff] [blame] | 1208 | return ret; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1209 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1210 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, |
| 1211 | bonding_show_carrier, bonding_store_carrier); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1212 | |
| 1213 | |
| 1214 | /* |
| 1215 | * Show and set currently active_slave. |
| 1216 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1217 | static ssize_t bonding_show_active_slave(struct device *d, |
| 1218 | struct device_attribute *attr, |
| 1219 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1220 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1221 | struct bonding *bond = to_bond(d); |
Jiri Pirko | 752d48b | 2013-10-18 17:43:37 +0200 | [diff] [blame^] | 1222 | struct net_device *slave_dev; |
Wagner Ferenc | 16cd016 | 2007-12-06 23:40:29 -0800 | [diff] [blame] | 1223 | int count = 0; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1224 | |
nikolay@redhat.com | 278b208 | 2013-08-01 16:54:51 +0200 | [diff] [blame] | 1225 | rcu_read_lock(); |
Jiri Pirko | 752d48b | 2013-10-18 17:43:37 +0200 | [diff] [blame^] | 1226 | slave_dev = bond_option_active_slave_get_rcu(bond); |
| 1227 | if (slave_dev) |
| 1228 | count = sprintf(buf, "%s\n", slave_dev->name); |
nikolay@redhat.com | 278b208 | 2013-08-01 16:54:51 +0200 | [diff] [blame] | 1229 | rcu_read_unlock(); |
| 1230 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1231 | return count; |
| 1232 | } |
| 1233 | |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1234 | static ssize_t bonding_store_active_slave(struct device *d, |
| 1235 | struct device_attribute *attr, |
| 1236 | const char *buf, size_t count) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1237 | { |
Jiri Pirko | d9e32b2 | 2013-10-18 17:43:35 +0200 | [diff] [blame] | 1238 | int ret; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1239 | struct bonding *bond = to_bond(d); |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1240 | char ifname[IFNAMSIZ]; |
Jiri Pirko | d9e32b2 | 2013-10-18 17:43:35 +0200 | [diff] [blame] | 1241 | struct net_device *dev; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1242 | |
Eric W. Biederman | 496a60c | 2009-05-13 17:02:50 +0000 | [diff] [blame] | 1243 | if (!rtnl_trylock()) |
| 1244 | return restart_syscall(); |
Neil Horman | e843fa5 | 2010-10-13 16:01:50 +0000 | [diff] [blame] | 1245 | |
nikolay@redhat.com | c84e159 | 2012-10-31 06:03:52 +0000 | [diff] [blame] | 1246 | sscanf(buf, "%15s", ifname); /* IFNAMSIZ */ |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1247 | if (!strlen(ifname) || buf[0] == '\n') { |
Jiri Pirko | d9e32b2 | 2013-10-18 17:43:35 +0200 | [diff] [blame] | 1248 | dev = NULL; |
| 1249 | } else { |
| 1250 | dev = __dev_get_by_name(dev_net(bond->dev), ifname); |
| 1251 | if (!dev) { |
| 1252 | ret = -ENODEV; |
| 1253 | goto out; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1254 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1255 | } |
Andy Gospodarek | f4bb2e9 | 2011-07-26 11:12:27 +0000 | [diff] [blame] | 1256 | |
Jiri Pirko | d9e32b2 | 2013-10-18 17:43:35 +0200 | [diff] [blame] | 1257 | ret = bond_option_active_slave_set(bond, dev); |
| 1258 | if (!ret) |
| 1259 | ret = count; |
Neil Horman | e843fa5 | 2010-10-13 16:01:50 +0000 | [diff] [blame] | 1260 | |
Jiri Pirko | d9e32b2 | 2013-10-18 17:43:35 +0200 | [diff] [blame] | 1261 | out: |
Jay Vosburgh | 6603a6f | 2007-10-17 17:37:50 -0700 | [diff] [blame] | 1262 | rtnl_unlock(); |
| 1263 | |
Jiri Pirko | d9e32b2 | 2013-10-18 17:43:35 +0200 | [diff] [blame] | 1264 | return ret; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1265 | |
| 1266 | } |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1267 | static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, |
| 1268 | bonding_show_active_slave, bonding_store_active_slave); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1269 | |
| 1270 | |
| 1271 | /* |
| 1272 | * Show link status of the bond interface. |
| 1273 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1274 | static ssize_t bonding_show_mii_status(struct device *d, |
| 1275 | struct device_attribute *attr, |
| 1276 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1277 | { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1278 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1279 | |
nikolay@redhat.com | 278b208 | 2013-08-01 16:54:51 +0200 | [diff] [blame] | 1280 | return sprintf(buf, "%s\n", bond->curr_active_slave ? "up" : "down"); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1281 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1282 | static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1283 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1284 | /* |
| 1285 | * Show current 802.3ad aggregator ID. |
| 1286 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1287 | static ssize_t bonding_show_ad_aggregator(struct device *d, |
| 1288 | struct device_attribute *attr, |
| 1289 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1290 | { |
| 1291 | int count = 0; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1292 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1293 | |
| 1294 | if (bond->params.mode == BOND_MODE_8023AD) { |
| 1295 | struct ad_info ad_info; |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1296 | count = sprintf(buf, "%d\n", |
nikolay@redhat.com | 318debd | 2013-05-18 01:18:31 +0000 | [diff] [blame] | 1297 | bond_3ad_get_active_agg_info(bond, &ad_info) |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1298 | ? 0 : ad_info.aggregator_id); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1299 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1300 | |
| 1301 | return count; |
| 1302 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1303 | static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1304 | |
| 1305 | |
| 1306 | /* |
| 1307 | * Show number of active 802.3ad ports. |
| 1308 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1309 | static ssize_t bonding_show_ad_num_ports(struct device *d, |
| 1310 | struct device_attribute *attr, |
| 1311 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1312 | { |
| 1313 | int count = 0; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1314 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1315 | |
| 1316 | if (bond->params.mode == BOND_MODE_8023AD) { |
| 1317 | struct ad_info ad_info; |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1318 | count = sprintf(buf, "%d\n", |
nikolay@redhat.com | 318debd | 2013-05-18 01:18:31 +0000 | [diff] [blame] | 1319 | bond_3ad_get_active_agg_info(bond, &ad_info) |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1320 | ? 0 : ad_info.ports); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1321 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1322 | |
| 1323 | return count; |
| 1324 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1325 | static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1326 | |
| 1327 | |
| 1328 | /* |
| 1329 | * Show current 802.3ad actor key. |
| 1330 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1331 | static ssize_t bonding_show_ad_actor_key(struct device *d, |
| 1332 | struct device_attribute *attr, |
| 1333 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1334 | { |
| 1335 | int count = 0; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1336 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1337 | |
| 1338 | if (bond->params.mode == BOND_MODE_8023AD) { |
| 1339 | struct ad_info ad_info; |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1340 | count = sprintf(buf, "%d\n", |
nikolay@redhat.com | 318debd | 2013-05-18 01:18:31 +0000 | [diff] [blame] | 1341 | bond_3ad_get_active_agg_info(bond, &ad_info) |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1342 | ? 0 : ad_info.actor_key); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1343 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1344 | |
| 1345 | return count; |
| 1346 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1347 | static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1348 | |
| 1349 | |
| 1350 | /* |
| 1351 | * Show current 802.3ad partner key. |
| 1352 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1353 | static ssize_t bonding_show_ad_partner_key(struct device *d, |
| 1354 | struct device_attribute *attr, |
| 1355 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1356 | { |
| 1357 | int count = 0; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1358 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1359 | |
| 1360 | if (bond->params.mode == BOND_MODE_8023AD) { |
| 1361 | struct ad_info ad_info; |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1362 | count = sprintf(buf, "%d\n", |
nikolay@redhat.com | 318debd | 2013-05-18 01:18:31 +0000 | [diff] [blame] | 1363 | bond_3ad_get_active_agg_info(bond, &ad_info) |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1364 | ? 0 : ad_info.partner_key); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1365 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1366 | |
| 1367 | return count; |
| 1368 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1369 | static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1370 | |
| 1371 | |
| 1372 | /* |
| 1373 | * Show current 802.3ad partner mac. |
| 1374 | */ |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1375 | static ssize_t bonding_show_ad_partner_mac(struct device *d, |
| 1376 | struct device_attribute *attr, |
| 1377 | char *buf) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1378 | { |
| 1379 | int count = 0; |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1380 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1381 | |
| 1382 | if (bond->params.mode == BOND_MODE_8023AD) { |
| 1383 | struct ad_info ad_info; |
Stephen Hemminger | 3d632c3 | 2009-06-12 19:02:48 +0000 | [diff] [blame] | 1384 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 1385 | count = sprintf(buf, "%pM\n", ad_info.partner_system); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1386 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1387 | |
| 1388 | return count; |
| 1389 | } |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1390 | static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1391 | |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1392 | /* |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1393 | * Show the queue_ids of the slaves in the current bond. |
| 1394 | */ |
| 1395 | static ssize_t bonding_show_queue_id(struct device *d, |
| 1396 | struct device_attribute *attr, |
| 1397 | char *buf) |
| 1398 | { |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1399 | struct bonding *bond = to_bond(d); |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1400 | struct list_head *iter; |
nikolay@redhat.com | dec1e90 | 2013-08-01 16:54:47 +0200 | [diff] [blame] | 1401 | struct slave *slave; |
| 1402 | int res = 0; |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1403 | |
| 1404 | if (!rtnl_trylock()) |
| 1405 | return restart_syscall(); |
| 1406 | |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1407 | bond_for_each_slave(bond, slave, iter) { |
Nicolas de Pesloüan | 7923668 | 2010-07-14 18:24:54 -0700 | [diff] [blame] | 1408 | if (res > (PAGE_SIZE - IFNAMSIZ - 6)) { |
| 1409 | /* not enough space for another interface_name:queue_id pair */ |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1410 | if ((PAGE_SIZE - res) > 10) |
| 1411 | res = PAGE_SIZE - 10; |
| 1412 | res += sprintf(buf + res, "++more++ "); |
| 1413 | break; |
| 1414 | } |
| 1415 | res += sprintf(buf + res, "%s:%d ", |
| 1416 | slave->dev->name, slave->queue_id); |
| 1417 | } |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1418 | if (res) |
| 1419 | buf[res-1] = '\n'; /* eat the leftover space */ |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 1420 | |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1421 | rtnl_unlock(); |
nikolay@redhat.com | dec1e90 | 2013-08-01 16:54:47 +0200 | [diff] [blame] | 1422 | |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1423 | return res; |
| 1424 | } |
| 1425 | |
| 1426 | /* |
| 1427 | * Set the queue_ids of the slaves in the current bond. The bond |
| 1428 | * interface must be enslaved for this to work. |
| 1429 | */ |
| 1430 | static ssize_t bonding_store_queue_id(struct device *d, |
| 1431 | struct device_attribute *attr, |
| 1432 | const char *buffer, size_t count) |
| 1433 | { |
| 1434 | struct slave *slave, *update_slave; |
| 1435 | struct bonding *bond = to_bond(d); |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1436 | struct list_head *iter; |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1437 | u16 qid; |
nikolay@redhat.com | dec1e90 | 2013-08-01 16:54:47 +0200 | [diff] [blame] | 1438 | int ret = count; |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1439 | char *delim; |
| 1440 | struct net_device *sdev = NULL; |
| 1441 | |
| 1442 | if (!rtnl_trylock()) |
| 1443 | return restart_syscall(); |
| 1444 | |
| 1445 | /* delim will point to queue id if successful */ |
| 1446 | delim = strchr(buffer, ':'); |
| 1447 | if (!delim) |
| 1448 | goto err_no_cmd; |
| 1449 | |
| 1450 | /* |
| 1451 | * Terminate string that points to device name and bump it |
| 1452 | * up one, so we can read the queue id there. |
| 1453 | */ |
| 1454 | *delim = '\0'; |
| 1455 | if (sscanf(++delim, "%hd\n", &qid) != 1) |
| 1456 | goto err_no_cmd; |
| 1457 | |
| 1458 | /* Check buffer length, valid ifname and queue id */ |
| 1459 | if (strlen(buffer) > IFNAMSIZ || |
| 1460 | !dev_valid_name(buffer) || |
Jiri Pirko | 8a540ff | 2012-07-20 02:28:50 +0000 | [diff] [blame] | 1461 | qid > bond->dev->real_num_tx_queues) |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1462 | goto err_no_cmd; |
| 1463 | |
| 1464 | /* Get the pointer to that interface if it exists */ |
| 1465 | sdev = __dev_get_by_name(dev_net(bond->dev), buffer); |
| 1466 | if (!sdev) |
| 1467 | goto err_no_cmd; |
| 1468 | |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1469 | /* Search for thes slave and check for duplicate qids */ |
| 1470 | update_slave = NULL; |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1471 | bond_for_each_slave(bond, slave, iter) { |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1472 | if (sdev == slave->dev) |
| 1473 | /* |
| 1474 | * We don't need to check the matching |
| 1475 | * slave for dups, since we're overwriting it |
| 1476 | */ |
| 1477 | update_slave = slave; |
| 1478 | else if (qid && qid == slave->queue_id) { |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 1479 | goto err_no_cmd; |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1480 | } |
| 1481 | } |
| 1482 | |
| 1483 | if (!update_slave) |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 1484 | goto err_no_cmd; |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1485 | |
| 1486 | /* Actually set the qids for the slave */ |
| 1487 | update_slave->queue_id = qid; |
| 1488 | |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1489 | out: |
| 1490 | rtnl_unlock(); |
| 1491 | return ret; |
| 1492 | |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1493 | err_no_cmd: |
| 1494 | pr_info("invalid input for queue_id set for %s.\n", |
| 1495 | bond->dev->name); |
| 1496 | ret = -EPERM; |
| 1497 | goto out; |
| 1498 | } |
| 1499 | |
| 1500 | static DEVICE_ATTR(queue_id, S_IRUGO | S_IWUSR, bonding_show_queue_id, |
| 1501 | bonding_store_queue_id); |
| 1502 | |
| 1503 | |
| 1504 | /* |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1505 | * Show and set the all_slaves_active flag. |
| 1506 | */ |
| 1507 | static ssize_t bonding_show_slaves_active(struct device *d, |
| 1508 | struct device_attribute *attr, |
| 1509 | char *buf) |
| 1510 | { |
| 1511 | struct bonding *bond = to_bond(d); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1512 | |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1513 | return sprintf(buf, "%d\n", bond->params.all_slaves_active); |
| 1514 | } |
| 1515 | |
| 1516 | static ssize_t bonding_store_slaves_active(struct device *d, |
| 1517 | struct device_attribute *attr, |
| 1518 | const char *buf, size_t count) |
| 1519 | { |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1520 | struct bonding *bond = to_bond(d); |
nikolay@redhat.com | dec1e90 | 2013-08-01 16:54:47 +0200 | [diff] [blame] | 1521 | int new_value, ret = count; |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1522 | struct list_head *iter; |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1523 | struct slave *slave; |
| 1524 | |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 1525 | if (!rtnl_trylock()) |
| 1526 | return restart_syscall(); |
| 1527 | |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1528 | if (sscanf(buf, "%d", &new_value) != 1) { |
| 1529 | pr_err("%s: no all_slaves_active value specified.\n", |
| 1530 | bond->dev->name); |
| 1531 | ret = -EINVAL; |
| 1532 | goto out; |
| 1533 | } |
| 1534 | |
| 1535 | if (new_value == bond->params.all_slaves_active) |
| 1536 | goto out; |
| 1537 | |
| 1538 | if ((new_value == 0) || (new_value == 1)) { |
| 1539 | bond->params.all_slaves_active = new_value; |
| 1540 | } else { |
| 1541 | pr_info("%s: Ignoring invalid all_slaves_active value %d.\n", |
| 1542 | bond->dev->name, new_value); |
| 1543 | ret = -EINVAL; |
| 1544 | goto out; |
| 1545 | } |
| 1546 | |
Veaceslav Falico | 9caff1e7 | 2013-09-25 09:20:14 +0200 | [diff] [blame] | 1547 | bond_for_each_slave(bond, slave, iter) { |
Jiri Pirko | e30bc06 | 2011-03-12 03:14:37 +0000 | [diff] [blame] | 1548 | if (!bond_is_active_slave(slave)) { |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1549 | if (new_value) |
Jiri Pirko | 2d7011c | 2011-03-16 08:46:43 +0000 | [diff] [blame] | 1550 | slave->inactive = 0; |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1551 | else |
Jiri Pirko | 2d7011c | 2011-03-16 08:46:43 +0000 | [diff] [blame] | 1552 | slave->inactive = 1; |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1553 | } |
| 1554 | } |
| 1555 | out: |
dingtianhong | 4d1ae5f | 2013-10-15 16:28:42 +0800 | [diff] [blame] | 1556 | rtnl_unlock(); |
Jiri Pirko | 672bda3 | 2011-01-25 11:03:25 +0000 | [diff] [blame] | 1557 | return ret; |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1558 | } |
| 1559 | static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR, |
| 1560 | bonding_show_slaves_active, bonding_store_slaves_active); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1561 | |
Flavio Leitner | c2952c3 | 2010-10-05 14:23:59 +0000 | [diff] [blame] | 1562 | /* |
| 1563 | * Show and set the number of IGMP membership reports to send on link failure |
| 1564 | */ |
| 1565 | static ssize_t bonding_show_resend_igmp(struct device *d, |
Flavio Leitner | 94265cf | 2011-05-25 08:38:58 +0000 | [diff] [blame] | 1566 | struct device_attribute *attr, |
| 1567 | char *buf) |
Flavio Leitner | c2952c3 | 2010-10-05 14:23:59 +0000 | [diff] [blame] | 1568 | { |
| 1569 | struct bonding *bond = to_bond(d); |
| 1570 | |
| 1571 | return sprintf(buf, "%d\n", bond->params.resend_igmp); |
| 1572 | } |
| 1573 | |
| 1574 | static ssize_t bonding_store_resend_igmp(struct device *d, |
Flavio Leitner | 94265cf | 2011-05-25 08:38:58 +0000 | [diff] [blame] | 1575 | struct device_attribute *attr, |
| 1576 | const char *buf, size_t count) |
Flavio Leitner | c2952c3 | 2010-10-05 14:23:59 +0000 | [diff] [blame] | 1577 | { |
| 1578 | int new_value, ret = count; |
| 1579 | struct bonding *bond = to_bond(d); |
| 1580 | |
| 1581 | if (sscanf(buf, "%d", &new_value) != 1) { |
| 1582 | pr_err("%s: no resend_igmp value specified.\n", |
| 1583 | bond->dev->name); |
| 1584 | ret = -EINVAL; |
| 1585 | goto out; |
| 1586 | } |
| 1587 | |
Flavio Leitner | 94265cf | 2011-05-25 08:38:58 +0000 | [diff] [blame] | 1588 | if (new_value < 0 || new_value > 255) { |
Flavio Leitner | c2952c3 | 2010-10-05 14:23:59 +0000 | [diff] [blame] | 1589 | pr_err("%s: Invalid resend_igmp value %d not in range 0-255; rejected.\n", |
| 1590 | bond->dev->name, new_value); |
| 1591 | ret = -EINVAL; |
| 1592 | goto out; |
| 1593 | } |
| 1594 | |
| 1595 | pr_info("%s: Setting resend_igmp to %d.\n", |
| 1596 | bond->dev->name, new_value); |
| 1597 | bond->params.resend_igmp = new_value; |
| 1598 | out: |
| 1599 | return ret; |
| 1600 | } |
| 1601 | |
| 1602 | static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR, |
| 1603 | bonding_show_resend_igmp, bonding_store_resend_igmp); |
| 1604 | |
Neil Horman | 7eacd03 | 2013-09-13 11:05:33 -0400 | [diff] [blame] | 1605 | |
| 1606 | static ssize_t bonding_show_lp_interval(struct device *d, |
| 1607 | struct device_attribute *attr, |
| 1608 | char *buf) |
| 1609 | { |
| 1610 | struct bonding *bond = to_bond(d); |
| 1611 | return sprintf(buf, "%d\n", bond->params.lp_interval); |
| 1612 | } |
| 1613 | |
| 1614 | static ssize_t bonding_store_lp_interval(struct device *d, |
| 1615 | struct device_attribute *attr, |
| 1616 | const char *buf, size_t count) |
| 1617 | { |
| 1618 | struct bonding *bond = to_bond(d); |
| 1619 | int new_value, ret = count; |
| 1620 | |
| 1621 | if (sscanf(buf, "%d", &new_value) != 1) { |
| 1622 | pr_err("%s: no lp interval value specified.\n", |
| 1623 | bond->dev->name); |
| 1624 | ret = -EINVAL; |
| 1625 | goto out; |
| 1626 | } |
| 1627 | |
| 1628 | if (new_value <= 0) { |
| 1629 | pr_err ("%s: lp_interval must be between 1 and %d\n", |
| 1630 | bond->dev->name, INT_MAX); |
| 1631 | ret = -EINVAL; |
| 1632 | goto out; |
| 1633 | } |
| 1634 | |
| 1635 | bond->params.lp_interval = new_value; |
| 1636 | out: |
| 1637 | return ret; |
| 1638 | } |
| 1639 | |
| 1640 | static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR, |
| 1641 | bonding_show_lp_interval, bonding_store_lp_interval); |
| 1642 | |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1643 | static struct attribute *per_bond_attrs[] = { |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1644 | &dev_attr_slaves.attr, |
| 1645 | &dev_attr_mode.attr, |
Jay Vosburgh | dd957c5 | 2007-10-09 19:57:24 -0700 | [diff] [blame] | 1646 | &dev_attr_fail_over_mac.attr, |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1647 | &dev_attr_arp_validate.attr, |
Veaceslav Falico | 8599b52 | 2013-06-24 11:49:34 +0200 | [diff] [blame] | 1648 | &dev_attr_arp_all_targets.attr, |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1649 | &dev_attr_arp_interval.attr, |
| 1650 | &dev_attr_arp_ip_target.attr, |
| 1651 | &dev_attr_downdelay.attr, |
| 1652 | &dev_attr_updelay.attr, |
| 1653 | &dev_attr_lacp_rate.attr, |
Jay Vosburgh | fd989c8 | 2008-11-04 17:51:16 -0800 | [diff] [blame] | 1654 | &dev_attr_ad_select.attr, |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1655 | &dev_attr_xmit_hash_policy.attr, |
Ben Hutchings | ad246c9 | 2011-04-26 15:25:52 +0000 | [diff] [blame] | 1656 | &dev_attr_num_grat_arp.attr, |
| 1657 | &dev_attr_num_unsol_na.attr, |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1658 | &dev_attr_miimon.attr, |
| 1659 | &dev_attr_primary.attr, |
Jiri Pirko | a549952 | 2009-09-25 03:28:09 +0000 | [diff] [blame] | 1660 | &dev_attr_primary_reselect.attr, |
Greg Kroah-Hartman | 43cb76d | 2002-04-09 12:14:34 -0700 | [diff] [blame] | 1661 | &dev_attr_use_carrier.attr, |
| 1662 | &dev_attr_active_slave.attr, |
| 1663 | &dev_attr_mii_status.attr, |
| 1664 | &dev_attr_ad_aggregator.attr, |
| 1665 | &dev_attr_ad_num_ports.attr, |
| 1666 | &dev_attr_ad_actor_key.attr, |
| 1667 | &dev_attr_ad_partner_key.attr, |
| 1668 | &dev_attr_ad_partner_mac.attr, |
Andy Gospodarek | bb1d912 | 2010-06-02 08:40:18 +0000 | [diff] [blame] | 1669 | &dev_attr_queue_id.attr, |
Andy Gospodarek | ebd8e49 | 2010-06-02 08:39:21 +0000 | [diff] [blame] | 1670 | &dev_attr_all_slaves_active.attr, |
Flavio Leitner | c2952c3 | 2010-10-05 14:23:59 +0000 | [diff] [blame] | 1671 | &dev_attr_resend_igmp.attr, |
stephen hemminger | 655f891 | 2011-06-22 09:54:39 +0000 | [diff] [blame] | 1672 | &dev_attr_min_links.attr, |
Neil Horman | 7eacd03 | 2013-09-13 11:05:33 -0400 | [diff] [blame] | 1673 | &dev_attr_lp_interval.attr, |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1674 | NULL, |
| 1675 | }; |
| 1676 | |
| 1677 | static struct attribute_group bonding_group = { |
| 1678 | .name = "bonding", |
| 1679 | .attrs = per_bond_attrs, |
| 1680 | }; |
| 1681 | |
| 1682 | /* |
| 1683 | * Initialize sysfs. This sets up the bonding_masters file in |
| 1684 | * /sys/class/net. |
| 1685 | */ |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 1686 | int bond_create_sysfs(struct bond_net *bn) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1687 | { |
Jay Vosburgh | b8a9787 | 2008-06-13 18:12:04 -0700 | [diff] [blame] | 1688 | int ret; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1689 | |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 1690 | bn->class_attr_bonding_masters = class_attr_bonding_masters; |
Eric W. Biederman | 01718e3 | 2011-10-21 22:43:07 +0000 | [diff] [blame] | 1691 | sysfs_attr_init(&bn->class_attr_bonding_masters.attr); |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 1692 | |
| 1693 | ret = netdev_class_create_file(&bn->class_attr_bonding_masters); |
Jay Vosburgh | 877cbd3 | 2007-01-19 18:15:47 -0800 | [diff] [blame] | 1694 | /* |
| 1695 | * Permit multiple loads of the module by ignoring failures to |
| 1696 | * create the bonding_masters sysfs file. Bonding devices |
| 1697 | * created by second or subsequent loads of the module will |
| 1698 | * not be listed in, or controllable by, bonding_masters, but |
| 1699 | * will have the usual "bonding" sysfs directory. |
| 1700 | * |
| 1701 | * This is done to preserve backwards compatibility for |
| 1702 | * initscripts/sysconfig, which load bonding multiple times to |
| 1703 | * configure multiple bonding devices. |
| 1704 | */ |
| 1705 | if (ret == -EEXIST) { |
Stephen Hemminger | 38d2f38 | 2008-05-14 22:35:04 -0700 | [diff] [blame] | 1706 | /* Is someone being kinky and naming a device bonding_master? */ |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 1707 | if (__dev_get_by_name(bn->net, |
Stephen Hemminger | 38d2f38 | 2008-05-14 22:35:04 -0700 | [diff] [blame] | 1708 | class_attr_bonding_masters.attr.name)) |
Joe Perches | a4aee5c | 2009-12-13 20:06:07 -0800 | [diff] [blame] | 1709 | pr_err("network device named %s already exists in sysfs", |
Stephen Hemminger | 38d2f38 | 2008-05-14 22:35:04 -0700 | [diff] [blame] | 1710 | class_attr_bonding_masters.attr.name); |
Stephen Hemminger | 130aa61 | 2009-06-11 05:46:04 -0700 | [diff] [blame] | 1711 | ret = 0; |
Jay Vosburgh | 877cbd3 | 2007-01-19 18:15:47 -0800 | [diff] [blame] | 1712 | } |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1713 | |
| 1714 | return ret; |
| 1715 | |
| 1716 | } |
| 1717 | |
| 1718 | /* |
| 1719 | * Remove /sys/class/net/bonding_masters. |
| 1720 | */ |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 1721 | void bond_destroy_sysfs(struct bond_net *bn) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1722 | { |
Eric W. Biederman | 4c22400 | 2011-10-12 21:56:25 +0000 | [diff] [blame] | 1723 | netdev_class_remove_file(&bn->class_attr_bonding_masters); |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1724 | } |
| 1725 | |
| 1726 | /* |
| 1727 | * Initialize sysfs for each bond. This sets up and registers |
| 1728 | * the 'bondctl' directory for each individual bond under /sys/class/net. |
| 1729 | */ |
Eric W. Biederman | 6151b3d | 2009-10-29 14:18:22 +0000 | [diff] [blame] | 1730 | void bond_prepare_sysfs_group(struct bonding *bond) |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1731 | { |
Eric W. Biederman | 6151b3d | 2009-10-29 14:18:22 +0000 | [diff] [blame] | 1732 | bond->dev->sysfs_groups[0] = &bonding_group; |
Mitch Williams | b76cdba | 2005-11-09 10:36:41 -0800 | [diff] [blame] | 1733 | } |
| 1734 | |