diff options
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 781 |
1 files changed, 197 insertions, 584 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 94cec3cf2a1..2582d98ef5c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -29,466 +29,6 @@ | |||
29 | * b: if a hw mac address already is there, eth0's hw mac address | 29 | * b: if a hw mac address already is there, eth0's hw mac address |
30 | * will then be set from bond0. | 30 | * will then be set from bond0. |
31 | * | 31 | * |
32 | * v0.1 - first working version. | ||
33 | * v0.2 - changed stats to be calculated by summing slaves stats. | ||
34 | * | ||
35 | * Changes: | ||
36 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br> | ||
37 | * - fix leaks on failure at bond_init | ||
38 | * | ||
39 | * 2000/09/30 - Willy Tarreau <willy at meta-x.org> | ||
40 | * - added trivial code to release a slave device. | ||
41 | * - fixed security bug (CAP_NET_ADMIN not checked) | ||
42 | * - implemented MII link monitoring to disable dead links : | ||
43 | * All MII capable slaves are checked every <miimon> milliseconds | ||
44 | * (100 ms seems good). This value can be changed by passing it to | ||
45 | * insmod. A value of zero disables the monitoring (default). | ||
46 | * - fixed an infinite loop in bond_xmit_roundrobin() when there's no | ||
47 | * good slave. | ||
48 | * - made the code hopefully SMP safe | ||
49 | * | ||
50 | * 2000/10/03 - Willy Tarreau <willy at meta-x.org> | ||
51 | * - optimized slave lists based on relevant suggestions from Thomas Davis | ||
52 | * - implemented active-backup method to obtain HA with two switches: | ||
53 | * stay as long as possible on the same active interface, while we | ||
54 | * also monitor the backup one (MII link status) because we want to know | ||
55 | * if we are able to switch at any time. ( pass "mode=1" to insmod ) | ||
56 | * - lots of stress testings because we need it to be more robust than the | ||
57 | * wires ! :-> | ||
58 | * | ||
59 | * 2000/10/09 - Willy Tarreau <willy at meta-x.org> | ||
60 | * - added up and down delays after link state change. | ||
61 | * - optimized the slaves chaining so that when we run forward, we never | ||
62 | * repass through the bond itself, but we can find it by searching | ||
63 | * backwards. Renders the deletion more difficult, but accelerates the | ||
64 | * scan. | ||
65 | * - smarter enslaving and releasing. | ||
66 | * - finer and more robust SMP locking | ||
67 | * | ||
68 | * 2000/10/17 - Willy Tarreau <willy at meta-x.org> | ||
69 | * - fixed two potential SMP race conditions | ||
70 | * | ||
71 | * 2000/10/18 - Willy Tarreau <willy at meta-x.org> | ||
72 | * - small fixes to the monitoring FSM in case of zero delays | ||
73 | * 2000/11/01 - Willy Tarreau <willy at meta-x.org> | ||
74 | * - fixed first slave not automatically used in trunk mode. | ||
75 | * 2000/11/10 : spelling of "EtherChannel" corrected. | ||
76 | * 2000/11/13 : fixed a race condition in case of concurrent accesses to ioctl(). | ||
77 | * 2000/12/16 : fixed improper usage of rtnl_exlock_nowait(). | ||
78 | * | ||
79 | * 2001/1/3 - Chad N. Tindel <ctindel at ieee dot org> | ||
80 | * - The bonding driver now simulates MII status monitoring, just like | ||
81 | * a normal network device. It will show that the link is down iff | ||
82 | * every slave in the bond shows that their links are down. If at least | ||
83 | * one slave is up, the bond's MII status will appear as up. | ||
84 | * | ||
85 | * 2001/2/7 - Chad N. Tindel <ctindel at ieee dot org> | ||
86 | * - Applications can now query the bond from user space to get | ||
87 | * information which may be useful. They do this by calling | ||
88 | * the BOND_INFO_QUERY ioctl. Once the app knows how many slaves | ||
89 | * are in the bond, it can call the BOND_SLAVE_INFO_QUERY ioctl to | ||
90 | * get slave specific information (# link failures, etc). See | ||
91 | * <linux/if_bonding.h> for more details. The structs of interest | ||
92 | * are ifbond and ifslave. | ||
93 | * | ||
94 | * 2001/4/5 - Chad N. Tindel <ctindel at ieee dot org> | ||
95 | * - Ported to 2.4 Kernel | ||
96 | * | ||
97 | * 2001/5/2 - Jeffrey E. Mast <jeff at mastfamily dot com> | ||
98 | * - When a device is detached from a bond, the slave device is no longer | ||
99 | * left thinking that is has a master. | ||
100 | * | ||
101 | * 2001/5/16 - Jeffrey E. Mast <jeff at mastfamily dot com> | ||
102 | * - memset did not appropriately initialized the bond rw_locks. Used | ||
103 | * rwlock_init to initialize to unlocked state to prevent deadlock when | ||
104 | * first attempting a lock | ||
105 | * - Called SET_MODULE_OWNER for bond device | ||
106 | * | ||
107 | * 2001/5/17 - Tim Anderson <tsa at mvista.com> | ||
108 | * - 2 paths for releasing for slave release; 1 through ioctl | ||
109 | * and 2) through close. Both paths need to release the same way. | ||
110 | * - the free slave in bond release is changing slave status before | ||
111 | * the free. The netdev_set_master() is intended to change slave state | ||
112 | * so it should not be done as part of the release process. | ||
113 | * - Simple rule for slave state at release: only the active in A/B and | ||
114 | * only one in the trunked case. | ||
115 | * | ||
116 | * 2001/6/01 - Tim Anderson <tsa at mvista.com> | ||
117 | * - Now call dev_close when releasing a slave so it doesn't screw up | ||
118 | * out routing table. | ||
119 | * | ||
120 | * 2001/6/01 - Chad N. Tindel <ctindel at ieee dot org> | ||
121 | * - Added /proc support for getting bond and slave information. | ||
122 | * Information is in /proc/net/<bond device>/info. | ||
123 | * - Changed the locking when calling bond_close to prevent deadlock. | ||
124 | * | ||
125 | * 2001/8/05 - Janice Girouard <girouard at us.ibm.com> | ||
126 | * - correct problem where refcnt of slave is not incremented in bond_ioctl | ||
127 | * so the system hangs when halting. | ||
128 | * - correct locking problem when unable to malloc in bond_enslave. | ||
129 | * - adding bond_xmit_xor logic. | ||
130 | * - adding multiple bond device support. | ||
131 | * | ||
132 | * 2001/8/13 - Erik Habbinga <erik_habbinga at hp dot com> | ||
133 | * - correct locking problem with rtnl_exlock_nowait | ||
134 | * | ||
135 | * 2001/8/23 - Janice Girouard <girouard at us.ibm.com> | ||
136 | * - bzero initial dev_bonds, to correct oops | ||
137 | * - convert SIOCDEVPRIVATE to new MII ioctl calls | ||
138 | * | ||
139 | * 2001/9/13 - Takao Indoh <indou dot takao at jp dot fujitsu dot com> | ||
140 | * - Add the BOND_CHANGE_ACTIVE ioctl implementation | ||
141 | * | ||
142 | * 2001/9/14 - Mark Huth <mhuth at mvista dot com> | ||
143 | * - Change MII_LINK_READY to not check for end of auto-negotiation, | ||
144 | * but only for an up link. | ||
145 | * | ||
146 | * 2001/9/20 - Chad N. Tindel <ctindel at ieee dot org> | ||
147 | * - Add the device field to bonding_t. Previously the net_device | ||
148 | * corresponding to a bond wasn't available from the bonding_t | ||
149 | * structure. | ||
150 | * | ||
151 | * 2001/9/25 - Janice Girouard <girouard at us.ibm.com> | ||
152 | * - add arp_monitor for active backup mode | ||
153 | * | ||
154 | * 2001/10/23 - Takao Indoh <indou dot takao at jp dot fujitsu dot com> | ||
155 | * - Various memory leak fixes | ||
156 | * | ||
157 | * 2001/11/5 - Mark Huth <mark dot huth at mvista dot com> | ||
158 | * - Don't take rtnl lock in bond_mii_monitor as it deadlocks under | ||
159 | * certain hotswap conditions. | ||
160 | * Note: this same change may be required in bond_arp_monitor ??? | ||
161 | * - Remove possibility of calling bond_sethwaddr with NULL slave_dev ptr | ||
162 | * - Handle hot swap ethernet interface deregistration events to remove | ||
163 | * kernel oops following hot swap of enslaved interface | ||
164 | * | ||
165 | * 2002/1/2 - Chad N. Tindel <ctindel at ieee dot org> | ||
166 | * - Restore original slave flags at release time. | ||
167 | * | ||
168 | * 2002/02/18 - Erik Habbinga <erik_habbinga at hp dot com> | ||
169 | * - bond_release(): calling kfree on our_slave after call to | ||
170 | * bond_restore_slave_flags, not before | ||
171 | * - bond_enslave(): saving slave flags into original_flags before | ||
172 | * call to netdev_set_master, so the IFF_SLAVE flag doesn't end | ||
173 | * up in original_flags | ||
174 | * | ||
175 | * 2002/04/05 - Mark Smith <mark.smith at comdev dot cc> and | ||
176 | * Steve Mead <steve.mead at comdev dot cc> | ||
177 | * - Port Gleb Natapov's multicast support patchs from 2.4.12 | ||
178 | * to 2.4.18 adding support for multicast. | ||
179 | * | ||
180 | * 2002/06/10 - Tony Cureington <tony.cureington * hp_com> | ||
181 | * - corrected uninitialized pointer (ifr.ifr_data) in bond_check_dev_link; | ||
182 | * actually changed function to use MIIPHY, then MIIREG, and finally | ||
183 | * ETHTOOL to determine the link status | ||
184 | * - fixed bad ifr_data pointer assignments in bond_ioctl | ||
185 | * - corrected mode 1 being reported as active-backup in bond_get_info; | ||
186 | * also added text to distinguish type of load balancing (rr or xor) | ||
187 | * - change arp_ip_target module param from "1-12s" (array of 12 ptrs) | ||
188 | * to "s" (a single ptr) | ||
189 | * | ||
190 | * 2002/08/30 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
191 | * - Removed acquisition of xmit_lock in set_multicast_list; caused | ||
192 | * deadlock on SMP (lock is held by caller). | ||
193 | * - Revamped SIOCGMIIPHY, SIOCGMIIREG portion of bond_check_dev_link(). | ||
194 | * | ||
195 | * 2002/09/18 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
196 | * - Fixed up bond_check_dev_link() (and callers): removed some magic | ||
197 | * numbers, banished local MII_ defines, wrapped ioctl calls to | ||
198 | * prevent EFAULT errors | ||
199 | * | ||
200 | * 2002/9/30 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
201 | * - make sure the ip target matches the arp_target before saving the | ||
202 | * hw address. | ||
203 | * | ||
204 | * 2002/9/30 - Dan Eisner <eisner at 2robots dot com> | ||
205 | * - make sure my_ip is set before taking down the link, since | ||
206 | * not all switches respond if the source ip is not set. | ||
207 | * | ||
208 | * 2002/10/8 - Janice Girouard <girouard at us dot ibm dot com> | ||
209 | * - read in the local ip address when enslaving a device | ||
210 | * - add primary support | ||
211 | * - make sure 2*arp_interval has passed when a new device | ||
212 | * is brought on-line before taking it down. | ||
213 | * | ||
214 | * 2002/09/11 - Philippe De Muyter <phdm at macqel dot be> | ||
215 | * - Added bond_xmit_broadcast logic. | ||
216 | * - Added bond_mode() support function. | ||
217 | * | ||
218 | * 2002/10/26 - Laurent Deniel <laurent.deniel at free.fr> | ||
219 | * - allow to register multicast addresses only on active slave | ||
220 | * (useful in active-backup mode) | ||
221 | * - add multicast module parameter | ||
222 | * - fix deletion of multicast groups after unloading module | ||
223 | * | ||
224 | * 2002/11/06 - Kameshwara Rayaprolu <kameshwara.rao * wipro_com> | ||
225 | * - Changes to prevent panic from closing the device twice; if we close | ||
226 | * the device in bond_release, we must set the original_flags to down | ||
227 | * so it won't be closed again by the network layer. | ||
228 | * | ||
229 | * 2002/11/07 - Tony Cureington <tony.cureington * hp_com> | ||
230 | * - Fix arp_target_hw_addr memory leak | ||
231 | * - Created activebackup_arp_monitor function to handle arp monitoring | ||
232 | * in active backup mode - the bond_arp_monitor had several problems... | ||
233 | * such as allowing slaves to tx arps sequentially without any delay | ||
234 | * for a response | ||
235 | * - Renamed bond_arp_monitor to loadbalance_arp_monitor and re-wrote | ||
236 | * this function to just handle arp monitoring in load-balancing mode; | ||
237 | * it is a lot more compact now | ||
238 | * - Changes to ensure one and only one slave transmits in active-backup | ||
239 | * mode | ||
240 | * - Robustesize parameters; warn users about bad combinations of | ||
241 | * parameters; also if miimon is specified and a network driver does | ||
242 | * not support MII or ETHTOOL, inform the user of this | ||
243 | * - Changes to support link_failure_count when in arp monitoring mode | ||
244 | * - Fix up/down delay reported in /proc | ||
245 | * - Added version; log version; make version available from "modinfo -d" | ||
246 | * - Fixed problem in bond_check_dev_link - if the first IOCTL (SIOCGMIIPH) | ||
247 | * failed, the ETHTOOL ioctl never got a chance | ||
248 | * | ||
249 | * 2002/11/16 - Laurent Deniel <laurent.deniel at free.fr> | ||
250 | * - fix multicast handling in activebackup_arp_monitor | ||
251 | * - remove one unnecessary and confusing curr_active_slave == slave test | ||
252 | * in activebackup_arp_monitor | ||
253 | * | ||
254 | * 2002/11/17 - Laurent Deniel <laurent.deniel at free.fr> | ||
255 | * - fix bond_slave_info_query when slave_id = num_slaves | ||
256 | * | ||
257 | * 2002/11/19 - Janice Girouard <girouard at us dot ibm dot com> | ||
258 | * - correct ifr_data reference. Update ifr_data reference | ||
259 | * to mii_ioctl_data struct values to avoid confusion. | ||
260 | * | ||
261 | * 2002/11/22 - Bert Barbe <bert.barbe at oracle dot com> | ||
262 | * - Add support for multiple arp_ip_target | ||
263 | * | ||
264 | * 2002/12/13 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
265 | * - Changed to allow text strings for mode and multicast, e.g., | ||
266 | * insmod bonding mode=active-backup. The numbers still work. | ||
267 | * One change: an invalid choice will cause module load failure, | ||
268 | * rather than the previous behavior of just picking one. | ||
269 | * - Minor cleanups; got rid of dup ctype stuff, atoi function | ||
270 | * | ||
271 | * 2003/02/07 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
272 | * - Added use_carrier module parameter that causes miimon to | ||
273 | * use netif_carrier_ok() test instead of MII/ETHTOOL ioctls. | ||
274 | * - Minor cleanups; consolidated ioctl calls to one function. | ||
275 | * | ||
276 | * 2003/02/07 - Tony Cureington <tony.cureington * hp_com> | ||
277 | * - Fix bond_mii_monitor() logic error that could result in | ||
278 | * bonding round-robin mode ignoring links after failover/recovery | ||
279 | * | ||
280 | * 2003/03/17 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
281 | * - kmalloc fix (GFP_KERNEL to GFP_ATOMIC) reported by | ||
282 | * Shmulik dot Hen at intel.com. | ||
283 | * - Based on discussion on mailing list, changed use of | ||
284 | * update_slave_cnt(), created wrapper functions for adding/removing | ||
285 | * slaves, changed bond_xmit_xor() to check slave_cnt instead of | ||
286 | * checking slave and slave->dev (which only worked by accident). | ||
287 | * - Misc code cleanup: get arp_send() prototype from header file, | ||
288 | * add max_bonds to bonding.txt. | ||
289 | * | ||
290 | * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
291 | * Shmulik Hen <shmulik.hen at intel dot com> | ||
292 | * - Make sure only bond_attach_slave() and bond_detach_slave() can | ||
293 | * manipulate the slave list, including slave_cnt, even when in | ||
294 | * bond_release_all(). | ||
295 | * - Fixed hang in bond_release() with traffic running: | ||
296 | * netdev_set_master() must not be called from within the bond lock. | ||
297 | * | ||
298 | * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
299 | * Shmulik Hen <shmulik.hen at intel dot com> | ||
300 | * - Fixed hang in bond_enslave() with traffic running: | ||
301 | * netdev_set_master() must not be called from within the bond lock. | ||
302 | * | ||
303 | * 2003/03/18 - Amir Noam <amir.noam at intel dot com> | ||
304 | * - Added support for getting slave's speed and duplex via ethtool. | ||
305 | * Needed for 802.3ad and other future modes. | ||
306 | * | ||
307 | * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
308 | * Shmulik Hen <shmulik.hen at intel dot com> | ||
309 | * - Enable support of modes that need to use the unique mac address of | ||
310 | * each slave. | ||
311 | * * bond_enslave(): Moved setting the slave's mac address, and | ||
312 | * openning it, from the application to the driver. This breaks | ||
313 | * backward comaptibility with old versions of ifenslave that open | ||
314 | * the slave before enalsving it !!!. | ||
315 | * * bond_release(): The driver also takes care of closing the slave | ||
316 | * and restoring its original mac address. | ||
317 | * - Removed the code that restores all base driver's flags. | ||
318 | * Flags are automatically restored once all undo stages are done | ||
319 | * properly. | ||
320 | * - Block possibility of enslaving before the master is up. This | ||
321 | * prevents putting the system in an unstable state. | ||
322 | * | ||
323 | * 2003/03/18 - Amir Noam <amir.noam at intel dot com>, | ||
324 | * Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
325 | * Shmulik Hen <shmulik.hen at intel dot com> | ||
326 | * - Added support for IEEE 802.3ad Dynamic link aggregation mode. | ||
327 | * | ||
328 | * 2003/05/01 - Amir Noam <amir.noam at intel dot com> | ||
329 | * - Added ABI version control to restore compatibility between | ||
330 | * new/old ifenslave and new/old bonding. | ||
331 | * | ||
332 | * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
333 | * - Fixed bug in bond_release_all(): save old value of curr_active_slave | ||
334 | * before setting it to NULL. | ||
335 | * - Changed driver versioning scheme to include version number instead | ||
336 | * of release date (that is already in another field). There are 3 | ||
337 | * fields X.Y.Z where: | ||
338 | * X - Major version - big behavior changes | ||
339 | * Y - Minor version - addition of features | ||
340 | * Z - Extra version - minor changes and bug fixes | ||
341 | * The current version is 1.0.0 as a base line. | ||
342 | * | ||
343 | * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
344 | * Amir Noam <amir.noam at intel dot com> | ||
345 | * - Added support for lacp_rate module param. | ||
346 | * - Code beautification and style changes (mainly in comments). | ||
347 | * new version - 1.0.1 | ||
348 | * | ||
349 | * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
350 | * - Based on discussion on mailing list, changed locking scheme | ||
351 | * to use lock/unlock or lock_bh/unlock_bh appropriately instead | ||
352 | * of lock_irqsave/unlock_irqrestore. The new scheme helps exposing | ||
353 | * hidden bugs and solves system hangs that occurred due to the fact | ||
354 | * that holding lock_irqsave doesn't prevent softirqs from running. | ||
355 | * This also increases total throughput since interrupts are not | ||
356 | * blocked on each transmitted packets or monitor timeout. | ||
357 | * new version - 2.0.0 | ||
358 | * | ||
359 | * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
360 | * - Added support for Transmit load balancing mode. | ||
361 | * - Concentrate all assignments of curr_active_slave to a single point | ||
362 | * so specific modes can take actions when the primary adapter is | ||
363 | * changed. | ||
364 | * - Take the updelay parameter into consideration during bond_enslave | ||
365 | * since some adapters loose their link during setting the device. | ||
366 | * - Renamed bond_3ad_link_status_changed() to | ||
367 | * bond_3ad_handle_link_change() for compatibility with TLB. | ||
368 | * new version - 2.1.0 | ||
369 | * | ||
370 | * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> | ||
371 | * - Added support for Adaptive load balancing mode which is | ||
372 | * equivalent to Transmit load balancing + Receive load balancing. | ||
373 | * new version - 2.2.0 | ||
374 | * | ||
375 | * 2003/05/15 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
376 | * - Applied fix to activebackup_arp_monitor posted to bonding-devel | ||
377 | * by Tony Cureington <tony.cureington * hp_com>. Fixes ARP | ||
378 | * monitor endless failover bug. Version to 2.2.10 | ||
379 | * | ||
380 | * 2003/05/20 - Amir Noam <amir.noam at intel dot com> | ||
381 | * - Fixed bug in ABI version control - Don't commit to a specific | ||
382 | * ABI version if receiving unsupported ioctl commands. | ||
383 | * | ||
384 | * 2003/05/22 - Jay Vosburgh <fubar at us dot ibm dot com> | ||
385 | * - Fix ifenslave -c causing bond to loose existing routes; | ||
386 | * added bond_set_mac_address() that doesn't require the | ||
387 | * bond to be down. | ||
388 | * - In conjunction with fix for ifenslave -c, in | ||
389 | * bond_change_active(), changing to the already active slave | ||
390 | * is no longer an error (it successfully does nothing). | ||
391 | * | ||
392 | * 2003/06/30 - Amir Noam <amir.noam at intel dot com> | ||
393 | * - Fixed bond_change_active() for ALB/TLB modes. | ||
394 | * Version to 2.2.14. | ||
395 | * | ||
396 | * 2003/07/29 - Amir Noam <amir.noam at intel dot com> | ||
397 | * - Fixed ARP monitoring bug. | ||
398 | * Version to 2.2.15. | ||
399 | * | ||
400 | * 2003/07/31 - Willy Tarreau <willy at ods dot org> | ||
401 | * - Fixed kernel panic when using ARP monitoring without | ||
402 | * setting bond's IP address. | ||
403 | * Version to 2.2.16. | ||
404 | * | ||
405 | * 2003/08/06 - Amir Noam <amir.noam at intel dot com> | ||
406 | * - Back port from 2.6: use alloc_netdev(); fix /proc handling; | ||
407 | * made stats a part of bond struct so no need to allocate | ||
408 | * and free it separately; use standard list operations instead | ||
409 | * of pre-allocated array of bonds. | ||
410 | * Version to 2.3.0. | ||
411 | * | ||
412 | * 2003/08/07 - Jay Vosburgh <fubar at us dot ibm dot com>, | ||
413 | * Amir Noam <amir.noam at intel dot com> and | ||
414 | * Shmulik Hen <shmulik.hen at intel dot com> | ||
415 | * - Propagating master's settings: Distinguish between modes that | ||
416 | * use a primary slave from those that don't, and propagate settings | ||
417 | * accordingly; Consolidate change_active opeartions and add | ||
418 | * reselect_active and find_best opeartions; Decouple promiscuous | ||
419 | * handling from the multicast mode setting; Add support for changing | ||
420 | * HW address and MTU with proper unwind; Consolidate procfs code, | ||
421 | * add CHANGENAME handler; Enhance netdev notification handling. | ||
422 | * Version to 2.4.0. | ||
423 | * | ||
424 | * 2003/09/15 - Stephen Hemminger <shemminger at osdl dot org>, | ||
425 | * Amir Noam <amir.noam at intel dot com> | ||
426 | * - Convert /proc to seq_file interface. | ||
427 | * Change /proc/net/bondX/info to /proc/net/bonding/bondX. | ||
428 | * Set version to 2.4.1. | ||
429 | * | ||
430 | * 2003/11/20 - Amir Noam <amir.noam at intel dot com> | ||
431 | * - Fix /proc creation/destruction. | ||
432 | * | ||
433 | * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
434 | * - Massive cleanup - Set version to 2.5.0 | ||
435 | * Code changes: | ||
436 | * o Consolidate format of prints and debug prints. | ||
437 | * o Remove bonding_t/slave_t typedefs and consolidate all casts. | ||
438 | * o Remove dead code and unnecessary checks. | ||
439 | * o Consolidate starting/stopping timers. | ||
440 | * o Consolidate handling of primary module param throughout the code. | ||
441 | * o Removed multicast module param support - all settings are done | ||
442 | * according to mode. | ||
443 | * o Slave list iteration - bond is no longer part of the list, | ||
444 | * added cyclic list iteration macros. | ||
445 | * o Consolidate error handling in all xmit functions. | ||
446 | * Style changes: | ||
447 | * o Consolidate function naming and declarations. | ||
448 | * o Consolidate function params and local variables names. | ||
449 | * o Consolidate return values. | ||
450 | * o Consolidate curly braces. | ||
451 | * o Consolidate conditionals format. | ||
452 | * o Change struct member names and types. | ||
453 | * o Chomp trailing spaces, remove empty lines, fix indentations. | ||
454 | * o Re-organize code according to context. | ||
455 | * | ||
456 | * 2003/12/30 - Amir Noam <amir.noam at intel dot com> | ||
457 | * - Fixed: Cannot remove and re-enslave the original active slave. | ||
458 | * - Fixed: Releasing the original active slave causes mac address | ||
459 | * duplication. | ||
460 | * - Add support for slaves that use ethtool_ops. | ||
461 | * Set version to 2.5.3. | ||
462 | * | ||
463 | * 2004/01/05 - Amir Noam <amir.noam at intel dot com> | ||
464 | * - Save bonding parameters per bond instead of using the global values. | ||
465 | * Set version to 2.5.4. | ||
466 | * | ||
467 | * 2004/01/14 - Shmulik Hen <shmulik.hen at intel dot com> | ||
468 | * - Enhance VLAN support: | ||
469 | * * Add support for VLAN hardware acceleration capable slaves. | ||
470 | * * Add capability to tag self generated packets in ALB/TLB modes. | ||
471 | * Set version to 2.6.0. | ||
472 | * 2004/10/29 - Mitch Williams <mitch.a.williams at intel dot com> | ||
473 | * - Fixed bug when unloading module while using 802.3ad. If | ||
474 | * spinlock debugging is turned on, this causes a stack dump. | ||
475 | * Solution is to move call to dev_remove_pack outside of the | ||
476 | * spinlock. | ||
477 | * Set version to 2.6.1. | ||
478 | * 2005/06/05 - Jay Vosburgh <fubar@us.ibm.com> | ||
479 | * - Support for generating gratuitous ARPs in active-backup mode. | ||
480 | * Includes support for VLAN tagging all bonding-generated ARPs | ||
481 | * as needed. Set version to 2.6.2. | ||
482 | * 2005/06/08 - Jason Gabler <jygabler at lbl dot gov> | ||
483 | * - alternate hashing policy support for mode 2 | ||
484 | * * Added kernel parameter "xmit_hash_policy" to allow the selection | ||
485 | * of different hashing policies for mode 2. The original mode 2 | ||
486 | * policy is the default, now found in xmit_hash_policy_layer2(). | ||
487 | * * Added xmit_hash_policy_layer34() | ||
488 | * - Modified by Jay Vosburgh <fubar@us.ibm.com> to also support mode 4. | ||
489 | * Set version to 2.6.3. | ||
490 | * 2005/09/26 - Jay Vosburgh <fubar@us.ibm.com> | ||
491 | * - Removed backwards compatibility for old ifenslaves. Version 2.6.4. | ||
492 | */ | 32 | */ |
493 | 33 | ||
494 | //#define BONDING_DEBUG 1 | 34 | //#define BONDING_DEBUG 1 |
@@ -557,6 +97,7 @@ static char *lacp_rate = NULL; | |||
557 | static char *xmit_hash_policy = NULL; | 97 | static char *xmit_hash_policy = NULL; |
558 | static int arp_interval = BOND_LINK_ARP_INTERV; | 98 | static int arp_interval = BOND_LINK_ARP_INTERV; |
559 | static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; | 99 | static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; |
100 | struct bond_params bonding_defaults; | ||
560 | 101 | ||
561 | module_param(max_bonds, int, 0); | 102 | module_param(max_bonds, int, 0); |
562 | MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); | 103 | MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); |
@@ -565,17 +106,24 @@ MODULE_PARM_DESC(miimon, "Link check interval in milliseconds"); | |||
565 | module_param(updelay, int, 0); | 106 | module_param(updelay, int, 0); |
566 | MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds"); | 107 | MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds"); |
567 | module_param(downdelay, int, 0); | 108 | module_param(downdelay, int, 0); |
568 | MODULE_PARM_DESC(downdelay, "Delay before considering link down, in milliseconds"); | 109 | MODULE_PARM_DESC(downdelay, "Delay before considering link down, " |
110 | "in milliseconds"); | ||
569 | module_param(use_carrier, int, 0); | 111 | module_param(use_carrier, int, 0); |
570 | MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default)"); | 112 | MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; " |
113 | "0 for off, 1 for on (default)"); | ||
571 | module_param(mode, charp, 0); | 114 | module_param(mode, charp, 0); |
572 | MODULE_PARM_DESC(mode, "Mode of operation : 0 for round robin, 1 for active-backup, 2 for xor"); | 115 | MODULE_PARM_DESC(mode, "Mode of operation : 0 for balance-rr, " |
116 | "1 for active-backup, 2 for balance-xor, " | ||
117 | "3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, " | ||
118 | "6 for balance-alb"); | ||
573 | module_param(primary, charp, 0); | 119 | module_param(primary, charp, 0); |
574 | MODULE_PARM_DESC(primary, "Primary network device to use"); | 120 | MODULE_PARM_DESC(primary, "Primary network device to use"); |
575 | module_param(lacp_rate, charp, 0); | 121 | module_param(lacp_rate, charp, 0); |
576 | MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)"); | 122 | MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner " |
123 | "(slow/fast)"); | ||
577 | module_param(xmit_hash_policy, charp, 0); | 124 | module_param(xmit_hash_policy, charp, 0); |
578 | MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method : 0 for layer 2 (default), 1 for layer 3+4"); | 125 | MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method: 0 for layer 2 (default)" |
126 | ", 1 for layer 3+4"); | ||
579 | module_param(arp_interval, int, 0); | 127 | module_param(arp_interval, int, 0); |
580 | MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); | 128 | MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); |
581 | module_param_array(arp_ip_target, charp, NULL, 0); | 129 | module_param_array(arp_ip_target, charp, NULL, 0); |
@@ -586,30 +134,27 @@ MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form"); | |||
586 | static const char *version = | 134 | static const char *version = |
587 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; | 135 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; |
588 | 136 | ||
589 | static LIST_HEAD(bond_dev_list); | 137 | LIST_HEAD(bond_dev_list); |
590 | 138 | ||
591 | #ifdef CONFIG_PROC_FS | 139 | #ifdef CONFIG_PROC_FS |
592 | static struct proc_dir_entry *bond_proc_dir = NULL; | 140 | static struct proc_dir_entry *bond_proc_dir = NULL; |
593 | #endif | 141 | #endif |
594 | 142 | ||
143 | extern struct rw_semaphore bonding_rwsem; | ||
595 | static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; | 144 | static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; |
596 | static int arp_ip_count = 0; | 145 | static int arp_ip_count = 0; |
597 | static int bond_mode = BOND_MODE_ROUNDROBIN; | 146 | static int bond_mode = BOND_MODE_ROUNDROBIN; |
598 | static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; | 147 | static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; |
599 | static int lacp_fast = 0; | 148 | static int lacp_fast = 0; |
600 | 149 | ||
601 | struct bond_parm_tbl { | ||
602 | char *modename; | ||
603 | int mode; | ||
604 | }; | ||
605 | 150 | ||
606 | static struct bond_parm_tbl bond_lacp_tbl[] = { | 151 | struct bond_parm_tbl bond_lacp_tbl[] = { |
607 | { "slow", AD_LACP_SLOW}, | 152 | { "slow", AD_LACP_SLOW}, |
608 | { "fast", AD_LACP_FAST}, | 153 | { "fast", AD_LACP_FAST}, |
609 | { NULL, -1}, | 154 | { NULL, -1}, |
610 | }; | 155 | }; |
611 | 156 | ||
612 | static struct bond_parm_tbl bond_mode_tbl[] = { | 157 | struct bond_parm_tbl bond_mode_tbl[] = { |
613 | { "balance-rr", BOND_MODE_ROUNDROBIN}, | 158 | { "balance-rr", BOND_MODE_ROUNDROBIN}, |
614 | { "active-backup", BOND_MODE_ACTIVEBACKUP}, | 159 | { "active-backup", BOND_MODE_ACTIVEBACKUP}, |
615 | { "balance-xor", BOND_MODE_XOR}, | 160 | { "balance-xor", BOND_MODE_XOR}, |
@@ -620,7 +165,7 @@ static struct bond_parm_tbl bond_mode_tbl[] = { | |||
620 | { NULL, -1}, | 165 | { NULL, -1}, |
621 | }; | 166 | }; |
622 | 167 | ||
623 | static struct bond_parm_tbl xmit_hashtype_tbl[] = { | 168 | struct bond_parm_tbl xmit_hashtype_tbl[] = { |
624 | { "layer2", BOND_XMIT_POLICY_LAYER2}, | 169 | { "layer2", BOND_XMIT_POLICY_LAYER2}, |
625 | { "layer3+4", BOND_XMIT_POLICY_LAYER34}, | 170 | { "layer3+4", BOND_XMIT_POLICY_LAYER34}, |
626 | { NULL, -1}, | 171 | { NULL, -1}, |
@@ -628,12 +173,11 @@ static struct bond_parm_tbl xmit_hashtype_tbl[] = { | |||
628 | 173 | ||
629 | /*-------------------------- Forward declarations ---------------------------*/ | 174 | /*-------------------------- Forward declarations ---------------------------*/ |
630 | 175 | ||
631 | static inline void bond_set_mode_ops(struct bonding *bond, int mode); | ||
632 | static void bond_send_gratuitous_arp(struct bonding *bond); | 176 | static void bond_send_gratuitous_arp(struct bonding *bond); |
633 | 177 | ||
634 | /*---------------------------- General routines -----------------------------*/ | 178 | /*---------------------------- General routines -----------------------------*/ |
635 | 179 | ||
636 | static const char *bond_mode_name(int mode) | 180 | const char *bond_mode_name(int mode) |
637 | { | 181 | { |
638 | switch (mode) { | 182 | switch (mode) { |
639 | case BOND_MODE_ROUNDROBIN : | 183 | case BOND_MODE_ROUNDROBIN : |
@@ -910,7 +454,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid) | |||
910 | res = bond_add_vlan(bond, vid); | 454 | res = bond_add_vlan(bond, vid); |
911 | if (res) { | 455 | if (res) { |
912 | printk(KERN_ERR DRV_NAME | 456 | printk(KERN_ERR DRV_NAME |
913 | ": %s: Failed to add vlan id %d\n", | 457 | ": %s: Error: Failed to add vlan id %d\n", |
914 | bond_dev->name, vid); | 458 | bond_dev->name, vid); |
915 | } | 459 | } |
916 | } | 460 | } |
@@ -944,7 +488,7 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid) | |||
944 | res = bond_del_vlan(bond, vid); | 488 | res = bond_del_vlan(bond, vid); |
945 | if (res) { | 489 | if (res) { |
946 | printk(KERN_ERR DRV_NAME | 490 | printk(KERN_ERR DRV_NAME |
947 | ": %s: Failed to remove vlan id %d\n", | 491 | ": %s: Error: Failed to remove vlan id %d\n", |
948 | bond_dev->name, vid); | 492 | bond_dev->name, vid); |
949 | } | 493 | } |
950 | } | 494 | } |
@@ -1449,7 +993,7 @@ static struct slave *bond_find_best_slave(struct bonding *bond) | |||
1449 | * | 993 | * |
1450 | * Warning: Caller must hold curr_slave_lock for writing. | 994 | * Warning: Caller must hold curr_slave_lock for writing. |
1451 | */ | 995 | */ |
1452 | static void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | 996 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active) |
1453 | { | 997 | { |
1454 | struct slave *old_active = bond->curr_active_slave; | 998 | struct slave *old_active = bond->curr_active_slave; |
1455 | 999 | ||
@@ -1523,7 +1067,7 @@ static void bond_change_active_slave(struct bonding *bond, struct slave *new_act | |||
1523 | * | 1067 | * |
1524 | * Warning: Caller must hold curr_slave_lock for writing. | 1068 | * Warning: Caller must hold curr_slave_lock for writing. |
1525 | */ | 1069 | */ |
1526 | static void bond_select_active_slave(struct bonding *bond) | 1070 | void bond_select_active_slave(struct bonding *bond) |
1527 | { | 1071 | { |
1528 | struct slave *best_slave; | 1072 | struct slave *best_slave; |
1529 | 1073 | ||
@@ -1591,7 +1135,7 @@ static void bond_detach_slave(struct bonding *bond, struct slave *slave) | |||
1591 | 1135 | ||
1592 | /*---------------------------------- IOCTL ----------------------------------*/ | 1136 | /*---------------------------------- IOCTL ----------------------------------*/ |
1593 | 1137 | ||
1594 | static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) | 1138 | int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) |
1595 | { | 1139 | { |
1596 | dprintk("bond_dev=%p\n", bond_dev); | 1140 | dprintk("bond_dev=%p\n", bond_dev); |
1597 | dprintk("slave_dev=%p\n", slave_dev); | 1141 | dprintk("slave_dev=%p\n", slave_dev); |
@@ -1631,7 +1175,7 @@ static int bond_compute_features(struct bonding *bond) | |||
1631 | } | 1175 | } |
1632 | 1176 | ||
1633 | /* enslave device <slave> to bond device <master> */ | 1177 | /* enslave device <slave> to bond device <master> */ |
1634 | static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | 1178 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) |
1635 | { | 1179 | { |
1636 | struct bonding *bond = bond_dev->priv; | 1180 | struct bonding *bond = bond_dev->priv; |
1637 | struct slave *new_slave = NULL; | 1181 | struct slave *new_slave = NULL; |
@@ -1644,8 +1188,8 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1644 | if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL && | 1188 | if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL && |
1645 | slave_dev->do_ioctl == NULL) { | 1189 | slave_dev->do_ioctl == NULL) { |
1646 | printk(KERN_WARNING DRV_NAME | 1190 | printk(KERN_WARNING DRV_NAME |
1647 | ": Warning : no link monitoring support for %s\n", | 1191 | ": %s: Warning: no link monitoring support for %s\n", |
1648 | slave_dev->name); | 1192 | bond_dev->name, slave_dev->name); |
1649 | } | 1193 | } |
1650 | 1194 | ||
1651 | /* bond must be initialized by bond_open() before enslaving */ | 1195 | /* bond must be initialized by bond_open() before enslaving */ |
@@ -1666,17 +1210,17 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1666 | dprintk("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); | 1210 | dprintk("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); |
1667 | if (!list_empty(&bond->vlan_list)) { | 1211 | if (!list_empty(&bond->vlan_list)) { |
1668 | printk(KERN_ERR DRV_NAME | 1212 | printk(KERN_ERR DRV_NAME |
1669 | ": Error: cannot enslave VLAN " | 1213 | ": %s: Error: cannot enslave VLAN " |
1670 | "challenged slave %s on VLAN enabled " | 1214 | "challenged slave %s on VLAN enabled " |
1671 | "bond %s\n", slave_dev->name, | 1215 | "bond %s\n", bond_dev->name, slave_dev->name, |
1672 | bond_dev->name); | 1216 | bond_dev->name); |
1673 | return -EPERM; | 1217 | return -EPERM; |
1674 | } else { | 1218 | } else { |
1675 | printk(KERN_WARNING DRV_NAME | 1219 | printk(KERN_WARNING DRV_NAME |
1676 | ": Warning: enslaved VLAN challenged " | 1220 | ": %s: Warning: enslaved VLAN challenged " |
1677 | "slave %s. Adding VLANs will be blocked as " | 1221 | "slave %s. Adding VLANs will be blocked as " |
1678 | "long as %s is part of bond %s\n", | 1222 | "long as %s is part of bond %s\n", |
1679 | slave_dev->name, slave_dev->name, | 1223 | bond_dev->name, slave_dev->name, slave_dev->name, |
1680 | bond_dev->name); | 1224 | bond_dev->name); |
1681 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; | 1225 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; |
1682 | } | 1226 | } |
@@ -1706,12 +1250,11 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1706 | 1250 | ||
1707 | if (slave_dev->set_mac_address == NULL) { | 1251 | if (slave_dev->set_mac_address == NULL) { |
1708 | printk(KERN_ERR DRV_NAME | 1252 | printk(KERN_ERR DRV_NAME |
1709 | ": Error: The slave device you specified does " | 1253 | ": %s: Error: The slave device you specified does " |
1710 | "not support setting the MAC address.\n"); | 1254 | "not support setting the MAC address. " |
1711 | printk(KERN_ERR | 1255 | "Your kernel likely does not support slave " |
1712 | "Your kernel likely does not support slave devices.\n"); | 1256 | "devices.\n", bond_dev->name); |
1713 | 1257 | res = -EOPNOTSUPP; | |
1714 | res = -EOPNOTSUPP; | ||
1715 | goto err_undo_flags; | 1258 | goto err_undo_flags; |
1716 | } | 1259 | } |
1717 | 1260 | ||
@@ -1827,21 +1370,21 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1827 | * the messages for netif_carrier. | 1370 | * the messages for netif_carrier. |
1828 | */ | 1371 | */ |
1829 | printk(KERN_WARNING DRV_NAME | 1372 | printk(KERN_WARNING DRV_NAME |
1830 | ": Warning: MII and ETHTOOL support not " | 1373 | ": %s: Warning: MII and ETHTOOL support not " |
1831 | "available for interface %s, and " | 1374 | "available for interface %s, and " |
1832 | "arp_interval/arp_ip_target module parameters " | 1375 | "arp_interval/arp_ip_target module parameters " |
1833 | "not specified, thus bonding will not detect " | 1376 | "not specified, thus bonding will not detect " |
1834 | "link failures! see bonding.txt for details.\n", | 1377 | "link failures! see bonding.txt for details.\n", |
1835 | slave_dev->name); | 1378 | bond_dev->name, slave_dev->name); |
1836 | } else if (link_reporting == -1) { | 1379 | } else if (link_reporting == -1) { |
1837 | /* unable get link status using mii/ethtool */ | 1380 | /* unable get link status using mii/ethtool */ |
1838 | printk(KERN_WARNING DRV_NAME | 1381 | printk(KERN_WARNING DRV_NAME |
1839 | ": Warning: can't get link status from " | 1382 | ": %s: Warning: can't get link status from " |
1840 | "interface %s; the network driver associated " | 1383 | "interface %s; the network driver associated " |
1841 | "with this interface does not support MII or " | 1384 | "with this interface does not support MII or " |
1842 | "ETHTOOL link status reporting, thus miimon " | 1385 | "ETHTOOL link status reporting, thus miimon " |
1843 | "has no effect on this interface.\n", | 1386 | "has no effect on this interface.\n", |
1844 | slave_dev->name); | 1387 | bond_dev->name, slave_dev->name); |
1845 | } | 1388 | } |
1846 | } | 1389 | } |
1847 | 1390 | ||
@@ -1868,15 +1411,15 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1868 | if (bond_update_speed_duplex(new_slave) && | 1411 | if (bond_update_speed_duplex(new_slave) && |
1869 | (new_slave->link != BOND_LINK_DOWN)) { | 1412 | (new_slave->link != BOND_LINK_DOWN)) { |
1870 | printk(KERN_WARNING DRV_NAME | 1413 | printk(KERN_WARNING DRV_NAME |
1871 | ": Warning: failed to get speed and duplex from %s, " | 1414 | ": %s: Warning: failed to get speed and duplex from %s, " |
1872 | "assumed to be 100Mb/sec and Full.\n", | 1415 | "assumed to be 100Mb/sec and Full.\n", |
1873 | new_slave->dev->name); | 1416 | bond_dev->name, new_slave->dev->name); |
1874 | 1417 | ||
1875 | if (bond->params.mode == BOND_MODE_8023AD) { | 1418 | if (bond->params.mode == BOND_MODE_8023AD) { |
1876 | printk(KERN_WARNING | 1419 | printk(KERN_WARNING DRV_NAME |
1877 | "Operation of 802.3ad mode requires ETHTOOL " | 1420 | ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL " |
1878 | "support in base driver for proper aggregator " | 1421 | "support in base driver for proper aggregator " |
1879 | "selection.\n"); | 1422 | "selection.\n", bond_dev->name); |
1880 | } | 1423 | } |
1881 | } | 1424 | } |
1882 | 1425 | ||
@@ -1958,6 +1501,10 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1958 | 1501 | ||
1959 | write_unlock_bh(&bond->lock); | 1502 | write_unlock_bh(&bond->lock); |
1960 | 1503 | ||
1504 | res = bond_create_slave_symlinks(bond_dev, slave_dev); | ||
1505 | if (res) | ||
1506 | goto err_unset_master; | ||
1507 | |||
1961 | printk(KERN_INFO DRV_NAME | 1508 | printk(KERN_INFO DRV_NAME |
1962 | ": %s: enslaving %s as a%s interface with a%s link.\n", | 1509 | ": %s: enslaving %s as a%s interface with a%s link.\n", |
1963 | bond_dev->name, slave_dev->name, | 1510 | bond_dev->name, slave_dev->name, |
@@ -1999,7 +1546,7 @@ err_undo_flags: | |||
1999 | * for Bonded connections: | 1546 | * for Bonded connections: |
2000 | * The first up interface should be left on and all others downed. | 1547 | * The first up interface should be left on and all others downed. |
2001 | */ | 1548 | */ |
2002 | static int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | 1549 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) |
2003 | { | 1550 | { |
2004 | struct bonding *bond = bond_dev->priv; | 1551 | struct bonding *bond = bond_dev->priv; |
2005 | struct slave *slave, *oldcurrent; | 1552 | struct slave *slave, *oldcurrent; |
@@ -2010,7 +1557,7 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de | |||
2010 | if (!(slave_dev->flags & IFF_SLAVE) || | 1557 | if (!(slave_dev->flags & IFF_SLAVE) || |
2011 | (slave_dev->master != bond_dev)) { | 1558 | (slave_dev->master != bond_dev)) { |
2012 | printk(KERN_ERR DRV_NAME | 1559 | printk(KERN_ERR DRV_NAME |
2013 | ": Error: %s: cannot release %s.\n", | 1560 | ": %s: Error: cannot release %s.\n", |
2014 | bond_dev->name, slave_dev->name); | 1561 | bond_dev->name, slave_dev->name); |
2015 | return -EINVAL; | 1562 | return -EINVAL; |
2016 | } | 1563 | } |
@@ -2031,11 +1578,12 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de | |||
2031 | ETH_ALEN); | 1578 | ETH_ALEN); |
2032 | if (!mac_addr_differ && (bond->slave_cnt > 1)) { | 1579 | if (!mac_addr_differ && (bond->slave_cnt > 1)) { |
2033 | printk(KERN_WARNING DRV_NAME | 1580 | printk(KERN_WARNING DRV_NAME |
2034 | ": Warning: the permanent HWaddr of %s " | 1581 | ": %s: Warning: the permanent HWaddr of %s " |
2035 | "- %02X:%02X:%02X:%02X:%02X:%02X - is " | 1582 | "- %02X:%02X:%02X:%02X:%02X:%02X - is " |
2036 | "still in use by %s. Set the HWaddr of " | 1583 | "still in use by %s. Set the HWaddr of " |
2037 | "%s to a different address to avoid " | 1584 | "%s to a different address to avoid " |
2038 | "conflicts.\n", | 1585 | "conflicts.\n", |
1586 | bond_dev->name, | ||
2039 | slave_dev->name, | 1587 | slave_dev->name, |
2040 | slave->perm_hwaddr[0], | 1588 | slave->perm_hwaddr[0], |
2041 | slave->perm_hwaddr[1], | 1589 | slave->perm_hwaddr[1], |
@@ -2111,24 +1659,28 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de | |||
2111 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; | 1659 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; |
2112 | } else { | 1660 | } else { |
2113 | printk(KERN_WARNING DRV_NAME | 1661 | printk(KERN_WARNING DRV_NAME |
2114 | ": Warning: clearing HW address of %s while it " | 1662 | ": %s: Warning: clearing HW address of %s while it " |
2115 | "still has VLANs.\n", | 1663 | "still has VLANs.\n", |
2116 | bond_dev->name); | 1664 | bond_dev->name, bond_dev->name); |
2117 | printk(KERN_WARNING DRV_NAME | 1665 | printk(KERN_WARNING DRV_NAME |
2118 | ": When re-adding slaves, make sure the bond's " | 1666 | ": %s: When re-adding slaves, make sure the bond's " |
2119 | "HW address matches its VLANs'.\n"); | 1667 | "HW address matches its VLANs'.\n", |
1668 | bond_dev->name); | ||
2120 | } | 1669 | } |
2121 | } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && | 1670 | } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && |
2122 | !bond_has_challenged_slaves(bond)) { | 1671 | !bond_has_challenged_slaves(bond)) { |
2123 | printk(KERN_INFO DRV_NAME | 1672 | printk(KERN_INFO DRV_NAME |
2124 | ": last VLAN challenged slave %s " | 1673 | ": %s: last VLAN challenged slave %s " |
2125 | "left bond %s. VLAN blocking is removed\n", | 1674 | "left bond %s. VLAN blocking is removed\n", |
2126 | slave_dev->name, bond_dev->name); | 1675 | bond_dev->name, slave_dev->name, bond_dev->name); |
2127 | bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED; | 1676 | bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED; |
2128 | } | 1677 | } |
2129 | 1678 | ||
2130 | write_unlock_bh(&bond->lock); | 1679 | write_unlock_bh(&bond->lock); |
2131 | 1680 | ||
1681 | /* must do this from outside any spinlocks */ | ||
1682 | bond_destroy_slave_symlinks(bond_dev, slave_dev); | ||
1683 | |||
2132 | bond_del_vlans_from_slave(bond, slave_dev); | 1684 | bond_del_vlans_from_slave(bond, slave_dev); |
2133 | 1685 | ||
2134 | /* If the mode USES_PRIMARY, then we should only remove its | 1686 | /* If the mode USES_PRIMARY, then we should only remove its |
@@ -2220,6 +1772,7 @@ static int bond_release_all(struct net_device *bond_dev) | |||
2220 | */ | 1772 | */ |
2221 | write_unlock_bh(&bond->lock); | 1773 | write_unlock_bh(&bond->lock); |
2222 | 1774 | ||
1775 | bond_destroy_slave_symlinks(bond_dev, slave_dev); | ||
2223 | bond_del_vlans_from_slave(bond, slave_dev); | 1776 | bond_del_vlans_from_slave(bond, slave_dev); |
2224 | 1777 | ||
2225 | /* If the mode USES_PRIMARY, then we should only remove its | 1778 | /* If the mode USES_PRIMARY, then we should only remove its |
@@ -2274,12 +1827,13 @@ static int bond_release_all(struct net_device *bond_dev) | |||
2274 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; | 1827 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; |
2275 | } else { | 1828 | } else { |
2276 | printk(KERN_WARNING DRV_NAME | 1829 | printk(KERN_WARNING DRV_NAME |
2277 | ": Warning: clearing HW address of %s while it " | 1830 | ": %s: Warning: clearing HW address of %s while it " |
2278 | "still has VLANs.\n", | 1831 | "still has VLANs.\n", |
2279 | bond_dev->name); | 1832 | bond_dev->name, bond_dev->name); |
2280 | printk(KERN_WARNING DRV_NAME | 1833 | printk(KERN_WARNING DRV_NAME |
2281 | ": When re-adding slaves, make sure the bond's " | 1834 | ": %s: When re-adding slaves, make sure the bond's " |
2282 | "HW address matches its VLANs'.\n"); | 1835 | "HW address matches its VLANs'.\n", |
1836 | bond_dev->name); | ||
2283 | } | 1837 | } |
2284 | 1838 | ||
2285 | printk(KERN_INFO DRV_NAME | 1839 | printk(KERN_INFO DRV_NAME |
@@ -2397,7 +1951,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in | |||
2397 | /*-------------------------------- Monitoring -------------------------------*/ | 1951 | /*-------------------------------- Monitoring -------------------------------*/ |
2398 | 1952 | ||
2399 | /* this function is called regularly to monitor each slave's link. */ | 1953 | /* this function is called regularly to monitor each slave's link. */ |
2400 | static void bond_mii_monitor(struct net_device *bond_dev) | 1954 | void bond_mii_monitor(struct net_device *bond_dev) |
2401 | { | 1955 | { |
2402 | struct bonding *bond = bond_dev->priv; | 1956 | struct bonding *bond = bond_dev->priv; |
2403 | struct slave *slave, *oldcurrent; | 1957 | struct slave *slave, *oldcurrent; |
@@ -2596,8 +2150,11 @@ static void bond_mii_monitor(struct net_device *bond_dev) | |||
2596 | break; | 2150 | break; |
2597 | default: | 2151 | default: |
2598 | /* Should not happen */ | 2152 | /* Should not happen */ |
2599 | printk(KERN_ERR "bonding: Error: %s Illegal value (link=%d)\n", | 2153 | printk(KERN_ERR DRV_NAME |
2600 | slave->dev->name, slave->link); | 2154 | ": %s: Error: %s Illegal value (link=%d)\n", |
2155 | bond_dev->name, | ||
2156 | slave->dev->name, | ||
2157 | slave->link); | ||
2601 | goto out; | 2158 | goto out; |
2602 | } /* end of switch (slave->link) */ | 2159 | } /* end of switch (slave->link) */ |
2603 | 2160 | ||
@@ -2721,7 +2278,9 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave) | |||
2721 | struct flowi fl; | 2278 | struct flowi fl; |
2722 | struct rtable *rt; | 2279 | struct rtable *rt; |
2723 | 2280 | ||
2724 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) { | 2281 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { |
2282 | if (!targets[i]) | ||
2283 | continue; | ||
2725 | dprintk("basa: target %x\n", targets[i]); | 2284 | dprintk("basa: target %x\n", targets[i]); |
2726 | if (list_empty(&bond->vlan_list)) { | 2285 | if (list_empty(&bond->vlan_list)) { |
2727 | dprintk("basa: empty vlan: arp_send\n"); | 2286 | dprintk("basa: empty vlan: arp_send\n"); |
@@ -2825,7 +2384,7 @@ static void bond_send_gratuitous_arp(struct bonding *bond) | |||
2825 | * arp is transmitted to generate traffic. see activebackup_arp_monitor for | 2384 | * arp is transmitted to generate traffic. see activebackup_arp_monitor for |
2826 | * arp monitoring in active backup mode. | 2385 | * arp monitoring in active backup mode. |
2827 | */ | 2386 | */ |
2828 | static void bond_loadbalance_arp_mon(struct net_device *bond_dev) | 2387 | void bond_loadbalance_arp_mon(struct net_device *bond_dev) |
2829 | { | 2388 | { |
2830 | struct bonding *bond = bond_dev->priv; | 2389 | struct bonding *bond = bond_dev->priv; |
2831 | struct slave *slave, *oldcurrent; | 2390 | struct slave *slave, *oldcurrent; |
@@ -2963,7 +2522,7 @@ out: | |||
2963 | * may have received. | 2522 | * may have received. |
2964 | * see loadbalance_arp_monitor for arp monitoring in load balancing mode | 2523 | * see loadbalance_arp_monitor for arp monitoring in load balancing mode |
2965 | */ | 2524 | */ |
2966 | static void bond_activebackup_arp_mon(struct net_device *bond_dev) | 2525 | void bond_activebackup_arp_mon(struct net_device *bond_dev) |
2967 | { | 2526 | { |
2968 | struct bonding *bond = bond_dev->priv; | 2527 | struct bonding *bond = bond_dev->priv; |
2969 | struct slave *slave; | 2528 | struct slave *slave; |
@@ -3249,6 +2808,8 @@ static void bond_info_show_master(struct seq_file *seq) | |||
3249 | { | 2808 | { |
3250 | struct bonding *bond = seq->private; | 2809 | struct bonding *bond = seq->private; |
3251 | struct slave *curr; | 2810 | struct slave *curr; |
2811 | int i; | ||
2812 | u32 target; | ||
3252 | 2813 | ||
3253 | read_lock(&bond->curr_slave_lock); | 2814 | read_lock(&bond->curr_slave_lock); |
3254 | curr = bond->curr_active_slave; | 2815 | curr = bond->curr_active_slave; |
@@ -3257,10 +2818,17 @@ static void bond_info_show_master(struct seq_file *seq) | |||
3257 | seq_printf(seq, "Bonding Mode: %s\n", | 2818 | seq_printf(seq, "Bonding Mode: %s\n", |
3258 | bond_mode_name(bond->params.mode)); | 2819 | bond_mode_name(bond->params.mode)); |
3259 | 2820 | ||
2821 | if (bond->params.mode == BOND_MODE_XOR || | ||
2822 | bond->params.mode == BOND_MODE_8023AD) { | ||
2823 | seq_printf(seq, "Transmit Hash Policy: %s (%d)\n", | ||
2824 | xmit_hashtype_tbl[bond->params.xmit_policy].modename, | ||
2825 | bond->params.xmit_policy); | ||
2826 | } | ||
2827 | |||
3260 | if (USES_PRIMARY(bond->params.mode)) { | 2828 | if (USES_PRIMARY(bond->params.mode)) { |
3261 | seq_printf(seq, "Primary Slave: %s\n", | 2829 | seq_printf(seq, "Primary Slave: %s\n", |
3262 | (bond->params.primary[0]) ? | 2830 | (bond->primary_slave) ? |
3263 | bond->params.primary : "None"); | 2831 | bond->primary_slave->dev->name : "None"); |
3264 | 2832 | ||
3265 | seq_printf(seq, "Currently Active Slave: %s\n", | 2833 | seq_printf(seq, "Currently Active Slave: %s\n", |
3266 | (curr) ? curr->dev->name : "None"); | 2834 | (curr) ? curr->dev->name : "None"); |
@@ -3273,6 +2841,27 @@ static void bond_info_show_master(struct seq_file *seq) | |||
3273 | seq_printf(seq, "Down Delay (ms): %d\n", | 2841 | seq_printf(seq, "Down Delay (ms): %d\n", |
3274 | bond->params.downdelay * bond->params.miimon); | 2842 | bond->params.downdelay * bond->params.miimon); |
3275 | 2843 | ||
2844 | |||
2845 | /* ARP information */ | ||
2846 | if(bond->params.arp_interval > 0) { | ||
2847 | int printed=0; | ||
2848 | seq_printf(seq, "ARP Polling Interval (ms): %d\n", | ||
2849 | bond->params.arp_interval); | ||
2850 | |||
2851 | seq_printf(seq, "ARP IP target/s (n.n.n.n form):"); | ||
2852 | |||
2853 | for(i = 0; (i < BOND_MAX_ARP_TARGETS) ;i++) { | ||
2854 | if (!bond->params.arp_targets[i]) | ||
2855 | continue; | ||
2856 | if (printed) | ||
2857 | seq_printf(seq, ","); | ||
2858 | target = ntohl(bond->params.arp_targets[i]); | ||
2859 | seq_printf(seq, " %d.%d.%d.%d", HIPQUAD(target)); | ||
2860 | printed = 1; | ||
2861 | } | ||
2862 | seq_printf(seq, "\n"); | ||
2863 | } | ||
2864 | |||
3276 | if (bond->params.mode == BOND_MODE_8023AD) { | 2865 | if (bond->params.mode == BOND_MODE_8023AD) { |
3277 | struct ad_info ad_info; | 2866 | struct ad_info ad_info; |
3278 | 2867 | ||
@@ -3478,7 +3067,10 @@ static int bond_event_changename(struct bonding *bond) | |||
3478 | bond_remove_proc_entry(bond); | 3067 | bond_remove_proc_entry(bond); |
3479 | bond_create_proc_entry(bond); | 3068 | bond_create_proc_entry(bond); |
3480 | #endif | 3069 | #endif |
3481 | 3070 | down_write(&(bonding_rwsem)); | |
3071 | bond_destroy_sysfs_entry(bond); | ||
3072 | bond_create_sysfs_entry(bond); | ||
3073 | up_write(&(bonding_rwsem)); | ||
3482 | return NOTIFY_DONE; | 3074 | return NOTIFY_DONE; |
3483 | } | 3075 | } |
3484 | 3076 | ||
@@ -3955,6 +3547,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3955 | return -EPERM; | 3547 | return -EPERM; |
3956 | } | 3548 | } |
3957 | 3549 | ||
3550 | down_write(&(bonding_rwsem)); | ||
3958 | slave_dev = dev_get_by_name(ifr->ifr_slave); | 3551 | slave_dev = dev_get_by_name(ifr->ifr_slave); |
3959 | 3552 | ||
3960 | dprintk("slave_dev=%p: \n", slave_dev); | 3553 | dprintk("slave_dev=%p: \n", slave_dev); |
@@ -3987,6 +3580,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3987 | dev_put(slave_dev); | 3580 | dev_put(slave_dev); |
3988 | } | 3581 | } |
3989 | 3582 | ||
3583 | up_write(&(bonding_rwsem)); | ||
3990 | return res; | 3584 | return res; |
3991 | } | 3585 | } |
3992 | 3586 | ||
@@ -4071,6 +3665,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) | |||
4071 | bond_for_each_slave(bond, slave, i) { | 3665 | bond_for_each_slave(bond, slave, i) { |
4072 | dprintk("s %p s->p %p c_m %p\n", slave, | 3666 | dprintk("s %p s->p %p c_m %p\n", slave, |
4073 | slave->prev, slave->dev->change_mtu); | 3667 | slave->prev, slave->dev->change_mtu); |
3668 | |||
4074 | res = dev_set_mtu(slave->dev, new_mtu); | 3669 | res = dev_set_mtu(slave->dev, new_mtu); |
4075 | 3670 | ||
4076 | if (res) { | 3671 | if (res) { |
@@ -4397,8 +3992,9 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) | |||
4397 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); | 3992 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); |
4398 | if (!skb2) { | 3993 | if (!skb2) { |
4399 | printk(KERN_ERR DRV_NAME | 3994 | printk(KERN_ERR DRV_NAME |
4400 | ": Error: bond_xmit_broadcast(): " | 3995 | ": %s: Error: bond_xmit_broadcast(): " |
4401 | "skb_clone() failed\n"); | 3996 | "skb_clone() failed\n", |
3997 | bond_dev->name); | ||
4402 | continue; | 3998 | continue; |
4403 | } | 3999 | } |
4404 | 4000 | ||
@@ -4431,7 +4027,7 @@ out: | |||
4431 | /* | 4027 | /* |
4432 | * set bond mode specific net device operations | 4028 | * set bond mode specific net device operations |
4433 | */ | 4029 | */ |
4434 | static inline void bond_set_mode_ops(struct bonding *bond, int mode) | 4030 | void bond_set_mode_ops(struct bonding *bond, int mode) |
4435 | { | 4031 | { |
4436 | struct net_device *bond_dev = bond->dev; | 4032 | struct net_device *bond_dev = bond->dev; |
4437 | 4033 | ||
@@ -4467,7 +4063,8 @@ static inline void bond_set_mode_ops(struct bonding *bond, int mode) | |||
4467 | default: | 4063 | default: |
4468 | /* Should never happen, mode already checked */ | 4064 | /* Should never happen, mode already checked */ |
4469 | printk(KERN_ERR DRV_NAME | 4065 | printk(KERN_ERR DRV_NAME |
4470 | ": Error: Unknown bonding mode %d\n", | 4066 | ": %s: Error: Unknown bonding mode %d\n", |
4067 | bond_dev->name, | ||
4471 | mode); | 4068 | mode); |
4472 | break; | 4069 | break; |
4473 | } | 4070 | } |
@@ -4491,7 +4088,7 @@ static struct ethtool_ops bond_ethtool_ops = { | |||
4491 | * Does not allocate but creates a /proc entry. | 4088 | * Does not allocate but creates a /proc entry. |
4492 | * Allowed to fail. | 4089 | * Allowed to fail. |
4493 | */ | 4090 | */ |
4494 | static int __init bond_init(struct net_device *bond_dev, struct bond_params *params) | 4091 | static int bond_init(struct net_device *bond_dev, struct bond_params *params) |
4495 | { | 4092 | { |
4496 | struct bonding *bond = bond_dev->priv; | 4093 | struct bonding *bond = bond_dev->priv; |
4497 | 4094 | ||
@@ -4565,7 +4162,7 @@ static int __init bond_init(struct net_device *bond_dev, struct bond_params *par | |||
4565 | /* De-initialize device specific data. | 4162 | /* De-initialize device specific data. |
4566 | * Caller must hold rtnl_lock. | 4163 | * Caller must hold rtnl_lock. |
4567 | */ | 4164 | */ |
4568 | static inline void bond_deinit(struct net_device *bond_dev) | 4165 | void bond_deinit(struct net_device *bond_dev) |
4569 | { | 4166 | { |
4570 | struct bonding *bond = bond_dev->priv; | 4167 | struct bonding *bond = bond_dev->priv; |
4571 | 4168 | ||
@@ -4601,7 +4198,7 @@ static void bond_free_all(void) | |||
4601 | * Convert string input module parms. Accept either the | 4198 | * Convert string input module parms. Accept either the |
4602 | * number of the mode or its string name. | 4199 | * number of the mode or its string name. |
4603 | */ | 4200 | */ |
4604 | static inline int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) | 4201 | int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) |
4605 | { | 4202 | { |
4606 | int i; | 4203 | int i; |
4607 | 4204 | ||
@@ -4670,7 +4267,7 @@ static int bond_check_params(struct bond_params *params) | |||
4670 | if (max_bonds < 1 || max_bonds > INT_MAX) { | 4267 | if (max_bonds < 1 || max_bonds > INT_MAX) { |
4671 | printk(KERN_WARNING DRV_NAME | 4268 | printk(KERN_WARNING DRV_NAME |
4672 | ": Warning: max_bonds (%d) not in range %d-%d, so it " | 4269 | ": Warning: max_bonds (%d) not in range %d-%d, so it " |
4673 | "was reset to BOND_DEFAULT_MAX_BONDS (%d)", | 4270 | "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n", |
4674 | max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS); | 4271 | max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS); |
4675 | max_bonds = BOND_DEFAULT_MAX_BONDS; | 4272 | max_bonds = BOND_DEFAULT_MAX_BONDS; |
4676 | } | 4273 | } |
@@ -4881,81 +4478,96 @@ static int bond_check_params(struct bond_params *params) | |||
4881 | return 0; | 4478 | return 0; |
4882 | } | 4479 | } |
4883 | 4480 | ||
4481 | /* Create a new bond based on the specified name and bonding parameters. | ||
4482 | * Caller must NOT hold rtnl_lock; we need to release it here before we | ||
4483 | * set up our sysfs entries. | ||
4484 | */ | ||
4485 | int bond_create(char *name, struct bond_params *params, struct bonding **newbond) | ||
4486 | { | ||
4487 | struct net_device *bond_dev; | ||
4488 | int res; | ||
4489 | |||
4490 | rtnl_lock(); | ||
4491 | bond_dev = alloc_netdev(sizeof(struct bonding), name, ether_setup); | ||
4492 | if (!bond_dev) { | ||
4493 | printk(KERN_ERR DRV_NAME | ||
4494 | ": %s: eek! can't alloc netdev!\n", | ||
4495 | name); | ||
4496 | res = -ENOMEM; | ||
4497 | goto out_rtnl; | ||
4498 | } | ||
4499 | |||
4500 | /* bond_init() must be called after dev_alloc_name() (for the | ||
4501 | * /proc files), but before register_netdevice(), because we | ||
4502 | * need to set function pointers. | ||
4503 | */ | ||
4504 | |||
4505 | res = bond_init(bond_dev, params); | ||
4506 | if (res < 0) { | ||
4507 | goto out_netdev; | ||
4508 | } | ||
4509 | |||
4510 | SET_MODULE_OWNER(bond_dev); | ||
4511 | |||
4512 | res = register_netdevice(bond_dev); | ||
4513 | if (res < 0) { | ||
4514 | goto out_bond; | ||
4515 | } | ||
4516 | if (newbond) | ||
4517 | *newbond = bond_dev->priv; | ||
4518 | |||
4519 | rtnl_unlock(); /* allows sysfs registration of net device */ | ||
4520 | res = bond_create_sysfs_entry(bond_dev->priv); | ||
4521 | goto done; | ||
4522 | out_bond: | ||
4523 | bond_deinit(bond_dev); | ||
4524 | out_netdev: | ||
4525 | free_netdev(bond_dev); | ||
4526 | out_rtnl: | ||
4527 | rtnl_unlock(); | ||
4528 | done: | ||
4529 | return res; | ||
4530 | } | ||
4531 | |||
4884 | static int __init bonding_init(void) | 4532 | static int __init bonding_init(void) |
4885 | { | 4533 | { |
4886 | struct bond_params params; | ||
4887 | int i; | 4534 | int i; |
4888 | int res; | 4535 | int res; |
4536 | char new_bond_name[8]; /* Enough room for 999 bonds at init. */ | ||
4889 | 4537 | ||
4890 | printk(KERN_INFO "%s", version); | 4538 | printk(KERN_INFO "%s", version); |
4891 | 4539 | ||
4892 | res = bond_check_params(¶ms); | 4540 | res = bond_check_params(&bonding_defaults); |
4893 | if (res) { | 4541 | if (res) { |
4894 | return res; | 4542 | goto out; |
4895 | } | 4543 | } |
4896 | 4544 | ||
4897 | rtnl_lock(); | ||
4898 | |||
4899 | #ifdef CONFIG_PROC_FS | 4545 | #ifdef CONFIG_PROC_FS |
4900 | bond_create_proc_dir(); | 4546 | bond_create_proc_dir(); |
4901 | #endif | 4547 | #endif |
4902 | |||
4903 | for (i = 0; i < max_bonds; i++) { | 4548 | for (i = 0; i < max_bonds; i++) { |
4904 | struct net_device *bond_dev; | 4549 | sprintf(new_bond_name, "bond%d",i); |
4905 | 4550 | res = bond_create(new_bond_name,&bonding_defaults, NULL); | |
4906 | bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); | 4551 | if (res) |
4907 | if (!bond_dev) { | 4552 | goto err; |
4908 | res = -ENOMEM; | ||
4909 | goto out_err; | ||
4910 | } | ||
4911 | |||
4912 | res = dev_alloc_name(bond_dev, "bond%d"); | ||
4913 | if (res < 0) { | ||
4914 | free_netdev(bond_dev); | ||
4915 | goto out_err; | ||
4916 | } | ||
4917 | |||
4918 | /* bond_init() must be called after dev_alloc_name() (for the | ||
4919 | * /proc files), but before register_netdevice(), because we | ||
4920 | * need to set function pointers. | ||
4921 | */ | ||
4922 | res = bond_init(bond_dev, ¶ms); | ||
4923 | if (res < 0) { | ||
4924 | free_netdev(bond_dev); | ||
4925 | goto out_err; | ||
4926 | } | ||
4927 | |||
4928 | SET_MODULE_OWNER(bond_dev); | ||
4929 | |||
4930 | res = register_netdevice(bond_dev); | ||
4931 | if (res < 0) { | ||
4932 | bond_deinit(bond_dev); | ||
4933 | free_netdev(bond_dev); | ||
4934 | goto out_err; | ||
4935 | } | ||
4936 | } | 4553 | } |
4937 | 4554 | ||
4938 | rtnl_unlock(); | 4555 | res = bond_create_sysfs(); |
4556 | if (res) | ||
4557 | goto err; | ||
4558 | |||
4939 | register_netdevice_notifier(&bond_netdev_notifier); | 4559 | register_netdevice_notifier(&bond_netdev_notifier); |
4940 | register_inetaddr_notifier(&bond_inetaddr_notifier); | 4560 | register_inetaddr_notifier(&bond_inetaddr_notifier); |
4941 | 4561 | ||
4942 | return 0; | 4562 | goto out; |
4943 | 4563 | err: | |
4944 | out_err: | ||
4945 | /* | ||
4946 | * rtnl_unlock() will run netdev_run_todo(), putting the | ||
4947 | * thus-far-registered bonding devices into a state which | ||
4948 | * unregigister_netdevice() will accept | ||
4949 | */ | ||
4950 | rtnl_unlock(); | ||
4951 | rtnl_lock(); | 4564 | rtnl_lock(); |
4952 | |||
4953 | /* free and unregister all bonds that were successfully added */ | ||
4954 | bond_free_all(); | 4565 | bond_free_all(); |
4955 | 4566 | bond_destroy_sysfs(); | |
4956 | rtnl_unlock(); | 4567 | rtnl_unlock(); |
4957 | 4568 | out: | |
4958 | return res; | 4569 | return res; |
4570 | |||
4959 | } | 4571 | } |
4960 | 4572 | ||
4961 | static void __exit bonding_exit(void) | 4573 | static void __exit bonding_exit(void) |
@@ -4965,6 +4577,7 @@ static void __exit bonding_exit(void) | |||
4965 | 4577 | ||
4966 | rtnl_lock(); | 4578 | rtnl_lock(); |
4967 | bond_free_all(); | 4579 | bond_free_all(); |
4580 | bond_destroy_sysfs(); | ||
4968 | rtnl_unlock(); | 4581 | rtnl_unlock(); |
4969 | } | 4582 | } |
4970 | 4583 | ||