diff options
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 106 | ||||
-rw-r--r-- | drivers/net/bonding/bond_3ad.h | 13 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 75 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.h | 9 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 781 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 1358 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 52 |
8 files changed, 1664 insertions, 732 deletions
diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile index cf50384b469..5cdae2bc055 100644 --- a/drivers/net/bonding/Makefile +++ b/drivers/net/bonding/Makefile | |||
@@ -4,5 +4,5 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_BONDING) += bonding.o | 5 | obj-$(CONFIG_BONDING) += bonding.o |
6 | 6 | ||
7 | bonding-objs := bond_main.o bond_3ad.o bond_alb.o | 7 | bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o |
8 | 8 | ||
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index d2f34d5a808..f3f5825469d 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -18,38 +18,6 @@ | |||
18 | * The full GNU General Public License is included in this distribution in the | 18 | * The full GNU General Public License is included in this distribution in the |
19 | * file called LICENSE. | 19 | * file called LICENSE. |
20 | * | 20 | * |
21 | * | ||
22 | * Changes: | ||
23 | * | ||
24 | * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
25 | * Amir Noam <amir.noam at intel dot com> | ||
26 | * - Added support for lacp_rate module param. | ||
27 | * | ||
28 | * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
29 | * - Based on discussion on mailing list, changed locking scheme | ||
30 | * to use lock/unlock or lock_bh/unlock_bh appropriately instead | ||
31 | * of lock_irqsave/unlock_irqrestore. The new scheme helps exposing | ||
32 | * hidden bugs and solves system hangs that occurred due to the fact | ||
33 | * that holding lock_irqsave doesn't prevent softirqs from running. | ||
34 | * This also increases total throughput since interrupts are not | ||
35 | * blocked on each transmitted packets or monitor timeout. | ||
36 | * | ||
37 | * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
38 | * - Renamed bond_3ad_link_status_changed() to | ||
39 | * bond_3ad_handle_link_change() for compatibility with TLB. | ||
40 | * | ||
41 | * 2003/05/20 - Amir Noam <amir.noam at intel dot com> | ||
42 | * - Fix long fail over time when releasing last slave of an active | ||
43 | * aggregator - send LACPDU on unbind of slave to tell partner this | ||
44 | * port is no longer aggregatable. | ||
45 | * | ||
46 | * 2003/06/25 - Tsippy Mendelson <tsippy.mendelson at intel dot com> | ||
47 | * - Send LACPDU as highest priority packet to further fix the above | ||
48 | * problem on very high Tx traffic load where packets may get dropped | ||
49 | * by the slave. | ||
50 | * | ||
51 | * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
52 | * - Code cleanup and style changes | ||
53 | */ | 21 | */ |
54 | 22 | ||
55 | //#define BONDING_DEBUG 1 | 23 | //#define BONDING_DEBUG 1 |
@@ -1198,10 +1166,10 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) | |||
1198 | // detect loopback situation | 1166 | // detect loopback situation |
1199 | if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { | 1167 | if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { |
1200 | // INFO_RECEIVED_LOOPBACK_FRAMES | 1168 | // INFO_RECEIVED_LOOPBACK_FRAMES |
1201 | printk(KERN_ERR DRV_NAME ": An illegal loopback occurred on adapter (%s)\n", | 1169 | printk(KERN_ERR DRV_NAME ": %s: An illegal loopback occurred on " |
1202 | port->slave->dev->name); | 1170 | "adapter (%s). Check the configuration to verify that all " |
1203 | printk(KERN_ERR "Check the configuration to verify that all Adapters " | 1171 | "Adapters are connected to 802.3ad compliant switch ports\n", |
1204 | "are connected to 802.3ad compliant switch ports\n"); | 1172 | port->slave->dev->master->name, port->slave->dev->name); |
1205 | __release_rx_machine_lock(port); | 1173 | __release_rx_machine_lock(port); |
1206 | return; | 1174 | return; |
1207 | } | 1175 | } |
@@ -1378,8 +1346,9 @@ static void ad_port_selection_logic(struct port *port) | |||
1378 | } | 1346 | } |
1379 | } | 1347 | } |
1380 | if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list | 1348 | if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list |
1381 | printk(KERN_WARNING DRV_NAME ": Warning: Port %d (on %s) was " | 1349 | printk(KERN_WARNING DRV_NAME ": %s: Warning: Port %d (on %s) was " |
1382 | "related to aggregator %d but was not on its port list\n", | 1350 | "related to aggregator %d but was not on its port list\n", |
1351 | port->slave->dev->master->name, | ||
1383 | port->actor_port_number, port->slave->dev->name, | 1352 | port->actor_port_number, port->slave->dev->name, |
1384 | port->aggregator->aggregator_identifier); | 1353 | port->aggregator->aggregator_identifier); |
1385 | } | 1354 | } |
@@ -1450,7 +1419,8 @@ static void ad_port_selection_logic(struct port *port) | |||
1450 | 1419 | ||
1451 | dprintk("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); | 1420 | dprintk("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); |
1452 | } else { | 1421 | } else { |
1453 | printk(KERN_ERR DRV_NAME ": Port %d (on %s) did not find a suitable aggregator\n", | 1422 | printk(KERN_ERR DRV_NAME ": %s: Port %d (on %s) did not find a suitable aggregator\n", |
1423 | port->slave->dev->master->name, | ||
1454 | port->actor_port_number, port->slave->dev->name); | 1424 | port->actor_port_number, port->slave->dev->name); |
1455 | } | 1425 | } |
1456 | } | 1426 | } |
@@ -1582,8 +1552,9 @@ static void ad_agg_selection_logic(struct aggregator *aggregator) | |||
1582 | 1552 | ||
1583 | // check if any partner replys | 1553 | // check if any partner replys |
1584 | if (best_aggregator->is_individual) { | 1554 | if (best_aggregator->is_individual) { |
1585 | printk(KERN_WARNING DRV_NAME ": Warning: No 802.3ad response from the link partner " | 1555 | printk(KERN_WARNING DRV_NAME ": %s: Warning: No 802.3ad response from " |
1586 | "for any adapters in the bond\n"); | 1556 | "the link partner for any adapters in the bond\n", |
1557 | best_aggregator->slave->dev->master->name); | ||
1587 | } | 1558 | } |
1588 | 1559 | ||
1589 | // check if there are more than one aggregator | 1560 | // check if there are more than one aggregator |
@@ -1915,7 +1886,8 @@ int bond_3ad_bind_slave(struct slave *slave) | |||
1915 | struct aggregator *aggregator; | 1886 | struct aggregator *aggregator; |
1916 | 1887 | ||
1917 | if (bond == NULL) { | 1888 | if (bond == NULL) { |
1918 | printk(KERN_ERR "The slave %s is not attached to its bond\n", slave->dev->name); | 1889 | printk(KERN_ERR DRV_NAME ": %s: The slave %s is not attached to its bond\n", |
1890 | slave->dev->master->name, slave->dev->name); | ||
1919 | return -1; | 1891 | return -1; |
1920 | } | 1892 | } |
1921 | 1893 | ||
@@ -1990,7 +1962,9 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
1990 | 1962 | ||
1991 | // if slave is null, the whole port is not initialized | 1963 | // if slave is null, the whole port is not initialized |
1992 | if (!port->slave) { | 1964 | if (!port->slave) { |
1993 | printk(KERN_WARNING DRV_NAME ": Trying to unbind an uninitialized port on %s\n", slave->dev->name); | 1965 | printk(KERN_WARNING DRV_NAME ": Warning: %s: Trying to " |
1966 | "unbind an uninitialized port on %s\n", | ||
1967 | slave->dev->master->name, slave->dev->name); | ||
1994 | return; | 1968 | return; |
1995 | } | 1969 | } |
1996 | 1970 | ||
@@ -2021,7 +1995,8 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2021 | dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier); | 1995 | dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier); |
2022 | 1996 | ||
2023 | if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { | 1997 | if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { |
2024 | printk(KERN_INFO DRV_NAME ": Removing an active aggregator\n"); | 1998 | printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", |
1999 | aggregator->slave->dev->master->name); | ||
2025 | // select new active aggregator | 2000 | // select new active aggregator |
2026 | select_new_active_agg = 1; | 2001 | select_new_active_agg = 1; |
2027 | } | 2002 | } |
@@ -2051,15 +2026,17 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2051 | ad_agg_selection_logic(__get_first_agg(port)); | 2026 | ad_agg_selection_logic(__get_first_agg(port)); |
2052 | } | 2027 | } |
2053 | } else { | 2028 | } else { |
2054 | printk(KERN_WARNING DRV_NAME ": Warning: unbinding aggregator, " | 2029 | printk(KERN_WARNING DRV_NAME ": %s: Warning: unbinding aggregator, " |
2055 | "and could not find a new aggregator for its ports\n"); | 2030 | "and could not find a new aggregator for its ports\n", |
2031 | slave->dev->master->name); | ||
2056 | } | 2032 | } |
2057 | } else { // in case that the only port related to this aggregator is the one we want to remove | 2033 | } else { // in case that the only port related to this aggregator is the one we want to remove |
2058 | select_new_active_agg = aggregator->is_active; | 2034 | select_new_active_agg = aggregator->is_active; |
2059 | // clear the aggregator | 2035 | // clear the aggregator |
2060 | ad_clear_agg(aggregator); | 2036 | ad_clear_agg(aggregator); |
2061 | if (select_new_active_agg) { | 2037 | if (select_new_active_agg) { |
2062 | printk(KERN_INFO "Removing an active aggregator\n"); | 2038 | printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", |
2039 | slave->dev->master->name); | ||
2063 | // select new active aggregator | 2040 | // select new active aggregator |
2064 | ad_agg_selection_logic(__get_first_agg(port)); | 2041 | ad_agg_selection_logic(__get_first_agg(port)); |
2065 | } | 2042 | } |
@@ -2085,7 +2062,8 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2085 | // clear the aggregator | 2062 | // clear the aggregator |
2086 | ad_clear_agg(temp_aggregator); | 2063 | ad_clear_agg(temp_aggregator); |
2087 | if (select_new_active_agg) { | 2064 | if (select_new_active_agg) { |
2088 | printk(KERN_INFO "Removing an active aggregator\n"); | 2065 | printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", |
2066 | slave->dev->master->name); | ||
2089 | // select new active aggregator | 2067 | // select new active aggregator |
2090 | ad_agg_selection_logic(__get_first_agg(port)); | 2068 | ad_agg_selection_logic(__get_first_agg(port)); |
2091 | } | 2069 | } |
@@ -2131,7 +2109,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond) | |||
2131 | // select the active aggregator for the bond | 2109 | // select the active aggregator for the bond |
2132 | if ((port = __get_first_port(bond))) { | 2110 | if ((port = __get_first_port(bond))) { |
2133 | if (!port->slave) { | 2111 | if (!port->slave) { |
2134 | printk(KERN_WARNING DRV_NAME ": Warning: bond's first port is uninitialized\n"); | 2112 | printk(KERN_WARNING DRV_NAME ": %s: Warning: bond's first port is " |
2113 | "uninitialized\n", bond->dev->name); | ||
2135 | goto re_arm; | 2114 | goto re_arm; |
2136 | } | 2115 | } |
2137 | 2116 | ||
@@ -2143,7 +2122,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond) | |||
2143 | // for each port run the state machines | 2122 | // for each port run the state machines |
2144 | for (port = __get_first_port(bond); port; port = __get_next_port(port)) { | 2123 | for (port = __get_first_port(bond); port; port = __get_next_port(port)) { |
2145 | if (!port->slave) { | 2124 | if (!port->slave) { |
2146 | printk(KERN_WARNING DRV_NAME ": Warning: Found an uninitialized port\n"); | 2125 | printk(KERN_WARNING DRV_NAME ": %s: Warning: Found an uninitialized " |
2126 | "port\n", bond->dev->name); | ||
2147 | goto re_arm; | 2127 | goto re_arm; |
2148 | } | 2128 | } |
2149 | 2129 | ||
@@ -2184,7 +2164,8 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u | |||
2184 | port = &(SLAVE_AD_INFO(slave).port); | 2164 | port = &(SLAVE_AD_INFO(slave).port); |
2185 | 2165 | ||
2186 | if (!port->slave) { | 2166 | if (!port->slave) { |
2187 | printk(KERN_WARNING DRV_NAME ": Warning: port of slave %s is uninitialized\n", slave->dev->name); | 2167 | printk(KERN_WARNING DRV_NAME ": %s: Warning: port of slave %s is " |
2168 | "uninitialized\n", slave->dev->name, slave->dev->master->name); | ||
2188 | return; | 2169 | return; |
2189 | } | 2170 | } |
2190 | 2171 | ||
@@ -2230,8 +2211,9 @@ void bond_3ad_adapter_speed_changed(struct slave *slave) | |||
2230 | 2211 | ||
2231 | // if slave is null, the whole port is not initialized | 2212 | // if slave is null, the whole port is not initialized |
2232 | if (!port->slave) { | 2213 | if (!port->slave) { |
2233 | printk(KERN_WARNING DRV_NAME ": Warning: speed changed for uninitialized port on %s\n", | 2214 | printk(KERN_WARNING DRV_NAME ": Warning: %s: speed " |
2234 | slave->dev->name); | 2215 | "changed for uninitialized port on %s\n", |
2216 | slave->dev->master->name, slave->dev->name); | ||
2235 | return; | 2217 | return; |
2236 | } | 2218 | } |
2237 | 2219 | ||
@@ -2257,8 +2239,9 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave) | |||
2257 | 2239 | ||
2258 | // if slave is null, the whole port is not initialized | 2240 | // if slave is null, the whole port is not initialized |
2259 | if (!port->slave) { | 2241 | if (!port->slave) { |
2260 | printk(KERN_WARNING DRV_NAME ": Warning: duplex changed for uninitialized port on %s\n", | 2242 | printk(KERN_WARNING DRV_NAME ": %s: Warning: duplex changed " |
2261 | slave->dev->name); | 2243 | "for uninitialized port on %s\n", |
2244 | slave->dev->master->name, slave->dev->name); | ||
2262 | return; | 2245 | return; |
2263 | } | 2246 | } |
2264 | 2247 | ||
@@ -2285,8 +2268,9 @@ void bond_3ad_handle_link_change(struct slave *slave, char link) | |||
2285 | 2268 | ||
2286 | // if slave is null, the whole port is not initialized | 2269 | // if slave is null, the whole port is not initialized |
2287 | if (!port->slave) { | 2270 | if (!port->slave) { |
2288 | printk(KERN_WARNING DRV_NAME ": Warning: link status changed for uninitialized port on %s\n", | 2271 | printk(KERN_WARNING DRV_NAME ": Warning: %s: link status changed for " |
2289 | slave->dev->name); | 2272 | "uninitialized port on %s\n", |
2273 | slave->dev->master->name, slave->dev->name); | ||
2290 | return; | 2274 | return; |
2291 | } | 2275 | } |
2292 | 2276 | ||
@@ -2363,7 +2347,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2363 | } | 2347 | } |
2364 | 2348 | ||
2365 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { | 2349 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { |
2366 | printk(KERN_DEBUG "ERROR: bond_3ad_get_active_agg_info failed\n"); | 2350 | printk(KERN_DEBUG DRV_NAME ": %s: Error: " |
2351 | "bond_3ad_get_active_agg_info failed\n", dev->name); | ||
2367 | goto out; | 2352 | goto out; |
2368 | } | 2353 | } |
2369 | 2354 | ||
@@ -2372,7 +2357,9 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2372 | 2357 | ||
2373 | if (slaves_in_agg == 0) { | 2358 | if (slaves_in_agg == 0) { |
2374 | /*the aggregator is empty*/ | 2359 | /*the aggregator is empty*/ |
2375 | printk(KERN_DEBUG "ERROR: active aggregator is empty\n"); | 2360 | printk(KERN_DEBUG DRV_NAME ": %s: Error: active " |
2361 | "aggregator is empty\n", | ||
2362 | dev->name); | ||
2376 | goto out; | 2363 | goto out; |
2377 | } | 2364 | } |
2378 | 2365 | ||
@@ -2390,7 +2377,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2390 | } | 2377 | } |
2391 | 2378 | ||
2392 | if (slave_agg_no >= 0) { | 2379 | if (slave_agg_no >= 0) { |
2393 | printk(KERN_ERR DRV_NAME ": Error: Couldn't find a slave to tx on for aggregator ID %d\n", agg_id); | 2380 | printk(KERN_ERR DRV_NAME ": %s: Error: Couldn't find a slave to tx on " |
2381 | "for aggregator ID %d\n", dev->name, agg_id); | ||
2394 | goto out; | 2382 | goto out; |
2395 | } | 2383 | } |
2396 | 2384 | ||
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index 673a30af566..5ee2cef5b03 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h | |||
@@ -18,19 +18,6 @@ | |||
18 | * The full GNU General Public License is included in this distribution in the | 18 | * The full GNU General Public License is included in this distribution in the |
19 | * file called LICENSE. | 19 | * file called LICENSE. |
20 | * | 20 | * |
21 | * | ||
22 | * Changes: | ||
23 | * | ||
24 | * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
25 | * Amir Noam <amir.noam at intel dot com> | ||
26 | * - Added support for lacp_rate module param. | ||
27 | * | ||
28 | * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
29 | * - Renamed bond_3ad_link_status_changed() to | ||
30 | * bond_3ad_handle_link_change() for compatibility with TLB. | ||
31 | * | ||
32 | * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
33 | * - Code cleanup and style changes | ||
34 | */ | 21 | */ |
35 | 22 | ||
36 | #ifndef __BOND_3AD_H__ | 23 | #ifndef __BOND_3AD_H__ |
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index f8fce396119..854ddfb90da 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -18,25 +18,6 @@ | |||
18 | * The full GNU General Public License is included in this distribution in the | 18 | * The full GNU General Public License is included in this distribution in the |
19 | * file called LICENSE. | 19 | * file called LICENSE. |
20 | * | 20 | * |
21 | * | ||
22 | * Changes: | ||
23 | * | ||
24 | * 2003/06/25 - Shmulik Hen <shmulik.hen at intel dot com> | ||
25 | * - Fixed signed/unsigned calculation errors that caused load sharing | ||
26 | * to collapse to one slave under very heavy UDP Tx stress. | ||
27 | * | ||
28 | * 2003/08/06 - Amir Noam <amir.noam at intel dot com> | ||
29 | * - Add support for setting bond's MAC address with special | ||
30 | * handling required for ALB/TLB. | ||
31 | * | ||
32 | * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
33 | * - Code cleanup and style changes | ||
34 | * | ||
35 | * 2003/12/30 - Amir Noam <amir.noam at intel dot com> | ||
36 | * - Fixed: Cannot remove and re-enslave the original active slave. | ||
37 | * | ||
38 | * 2004/01/14 - Shmulik Hen <shmulik.hen at intel dot com> | ||
39 | * - Add capability to tag self generated packets in ALB/TLB modes. | ||
40 | */ | 21 | */ |
41 | 22 | ||
42 | //#define BONDING_DEBUG 1 | 23 | //#define BONDING_DEBUG 1 |
@@ -198,20 +179,21 @@ static int tlb_initialize(struct bonding *bond) | |||
198 | { | 179 | { |
199 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 180 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); |
200 | int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); | 181 | int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); |
182 | struct tlb_client_info *new_hashtbl; | ||
201 | int i; | 183 | int i; |
202 | 184 | ||
203 | spin_lock_init(&(bond_info->tx_hashtbl_lock)); | 185 | spin_lock_init(&(bond_info->tx_hashtbl_lock)); |
204 | 186 | ||
205 | _lock_tx_hashtbl(bond); | 187 | new_hashtbl = kmalloc(size, GFP_KERNEL); |
206 | 188 | if (!new_hashtbl) { | |
207 | bond_info->tx_hashtbl = kmalloc(size, GFP_KERNEL); | ||
208 | if (!bond_info->tx_hashtbl) { | ||
209 | printk(KERN_ERR DRV_NAME | 189 | printk(KERN_ERR DRV_NAME |
210 | ": Error: %s: Failed to allocate TLB hash table\n", | 190 | ": %s: Error: Failed to allocate TLB hash table\n", |
211 | bond->dev->name); | 191 | bond->dev->name); |
212 | _unlock_tx_hashtbl(bond); | ||
213 | return -1; | 192 | return -1; |
214 | } | 193 | } |
194 | _lock_tx_hashtbl(bond); | ||
195 | |||
196 | bond_info->tx_hashtbl = new_hashtbl; | ||
215 | 197 | ||
216 | memset(bond_info->tx_hashtbl, 0, size); | 198 | memset(bond_info->tx_hashtbl, 0, size); |
217 | 199 | ||
@@ -513,7 +495,8 @@ static void rlb_update_client(struct rlb_client_info *client_info) | |||
513 | client_info->mac_dst); | 495 | client_info->mac_dst); |
514 | if (!skb) { | 496 | if (!skb) { |
515 | printk(KERN_ERR DRV_NAME | 497 | printk(KERN_ERR DRV_NAME |
516 | ": Error: failed to create an ARP packet\n"); | 498 | ": %s: Error: failed to create an ARP packet\n", |
499 | client_info->slave->dev->master->name); | ||
517 | continue; | 500 | continue; |
518 | } | 501 | } |
519 | 502 | ||
@@ -523,7 +506,8 @@ static void rlb_update_client(struct rlb_client_info *client_info) | |||
523 | skb = vlan_put_tag(skb, client_info->vlan_id); | 506 | skb = vlan_put_tag(skb, client_info->vlan_id); |
524 | if (!skb) { | 507 | if (!skb) { |
525 | printk(KERN_ERR DRV_NAME | 508 | printk(KERN_ERR DRV_NAME |
526 | ": Error: failed to insert VLAN tag\n"); | 509 | ": %s: Error: failed to insert VLAN tag\n", |
510 | client_info->slave->dev->master->name); | ||
527 | continue; | 511 | continue; |
528 | } | 512 | } |
529 | } | 513 | } |
@@ -606,8 +590,9 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip) | |||
606 | 590 | ||
607 | if (!client_info->slave) { | 591 | if (!client_info->slave) { |
608 | printk(KERN_ERR DRV_NAME | 592 | printk(KERN_ERR DRV_NAME |
609 | ": Error: found a client with no channel in " | 593 | ": %s: Error: found a client with no channel in " |
610 | "the client's hash table\n"); | 594 | "the client's hash table\n", |
595 | bond->dev->name); | ||
611 | continue; | 596 | continue; |
612 | } | 597 | } |
613 | /*update all clients using this src_ip, that are not assigned | 598 | /*update all clients using this src_ip, that are not assigned |
@@ -797,21 +782,22 @@ static int rlb_initialize(struct bonding *bond) | |||
797 | { | 782 | { |
798 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 783 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); |
799 | struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); | 784 | struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); |
785 | struct rlb_client_info *new_hashtbl; | ||
800 | int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); | 786 | int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); |
801 | int i; | 787 | int i; |
802 | 788 | ||
803 | spin_lock_init(&(bond_info->rx_hashtbl_lock)); | 789 | spin_lock_init(&(bond_info->rx_hashtbl_lock)); |
804 | 790 | ||
805 | _lock_rx_hashtbl(bond); | 791 | new_hashtbl = kmalloc(size, GFP_KERNEL); |
806 | 792 | if (!new_hashtbl) { | |
807 | bond_info->rx_hashtbl = kmalloc(size, GFP_KERNEL); | ||
808 | if (!bond_info->rx_hashtbl) { | ||
809 | printk(KERN_ERR DRV_NAME | 793 | printk(KERN_ERR DRV_NAME |
810 | ": Error: %s: Failed to allocate RLB hash table\n", | 794 | ": %s: Error: Failed to allocate RLB hash table\n", |
811 | bond->dev->name); | 795 | bond->dev->name); |
812 | _unlock_rx_hashtbl(bond); | ||
813 | return -1; | 796 | return -1; |
814 | } | 797 | } |
798 | _lock_rx_hashtbl(bond); | ||
799 | |||
800 | bond_info->rx_hashtbl = new_hashtbl; | ||
815 | 801 | ||
816 | bond_info->rx_hashtbl_head = RLB_NULL_INDEX; | 802 | bond_info->rx_hashtbl_head = RLB_NULL_INDEX; |
817 | 803 | ||
@@ -927,7 +913,8 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) | |||
927 | skb = vlan_put_tag(skb, vlan->vlan_id); | 913 | skb = vlan_put_tag(skb, vlan->vlan_id); |
928 | if (!skb) { | 914 | if (!skb) { |
929 | printk(KERN_ERR DRV_NAME | 915 | printk(KERN_ERR DRV_NAME |
930 | ": Error: failed to insert VLAN tag\n"); | 916 | ": %s: Error: failed to insert VLAN tag\n", |
917 | bond->dev->name); | ||
931 | continue; | 918 | continue; |
932 | } | 919 | } |
933 | } | 920 | } |
@@ -956,11 +943,11 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw) | |||
956 | s_addr.sa_family = dev->type; | 943 | s_addr.sa_family = dev->type; |
957 | if (dev_set_mac_address(dev, &s_addr)) { | 944 | if (dev_set_mac_address(dev, &s_addr)) { |
958 | printk(KERN_ERR DRV_NAME | 945 | printk(KERN_ERR DRV_NAME |
959 | ": Error: dev_set_mac_address of dev %s failed! ALB " | 946 | ": %s: Error: dev_set_mac_address of dev %s failed! ALB " |
960 | "mode requires that the base driver support setting " | 947 | "mode requires that the base driver support setting " |
961 | "the hw address also when the network device's " | 948 | "the hw address also when the network device's " |
962 | "interface is open\n", | 949 | "interface is open\n", |
963 | dev->name); | 950 | dev->master->name, dev->name); |
964 | return -EOPNOTSUPP; | 951 | return -EOPNOTSUPP; |
965 | } | 952 | } |
966 | return 0; | 953 | return 0; |
@@ -1153,16 +1140,16 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav | |||
1153 | bond->alb_info.rlb_enabled); | 1140 | bond->alb_info.rlb_enabled); |
1154 | 1141 | ||
1155 | printk(KERN_WARNING DRV_NAME | 1142 | printk(KERN_WARNING DRV_NAME |
1156 | ": Warning: the hw address of slave %s is in use by " | 1143 | ": %s: Warning: the hw address of slave %s is in use by " |
1157 | "the bond; giving it the hw address of %s\n", | 1144 | "the bond; giving it the hw address of %s\n", |
1158 | slave->dev->name, free_mac_slave->dev->name); | 1145 | bond->dev->name, slave->dev->name, free_mac_slave->dev->name); |
1159 | 1146 | ||
1160 | } else if (has_bond_addr) { | 1147 | } else if (has_bond_addr) { |
1161 | printk(KERN_ERR DRV_NAME | 1148 | printk(KERN_ERR DRV_NAME |
1162 | ": Error: the hw address of slave %s is in use by the " | 1149 | ": %s: Error: the hw address of slave %s is in use by the " |
1163 | "bond; couldn't find a slave with a free hw address to " | 1150 | "bond; couldn't find a slave with a free hw address to " |
1164 | "give it (this should not have happened)\n", | 1151 | "give it (this should not have happened)\n", |
1165 | slave->dev->name); | 1152 | bond->dev->name, slave->dev->name); |
1166 | return -EFAULT; | 1153 | return -EFAULT; |
1167 | } | 1154 | } |
1168 | 1155 | ||
@@ -1250,6 +1237,8 @@ int bond_alb_initialize(struct bonding *bond, int rlb_enabled) | |||
1250 | tlb_deinitialize(bond); | 1237 | tlb_deinitialize(bond); |
1251 | return res; | 1238 | return res; |
1252 | } | 1239 | } |
1240 | } else { | ||
1241 | bond->alb_info.rlb_enabled = 0; | ||
1253 | } | 1242 | } |
1254 | 1243 | ||
1255 | return 0; | 1244 | return 0; |
@@ -1409,7 +1398,7 @@ void bond_alb_monitor(struct bonding *bond) | |||
1409 | read_lock(&bond->curr_slave_lock); | 1398 | read_lock(&bond->curr_slave_lock); |
1410 | 1399 | ||
1411 | bond_for_each_slave(bond, slave, i) { | 1400 | bond_for_each_slave(bond, slave, i) { |
1412 | alb_send_learning_packets(slave,slave->dev->dev_addr); | 1401 | alb_send_learning_packets(slave, slave->dev->dev_addr); |
1413 | } | 1402 | } |
1414 | 1403 | ||
1415 | read_unlock(&bond->curr_slave_lock); | 1404 | read_unlock(&bond->curr_slave_lock); |
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h index e4091cd8d65..28f2a2fd1b5 100644 --- a/drivers/net/bonding/bond_alb.h +++ b/drivers/net/bonding/bond_alb.h | |||
@@ -18,15 +18,6 @@ | |||
18 | * The full GNU General Public License is included in this distribution in the | 18 | * The full GNU General Public License is included in this distribution in the |
19 | * file called LICENSE. | 19 | * file called LICENSE. |
20 | * | 20 | * |
21 | * | ||
22 | * Changes: | ||
23 | * | ||
24 | * 2003/08/06 - Amir Noam <amir.noam at intel dot com> | ||
25 | * - Add support for setting bond's MAC address with special | ||
26 | * handling required for ALB/TLB. | ||
27 | * | ||
28 | * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
29 | * - Code cleanup and style changes | ||
30 | */ | 21 | */ |
31 | 22 | ||
32 | #ifndef __BOND_ALB_H__ | 23 | #ifndef __BOND_ALB_H__ |
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 | ||
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c new file mode 100644 index 00000000000..32d13da43a0 --- /dev/null +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -0,0 +1,1358 @@ | |||
1 | |||
2 | /* | ||
3 | * Copyright(c) 2004-2005 Intel Corporation. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License as published by the | ||
7 | * Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
13 | * for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | * | ||
19 | * The full GNU General Public License is included in this distribution in the | ||
20 | * file called LICENSE. | ||
21 | * | ||
22 | */ | ||
23 | #include <linux/config.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/device.h> | ||
28 | #include <linux/sysdev.h> | ||
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> | ||
36 | #include <linux/string.h> | ||
37 | #include <linux/ctype.h> | ||
38 | #include <linux/inet.h> | ||
39 | #include <linux/rtnetlink.h> | ||
40 | |||
41 | /* #define BONDING_DEBUG 1 */ | ||
42 | #include "bonding.h" | ||
43 | #define to_class_dev(obj) container_of(obj,struct class_device,kobj) | ||
44 | #define to_net_dev(class) container_of(class, struct net_device, class_dev) | ||
45 | #define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) | ||
46 | |||
47 | /*---------------------------- Declarations -------------------------------*/ | ||
48 | |||
49 | |||
50 | extern struct list_head bond_dev_list; | ||
51 | extern struct bond_params bonding_defaults; | ||
52 | extern struct bond_parm_tbl bond_mode_tbl[]; | ||
53 | extern struct bond_parm_tbl bond_lacp_tbl[]; | ||
54 | extern struct bond_parm_tbl xmit_hashtype_tbl[]; | ||
55 | |||
56 | static int expected_refcount = -1; | ||
57 | static struct class *netdev_class; | ||
58 | /*--------------------------- Data Structures -----------------------------*/ | ||
59 | |||
60 | /* Bonding sysfs lock. Why can't we just use the subsytem lock? | ||
61 | * Because kobject_register tries to acquire the subsystem lock. If | ||
62 | * we already hold the lock (which we would if the user was creating | ||
63 | * a new bond through the sysfs interface), we deadlock. | ||
64 | * This lock is only needed when deleting a bond - we need to make sure | ||
65 | * that we don't collide with an ongoing ioctl. | ||
66 | */ | ||
67 | |||
68 | struct rw_semaphore bonding_rwsem; | ||
69 | |||
70 | |||
71 | |||
72 | |||
73 | /*------------------------------ Functions --------------------------------*/ | ||
74 | |||
75 | /* | ||
76 | * "show" function for the bond_masters attribute. | ||
77 | * The class parameter is ignored. | ||
78 | */ | ||
79 | static ssize_t bonding_show_bonds(struct class *cls, char *buffer) | ||
80 | { | ||
81 | int res = 0; | ||
82 | struct bonding *bond; | ||
83 | |||
84 | down_read(&(bonding_rwsem)); | ||
85 | |||
86 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | ||
87 | if (res > (PAGE_SIZE - IFNAMSIZ)) { | ||
88 | /* not enough space for another interface name */ | ||
89 | if ((PAGE_SIZE - res) > 10) | ||
90 | res = PAGE_SIZE - 10; | ||
91 | res += sprintf(buffer + res, "++more++"); | ||
92 | break; | ||
93 | } | ||
94 | res += sprintf(buffer + res, "%s ", | ||
95 | bond->dev->name); | ||
96 | } | ||
97 | res += sprintf(buffer + res, "\n"); | ||
98 | res++; | ||
99 | up_read(&(bonding_rwsem)); | ||
100 | return res; | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * "store" function for the bond_masters attribute. This is what | ||
105 | * creates and deletes entire bonds. | ||
106 | * | ||
107 | * The class parameter is ignored. | ||
108 | * | ||
109 | */ | ||
110 | |||
111 | static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t count) | ||
112 | { | ||
113 | char command[IFNAMSIZ + 1] = {0, }; | ||
114 | char *ifname; | ||
115 | int res = count; | ||
116 | struct bonding *bond; | ||
117 | struct bonding *nxt; | ||
118 | |||
119 | down_write(&(bonding_rwsem)); | ||
120 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ | ||
121 | ifname = command + 1; | ||
122 | if ((strlen(command) <= 1) || | ||
123 | !dev_valid_name(ifname)) | ||
124 | goto err_no_cmd; | ||
125 | |||
126 | if (command[0] == '+') { | ||
127 | |||
128 | /* Check to see if the bond already exists. */ | ||
129 | list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) | ||
130 | if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { | ||
131 | printk(KERN_ERR DRV_NAME | ||
132 | ": cannot add bond %s; it already exists\n", | ||
133 | ifname); | ||
134 | res = -EPERM; | ||
135 | goto out; | ||
136 | } | ||
137 | |||
138 | printk(KERN_INFO DRV_NAME | ||
139 | ": %s is being created...\n", ifname); | ||
140 | if (bond_create(ifname, &bonding_defaults, &bond)) { | ||
141 | printk(KERN_INFO DRV_NAME | ||
142 | ": %s interface already exists. Bond creation failed.\n", | ||
143 | ifname); | ||
144 | res = -EPERM; | ||
145 | } | ||
146 | goto out; | ||
147 | } | ||
148 | |||
149 | if (command[0] == '-') { | ||
150 | list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) | ||
151 | if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { | ||
152 | rtnl_lock(); | ||
153 | /* check the ref count on the bond's kobject. | ||
154 | * If it's > expected, then there's a file open, | ||
155 | * and we have to fail. | ||
156 | */ | ||
157 | if (atomic_read(&bond->dev->class_dev.kobj.kref.refcount) | ||
158 | > expected_refcount){ | ||
159 | rtnl_unlock(); | ||
160 | printk(KERN_INFO DRV_NAME | ||
161 | ": Unable remove bond %s due to open references.\n", | ||
162 | ifname); | ||
163 | res = -EPERM; | ||
164 | goto out; | ||
165 | } | ||
166 | printk(KERN_INFO DRV_NAME | ||
167 | ": %s is being deleted...\n", | ||
168 | bond->dev->name); | ||
169 | unregister_netdevice(bond->dev); | ||
170 | bond_deinit(bond->dev); | ||
171 | bond_destroy_sysfs_entry(bond); | ||
172 | rtnl_unlock(); | ||
173 | goto out; | ||
174 | } | ||
175 | |||
176 | printk(KERN_ERR DRV_NAME | ||
177 | ": unable to delete non-existent bond %s\n", ifname); | ||
178 | res = -ENODEV; | ||
179 | goto out; | ||
180 | } | ||
181 | |||
182 | err_no_cmd: | ||
183 | printk(KERN_ERR DRV_NAME | ||
184 | ": no command found in bonding_masters. Use +ifname or -ifname.\n"); | ||
185 | res = -EPERM; | ||
186 | |||
187 | /* Always return either count or an error. If you return 0, you'll | ||
188 | * get called forever, which is bad. | ||
189 | */ | ||
190 | out: | ||
191 | up_write(&(bonding_rwsem)); | ||
192 | return res; | ||
193 | } | ||
194 | /* class attribute for bond_masters file. This ends up in /sys/class/net */ | ||
195 | static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO, | ||
196 | bonding_show_bonds, bonding_store_bonds); | ||
197 | |||
198 | int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave) | ||
199 | { | ||
200 | char linkname[IFNAMSIZ+7]; | ||
201 | int ret = 0; | ||
202 | |||
203 | /* first, create a link from the slave back to the master */ | ||
204 | ret = sysfs_create_link(&(slave->class_dev.kobj), &(master->class_dev.kobj), | ||
205 | "master"); | ||
206 | if (ret) | ||
207 | return ret; | ||
208 | /* next, create a link from the master to the slave */ | ||
209 | sprintf(linkname,"slave_%s",slave->name); | ||
210 | ret = sysfs_create_link(&(master->class_dev.kobj), &(slave->class_dev.kobj), | ||
211 | linkname); | ||
212 | return ret; | ||
213 | |||
214 | } | ||
215 | |||
216 | void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave) | ||
217 | { | ||
218 | char linkname[IFNAMSIZ+7]; | ||
219 | |||
220 | sysfs_remove_link(&(slave->class_dev.kobj), "master"); | ||
221 | sprintf(linkname,"slave_%s",slave->name); | ||
222 | sysfs_remove_link(&(master->class_dev.kobj), linkname); | ||
223 | } | ||
224 | |||
225 | |||
226 | /* | ||
227 | * Show the slaves in the current bond. | ||
228 | */ | ||
229 | static ssize_t bonding_show_slaves(struct class_device *cd, char *buf) | ||
230 | { | ||
231 | struct slave *slave; | ||
232 | int i, res = 0; | ||
233 | struct bonding *bond = to_bond(cd); | ||
234 | |||
235 | read_lock_bh(&bond->lock); | ||
236 | bond_for_each_slave(bond, slave, i) { | ||
237 | if (res > (PAGE_SIZE - IFNAMSIZ)) { | ||
238 | /* not enough space for another interface name */ | ||
239 | if ((PAGE_SIZE - res) > 10) | ||
240 | res = PAGE_SIZE - 10; | ||
241 | res += sprintf(buf + res, "++more++"); | ||
242 | break; | ||
243 | } | ||
244 | res += sprintf(buf + res, "%s ", slave->dev->name); | ||
245 | } | ||
246 | read_unlock_bh(&bond->lock); | ||
247 | res += sprintf(buf + res, "\n"); | ||
248 | res++; | ||
249 | return res; | ||
250 | } | ||
251 | |||
252 | /* | ||
253 | * Set the slaves in the current bond. The bond interface must be | ||
254 | * up for this to succeed. | ||
255 | * This function is largely the same flow as bonding_update_bonds(). | ||
256 | */ | ||
257 | static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer, size_t count) | ||
258 | { | ||
259 | char command[IFNAMSIZ + 1] = { 0, }; | ||
260 | char *ifname; | ||
261 | int i, res, found, ret = count; | ||
262 | struct slave *slave; | ||
263 | struct net_device *dev = 0; | ||
264 | struct bonding *bond = to_bond(cd); | ||
265 | |||
266 | /* Quick sanity check -- is the bond interface up? */ | ||
267 | if (!(bond->dev->flags & IFF_UP)) { | ||
268 | printk(KERN_ERR DRV_NAME | ||
269 | ": %s: Unable to update slaves because interface is down.\n", | ||
270 | bond->dev->name); | ||
271 | ret = -EPERM; | ||
272 | goto out; | ||
273 | } | ||
274 | |||
275 | /* Note: We can't hold bond->lock here, as bond_create grabs it. */ | ||
276 | |||
277 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ | ||
278 | ifname = command + 1; | ||
279 | if ((strlen(command) <= 1) || | ||
280 | !dev_valid_name(ifname)) | ||
281 | goto err_no_cmd; | ||
282 | |||
283 | if (command[0] == '+') { | ||
284 | |||
285 | /* Got a slave name in ifname. Is it already in the list? */ | ||
286 | found = 0; | ||
287 | read_lock_bh(&bond->lock); | ||
288 | bond_for_each_slave(bond, slave, i) | ||
289 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { | ||
290 | printk(KERN_ERR DRV_NAME | ||
291 | ": %s: Interface %s is already enslaved!\n", | ||
292 | bond->dev->name, ifname); | ||
293 | ret = -EPERM; | ||
294 | read_unlock_bh(&bond->lock); | ||
295 | goto out; | ||
296 | } | ||
297 | |||
298 | read_unlock_bh(&bond->lock); | ||
299 | printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", | ||
300 | bond->dev->name, ifname); | ||
301 | dev = dev_get_by_name(ifname); | ||
302 | if (!dev) { | ||
303 | printk(KERN_INFO DRV_NAME | ||
304 | ": %s: Interface %s does not exist!\n", | ||
305 | bond->dev->name, ifname); | ||
306 | ret = -EPERM; | ||
307 | goto out; | ||
308 | } | ||
309 | else | ||
310 | dev_put(dev); | ||
311 | |||
312 | if (dev->flags & IFF_UP) { | ||
313 | printk(KERN_ERR DRV_NAME | ||
314 | ": %s: Error: Unable to enslave %s " | ||
315 | "because it is already up.\n", | ||
316 | bond->dev->name, dev->name); | ||
317 | ret = -EPERM; | ||
318 | goto out; | ||
319 | } | ||
320 | /* If this is the first slave, then we need to set | ||
321 | the master's hardware address to be the same as the | ||
322 | slave's. */ | ||
323 | if (!(*((u32 *) & (bond->dev->dev_addr[0])))) { | ||
324 | memcpy(bond->dev->dev_addr, dev->dev_addr, | ||
325 | dev->addr_len); | ||
326 | } | ||
327 | |||
328 | /* Set the slave's MTU to match the bond */ | ||
329 | if (dev->mtu != bond->dev->mtu) { | ||
330 | if (dev->change_mtu) { | ||
331 | res = dev->change_mtu(dev, | ||
332 | bond->dev->mtu); | ||
333 | if (res) { | ||
334 | ret = res; | ||
335 | goto out; | ||
336 | } | ||
337 | } else { | ||
338 | dev->mtu = bond->dev->mtu; | ||
339 | } | ||
340 | } | ||
341 | rtnl_lock(); | ||
342 | res = bond_enslave(bond->dev, dev); | ||
343 | rtnl_unlock(); | ||
344 | if (res) { | ||
345 | ret = res; | ||
346 | } | ||
347 | goto out; | ||
348 | } | ||
349 | |||
350 | if (command[0] == '-') { | ||
351 | dev = NULL; | ||
352 | bond_for_each_slave(bond, slave, i) | ||
353 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { | ||
354 | dev = slave->dev; | ||
355 | break; | ||
356 | } | ||
357 | if (dev) { | ||
358 | printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", | ||
359 | bond->dev->name, dev->name); | ||
360 | rtnl_lock(); | ||
361 | res = bond_release(bond->dev, dev); | ||
362 | rtnl_unlock(); | ||
363 | if (res) { | ||
364 | ret = res; | ||
365 | goto out; | ||
366 | } | ||
367 | /* set the slave MTU to the default */ | ||
368 | if (dev->change_mtu) { | ||
369 | dev->change_mtu(dev, 1500); | ||
370 | } else { | ||
371 | dev->mtu = 1500; | ||
372 | } | ||
373 | } | ||
374 | else { | ||
375 | printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n", | ||
376 | ifname, bond->dev->name); | ||
377 | ret = -ENODEV; | ||
378 | } | ||
379 | goto out; | ||
380 | } | ||
381 | |||
382 | err_no_cmd: | ||
383 | printk(KERN_ERR DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); | ||
384 | ret = -EPERM; | ||
385 | |||
386 | out: | ||
387 | return ret; | ||
388 | } | ||
389 | |||
390 | static CLASS_DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); | ||
391 | |||
392 | /* | ||
393 | * Show and set the bonding mode. The bond interface must be down to | ||
394 | * change the mode. | ||
395 | */ | ||
396 | static ssize_t bonding_show_mode(struct class_device *cd, char *buf) | ||
397 | { | ||
398 | struct bonding *bond = to_bond(cd); | ||
399 | |||
400 | return sprintf(buf, "%s %d\n", | ||
401 | bond_mode_tbl[bond->params.mode].modename, | ||
402 | bond->params.mode) + 1; | ||
403 | } | ||
404 | |||
405 | static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size_t count) | ||
406 | { | ||
407 | int new_value, ret = count; | ||
408 | struct bonding *bond = to_bond(cd); | ||
409 | |||
410 | if (bond->dev->flags & IFF_UP) { | ||
411 | printk(KERN_ERR DRV_NAME | ||
412 | ": unable to update mode of %s because interface is up.\n", | ||
413 | bond->dev->name); | ||
414 | ret = -EPERM; | ||
415 | goto out; | ||
416 | } | ||
417 | |||
418 | new_value = bond_parse_parm((char *)buf, bond_mode_tbl); | ||
419 | if (new_value < 0) { | ||
420 | printk(KERN_ERR DRV_NAME | ||
421 | ": %s: Ignoring invalid mode value %.*s.\n", | ||
422 | bond->dev->name, | ||
423 | (int)strlen(buf) - 1, buf); | ||
424 | ret = -EINVAL; | ||
425 | goto out; | ||
426 | } else { | ||
427 | bond->params.mode = new_value; | ||
428 | bond_set_mode_ops(bond, bond->params.mode); | ||
429 | printk(KERN_INFO DRV_NAME ": %s: setting mode to %s (%d).\n", | ||
430 | bond->dev->name, bond_mode_tbl[new_value].modename, new_value); | ||
431 | } | ||
432 | out: | ||
433 | return ret; | ||
434 | } | ||
435 | static CLASS_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); | ||
436 | |||
437 | /* | ||
438 | * Show and set the bonding transmit hash method. The bond interface must be down to | ||
439 | * change the xmit hash policy. | ||
440 | */ | ||
441 | static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf) | ||
442 | { | ||
443 | int count; | ||
444 | struct bonding *bond = to_bond(cd); | ||
445 | |||
446 | if ((bond->params.mode != BOND_MODE_XOR) && | ||
447 | (bond->params.mode != BOND_MODE_8023AD)) { | ||
448 | // Not Applicable | ||
449 | count = sprintf(buf, "NA\n") + 1; | ||
450 | } else { | ||
451 | count = sprintf(buf, "%s %d\n", | ||
452 | xmit_hashtype_tbl[bond->params.xmit_policy].modename, | ||
453 | bond->params.xmit_policy) + 1; | ||
454 | } | ||
455 | |||
456 | return count; | ||
457 | } | ||
458 | |||
459 | static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf, size_t count) | ||
460 | { | ||
461 | int new_value, ret = count; | ||
462 | struct bonding *bond = to_bond(cd); | ||
463 | |||
464 | if (bond->dev->flags & IFF_UP) { | ||
465 | printk(KERN_ERR DRV_NAME | ||
466 | "%s: Interface is up. Unable to update xmit policy.\n", | ||
467 | bond->dev->name); | ||
468 | ret = -EPERM; | ||
469 | goto out; | ||
470 | } | ||
471 | |||
472 | if ((bond->params.mode != BOND_MODE_XOR) && | ||
473 | (bond->params.mode != BOND_MODE_8023AD)) { | ||
474 | printk(KERN_ERR DRV_NAME | ||
475 | "%s: Transmit hash policy is irrelevant in this mode.\n", | ||
476 | bond->dev->name); | ||
477 | ret = -EPERM; | ||
478 | goto out; | ||
479 | } | ||
480 | |||
481 | new_value = bond_parse_parm((char *)buf, xmit_hashtype_tbl); | ||
482 | if (new_value < 0) { | ||
483 | printk(KERN_ERR DRV_NAME | ||
484 | ": %s: Ignoring invalid xmit hash policy value %.*s.\n", | ||
485 | bond->dev->name, | ||
486 | (int)strlen(buf) - 1, buf); | ||
487 | ret = -EINVAL; | ||
488 | goto out; | ||
489 | } else { | ||
490 | bond->params.xmit_policy = new_value; | ||
491 | bond_set_mode_ops(bond, bond->params.mode); | ||
492 | printk(KERN_INFO DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", | ||
493 | bond->dev->name, xmit_hashtype_tbl[new_value].modename, new_value); | ||
494 | } | ||
495 | out: | ||
496 | return ret; | ||
497 | } | ||
498 | static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); | ||
499 | |||
500 | /* | ||
501 | * Show and set the arp timer interval. There are two tricky bits | ||
502 | * here. First, if ARP monitoring is activated, then we must disable | ||
503 | * MII monitoring. Second, if the ARP timer isn't running, we must | ||
504 | * start it. | ||
505 | */ | ||
506 | static ssize_t bonding_show_arp_interval(struct class_device *cd, char *buf) | ||
507 | { | ||
508 | struct bonding *bond = to_bond(cd); | ||
509 | |||
510 | return sprintf(buf, "%d\n", bond->params.arp_interval) + 1; | ||
511 | } | ||
512 | |||
513 | static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *buf, size_t count) | ||
514 | { | ||
515 | int new_value, ret = count; | ||
516 | struct bonding *bond = to_bond(cd); | ||
517 | |||
518 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
519 | printk(KERN_ERR DRV_NAME | ||
520 | ": %s: no arp_interval value specified.\n", | ||
521 | bond->dev->name); | ||
522 | ret = -EINVAL; | ||
523 | goto out; | ||
524 | } | ||
525 | if (new_value < 0) { | ||
526 | printk(KERN_ERR DRV_NAME | ||
527 | ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", | ||
528 | bond->dev->name, new_value, INT_MAX); | ||
529 | ret = -EINVAL; | ||
530 | goto out; | ||
531 | } | ||
532 | |||
533 | printk(KERN_INFO DRV_NAME | ||
534 | ": %s: Setting ARP monitoring interval to %d.\n", | ||
535 | bond->dev->name, new_value); | ||
536 | bond->params.arp_interval = new_value; | ||
537 | if (bond->params.miimon) { | ||
538 | printk(KERN_INFO DRV_NAME | ||
539 | ": %s: ARP monitoring cannot be used with MII monitoring. " | ||
540 | "%s Disabling MII monitoring.\n", | ||
541 | bond->dev->name, bond->dev->name); | ||
542 | bond->params.miimon = 0; | ||
543 | /* Kill MII timer, else it brings bond's link down */ | ||
544 | if (bond->arp_timer.function) { | ||
545 | printk(KERN_INFO DRV_NAME | ||
546 | ": %s: Kill MII timer, else it brings bond's link down...\n", | ||
547 | bond->dev->name); | ||
548 | del_timer_sync(&bond->mii_timer); | ||
549 | } | ||
550 | } | ||
551 | if (!bond->params.arp_targets[0]) { | ||
552 | printk(KERN_INFO DRV_NAME | ||
553 | ": %s: ARP monitoring has been set up, " | ||
554 | "but no ARP targets have been specified.\n", | ||
555 | bond->dev->name); | ||
556 | } | ||
557 | if (bond->dev->flags & IFF_UP) { | ||
558 | /* If the interface is up, we may need to fire off | ||
559 | * the ARP timer. If the interface is down, the | ||
560 | * timer will get fired off when the open function | ||
561 | * is called. | ||
562 | */ | ||
563 | if (bond->arp_timer.function) { | ||
564 | /* The timer's already set up, so fire it off */ | ||
565 | mod_timer(&bond->arp_timer, jiffies + 1); | ||
566 | } else { | ||
567 | /* Set up the timer. */ | ||
568 | init_timer(&bond->arp_timer); | ||
569 | bond->arp_timer.expires = jiffies + 1; | ||
570 | bond->arp_timer.data = | ||
571 | (unsigned long) bond->dev; | ||
572 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { | ||
573 | bond->arp_timer.function = | ||
574 | (void *) | ||
575 | &bond_activebackup_arp_mon; | ||
576 | } else { | ||
577 | bond->arp_timer.function = | ||
578 | (void *) | ||
579 | &bond_loadbalance_arp_mon; | ||
580 | } | ||
581 | add_timer(&bond->arp_timer); | ||
582 | } | ||
583 | } | ||
584 | |||
585 | out: | ||
586 | return ret; | ||
587 | } | ||
588 | static CLASS_DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); | ||
589 | |||
590 | /* | ||
591 | * Show and set the arp targets. | ||
592 | */ | ||
593 | static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf) | ||
594 | { | ||
595 | int i, res = 0; | ||
596 | struct bonding *bond = to_bond(cd); | ||
597 | |||
598 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { | ||
599 | if (bond->params.arp_targets[i]) | ||
600 | res += sprintf(buf + res, "%u.%u.%u.%u ", | ||
601 | NIPQUAD(bond->params.arp_targets[i])); | ||
602 | } | ||
603 | if (res) | ||
604 | res--; /* eat the leftover space */ | ||
605 | res += sprintf(buf + res, "\n"); | ||
606 | res++; | ||
607 | return res; | ||
608 | } | ||
609 | |||
610 | static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *buf, size_t count) | ||
611 | { | ||
612 | u32 newtarget; | ||
613 | int i = 0, done = 0, ret = count; | ||
614 | struct bonding *bond = to_bond(cd); | ||
615 | u32 *targets; | ||
616 | |||
617 | targets = bond->params.arp_targets; | ||
618 | newtarget = in_aton(buf + 1); | ||
619 | /* look for adds */ | ||
620 | if (buf[0] == '+') { | ||
621 | if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) { | ||
622 | printk(KERN_ERR DRV_NAME | ||
623 | ": %s: invalid ARP target %u.%u.%u.%u specified for addition\n", | ||
624 | bond->dev->name, NIPQUAD(newtarget)); | ||
625 | ret = -EINVAL; | ||
626 | goto out; | ||
627 | } | ||
628 | /* look for an empty slot to put the target in, and check for dupes */ | ||
629 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { | ||
630 | if (targets[i] == newtarget) { /* duplicate */ | ||
631 | printk(KERN_ERR DRV_NAME | ||
632 | ": %s: ARP target %u.%u.%u.%u is already present\n", | ||
633 | bond->dev->name, NIPQUAD(newtarget)); | ||
634 | if (done) | ||
635 | targets[i] = 0; | ||
636 | ret = -EINVAL; | ||
637 | goto out; | ||
638 | } | ||
639 | if (targets[i] == 0 && !done) { | ||
640 | printk(KERN_INFO DRV_NAME | ||
641 | ": %s: adding ARP target %d.%d.%d.%d.\n", | ||
642 | bond->dev->name, NIPQUAD(newtarget)); | ||
643 | done = 1; | ||
644 | targets[i] = newtarget; | ||
645 | } | ||
646 | } | ||
647 | if (!done) { | ||
648 | printk(KERN_ERR DRV_NAME | ||
649 | ": %s: ARP target table is full!\n", | ||
650 | bond->dev->name); | ||
651 | ret = -EINVAL; | ||
652 | goto out; | ||
653 | } | ||
654 | |||
655 | } | ||
656 | else if (buf[0] == '-') { | ||
657 | if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) { | ||
658 | printk(KERN_ERR DRV_NAME | ||
659 | ": %s: invalid ARP target %d.%d.%d.%d specified for removal\n", | ||
660 | bond->dev->name, NIPQUAD(newtarget)); | ||
661 | ret = -EINVAL; | ||
662 | goto out; | ||
663 | } | ||
664 | |||
665 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { | ||
666 | if (targets[i] == newtarget) { | ||
667 | printk(KERN_INFO DRV_NAME | ||
668 | ": %s: removing ARP target %d.%d.%d.%d.\n", | ||
669 | bond->dev->name, NIPQUAD(newtarget)); | ||
670 | targets[i] = 0; | ||
671 | done = 1; | ||
672 | } | ||
673 | } | ||
674 | if (!done) { | ||
675 | printk(KERN_INFO DRV_NAME | ||
676 | ": %s: unable to remove nonexistent ARP target %d.%d.%d.%d.\n", | ||
677 | bond->dev->name, NIPQUAD(newtarget)); | ||
678 | ret = -EINVAL; | ||
679 | goto out; | ||
680 | } | ||
681 | } | ||
682 | else { | ||
683 | printk(KERN_ERR DRV_NAME ": no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", | ||
684 | bond->dev->name); | ||
685 | ret = -EPERM; | ||
686 | goto out; | ||
687 | } | ||
688 | |||
689 | out: | ||
690 | return ret; | ||
691 | } | ||
692 | static CLASS_DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); | ||
693 | |||
694 | /* | ||
695 | * Show and set the up and down delays. These must be multiples of the | ||
696 | * MII monitoring value, and are stored internally as the multiplier. | ||
697 | * Thus, we must translate to MS for the real world. | ||
698 | */ | ||
699 | static ssize_t bonding_show_downdelay(struct class_device *cd, char *buf) | ||
700 | { | ||
701 | struct bonding *bond = to_bond(cd); | ||
702 | |||
703 | return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1; | ||
704 | } | ||
705 | |||
706 | static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf, size_t count) | ||
707 | { | ||
708 | int new_value, ret = count; | ||
709 | struct bonding *bond = to_bond(cd); | ||
710 | |||
711 | if (!(bond->params.miimon)) { | ||
712 | printk(KERN_ERR DRV_NAME | ||
713 | ": %s: Unable to set down delay as MII monitoring is disabled\n", | ||
714 | bond->dev->name); | ||
715 | ret = -EPERM; | ||
716 | goto out; | ||
717 | } | ||
718 | |||
719 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
720 | printk(KERN_ERR DRV_NAME | ||
721 | ": %s: no down delay value specified.\n", | ||
722 | bond->dev->name); | ||
723 | ret = -EINVAL; | ||
724 | goto out; | ||
725 | } | ||
726 | if (new_value < 0) { | ||
727 | printk(KERN_ERR DRV_NAME | ||
728 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | ||
729 | bond->dev->name, new_value, 1, INT_MAX); | ||
730 | ret = -EINVAL; | ||
731 | goto out; | ||
732 | } else { | ||
733 | if ((new_value % bond->params.miimon) != 0) { | ||
734 | printk(KERN_WARNING DRV_NAME | ||
735 | ": %s: Warning: down delay (%d) is not a multiple " | ||
736 | "of miimon (%d), delay rounded to %d ms\n", | ||
737 | bond->dev->name, new_value, bond->params.miimon, | ||
738 | (new_value / bond->params.miimon) * | ||
739 | bond->params.miimon); | ||
740 | } | ||
741 | bond->params.downdelay = new_value / bond->params.miimon; | ||
742 | printk(KERN_INFO DRV_NAME ": %s: Setting down delay to %d.\n", | ||
743 | bond->dev->name, bond->params.downdelay * bond->params.miimon); | ||
744 | |||
745 | } | ||
746 | |||
747 | out: | ||
748 | return ret; | ||
749 | } | ||
750 | static CLASS_DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); | ||
751 | |||
752 | static ssize_t bonding_show_updelay(struct class_device *cd, char *buf) | ||
753 | { | ||
754 | struct bonding *bond = to_bond(cd); | ||
755 | |||
756 | return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1; | ||
757 | |||
758 | } | ||
759 | |||
760 | static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, size_t count) | ||
761 | { | ||
762 | int new_value, ret = count; | ||
763 | struct bonding *bond = to_bond(cd); | ||
764 | |||
765 | if (!(bond->params.miimon)) { | ||
766 | printk(KERN_ERR DRV_NAME | ||
767 | ": %s: Unable to set up delay as MII monitoring is disabled\n", | ||
768 | bond->dev->name); | ||
769 | ret = -EPERM; | ||
770 | goto out; | ||
771 | } | ||
772 | |||
773 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
774 | printk(KERN_ERR DRV_NAME | ||
775 | ": %s: no up delay value specified.\n", | ||
776 | bond->dev->name); | ||
777 | ret = -EINVAL; | ||
778 | goto out; | ||
779 | } | ||
780 | if (new_value < 0) { | ||
781 | printk(KERN_ERR DRV_NAME | ||
782 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | ||
783 | bond->dev->name, new_value, 1, INT_MAX); | ||
784 | ret = -EINVAL; | ||
785 | goto out; | ||
786 | } else { | ||
787 | if ((new_value % bond->params.miimon) != 0) { | ||
788 | printk(KERN_WARNING DRV_NAME | ||
789 | ": %s: Warning: up delay (%d) is not a multiple " | ||
790 | "of miimon (%d), updelay rounded to %d ms\n", | ||
791 | bond->dev->name, new_value, bond->params.miimon, | ||
792 | (new_value / bond->params.miimon) * | ||
793 | bond->params.miimon); | ||
794 | } | ||
795 | bond->params.updelay = new_value / bond->params.miimon; | ||
796 | printk(KERN_INFO DRV_NAME ": %s: Setting up delay to %d.\n", | ||
797 | bond->dev->name, bond->params.updelay * bond->params.miimon); | ||
798 | |||
799 | } | ||
800 | |||
801 | out: | ||
802 | return ret; | ||
803 | } | ||
804 | static CLASS_DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); | ||
805 | |||
806 | /* | ||
807 | * Show and set the LACP interval. Interface must be down, and the mode | ||
808 | * must be set to 802.3ad mode. | ||
809 | */ | ||
810 | static ssize_t bonding_show_lacp(struct class_device *cd, char *buf) | ||
811 | { | ||
812 | struct bonding *bond = to_bond(cd); | ||
813 | |||
814 | return sprintf(buf, "%s %d\n", | ||
815 | bond_lacp_tbl[bond->params.lacp_fast].modename, | ||
816 | bond->params.lacp_fast) + 1; | ||
817 | } | ||
818 | |||
819 | static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size_t count) | ||
820 | { | ||
821 | int new_value, ret = count; | ||
822 | struct bonding *bond = to_bond(cd); | ||
823 | |||
824 | if (bond->dev->flags & IFF_UP) { | ||
825 | printk(KERN_ERR DRV_NAME | ||
826 | ": %s: Unable to update LACP rate because interface is up.\n", | ||
827 | bond->dev->name); | ||
828 | ret = -EPERM; | ||
829 | goto out; | ||
830 | } | ||
831 | |||
832 | if (bond->params.mode != BOND_MODE_8023AD) { | ||
833 | printk(KERN_ERR DRV_NAME | ||
834 | ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", | ||
835 | bond->dev->name); | ||
836 | ret = -EPERM; | ||
837 | goto out; | ||
838 | } | ||
839 | |||
840 | new_value = bond_parse_parm((char *)buf, bond_lacp_tbl); | ||
841 | |||
842 | if ((new_value == 1) || (new_value == 0)) { | ||
843 | bond->params.lacp_fast = new_value; | ||
844 | printk(KERN_INFO DRV_NAME | ||
845 | ": %s: Setting LACP rate to %s (%d).\n", | ||
846 | bond->dev->name, bond_lacp_tbl[new_value].modename, new_value); | ||
847 | } else { | ||
848 | printk(KERN_ERR DRV_NAME | ||
849 | ": %s: Ignoring invalid LACP rate value %.*s.\n", | ||
850 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
851 | ret = -EINVAL; | ||
852 | } | ||
853 | out: | ||
854 | return ret; | ||
855 | } | ||
856 | static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); | ||
857 | |||
858 | /* | ||
859 | * Show and set the MII monitor interval. There are two tricky bits | ||
860 | * here. First, if MII monitoring is activated, then we must disable | ||
861 | * ARP monitoring. Second, if the timer isn't running, we must | ||
862 | * start it. | ||
863 | */ | ||
864 | static ssize_t bonding_show_miimon(struct class_device *cd, char *buf) | ||
865 | { | ||
866 | struct bonding *bond = to_bond(cd); | ||
867 | |||
868 | return sprintf(buf, "%d\n", bond->params.miimon) + 1; | ||
869 | } | ||
870 | |||
871 | static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, size_t count) | ||
872 | { | ||
873 | int new_value, ret = count; | ||
874 | struct bonding *bond = to_bond(cd); | ||
875 | |||
876 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
877 | printk(KERN_ERR DRV_NAME | ||
878 | ": %s: no miimon value specified.\n", | ||
879 | bond->dev->name); | ||
880 | ret = -EINVAL; | ||
881 | goto out; | ||
882 | } | ||
883 | if (new_value < 0) { | ||
884 | printk(KERN_ERR DRV_NAME | ||
885 | ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n", | ||
886 | bond->dev->name, new_value, 1, INT_MAX); | ||
887 | ret = -EINVAL; | ||
888 | goto out; | ||
889 | } else { | ||
890 | printk(KERN_INFO DRV_NAME | ||
891 | ": %s: Setting MII monitoring interval to %d.\n", | ||
892 | bond->dev->name, new_value); | ||
893 | bond->params.miimon = new_value; | ||
894 | if(bond->params.updelay) | ||
895 | printk(KERN_INFO DRV_NAME | ||
896 | ": %s: Note: Updating updelay (to %d) " | ||
897 | "since it is a multiple of the miimon value.\n", | ||
898 | bond->dev->name, | ||
899 | bond->params.updelay * bond->params.miimon); | ||
900 | if(bond->params.downdelay) | ||
901 | printk(KERN_INFO DRV_NAME | ||
902 | ": %s: Note: Updating downdelay (to %d) " | ||
903 | "since it is a multiple of the miimon value.\n", | ||
904 | bond->dev->name, | ||
905 | bond->params.downdelay * bond->params.miimon); | ||
906 | if (bond->params.arp_interval) { | ||
907 | printk(KERN_INFO DRV_NAME | ||
908 | ": %s: MII monitoring cannot be used with " | ||
909 | "ARP monitoring. Disabling ARP monitoring...\n", | ||
910 | bond->dev->name); | ||
911 | bond->params.arp_interval = 0; | ||
912 | /* Kill ARP timer, else it brings bond's link down */ | ||
913 | if (bond->mii_timer.function) { | ||
914 | printk(KERN_INFO DRV_NAME | ||
915 | ": %s: Kill ARP timer, else it brings bond's link down...\n", | ||
916 | bond->dev->name); | ||
917 | del_timer_sync(&bond->arp_timer); | ||
918 | } | ||
919 | } | ||
920 | |||
921 | if (bond->dev->flags & IFF_UP) { | ||
922 | /* If the interface is up, we may need to fire off | ||
923 | * the MII timer. If the interface is down, the | ||
924 | * timer will get fired off when the open function | ||
925 | * is called. | ||
926 | */ | ||
927 | if (bond->mii_timer.function) { | ||
928 | /* The timer's already set up, so fire it off */ | ||
929 | mod_timer(&bond->mii_timer, jiffies + 1); | ||
930 | } else { | ||
931 | /* Set up the timer. */ | ||
932 | init_timer(&bond->mii_timer); | ||
933 | bond->mii_timer.expires = jiffies + 1; | ||
934 | bond->mii_timer.data = | ||
935 | (unsigned long) bond->dev; | ||
936 | bond->mii_timer.function = | ||
937 | (void *) &bond_mii_monitor; | ||
938 | add_timer(&bond->mii_timer); | ||
939 | } | ||
940 | } | ||
941 | } | ||
942 | out: | ||
943 | return ret; | ||
944 | } | ||
945 | static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); | ||
946 | |||
947 | /* | ||
948 | * Show and set the primary slave. The store function is much | ||
949 | * simpler than bonding_store_slaves function because it only needs to | ||
950 | * handle one interface name. | ||
951 | * The bond must be a mode that supports a primary for this be | ||
952 | * set. | ||
953 | */ | ||
954 | static ssize_t bonding_show_primary(struct class_device *cd, char *buf) | ||
955 | { | ||
956 | int count = 0; | ||
957 | struct bonding *bond = to_bond(cd); | ||
958 | |||
959 | if (bond->primary_slave) | ||
960 | count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1; | ||
961 | else | ||
962 | count = sprintf(buf, "\n") + 1; | ||
963 | |||
964 | return count; | ||
965 | } | ||
966 | |||
967 | static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, size_t count) | ||
968 | { | ||
969 | int i; | ||
970 | struct slave *slave; | ||
971 | struct bonding *bond = to_bond(cd); | ||
972 | |||
973 | write_lock_bh(&bond->lock); | ||
974 | if (!USES_PRIMARY(bond->params.mode)) { | ||
975 | printk(KERN_INFO DRV_NAME | ||
976 | ": %s: Unable to set primary slave; %s is in mode %d\n", | ||
977 | bond->dev->name, bond->dev->name, bond->params.mode); | ||
978 | } else { | ||
979 | bond_for_each_slave(bond, slave, i) { | ||
980 | if (strnicmp | ||
981 | (slave->dev->name, buf, | ||
982 | strlen(slave->dev->name)) == 0) { | ||
983 | printk(KERN_INFO DRV_NAME | ||
984 | ": %s: Setting %s as primary slave.\n", | ||
985 | bond->dev->name, slave->dev->name); | ||
986 | bond->primary_slave = slave; | ||
987 | bond_select_active_slave(bond); | ||
988 | goto out; | ||
989 | } | ||
990 | } | ||
991 | |||
992 | /* if we got here, then we didn't match the name of any slave */ | ||
993 | |||
994 | if (strlen(buf) == 0 || buf[0] == '\n') { | ||
995 | printk(KERN_INFO DRV_NAME | ||
996 | ": %s: Setting primary slave to None.\n", | ||
997 | bond->dev->name); | ||
998 | bond->primary_slave = 0; | ||
999 | bond_select_active_slave(bond); | ||
1000 | } else { | ||
1001 | printk(KERN_INFO DRV_NAME | ||
1002 | ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", | ||
1003 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
1004 | } | ||
1005 | } | ||
1006 | out: | ||
1007 | write_unlock_bh(&bond->lock); | ||
1008 | return count; | ||
1009 | } | ||
1010 | static CLASS_DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); | ||
1011 | |||
1012 | /* | ||
1013 | * Show and set the use_carrier flag. | ||
1014 | */ | ||
1015 | static ssize_t bonding_show_carrier(struct class_device *cd, char *buf) | ||
1016 | { | ||
1017 | struct bonding *bond = to_bond(cd); | ||
1018 | |||
1019 | return sprintf(buf, "%d\n", bond->params.use_carrier) + 1; | ||
1020 | } | ||
1021 | |||
1022 | static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, size_t count) | ||
1023 | { | ||
1024 | int new_value, ret = count; | ||
1025 | struct bonding *bond = to_bond(cd); | ||
1026 | |||
1027 | |||
1028 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
1029 | printk(KERN_ERR DRV_NAME | ||
1030 | ": %s: no use_carrier value specified.\n", | ||
1031 | bond->dev->name); | ||
1032 | ret = -EINVAL; | ||
1033 | goto out; | ||
1034 | } | ||
1035 | if ((new_value == 0) || (new_value == 1)) { | ||
1036 | bond->params.use_carrier = new_value; | ||
1037 | printk(KERN_INFO DRV_NAME ": %s: Setting use_carrier to %d.\n", | ||
1038 | bond->dev->name, new_value); | ||
1039 | } else { | ||
1040 | printk(KERN_INFO DRV_NAME | ||
1041 | ": %s: Ignoring invalid use_carrier value %d.\n", | ||
1042 | bond->dev->name, new_value); | ||
1043 | } | ||
1044 | out: | ||
1045 | return count; | ||
1046 | } | ||
1047 | static CLASS_DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); | ||
1048 | |||
1049 | |||
1050 | /* | ||
1051 | * Show and set currently active_slave. | ||
1052 | */ | ||
1053 | static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf) | ||
1054 | { | ||
1055 | struct slave *curr; | ||
1056 | struct bonding *bond = to_bond(cd); | ||
1057 | int count; | ||
1058 | |||
1059 | |||
1060 | read_lock(&bond->curr_slave_lock); | ||
1061 | curr = bond->curr_active_slave; | ||
1062 | read_unlock(&bond->curr_slave_lock); | ||
1063 | |||
1064 | if (USES_PRIMARY(bond->params.mode) && curr) | ||
1065 | count = sprintf(buf, "%s\n", curr->dev->name) + 1; | ||
1066 | else | ||
1067 | count = sprintf(buf, "\n") + 1; | ||
1068 | return count; | ||
1069 | } | ||
1070 | |||
1071 | static ssize_t bonding_store_active_slave(struct class_device *cd, const char *buf, size_t count) | ||
1072 | { | ||
1073 | int i; | ||
1074 | struct slave *slave; | ||
1075 | struct slave *old_active = NULL; | ||
1076 | struct slave *new_active = NULL; | ||
1077 | struct bonding *bond = to_bond(cd); | ||
1078 | |||
1079 | write_lock_bh(&bond->lock); | ||
1080 | if (!USES_PRIMARY(bond->params.mode)) { | ||
1081 | printk(KERN_INFO DRV_NAME | ||
1082 | ": %s: Unable to change active slave; %s is in mode %d\n", | ||
1083 | bond->dev->name, bond->dev->name, bond->params.mode); | ||
1084 | } else { | ||
1085 | bond_for_each_slave(bond, slave, i) { | ||
1086 | if (strnicmp | ||
1087 | (slave->dev->name, buf, | ||
1088 | strlen(slave->dev->name)) == 0) { | ||
1089 | old_active = bond->curr_active_slave; | ||
1090 | new_active = slave; | ||
1091 | if (new_active && (new_active == old_active)) { | ||
1092 | /* do nothing */ | ||
1093 | printk(KERN_INFO DRV_NAME | ||
1094 | ": %s: %s is already the current active slave.\n", | ||
1095 | bond->dev->name, slave->dev->name); | ||
1096 | goto out; | ||
1097 | } | ||
1098 | else { | ||
1099 | if ((new_active) && | ||
1100 | (old_active) && | ||
1101 | (new_active->link == BOND_LINK_UP) && | ||
1102 | IS_UP(new_active->dev)) { | ||
1103 | printk(KERN_INFO DRV_NAME | ||
1104 | ": %s: Setting %s as active slave.\n", | ||
1105 | bond->dev->name, slave->dev->name); | ||
1106 | bond_change_active_slave(bond, new_active); | ||
1107 | } | ||
1108 | else { | ||
1109 | printk(KERN_INFO DRV_NAME | ||
1110 | ": %s: Could not set %s as active slave; " | ||
1111 | "either %s is down or the link is down.\n", | ||
1112 | bond->dev->name, slave->dev->name, | ||
1113 | slave->dev->name); | ||
1114 | } | ||
1115 | goto out; | ||
1116 | } | ||
1117 | } | ||
1118 | } | ||
1119 | |||
1120 | /* if we got here, then we didn't match the name of any slave */ | ||
1121 | |||
1122 | if (strlen(buf) == 0 || buf[0] == '\n') { | ||
1123 | printk(KERN_INFO DRV_NAME | ||
1124 | ": %s: Setting active slave to None.\n", | ||
1125 | bond->dev->name); | ||
1126 | bond->primary_slave = 0; | ||
1127 | bond_select_active_slave(bond); | ||
1128 | } else { | ||
1129 | printk(KERN_INFO DRV_NAME | ||
1130 | ": %s: Unable to set %.*s as active slave as it is not a slave.\n", | ||
1131 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
1132 | } | ||
1133 | } | ||
1134 | out: | ||
1135 | write_unlock_bh(&bond->lock); | ||
1136 | return count; | ||
1137 | |||
1138 | } | ||
1139 | static CLASS_DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); | ||
1140 | |||
1141 | |||
1142 | /* | ||
1143 | * Show link status of the bond interface. | ||
1144 | */ | ||
1145 | static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf) | ||
1146 | { | ||
1147 | struct slave *curr; | ||
1148 | struct bonding *bond = to_bond(cd); | ||
1149 | |||
1150 | read_lock(&bond->curr_slave_lock); | ||
1151 | curr = bond->curr_active_slave; | ||
1152 | read_unlock(&bond->curr_slave_lock); | ||
1153 | |||
1154 | return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1; | ||
1155 | } | ||
1156 | static CLASS_DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); | ||
1157 | |||
1158 | |||
1159 | /* | ||
1160 | * Show current 802.3ad aggregator ID. | ||
1161 | */ | ||
1162 | static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf) | ||
1163 | { | ||
1164 | int count = 0; | ||
1165 | struct bonding *bond = to_bond(cd); | ||
1166 | |||
1167 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1168 | struct ad_info ad_info; | ||
1169 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id) + 1; | ||
1170 | } | ||
1171 | else | ||
1172 | count = sprintf(buf, "\n") + 1; | ||
1173 | |||
1174 | return count; | ||
1175 | } | ||
1176 | static CLASS_DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); | ||
1177 | |||
1178 | |||
1179 | /* | ||
1180 | * Show number of active 802.3ad ports. | ||
1181 | */ | ||
1182 | static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf) | ||
1183 | { | ||
1184 | int count = 0; | ||
1185 | struct bonding *bond = to_bond(cd); | ||
1186 | |||
1187 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1188 | struct ad_info ad_info; | ||
1189 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports) + 1; | ||
1190 | } | ||
1191 | else | ||
1192 | count = sprintf(buf, "\n") + 1; | ||
1193 | |||
1194 | return count; | ||
1195 | } | ||
1196 | static CLASS_DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); | ||
1197 | |||
1198 | |||
1199 | /* | ||
1200 | * Show current 802.3ad actor key. | ||
1201 | */ | ||
1202 | static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf) | ||
1203 | { | ||
1204 | int count = 0; | ||
1205 | struct bonding *bond = to_bond(cd); | ||
1206 | |||
1207 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1208 | struct ad_info ad_info; | ||
1209 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key) + 1; | ||
1210 | } | ||
1211 | else | ||
1212 | count = sprintf(buf, "\n") + 1; | ||
1213 | |||
1214 | return count; | ||
1215 | } | ||
1216 | static CLASS_DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); | ||
1217 | |||
1218 | |||
1219 | /* | ||
1220 | * Show current 802.3ad partner key. | ||
1221 | */ | ||
1222 | static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf) | ||
1223 | { | ||
1224 | int count = 0; | ||
1225 | struct bonding *bond = to_bond(cd); | ||
1226 | |||
1227 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1228 | struct ad_info ad_info; | ||
1229 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key) + 1; | ||
1230 | } | ||
1231 | else | ||
1232 | count = sprintf(buf, "\n") + 1; | ||
1233 | |||
1234 | return count; | ||
1235 | } | ||
1236 | static CLASS_DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); | ||
1237 | |||
1238 | |||
1239 | /* | ||
1240 | * Show current 802.3ad partner mac. | ||
1241 | */ | ||
1242 | static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf) | ||
1243 | { | ||
1244 | int count = 0; | ||
1245 | struct bonding *bond = to_bond(cd); | ||
1246 | |||
1247 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1248 | struct ad_info ad_info; | ||
1249 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { | ||
1250 | count = sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x\n", | ||
1251 | ad_info.partner_system[0], | ||
1252 | ad_info.partner_system[1], | ||
1253 | ad_info.partner_system[2], | ||
1254 | ad_info.partner_system[3], | ||
1255 | ad_info.partner_system[4], | ||
1256 | ad_info.partner_system[5]) + 1; | ||
1257 | } | ||
1258 | } | ||
1259 | else | ||
1260 | count = sprintf(buf, "\n") + 1; | ||
1261 | |||
1262 | return count; | ||
1263 | } | ||
1264 | static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); | ||
1265 | |||
1266 | |||
1267 | |||
1268 | static struct attribute *per_bond_attrs[] = { | ||
1269 | &class_device_attr_slaves.attr, | ||
1270 | &class_device_attr_mode.attr, | ||
1271 | &class_device_attr_arp_interval.attr, | ||
1272 | &class_device_attr_arp_ip_target.attr, | ||
1273 | &class_device_attr_downdelay.attr, | ||
1274 | &class_device_attr_updelay.attr, | ||
1275 | &class_device_attr_lacp_rate.attr, | ||
1276 | &class_device_attr_xmit_hash_policy.attr, | ||
1277 | &class_device_attr_miimon.attr, | ||
1278 | &class_device_attr_primary.attr, | ||
1279 | &class_device_attr_use_carrier.attr, | ||
1280 | &class_device_attr_active_slave.attr, | ||
1281 | &class_device_attr_mii_status.attr, | ||
1282 | &class_device_attr_ad_aggregator.attr, | ||
1283 | &class_device_attr_ad_num_ports.attr, | ||
1284 | &class_device_attr_ad_actor_key.attr, | ||
1285 | &class_device_attr_ad_partner_key.attr, | ||
1286 | &class_device_attr_ad_partner_mac.attr, | ||
1287 | NULL, | ||
1288 | }; | ||
1289 | |||
1290 | static struct attribute_group bonding_group = { | ||
1291 | .name = "bonding", | ||
1292 | .attrs = per_bond_attrs, | ||
1293 | }; | ||
1294 | |||
1295 | /* | ||
1296 | * Initialize sysfs. This sets up the bonding_masters file in | ||
1297 | * /sys/class/net. | ||
1298 | */ | ||
1299 | int bond_create_sysfs(void) | ||
1300 | { | ||
1301 | int ret = 0; | ||
1302 | struct bonding *firstbond; | ||
1303 | |||
1304 | init_rwsem(&bonding_rwsem); | ||
1305 | |||
1306 | /* get the netdev class pointer */ | ||
1307 | firstbond = container_of(bond_dev_list.next, struct bonding, bond_list); | ||
1308 | if (!firstbond) | ||
1309 | return -ENODEV; | ||
1310 | |||
1311 | netdev_class = firstbond->dev->class_dev.class; | ||
1312 | if (!netdev_class) | ||
1313 | return -ENODEV; | ||
1314 | |||
1315 | ret = class_create_file(netdev_class, &class_attr_bonding_masters); | ||
1316 | |||
1317 | return ret; | ||
1318 | |||
1319 | } | ||
1320 | |||
1321 | /* | ||
1322 | * Remove /sys/class/net/bonding_masters. | ||
1323 | */ | ||
1324 | void bond_destroy_sysfs(void) | ||
1325 | { | ||
1326 | if (netdev_class) | ||
1327 | class_remove_file(netdev_class, &class_attr_bonding_masters); | ||
1328 | } | ||
1329 | |||
1330 | /* | ||
1331 | * Initialize sysfs for each bond. This sets up and registers | ||
1332 | * the 'bondctl' directory for each individual bond under /sys/class/net. | ||
1333 | */ | ||
1334 | int bond_create_sysfs_entry(struct bonding *bond) | ||
1335 | { | ||
1336 | struct net_device *dev = bond->dev; | ||
1337 | int err; | ||
1338 | |||
1339 | err = sysfs_create_group(&(dev->class_dev.kobj), &bonding_group); | ||
1340 | if (err) { | ||
1341 | printk(KERN_EMERG "eek! didn't create group!\n"); | ||
1342 | } | ||
1343 | |||
1344 | if (expected_refcount < 1) | ||
1345 | expected_refcount = atomic_read(&bond->dev->class_dev.kobj.kref.refcount); | ||
1346 | |||
1347 | return err; | ||
1348 | } | ||
1349 | /* | ||
1350 | * Remove sysfs entries for each bond. | ||
1351 | */ | ||
1352 | void bond_destroy_sysfs_entry(struct bonding *bond) | ||
1353 | { | ||
1354 | struct net_device *dev = bond->dev; | ||
1355 | |||
1356 | sysfs_remove_group(&(dev->class_dev.kobj), &bonding_group); | ||
1357 | } | ||
1358 | |||
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 1433e91db0f..015c7f1d1bc 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -10,25 +10,6 @@ | |||
10 | * This software may be used and distributed according to the terms | 10 | * This software may be used and distributed according to the terms |
11 | * of the GNU Public License, incorporated herein by reference. | 11 | * of the GNU Public License, incorporated herein by reference. |
12 | * | 12 | * |
13 | * | ||
14 | * 2003/03/18 - Amir Noam <amir.noam at intel dot com>, | ||
15 | * Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
16 | * Shmulik Hen <shmulik.hen at intel dot com> | ||
17 | * - Added support for IEEE 802.3ad Dynamic link aggregation mode. | ||
18 | * | ||
19 | * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and | ||
20 | * Amir Noam <amir.noam at intel dot com> | ||
21 | * - Code beautification and style changes (mainly in comments). | ||
22 | * | ||
23 | * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
24 | * - Added support for Transmit load balancing mode. | ||
25 | * | ||
26 | * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com> | ||
27 | * - Code cleanup and style changes | ||
28 | * | ||
29 | * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov> | ||
30 | * - added "xmit_policy" kernel parameter for alternate hashing policy | ||
31 | * support for mode 2 | ||
32 | */ | 13 | */ |
33 | 14 | ||
34 | #ifndef _LINUX_BONDING_H | 15 | #ifndef _LINUX_BONDING_H |
@@ -37,11 +18,12 @@ | |||
37 | #include <linux/timer.h> | 18 | #include <linux/timer.h> |
38 | #include <linux/proc_fs.h> | 19 | #include <linux/proc_fs.h> |
39 | #include <linux/if_bonding.h> | 20 | #include <linux/if_bonding.h> |
21 | #include <linux/kobject.h> | ||
40 | #include "bond_3ad.h" | 22 | #include "bond_3ad.h" |
41 | #include "bond_alb.h" | 23 | #include "bond_alb.h" |
42 | 24 | ||
43 | #define DRV_VERSION "2.6.5" | 25 | #define DRV_VERSION "3.0.0" |
44 | #define DRV_RELDATE "November 4, 2005" | 26 | #define DRV_RELDATE "November 8, 2005" |
45 | #define DRV_NAME "bonding" | 27 | #define DRV_NAME "bonding" |
46 | #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" | 28 | #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" |
47 | 29 | ||
@@ -152,6 +134,11 @@ struct bond_params { | |||
152 | u32 arp_targets[BOND_MAX_ARP_TARGETS]; | 134 | u32 arp_targets[BOND_MAX_ARP_TARGETS]; |
153 | }; | 135 | }; |
154 | 136 | ||
137 | struct bond_parm_tbl { | ||
138 | char *modename; | ||
139 | int mode; | ||
140 | }; | ||
141 | |||
155 | struct vlan_entry { | 142 | struct vlan_entry { |
156 | struct list_head vlan_list; | 143 | struct list_head vlan_list; |
157 | u32 vlan_ip; | 144 | u32 vlan_ip; |
@@ -159,7 +146,7 @@ struct vlan_entry { | |||
159 | }; | 146 | }; |
160 | 147 | ||
161 | struct slave { | 148 | struct slave { |
162 | struct net_device *dev; /* first - usefull for panic debug */ | 149 | struct net_device *dev; /* first - useful for panic debug */ |
163 | struct slave *next; | 150 | struct slave *next; |
164 | struct slave *prev; | 151 | struct slave *prev; |
165 | s16 delay; | 152 | s16 delay; |
@@ -185,7 +172,7 @@ struct slave { | |||
185 | * beforehand. | 172 | * beforehand. |
186 | */ | 173 | */ |
187 | struct bonding { | 174 | struct bonding { |
188 | struct net_device *dev; /* first - usefull for panic debug */ | 175 | struct net_device *dev; /* first - useful for panic debug */ |
189 | struct slave *first_slave; | 176 | struct slave *first_slave; |
190 | struct slave *curr_active_slave; | 177 | struct slave *curr_active_slave; |
191 | struct slave *current_arp_slave; | 178 | struct slave *current_arp_slave; |
@@ -255,6 +242,25 @@ extern inline void bond_set_slave_active_flags(struct slave *slave) | |||
255 | 242 | ||
256 | struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); | 243 | struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); |
257 | int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); | 244 | int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); |
245 | int bond_create(char *name, struct bond_params *params, struct bonding **newbond); | ||
246 | void bond_deinit(struct net_device *bond_dev); | ||
247 | int bond_create_sysfs(void); | ||
248 | void bond_destroy_sysfs(void); | ||
249 | void bond_destroy_sysfs_entry(struct bonding *bond); | ||
250 | int bond_create_sysfs_entry(struct bonding *bond); | ||
251 | int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave); | ||
252 | void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); | ||
253 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); | ||
254 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); | ||
255 | int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev); | ||
256 | void bond_mii_monitor(struct net_device *bond_dev); | ||
257 | void bond_loadbalance_arp_mon(struct net_device *bond_dev); | ||
258 | void bond_activebackup_arp_mon(struct net_device *bond_dev); | ||
259 | void bond_set_mode_ops(struct bonding *bond, int mode); | ||
260 | int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl); | ||
261 | const char *bond_mode_name(int mode); | ||
262 | void bond_select_active_slave(struct bonding *bond); | ||
263 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); | ||
258 | 264 | ||
259 | #endif /* _LINUX_BONDING_H */ | 265 | #endif /* _LINUX_BONDING_H */ |
260 | 266 | ||