diff options
-rw-r--r-- | drivers/net/bonding/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 74 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 56 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 343 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 1399 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 37 | ||||
-rw-r--r-- | include/linux/netdevice.h | 1 | ||||
-rw-r--r-- | net/core/dev.c | 3 | ||||
-rw-r--r-- | net/core/utils.c | 2 |
9 files changed, 1735 insertions, 182 deletions
diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile index cf50384b469e..5cdae2bc055a 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 d2f34d5a8083..04705233ca0b 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -1198,10 +1198,10 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) | |||
1198 | // detect loopback situation | 1198 | // detect loopback situation |
1199 | if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { | 1199 | if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { |
1200 | // INFO_RECEIVED_LOOPBACK_FRAMES | 1200 | // INFO_RECEIVED_LOOPBACK_FRAMES |
1201 | printk(KERN_ERR DRV_NAME ": An illegal loopback occurred on adapter (%s)\n", | 1201 | printk(KERN_ERR DRV_NAME ": %s: An illegal loopback occurred on " |
1202 | port->slave->dev->name); | 1202 | "adapter (%s). Check the configuration to verify that all " |
1203 | printk(KERN_ERR "Check the configuration to verify that all Adapters " | 1203 | "Adapters are connected to 802.3ad compliant switch ports\n", |
1204 | "are connected to 802.3ad compliant switch ports\n"); | 1204 | port->slave->dev->master->name, port->slave->dev->name); |
1205 | __release_rx_machine_lock(port); | 1205 | __release_rx_machine_lock(port); |
1206 | return; | 1206 | return; |
1207 | } | 1207 | } |
@@ -1378,8 +1378,9 @@ static void ad_port_selection_logic(struct port *port) | |||
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list | 1380 | 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 " | 1381 | 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", | 1382 | "related to aggregator %d but was not on its port list\n", |
1383 | port->slave->dev->master->name, | ||
1383 | port->actor_port_number, port->slave->dev->name, | 1384 | port->actor_port_number, port->slave->dev->name, |
1384 | port->aggregator->aggregator_identifier); | 1385 | port->aggregator->aggregator_identifier); |
1385 | } | 1386 | } |
@@ -1450,7 +1451,8 @@ static void ad_port_selection_logic(struct port *port) | |||
1450 | 1451 | ||
1451 | dprintk("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); | 1452 | dprintk("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); |
1452 | } else { | 1453 | } else { |
1453 | printk(KERN_ERR DRV_NAME ": Port %d (on %s) did not find a suitable aggregator\n", | 1454 | printk(KERN_ERR DRV_NAME ": %s: Port %d (on %s) did not find a suitable aggregator\n", |
1455 | port->slave->dev->master->name, | ||
1454 | port->actor_port_number, port->slave->dev->name); | 1456 | port->actor_port_number, port->slave->dev->name); |
1455 | } | 1457 | } |
1456 | } | 1458 | } |
@@ -1582,8 +1584,9 @@ static void ad_agg_selection_logic(struct aggregator *aggregator) | |||
1582 | 1584 | ||
1583 | // check if any partner replys | 1585 | // check if any partner replys |
1584 | if (best_aggregator->is_individual) { | 1586 | if (best_aggregator->is_individual) { |
1585 | printk(KERN_WARNING DRV_NAME ": Warning: No 802.3ad response from the link partner " | 1587 | printk(KERN_WARNING DRV_NAME ": %s: Warning: No 802.3ad response from " |
1586 | "for any adapters in the bond\n"); | 1588 | "the link partner for any adapters in the bond\n", |
1589 | best_aggregator->slave->dev->master->name); | ||
1587 | } | 1590 | } |
1588 | 1591 | ||
1589 | // check if there are more than one aggregator | 1592 | // check if there are more than one aggregator |
@@ -1915,7 +1918,8 @@ int bond_3ad_bind_slave(struct slave *slave) | |||
1915 | struct aggregator *aggregator; | 1918 | struct aggregator *aggregator; |
1916 | 1919 | ||
1917 | if (bond == NULL) { | 1920 | if (bond == NULL) { |
1918 | printk(KERN_ERR "The slave %s is not attached to its bond\n", slave->dev->name); | 1921 | printk(KERN_ERR DRV_NAME ": %s: The slave %s is not attached to its bond\n", |
1922 | slave->dev->master->name, slave->dev->name); | ||
1919 | return -1; | 1923 | return -1; |
1920 | } | 1924 | } |
1921 | 1925 | ||
@@ -1990,7 +1994,9 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
1990 | 1994 | ||
1991 | // if slave is null, the whole port is not initialized | 1995 | // if slave is null, the whole port is not initialized |
1992 | if (!port->slave) { | 1996 | if (!port->slave) { |
1993 | printk(KERN_WARNING DRV_NAME ": Trying to unbind an uninitialized port on %s\n", slave->dev->name); | 1997 | printk(KERN_WARNING DRV_NAME ": Warning: %s: Trying to " |
1998 | "unbind an uninitialized port on %s\n", | ||
1999 | slave->dev->master->name, slave->dev->name); | ||
1994 | return; | 2000 | return; |
1995 | } | 2001 | } |
1996 | 2002 | ||
@@ -2021,7 +2027,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); | 2027 | dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier); |
2022 | 2028 | ||
2023 | if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { | 2029 | if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { |
2024 | printk(KERN_INFO DRV_NAME ": Removing an active aggregator\n"); | 2030 | printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", |
2031 | aggregator->slave->dev->master->name); | ||
2025 | // select new active aggregator | 2032 | // select new active aggregator |
2026 | select_new_active_agg = 1; | 2033 | select_new_active_agg = 1; |
2027 | } | 2034 | } |
@@ -2051,15 +2058,17 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2051 | ad_agg_selection_logic(__get_first_agg(port)); | 2058 | ad_agg_selection_logic(__get_first_agg(port)); |
2052 | } | 2059 | } |
2053 | } else { | 2060 | } else { |
2054 | printk(KERN_WARNING DRV_NAME ": Warning: unbinding aggregator, " | 2061 | printk(KERN_WARNING DRV_NAME ": %s: Warning: unbinding aggregator, " |
2055 | "and could not find a new aggregator for its ports\n"); | 2062 | "and could not find a new aggregator for its ports\n", |
2063 | slave->dev->master->name); | ||
2056 | } | 2064 | } |
2057 | } else { // in case that the only port related to this aggregator is the one we want to remove | 2065 | } 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; | 2066 | select_new_active_agg = aggregator->is_active; |
2059 | // clear the aggregator | 2067 | // clear the aggregator |
2060 | ad_clear_agg(aggregator); | 2068 | ad_clear_agg(aggregator); |
2061 | if (select_new_active_agg) { | 2069 | if (select_new_active_agg) { |
2062 | printk(KERN_INFO "Removing an active aggregator\n"); | 2070 | printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", |
2071 | slave->dev->master->name); | ||
2063 | // select new active aggregator | 2072 | // select new active aggregator |
2064 | ad_agg_selection_logic(__get_first_agg(port)); | 2073 | ad_agg_selection_logic(__get_first_agg(port)); |
2065 | } | 2074 | } |
@@ -2085,7 +2094,8 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2085 | // clear the aggregator | 2094 | // clear the aggregator |
2086 | ad_clear_agg(temp_aggregator); | 2095 | ad_clear_agg(temp_aggregator); |
2087 | if (select_new_active_agg) { | 2096 | if (select_new_active_agg) { |
2088 | printk(KERN_INFO "Removing an active aggregator\n"); | 2097 | printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", |
2098 | slave->dev->master->name); | ||
2089 | // select new active aggregator | 2099 | // select new active aggregator |
2090 | ad_agg_selection_logic(__get_first_agg(port)); | 2100 | ad_agg_selection_logic(__get_first_agg(port)); |
2091 | } | 2101 | } |
@@ -2131,7 +2141,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond) | |||
2131 | // select the active aggregator for the bond | 2141 | // select the active aggregator for the bond |
2132 | if ((port = __get_first_port(bond))) { | 2142 | if ((port = __get_first_port(bond))) { |
2133 | if (!port->slave) { | 2143 | if (!port->slave) { |
2134 | printk(KERN_WARNING DRV_NAME ": Warning: bond's first port is uninitialized\n"); | 2144 | printk(KERN_WARNING DRV_NAME ": %s: Warning: bond's first port is " |
2145 | "uninitialized\n", bond->dev->name); | ||
2135 | goto re_arm; | 2146 | goto re_arm; |
2136 | } | 2147 | } |
2137 | 2148 | ||
@@ -2143,7 +2154,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond) | |||
2143 | // for each port run the state machines | 2154 | // for each port run the state machines |
2144 | for (port = __get_first_port(bond); port; port = __get_next_port(port)) { | 2155 | for (port = __get_first_port(bond); port; port = __get_next_port(port)) { |
2145 | if (!port->slave) { | 2156 | if (!port->slave) { |
2146 | printk(KERN_WARNING DRV_NAME ": Warning: Found an uninitialized port\n"); | 2157 | printk(KERN_WARNING DRV_NAME ": %s: Warning: Found an uninitialized " |
2158 | "port\n", bond->dev->name); | ||
2147 | goto re_arm; | 2159 | goto re_arm; |
2148 | } | 2160 | } |
2149 | 2161 | ||
@@ -2184,7 +2196,8 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u | |||
2184 | port = &(SLAVE_AD_INFO(slave).port); | 2196 | port = &(SLAVE_AD_INFO(slave).port); |
2185 | 2197 | ||
2186 | if (!port->slave) { | 2198 | if (!port->slave) { |
2187 | printk(KERN_WARNING DRV_NAME ": Warning: port of slave %s is uninitialized\n", slave->dev->name); | 2199 | printk(KERN_WARNING DRV_NAME ": %s: Warning: port of slave %s is " |
2200 | "uninitialized\n", slave->dev->name, slave->dev->master->name); | ||
2188 | return; | 2201 | return; |
2189 | } | 2202 | } |
2190 | 2203 | ||
@@ -2230,8 +2243,9 @@ void bond_3ad_adapter_speed_changed(struct slave *slave) | |||
2230 | 2243 | ||
2231 | // if slave is null, the whole port is not initialized | 2244 | // if slave is null, the whole port is not initialized |
2232 | if (!port->slave) { | 2245 | if (!port->slave) { |
2233 | printk(KERN_WARNING DRV_NAME ": Warning: speed changed for uninitialized port on %s\n", | 2246 | printk(KERN_WARNING DRV_NAME ": Warning: %s: speed " |
2234 | slave->dev->name); | 2247 | "changed for uninitialized port on %s\n", |
2248 | slave->dev->master->name, slave->dev->name); | ||
2235 | return; | 2249 | return; |
2236 | } | 2250 | } |
2237 | 2251 | ||
@@ -2257,8 +2271,9 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave) | |||
2257 | 2271 | ||
2258 | // if slave is null, the whole port is not initialized | 2272 | // if slave is null, the whole port is not initialized |
2259 | if (!port->slave) { | 2273 | if (!port->slave) { |
2260 | printk(KERN_WARNING DRV_NAME ": Warning: duplex changed for uninitialized port on %s\n", | 2274 | printk(KERN_WARNING DRV_NAME ": %s: Warning: duplex changed " |
2261 | slave->dev->name); | 2275 | "for uninitialized port on %s\n", |
2276 | slave->dev->master->name, slave->dev->name); | ||
2262 | return; | 2277 | return; |
2263 | } | 2278 | } |
2264 | 2279 | ||
@@ -2285,8 +2300,9 @@ void bond_3ad_handle_link_change(struct slave *slave, char link) | |||
2285 | 2300 | ||
2286 | // if slave is null, the whole port is not initialized | 2301 | // if slave is null, the whole port is not initialized |
2287 | if (!port->slave) { | 2302 | if (!port->slave) { |
2288 | printk(KERN_WARNING DRV_NAME ": Warning: link status changed for uninitialized port on %s\n", | 2303 | printk(KERN_WARNING DRV_NAME ": Warning: %s: link status changed for " |
2289 | slave->dev->name); | 2304 | "uninitialized port on %s\n", |
2305 | slave->dev->master->name, slave->dev->name); | ||
2290 | return; | 2306 | return; |
2291 | } | 2307 | } |
2292 | 2308 | ||
@@ -2363,7 +2379,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2363 | } | 2379 | } |
2364 | 2380 | ||
2365 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { | 2381 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { |
2366 | printk(KERN_DEBUG "ERROR: bond_3ad_get_active_agg_info failed\n"); | 2382 | printk(KERN_DEBUG DRV_NAME ": %s: Error: " |
2383 | "bond_3ad_get_active_agg_info failed\n", dev->name); | ||
2367 | goto out; | 2384 | goto out; |
2368 | } | 2385 | } |
2369 | 2386 | ||
@@ -2372,7 +2389,9 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2372 | 2389 | ||
2373 | if (slaves_in_agg == 0) { | 2390 | if (slaves_in_agg == 0) { |
2374 | /*the aggregator is empty*/ | 2391 | /*the aggregator is empty*/ |
2375 | printk(KERN_DEBUG "ERROR: active aggregator is empty\n"); | 2392 | printk(KERN_DEBUG DRV_NAME ": %s: Error: active " |
2393 | "aggregator is empty\n", | ||
2394 | dev->name); | ||
2376 | goto out; | 2395 | goto out; |
2377 | } | 2396 | } |
2378 | 2397 | ||
@@ -2390,7 +2409,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2390 | } | 2409 | } |
2391 | 2410 | ||
2392 | if (slave_agg_no >= 0) { | 2411 | 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); | 2412 | printk(KERN_ERR DRV_NAME ": %s: Error: Couldn't find a slave to tx on " |
2413 | "for aggregator ID %d\n", dev->name, agg_id); | ||
2394 | goto out; | 2414 | goto out; |
2395 | } | 2415 | } |
2396 | 2416 | ||
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index f8fce3961197..9bd1e104554a 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -198,20 +198,21 @@ static int tlb_initialize(struct bonding *bond) | |||
198 | { | 198 | { |
199 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 199 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); |
200 | int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); | 200 | int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); |
201 | struct tlb_client_info *new_hashtbl; | ||
201 | int i; | 202 | int i; |
202 | 203 | ||
203 | spin_lock_init(&(bond_info->tx_hashtbl_lock)); | 204 | spin_lock_init(&(bond_info->tx_hashtbl_lock)); |
204 | 205 | ||
205 | _lock_tx_hashtbl(bond); | 206 | new_hashtbl = kmalloc(size, GFP_KERNEL); |
206 | 207 | if (!new_hashtbl) { | |
207 | bond_info->tx_hashtbl = kmalloc(size, GFP_KERNEL); | ||
208 | if (!bond_info->tx_hashtbl) { | ||
209 | printk(KERN_ERR DRV_NAME | 208 | printk(KERN_ERR DRV_NAME |
210 | ": Error: %s: Failed to allocate TLB hash table\n", | 209 | ": %s: Error: Failed to allocate TLB hash table\n", |
211 | bond->dev->name); | 210 | bond->dev->name); |
212 | _unlock_tx_hashtbl(bond); | ||
213 | return -1; | 211 | return -1; |
214 | } | 212 | } |
213 | _lock_tx_hashtbl(bond); | ||
214 | |||
215 | bond_info->tx_hashtbl = new_hashtbl; | ||
215 | 216 | ||
216 | memset(bond_info->tx_hashtbl, 0, size); | 217 | memset(bond_info->tx_hashtbl, 0, size); |
217 | 218 | ||
@@ -513,7 +514,8 @@ static void rlb_update_client(struct rlb_client_info *client_info) | |||
513 | client_info->mac_dst); | 514 | client_info->mac_dst); |
514 | if (!skb) { | 515 | if (!skb) { |
515 | printk(KERN_ERR DRV_NAME | 516 | printk(KERN_ERR DRV_NAME |
516 | ": Error: failed to create an ARP packet\n"); | 517 | ": %s: Error: failed to create an ARP packet\n", |
518 | client_info->slave->dev->master->name); | ||
517 | continue; | 519 | continue; |
518 | } | 520 | } |
519 | 521 | ||
@@ -523,7 +525,8 @@ static void rlb_update_client(struct rlb_client_info *client_info) | |||
523 | skb = vlan_put_tag(skb, client_info->vlan_id); | 525 | skb = vlan_put_tag(skb, client_info->vlan_id); |
524 | if (!skb) { | 526 | if (!skb) { |
525 | printk(KERN_ERR DRV_NAME | 527 | printk(KERN_ERR DRV_NAME |
526 | ": Error: failed to insert VLAN tag\n"); | 528 | ": %s: Error: failed to insert VLAN tag\n", |
529 | client_info->slave->dev->master->name); | ||
527 | continue; | 530 | continue; |
528 | } | 531 | } |
529 | } | 532 | } |
@@ -606,8 +609,9 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip) | |||
606 | 609 | ||
607 | if (!client_info->slave) { | 610 | if (!client_info->slave) { |
608 | printk(KERN_ERR DRV_NAME | 611 | printk(KERN_ERR DRV_NAME |
609 | ": Error: found a client with no channel in " | 612 | ": %s: Error: found a client with no channel in " |
610 | "the client's hash table\n"); | 613 | "the client's hash table\n", |
614 | bond->dev->name); | ||
611 | continue; | 615 | continue; |
612 | } | 616 | } |
613 | /*update all clients using this src_ip, that are not assigned | 617 | /*update all clients using this src_ip, that are not assigned |
@@ -797,21 +801,22 @@ static int rlb_initialize(struct bonding *bond) | |||
797 | { | 801 | { |
798 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 802 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); |
799 | struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); | 803 | struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); |
804 | struct rlb_client_info *new_hashtbl; | ||
800 | int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); | 805 | int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); |
801 | int i; | 806 | int i; |
802 | 807 | ||
803 | spin_lock_init(&(bond_info->rx_hashtbl_lock)); | 808 | spin_lock_init(&(bond_info->rx_hashtbl_lock)); |
804 | 809 | ||
805 | _lock_rx_hashtbl(bond); | 810 | new_hashtbl = kmalloc(size, GFP_KERNEL); |
806 | 811 | if (!new_hashtbl) { | |
807 | bond_info->rx_hashtbl = kmalloc(size, GFP_KERNEL); | ||
808 | if (!bond_info->rx_hashtbl) { | ||
809 | printk(KERN_ERR DRV_NAME | 812 | printk(KERN_ERR DRV_NAME |
810 | ": Error: %s: Failed to allocate RLB hash table\n", | 813 | ": %s: Error: Failed to allocate RLB hash table\n", |
811 | bond->dev->name); | 814 | bond->dev->name); |
812 | _unlock_rx_hashtbl(bond); | ||
813 | return -1; | 815 | return -1; |
814 | } | 816 | } |
817 | _lock_rx_hashtbl(bond); | ||
818 | |||
819 | bond_info->rx_hashtbl = new_hashtbl; | ||
815 | 820 | ||
816 | bond_info->rx_hashtbl_head = RLB_NULL_INDEX; | 821 | bond_info->rx_hashtbl_head = RLB_NULL_INDEX; |
817 | 822 | ||
@@ -927,7 +932,8 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) | |||
927 | skb = vlan_put_tag(skb, vlan->vlan_id); | 932 | skb = vlan_put_tag(skb, vlan->vlan_id); |
928 | if (!skb) { | 933 | if (!skb) { |
929 | printk(KERN_ERR DRV_NAME | 934 | printk(KERN_ERR DRV_NAME |
930 | ": Error: failed to insert VLAN tag\n"); | 935 | ": %s: Error: failed to insert VLAN tag\n", |
936 | bond->dev->name); | ||
931 | continue; | 937 | continue; |
932 | } | 938 | } |
933 | } | 939 | } |
@@ -956,11 +962,11 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw) | |||
956 | s_addr.sa_family = dev->type; | 962 | s_addr.sa_family = dev->type; |
957 | if (dev_set_mac_address(dev, &s_addr)) { | 963 | if (dev_set_mac_address(dev, &s_addr)) { |
958 | printk(KERN_ERR DRV_NAME | 964 | printk(KERN_ERR DRV_NAME |
959 | ": Error: dev_set_mac_address of dev %s failed! ALB " | 965 | ": %s: Error: dev_set_mac_address of dev %s failed! ALB " |
960 | "mode requires that the base driver support setting " | 966 | "mode requires that the base driver support setting " |
961 | "the hw address also when the network device's " | 967 | "the hw address also when the network device's " |
962 | "interface is open\n", | 968 | "interface is open\n", |
963 | dev->name); | 969 | dev->master->name, dev->name); |
964 | return -EOPNOTSUPP; | 970 | return -EOPNOTSUPP; |
965 | } | 971 | } |
966 | return 0; | 972 | return 0; |
@@ -1153,16 +1159,16 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav | |||
1153 | bond->alb_info.rlb_enabled); | 1159 | bond->alb_info.rlb_enabled); |
1154 | 1160 | ||
1155 | printk(KERN_WARNING DRV_NAME | 1161 | printk(KERN_WARNING DRV_NAME |
1156 | ": Warning: the hw address of slave %s is in use by " | 1162 | ": %s: Warning: the hw address of slave %s is in use by " |
1157 | "the bond; giving it the hw address of %s\n", | 1163 | "the bond; giving it the hw address of %s\n", |
1158 | slave->dev->name, free_mac_slave->dev->name); | 1164 | bond->dev->name, slave->dev->name, free_mac_slave->dev->name); |
1159 | 1165 | ||
1160 | } else if (has_bond_addr) { | 1166 | } else if (has_bond_addr) { |
1161 | printk(KERN_ERR DRV_NAME | 1167 | printk(KERN_ERR DRV_NAME |
1162 | ": Error: the hw address of slave %s is in use by the " | 1168 | ": %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 " | 1169 | "bond; couldn't find a slave with a free hw address to " |
1164 | "give it (this should not have happened)\n", | 1170 | "give it (this should not have happened)\n", |
1165 | slave->dev->name); | 1171 | bond->dev->name, slave->dev->name); |
1166 | return -EFAULT; | 1172 | return -EFAULT; |
1167 | } | 1173 | } |
1168 | 1174 | ||
@@ -1250,6 +1256,8 @@ int bond_alb_initialize(struct bonding *bond, int rlb_enabled) | |||
1250 | tlb_deinitialize(bond); | 1256 | tlb_deinitialize(bond); |
1251 | return res; | 1257 | return res; |
1252 | } | 1258 | } |
1259 | } else { | ||
1260 | bond->alb_info.rlb_enabled = 0; | ||
1253 | } | 1261 | } |
1254 | 1262 | ||
1255 | return 0; | 1263 | return 0; |
@@ -1409,7 +1417,7 @@ void bond_alb_monitor(struct bonding *bond) | |||
1409 | read_lock(&bond->curr_slave_lock); | 1417 | read_lock(&bond->curr_slave_lock); |
1410 | 1418 | ||
1411 | bond_for_each_slave(bond, slave, i) { | 1419 | bond_for_each_slave(bond, slave, i) { |
1412 | alb_send_learning_packets(slave,slave->dev->dev_addr); | 1420 | alb_send_learning_packets(slave, slave->dev->dev_addr); |
1413 | } | 1421 | } |
1414 | 1422 | ||
1415 | read_unlock(&bond->curr_slave_lock); | 1423 | read_unlock(&bond->curr_slave_lock); |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 94cec3cf2a13..40ff79175c4a 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -489,6 +489,28 @@ | |||
489 | * Set version to 2.6.3. | 489 | * Set version to 2.6.3. |
490 | * 2005/09/26 - Jay Vosburgh <fubar@us.ibm.com> | 490 | * 2005/09/26 - Jay Vosburgh <fubar@us.ibm.com> |
491 | * - Removed backwards compatibility for old ifenslaves. Version 2.6.4. | 491 | * - Removed backwards compatibility for old ifenslaves. Version 2.6.4. |
492 | * 2005/09/27 - Mitch Williams <mitch.a.williams at intel dot com> | ||
493 | * - Radheka Godse <radheka.godse at intel dot com> | ||
494 | * - Split out bond creation code to allow for sysfs interface. | ||
495 | * - Removed static declaration on some functions and data items. | ||
496 | * - Added sysfs support, including capability to add/remove/change | ||
497 | * any bond at runtime. | ||
498 | * | ||
499 | * - Miscellaneous: | ||
500 | * - Added bonding: <bondname>: prefix to sysfs log messages | ||
501 | * - Added arp_ip_targets to /proc entry | ||
502 | * - Allow ARP target table to have empty entries | ||
503 | * - trivial fix: added missing modes description to modinfo | ||
504 | * - Corrected bug in ALB init where kmalloc is called inside | ||
505 | * a held lock | ||
506 | * - Corrected behavior to maintain bond link when changing | ||
507 | * from arp monitor to miimon and vice versa | ||
508 | * - Added missing bonding: <bondname>: prefix to alb, ad log messages | ||
509 | * - Fixed stack dump warnings seen if changing between miimon | ||
510 | * and arp monitoring when the bond interface is down. | ||
511 | * - Fixed stack dump warnings seen when enslaving an e100 | ||
512 | * driver | ||
513 | * - Set version to 3.0.0 | ||
492 | */ | 514 | */ |
493 | 515 | ||
494 | //#define BONDING_DEBUG 1 | 516 | //#define BONDING_DEBUG 1 |
@@ -557,6 +579,7 @@ static char *lacp_rate = NULL; | |||
557 | static char *xmit_hash_policy = NULL; | 579 | static char *xmit_hash_policy = NULL; |
558 | static int arp_interval = BOND_LINK_ARP_INTERV; | 580 | static int arp_interval = BOND_LINK_ARP_INTERV; |
559 | static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; | 581 | static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; |
582 | struct bond_params bonding_defaults; | ||
560 | 583 | ||
561 | module_param(max_bonds, int, 0); | 584 | module_param(max_bonds, int, 0); |
562 | MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); | 585 | MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); |
@@ -565,17 +588,24 @@ MODULE_PARM_DESC(miimon, "Link check interval in milliseconds"); | |||
565 | module_param(updelay, int, 0); | 588 | module_param(updelay, int, 0); |
566 | MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds"); | 589 | MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds"); |
567 | module_param(downdelay, int, 0); | 590 | module_param(downdelay, int, 0); |
568 | MODULE_PARM_DESC(downdelay, "Delay before considering link down, in milliseconds"); | 591 | MODULE_PARM_DESC(downdelay, "Delay before considering link down, " |
592 | "in milliseconds"); | ||
569 | module_param(use_carrier, int, 0); | 593 | 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)"); | 594 | MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; " |
595 | "0 for off, 1 for on (default)"); | ||
571 | module_param(mode, charp, 0); | 596 | module_param(mode, charp, 0); |
572 | MODULE_PARM_DESC(mode, "Mode of operation : 0 for round robin, 1 for active-backup, 2 for xor"); | 597 | MODULE_PARM_DESC(mode, "Mode of operation : 0 for balance-rr, " |
598 | "1 for active-backup, 2 for balance-xor, " | ||
599 | "3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, " | ||
600 | "6 for balance-alb"); | ||
573 | module_param(primary, charp, 0); | 601 | module_param(primary, charp, 0); |
574 | MODULE_PARM_DESC(primary, "Primary network device to use"); | 602 | MODULE_PARM_DESC(primary, "Primary network device to use"); |
575 | module_param(lacp_rate, charp, 0); | 603 | module_param(lacp_rate, charp, 0); |
576 | MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)"); | 604 | MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner " |
605 | "(slow/fast)"); | ||
577 | module_param(xmit_hash_policy, charp, 0); | 606 | 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"); | 607 | MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method: 0 for layer 2 (default)" |
608 | ", 1 for layer 3+4"); | ||
579 | module_param(arp_interval, int, 0); | 609 | module_param(arp_interval, int, 0); |
580 | MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); | 610 | MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); |
581 | module_param_array(arp_ip_target, charp, NULL, 0); | 611 | module_param_array(arp_ip_target, charp, NULL, 0); |
@@ -586,30 +616,27 @@ MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form"); | |||
586 | static const char *version = | 616 | static const char *version = |
587 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; | 617 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; |
588 | 618 | ||
589 | static LIST_HEAD(bond_dev_list); | 619 | LIST_HEAD(bond_dev_list); |
590 | 620 | ||
591 | #ifdef CONFIG_PROC_FS | 621 | #ifdef CONFIG_PROC_FS |
592 | static struct proc_dir_entry *bond_proc_dir = NULL; | 622 | static struct proc_dir_entry *bond_proc_dir = NULL; |
593 | #endif | 623 | #endif |
594 | 624 | ||
625 | extern struct rw_semaphore bonding_rwsem; | ||
595 | static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; | 626 | static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; |
596 | static int arp_ip_count = 0; | 627 | static int arp_ip_count = 0; |
597 | static int bond_mode = BOND_MODE_ROUNDROBIN; | 628 | static int bond_mode = BOND_MODE_ROUNDROBIN; |
598 | static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; | 629 | static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; |
599 | static int lacp_fast = 0; | 630 | static int lacp_fast = 0; |
600 | 631 | ||
601 | struct bond_parm_tbl { | ||
602 | char *modename; | ||
603 | int mode; | ||
604 | }; | ||
605 | 632 | ||
606 | static struct bond_parm_tbl bond_lacp_tbl[] = { | 633 | struct bond_parm_tbl bond_lacp_tbl[] = { |
607 | { "slow", AD_LACP_SLOW}, | 634 | { "slow", AD_LACP_SLOW}, |
608 | { "fast", AD_LACP_FAST}, | 635 | { "fast", AD_LACP_FAST}, |
609 | { NULL, -1}, | 636 | { NULL, -1}, |
610 | }; | 637 | }; |
611 | 638 | ||
612 | static struct bond_parm_tbl bond_mode_tbl[] = { | 639 | struct bond_parm_tbl bond_mode_tbl[] = { |
613 | { "balance-rr", BOND_MODE_ROUNDROBIN}, | 640 | { "balance-rr", BOND_MODE_ROUNDROBIN}, |
614 | { "active-backup", BOND_MODE_ACTIVEBACKUP}, | 641 | { "active-backup", BOND_MODE_ACTIVEBACKUP}, |
615 | { "balance-xor", BOND_MODE_XOR}, | 642 | { "balance-xor", BOND_MODE_XOR}, |
@@ -620,7 +647,7 @@ static struct bond_parm_tbl bond_mode_tbl[] = { | |||
620 | { NULL, -1}, | 647 | { NULL, -1}, |
621 | }; | 648 | }; |
622 | 649 | ||
623 | static struct bond_parm_tbl xmit_hashtype_tbl[] = { | 650 | struct bond_parm_tbl xmit_hashtype_tbl[] = { |
624 | { "layer2", BOND_XMIT_POLICY_LAYER2}, | 651 | { "layer2", BOND_XMIT_POLICY_LAYER2}, |
625 | { "layer3+4", BOND_XMIT_POLICY_LAYER34}, | 652 | { "layer3+4", BOND_XMIT_POLICY_LAYER34}, |
626 | { NULL, -1}, | 653 | { NULL, -1}, |
@@ -628,12 +655,11 @@ static struct bond_parm_tbl xmit_hashtype_tbl[] = { | |||
628 | 655 | ||
629 | /*-------------------------- Forward declarations ---------------------------*/ | 656 | /*-------------------------- Forward declarations ---------------------------*/ |
630 | 657 | ||
631 | static inline void bond_set_mode_ops(struct bonding *bond, int mode); | ||
632 | static void bond_send_gratuitous_arp(struct bonding *bond); | 658 | static void bond_send_gratuitous_arp(struct bonding *bond); |
633 | 659 | ||
634 | /*---------------------------- General routines -----------------------------*/ | 660 | /*---------------------------- General routines -----------------------------*/ |
635 | 661 | ||
636 | static const char *bond_mode_name(int mode) | 662 | const char *bond_mode_name(int mode) |
637 | { | 663 | { |
638 | switch (mode) { | 664 | switch (mode) { |
639 | case BOND_MODE_ROUNDROBIN : | 665 | case BOND_MODE_ROUNDROBIN : |
@@ -910,7 +936,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid) | |||
910 | res = bond_add_vlan(bond, vid); | 936 | res = bond_add_vlan(bond, vid); |
911 | if (res) { | 937 | if (res) { |
912 | printk(KERN_ERR DRV_NAME | 938 | printk(KERN_ERR DRV_NAME |
913 | ": %s: Failed to add vlan id %d\n", | 939 | ": %s: Error: Failed to add vlan id %d\n", |
914 | bond_dev->name, vid); | 940 | bond_dev->name, vid); |
915 | } | 941 | } |
916 | } | 942 | } |
@@ -944,7 +970,7 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid) | |||
944 | res = bond_del_vlan(bond, vid); | 970 | res = bond_del_vlan(bond, vid); |
945 | if (res) { | 971 | if (res) { |
946 | printk(KERN_ERR DRV_NAME | 972 | printk(KERN_ERR DRV_NAME |
947 | ": %s: Failed to remove vlan id %d\n", | 973 | ": %s: Error: Failed to remove vlan id %d\n", |
948 | bond_dev->name, vid); | 974 | bond_dev->name, vid); |
949 | } | 975 | } |
950 | } | 976 | } |
@@ -1449,7 +1475,7 @@ static struct slave *bond_find_best_slave(struct bonding *bond) | |||
1449 | * | 1475 | * |
1450 | * Warning: Caller must hold curr_slave_lock for writing. | 1476 | * Warning: Caller must hold curr_slave_lock for writing. |
1451 | */ | 1477 | */ |
1452 | static void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | 1478 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active) |
1453 | { | 1479 | { |
1454 | struct slave *old_active = bond->curr_active_slave; | 1480 | struct slave *old_active = bond->curr_active_slave; |
1455 | 1481 | ||
@@ -1523,7 +1549,7 @@ static void bond_change_active_slave(struct bonding *bond, struct slave *new_act | |||
1523 | * | 1549 | * |
1524 | * Warning: Caller must hold curr_slave_lock for writing. | 1550 | * Warning: Caller must hold curr_slave_lock for writing. |
1525 | */ | 1551 | */ |
1526 | static void bond_select_active_slave(struct bonding *bond) | 1552 | void bond_select_active_slave(struct bonding *bond) |
1527 | { | 1553 | { |
1528 | struct slave *best_slave; | 1554 | struct slave *best_slave; |
1529 | 1555 | ||
@@ -1591,7 +1617,7 @@ static void bond_detach_slave(struct bonding *bond, struct slave *slave) | |||
1591 | 1617 | ||
1592 | /*---------------------------------- IOCTL ----------------------------------*/ | 1618 | /*---------------------------------- IOCTL ----------------------------------*/ |
1593 | 1619 | ||
1594 | static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) | 1620 | int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) |
1595 | { | 1621 | { |
1596 | dprintk("bond_dev=%p\n", bond_dev); | 1622 | dprintk("bond_dev=%p\n", bond_dev); |
1597 | dprintk("slave_dev=%p\n", slave_dev); | 1623 | dprintk("slave_dev=%p\n", slave_dev); |
@@ -1631,7 +1657,7 @@ static int bond_compute_features(struct bonding *bond) | |||
1631 | } | 1657 | } |
1632 | 1658 | ||
1633 | /* enslave device <slave> to bond device <master> */ | 1659 | /* enslave device <slave> to bond device <master> */ |
1634 | static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | 1660 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) |
1635 | { | 1661 | { |
1636 | struct bonding *bond = bond_dev->priv; | 1662 | struct bonding *bond = bond_dev->priv; |
1637 | struct slave *new_slave = NULL; | 1663 | struct slave *new_slave = NULL; |
@@ -1644,8 +1670,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 && | 1670 | if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL && |
1645 | slave_dev->do_ioctl == NULL) { | 1671 | slave_dev->do_ioctl == NULL) { |
1646 | printk(KERN_WARNING DRV_NAME | 1672 | printk(KERN_WARNING DRV_NAME |
1647 | ": Warning : no link monitoring support for %s\n", | 1673 | ": %s: Warning: no link monitoring support for %s\n", |
1648 | slave_dev->name); | 1674 | bond_dev->name, slave_dev->name); |
1649 | } | 1675 | } |
1650 | 1676 | ||
1651 | /* bond must be initialized by bond_open() before enslaving */ | 1677 | /* bond must be initialized by bond_open() before enslaving */ |
@@ -1666,17 +1692,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); | 1692 | dprintk("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); |
1667 | if (!list_empty(&bond->vlan_list)) { | 1693 | if (!list_empty(&bond->vlan_list)) { |
1668 | printk(KERN_ERR DRV_NAME | 1694 | printk(KERN_ERR DRV_NAME |
1669 | ": Error: cannot enslave VLAN " | 1695 | ": %s: Error: cannot enslave VLAN " |
1670 | "challenged slave %s on VLAN enabled " | 1696 | "challenged slave %s on VLAN enabled " |
1671 | "bond %s\n", slave_dev->name, | 1697 | "bond %s\n", bond_dev->name, slave_dev->name, |
1672 | bond_dev->name); | 1698 | bond_dev->name); |
1673 | return -EPERM; | 1699 | return -EPERM; |
1674 | } else { | 1700 | } else { |
1675 | printk(KERN_WARNING DRV_NAME | 1701 | printk(KERN_WARNING DRV_NAME |
1676 | ": Warning: enslaved VLAN challenged " | 1702 | ": %s: Warning: enslaved VLAN challenged " |
1677 | "slave %s. Adding VLANs will be blocked as " | 1703 | "slave %s. Adding VLANs will be blocked as " |
1678 | "long as %s is part of bond %s\n", | 1704 | "long as %s is part of bond %s\n", |
1679 | slave_dev->name, slave_dev->name, | 1705 | bond_dev->name, slave_dev->name, slave_dev->name, |
1680 | bond_dev->name); | 1706 | bond_dev->name); |
1681 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; | 1707 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; |
1682 | } | 1708 | } |
@@ -1706,12 +1732,11 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1706 | 1732 | ||
1707 | if (slave_dev->set_mac_address == NULL) { | 1733 | if (slave_dev->set_mac_address == NULL) { |
1708 | printk(KERN_ERR DRV_NAME | 1734 | printk(KERN_ERR DRV_NAME |
1709 | ": Error: The slave device you specified does " | 1735 | ": %s: Error: The slave device you specified does " |
1710 | "not support setting the MAC address.\n"); | 1736 | "not support setting the MAC address. " |
1711 | printk(KERN_ERR | 1737 | "Your kernel likely does not support slave " |
1712 | "Your kernel likely does not support slave devices.\n"); | 1738 | "devices.\n", bond_dev->name); |
1713 | 1739 | res = -EOPNOTSUPP; | |
1714 | res = -EOPNOTSUPP; | ||
1715 | goto err_undo_flags; | 1740 | goto err_undo_flags; |
1716 | } | 1741 | } |
1717 | 1742 | ||
@@ -1827,21 +1852,21 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1827 | * the messages for netif_carrier. | 1852 | * the messages for netif_carrier. |
1828 | */ | 1853 | */ |
1829 | printk(KERN_WARNING DRV_NAME | 1854 | printk(KERN_WARNING DRV_NAME |
1830 | ": Warning: MII and ETHTOOL support not " | 1855 | ": %s: Warning: MII and ETHTOOL support not " |
1831 | "available for interface %s, and " | 1856 | "available for interface %s, and " |
1832 | "arp_interval/arp_ip_target module parameters " | 1857 | "arp_interval/arp_ip_target module parameters " |
1833 | "not specified, thus bonding will not detect " | 1858 | "not specified, thus bonding will not detect " |
1834 | "link failures! see bonding.txt for details.\n", | 1859 | "link failures! see bonding.txt for details.\n", |
1835 | slave_dev->name); | 1860 | bond_dev->name, slave_dev->name); |
1836 | } else if (link_reporting == -1) { | 1861 | } else if (link_reporting == -1) { |
1837 | /* unable get link status using mii/ethtool */ | 1862 | /* unable get link status using mii/ethtool */ |
1838 | printk(KERN_WARNING DRV_NAME | 1863 | printk(KERN_WARNING DRV_NAME |
1839 | ": Warning: can't get link status from " | 1864 | ": %s: Warning: can't get link status from " |
1840 | "interface %s; the network driver associated " | 1865 | "interface %s; the network driver associated " |
1841 | "with this interface does not support MII or " | 1866 | "with this interface does not support MII or " |
1842 | "ETHTOOL link status reporting, thus miimon " | 1867 | "ETHTOOL link status reporting, thus miimon " |
1843 | "has no effect on this interface.\n", | 1868 | "has no effect on this interface.\n", |
1844 | slave_dev->name); | 1869 | bond_dev->name, slave_dev->name); |
1845 | } | 1870 | } |
1846 | } | 1871 | } |
1847 | 1872 | ||
@@ -1868,15 +1893,15 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1868 | if (bond_update_speed_duplex(new_slave) && | 1893 | if (bond_update_speed_duplex(new_slave) && |
1869 | (new_slave->link != BOND_LINK_DOWN)) { | 1894 | (new_slave->link != BOND_LINK_DOWN)) { |
1870 | printk(KERN_WARNING DRV_NAME | 1895 | printk(KERN_WARNING DRV_NAME |
1871 | ": Warning: failed to get speed and duplex from %s, " | 1896 | ": %s: Warning: failed to get speed and duplex from %s, " |
1872 | "assumed to be 100Mb/sec and Full.\n", | 1897 | "assumed to be 100Mb/sec and Full.\n", |
1873 | new_slave->dev->name); | 1898 | bond_dev->name, new_slave->dev->name); |
1874 | 1899 | ||
1875 | if (bond->params.mode == BOND_MODE_8023AD) { | 1900 | if (bond->params.mode == BOND_MODE_8023AD) { |
1876 | printk(KERN_WARNING | 1901 | printk(KERN_WARNING DRV_NAME |
1877 | "Operation of 802.3ad mode requires ETHTOOL " | 1902 | ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL " |
1878 | "support in base driver for proper aggregator " | 1903 | "support in base driver for proper aggregator " |
1879 | "selection.\n"); | 1904 | "selection.\n", bond_dev->name); |
1880 | } | 1905 | } |
1881 | } | 1906 | } |
1882 | 1907 | ||
@@ -1958,6 +1983,10 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de | |||
1958 | 1983 | ||
1959 | write_unlock_bh(&bond->lock); | 1984 | write_unlock_bh(&bond->lock); |
1960 | 1985 | ||
1986 | res = bond_create_slave_symlinks(bond_dev, slave_dev); | ||
1987 | if (res) | ||
1988 | goto err_unset_master; | ||
1989 | |||
1961 | printk(KERN_INFO DRV_NAME | 1990 | printk(KERN_INFO DRV_NAME |
1962 | ": %s: enslaving %s as a%s interface with a%s link.\n", | 1991 | ": %s: enslaving %s as a%s interface with a%s link.\n", |
1963 | bond_dev->name, slave_dev->name, | 1992 | bond_dev->name, slave_dev->name, |
@@ -1999,7 +2028,7 @@ err_undo_flags: | |||
1999 | * for Bonded connections: | 2028 | * for Bonded connections: |
2000 | * The first up interface should be left on and all others downed. | 2029 | * The first up interface should be left on and all others downed. |
2001 | */ | 2030 | */ |
2002 | static int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | 2031 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) |
2003 | { | 2032 | { |
2004 | struct bonding *bond = bond_dev->priv; | 2033 | struct bonding *bond = bond_dev->priv; |
2005 | struct slave *slave, *oldcurrent; | 2034 | struct slave *slave, *oldcurrent; |
@@ -2010,7 +2039,7 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de | |||
2010 | if (!(slave_dev->flags & IFF_SLAVE) || | 2039 | if (!(slave_dev->flags & IFF_SLAVE) || |
2011 | (slave_dev->master != bond_dev)) { | 2040 | (slave_dev->master != bond_dev)) { |
2012 | printk(KERN_ERR DRV_NAME | 2041 | printk(KERN_ERR DRV_NAME |
2013 | ": Error: %s: cannot release %s.\n", | 2042 | ": %s: Error: cannot release %s.\n", |
2014 | bond_dev->name, slave_dev->name); | 2043 | bond_dev->name, slave_dev->name); |
2015 | return -EINVAL; | 2044 | return -EINVAL; |
2016 | } | 2045 | } |
@@ -2031,11 +2060,12 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de | |||
2031 | ETH_ALEN); | 2060 | ETH_ALEN); |
2032 | if (!mac_addr_differ && (bond->slave_cnt > 1)) { | 2061 | if (!mac_addr_differ && (bond->slave_cnt > 1)) { |
2033 | printk(KERN_WARNING DRV_NAME | 2062 | printk(KERN_WARNING DRV_NAME |
2034 | ": Warning: the permanent HWaddr of %s " | 2063 | ": %s: Warning: the permanent HWaddr of %s " |
2035 | "- %02X:%02X:%02X:%02X:%02X:%02X - is " | 2064 | "- %02X:%02X:%02X:%02X:%02X:%02X - is " |
2036 | "still in use by %s. Set the HWaddr of " | 2065 | "still in use by %s. Set the HWaddr of " |
2037 | "%s to a different address to avoid " | 2066 | "%s to a different address to avoid " |
2038 | "conflicts.\n", | 2067 | "conflicts.\n", |
2068 | bond_dev->name, | ||
2039 | slave_dev->name, | 2069 | slave_dev->name, |
2040 | slave->perm_hwaddr[0], | 2070 | slave->perm_hwaddr[0], |
2041 | slave->perm_hwaddr[1], | 2071 | slave->perm_hwaddr[1], |
@@ -2111,24 +2141,28 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de | |||
2111 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; | 2141 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; |
2112 | } else { | 2142 | } else { |
2113 | printk(KERN_WARNING DRV_NAME | 2143 | printk(KERN_WARNING DRV_NAME |
2114 | ": Warning: clearing HW address of %s while it " | 2144 | ": %s: Warning: clearing HW address of %s while it " |
2115 | "still has VLANs.\n", | 2145 | "still has VLANs.\n", |
2116 | bond_dev->name); | 2146 | bond_dev->name, bond_dev->name); |
2117 | printk(KERN_WARNING DRV_NAME | 2147 | printk(KERN_WARNING DRV_NAME |
2118 | ": When re-adding slaves, make sure the bond's " | 2148 | ": %s: When re-adding slaves, make sure the bond's " |
2119 | "HW address matches its VLANs'.\n"); | 2149 | "HW address matches its VLANs'.\n", |
2150 | bond_dev->name); | ||
2120 | } | 2151 | } |
2121 | } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && | 2152 | } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && |
2122 | !bond_has_challenged_slaves(bond)) { | 2153 | !bond_has_challenged_slaves(bond)) { |
2123 | printk(KERN_INFO DRV_NAME | 2154 | printk(KERN_INFO DRV_NAME |
2124 | ": last VLAN challenged slave %s " | 2155 | ": %s: last VLAN challenged slave %s " |
2125 | "left bond %s. VLAN blocking is removed\n", | 2156 | "left bond %s. VLAN blocking is removed\n", |
2126 | slave_dev->name, bond_dev->name); | 2157 | bond_dev->name, slave_dev->name, bond_dev->name); |
2127 | bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED; | 2158 | bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED; |
2128 | } | 2159 | } |
2129 | 2160 | ||
2130 | write_unlock_bh(&bond->lock); | 2161 | write_unlock_bh(&bond->lock); |
2131 | 2162 | ||
2163 | /* must do this from outside any spinlocks */ | ||
2164 | bond_destroy_slave_symlinks(bond_dev, slave_dev); | ||
2165 | |||
2132 | bond_del_vlans_from_slave(bond, slave_dev); | 2166 | bond_del_vlans_from_slave(bond, slave_dev); |
2133 | 2167 | ||
2134 | /* If the mode USES_PRIMARY, then we should only remove its | 2168 | /* If the mode USES_PRIMARY, then we should only remove its |
@@ -2220,6 +2254,7 @@ static int bond_release_all(struct net_device *bond_dev) | |||
2220 | */ | 2254 | */ |
2221 | write_unlock_bh(&bond->lock); | 2255 | write_unlock_bh(&bond->lock); |
2222 | 2256 | ||
2257 | bond_destroy_slave_symlinks(bond_dev, slave_dev); | ||
2223 | bond_del_vlans_from_slave(bond, slave_dev); | 2258 | bond_del_vlans_from_slave(bond, slave_dev); |
2224 | 2259 | ||
2225 | /* If the mode USES_PRIMARY, then we should only remove its | 2260 | /* If the mode USES_PRIMARY, then we should only remove its |
@@ -2274,12 +2309,13 @@ static int bond_release_all(struct net_device *bond_dev) | |||
2274 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; | 2309 | bond_dev->features |= NETIF_F_VLAN_CHALLENGED; |
2275 | } else { | 2310 | } else { |
2276 | printk(KERN_WARNING DRV_NAME | 2311 | printk(KERN_WARNING DRV_NAME |
2277 | ": Warning: clearing HW address of %s while it " | 2312 | ": %s: Warning: clearing HW address of %s while it " |
2278 | "still has VLANs.\n", | 2313 | "still has VLANs.\n", |
2279 | bond_dev->name); | 2314 | bond_dev->name, bond_dev->name); |
2280 | printk(KERN_WARNING DRV_NAME | 2315 | printk(KERN_WARNING DRV_NAME |
2281 | ": When re-adding slaves, make sure the bond's " | 2316 | ": %s: When re-adding slaves, make sure the bond's " |
2282 | "HW address matches its VLANs'.\n"); | 2317 | "HW address matches its VLANs'.\n", |
2318 | bond_dev->name); | ||
2283 | } | 2319 | } |
2284 | 2320 | ||
2285 | printk(KERN_INFO DRV_NAME | 2321 | printk(KERN_INFO DRV_NAME |
@@ -2397,7 +2433,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in | |||
2397 | /*-------------------------------- Monitoring -------------------------------*/ | 2433 | /*-------------------------------- Monitoring -------------------------------*/ |
2398 | 2434 | ||
2399 | /* this function is called regularly to monitor each slave's link. */ | 2435 | /* this function is called regularly to monitor each slave's link. */ |
2400 | static void bond_mii_monitor(struct net_device *bond_dev) | 2436 | void bond_mii_monitor(struct net_device *bond_dev) |
2401 | { | 2437 | { |
2402 | struct bonding *bond = bond_dev->priv; | 2438 | struct bonding *bond = bond_dev->priv; |
2403 | struct slave *slave, *oldcurrent; | 2439 | struct slave *slave, *oldcurrent; |
@@ -2596,8 +2632,11 @@ static void bond_mii_monitor(struct net_device *bond_dev) | |||
2596 | break; | 2632 | break; |
2597 | default: | 2633 | default: |
2598 | /* Should not happen */ | 2634 | /* Should not happen */ |
2599 | printk(KERN_ERR "bonding: Error: %s Illegal value (link=%d)\n", | 2635 | printk(KERN_ERR DRV_NAME |
2600 | slave->dev->name, slave->link); | 2636 | ": %s: Error: %s Illegal value (link=%d)\n", |
2637 | bond_dev->name, | ||
2638 | slave->dev->name, | ||
2639 | slave->link); | ||
2601 | goto out; | 2640 | goto out; |
2602 | } /* end of switch (slave->link) */ | 2641 | } /* end of switch (slave->link) */ |
2603 | 2642 | ||
@@ -2721,7 +2760,9 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave) | |||
2721 | struct flowi fl; | 2760 | struct flowi fl; |
2722 | struct rtable *rt; | 2761 | struct rtable *rt; |
2723 | 2762 | ||
2724 | for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) { | 2763 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { |
2764 | if (!targets[i]) | ||
2765 | continue; | ||
2725 | dprintk("basa: target %x\n", targets[i]); | 2766 | dprintk("basa: target %x\n", targets[i]); |
2726 | if (list_empty(&bond->vlan_list)) { | 2767 | if (list_empty(&bond->vlan_list)) { |
2727 | dprintk("basa: empty vlan: arp_send\n"); | 2768 | dprintk("basa: empty vlan: arp_send\n"); |
@@ -2825,7 +2866,7 @@ static void bond_send_gratuitous_arp(struct bonding *bond) | |||
2825 | * arp is transmitted to generate traffic. see activebackup_arp_monitor for | 2866 | * arp is transmitted to generate traffic. see activebackup_arp_monitor for |
2826 | * arp monitoring in active backup mode. | 2867 | * arp monitoring in active backup mode. |
2827 | */ | 2868 | */ |
2828 | static void bond_loadbalance_arp_mon(struct net_device *bond_dev) | 2869 | void bond_loadbalance_arp_mon(struct net_device *bond_dev) |
2829 | { | 2870 | { |
2830 | struct bonding *bond = bond_dev->priv; | 2871 | struct bonding *bond = bond_dev->priv; |
2831 | struct slave *slave, *oldcurrent; | 2872 | struct slave *slave, *oldcurrent; |
@@ -2963,7 +3004,7 @@ out: | |||
2963 | * may have received. | 3004 | * may have received. |
2964 | * see loadbalance_arp_monitor for arp monitoring in load balancing mode | 3005 | * see loadbalance_arp_monitor for arp monitoring in load balancing mode |
2965 | */ | 3006 | */ |
2966 | static void bond_activebackup_arp_mon(struct net_device *bond_dev) | 3007 | void bond_activebackup_arp_mon(struct net_device *bond_dev) |
2967 | { | 3008 | { |
2968 | struct bonding *bond = bond_dev->priv; | 3009 | struct bonding *bond = bond_dev->priv; |
2969 | struct slave *slave; | 3010 | struct slave *slave; |
@@ -3249,6 +3290,8 @@ static void bond_info_show_master(struct seq_file *seq) | |||
3249 | { | 3290 | { |
3250 | struct bonding *bond = seq->private; | 3291 | struct bonding *bond = seq->private; |
3251 | struct slave *curr; | 3292 | struct slave *curr; |
3293 | int i; | ||
3294 | u32 target; | ||
3252 | 3295 | ||
3253 | read_lock(&bond->curr_slave_lock); | 3296 | read_lock(&bond->curr_slave_lock); |
3254 | curr = bond->curr_active_slave; | 3297 | curr = bond->curr_active_slave; |
@@ -3257,10 +3300,17 @@ static void bond_info_show_master(struct seq_file *seq) | |||
3257 | seq_printf(seq, "Bonding Mode: %s\n", | 3300 | seq_printf(seq, "Bonding Mode: %s\n", |
3258 | bond_mode_name(bond->params.mode)); | 3301 | bond_mode_name(bond->params.mode)); |
3259 | 3302 | ||
3303 | if (bond->params.mode == BOND_MODE_XOR || | ||
3304 | bond->params.mode == BOND_MODE_8023AD) { | ||
3305 | seq_printf(seq, "Transmit Hash Policy: %s (%d)\n", | ||
3306 | xmit_hashtype_tbl[bond->params.xmit_policy].modename, | ||
3307 | bond->params.xmit_policy); | ||
3308 | } | ||
3309 | |||
3260 | if (USES_PRIMARY(bond->params.mode)) { | 3310 | if (USES_PRIMARY(bond->params.mode)) { |
3261 | seq_printf(seq, "Primary Slave: %s\n", | 3311 | seq_printf(seq, "Primary Slave: %s\n", |
3262 | (bond->params.primary[0]) ? | 3312 | (bond->primary_slave) ? |
3263 | bond->params.primary : "None"); | 3313 | bond->primary_slave->dev->name : "None"); |
3264 | 3314 | ||
3265 | seq_printf(seq, "Currently Active Slave: %s\n", | 3315 | seq_printf(seq, "Currently Active Slave: %s\n", |
3266 | (curr) ? curr->dev->name : "None"); | 3316 | (curr) ? curr->dev->name : "None"); |
@@ -3273,6 +3323,27 @@ static void bond_info_show_master(struct seq_file *seq) | |||
3273 | seq_printf(seq, "Down Delay (ms): %d\n", | 3323 | seq_printf(seq, "Down Delay (ms): %d\n", |
3274 | bond->params.downdelay * bond->params.miimon); | 3324 | bond->params.downdelay * bond->params.miimon); |
3275 | 3325 | ||
3326 | |||
3327 | /* ARP information */ | ||
3328 | if(bond->params.arp_interval > 0) { | ||
3329 | int printed=0; | ||
3330 | seq_printf(seq, "ARP Polling Interval (ms): %d\n", | ||
3331 | bond->params.arp_interval); | ||
3332 | |||
3333 | seq_printf(seq, "ARP IP target/s (n.n.n.n form):"); | ||
3334 | |||
3335 | for(i = 0; (i < BOND_MAX_ARP_TARGETS) ;i++) { | ||
3336 | if (!bond->params.arp_targets[i]) | ||
3337 | continue; | ||
3338 | if (printed) | ||
3339 | seq_printf(seq, ","); | ||
3340 | target = ntohl(bond->params.arp_targets[i]); | ||
3341 | seq_printf(seq, " %d.%d.%d.%d", HIPQUAD(target)); | ||
3342 | printed = 1; | ||
3343 | } | ||
3344 | seq_printf(seq, "\n"); | ||
3345 | } | ||
3346 | |||
3276 | if (bond->params.mode == BOND_MODE_8023AD) { | 3347 | if (bond->params.mode == BOND_MODE_8023AD) { |
3277 | struct ad_info ad_info; | 3348 | struct ad_info ad_info; |
3278 | 3349 | ||
@@ -3478,7 +3549,10 @@ static int bond_event_changename(struct bonding *bond) | |||
3478 | bond_remove_proc_entry(bond); | 3549 | bond_remove_proc_entry(bond); |
3479 | bond_create_proc_entry(bond); | 3550 | bond_create_proc_entry(bond); |
3480 | #endif | 3551 | #endif |
3481 | 3552 | down_write(&(bonding_rwsem)); | |
3553 | bond_destroy_sysfs_entry(bond); | ||
3554 | bond_create_sysfs_entry(bond); | ||
3555 | up_write(&(bonding_rwsem)); | ||
3482 | return NOTIFY_DONE; | 3556 | return NOTIFY_DONE; |
3483 | } | 3557 | } |
3484 | 3558 | ||
@@ -3955,6 +4029,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3955 | return -EPERM; | 4029 | return -EPERM; |
3956 | } | 4030 | } |
3957 | 4031 | ||
4032 | down_write(&(bonding_rwsem)); | ||
3958 | slave_dev = dev_get_by_name(ifr->ifr_slave); | 4033 | slave_dev = dev_get_by_name(ifr->ifr_slave); |
3959 | 4034 | ||
3960 | dprintk("slave_dev=%p: \n", slave_dev); | 4035 | dprintk("slave_dev=%p: \n", slave_dev); |
@@ -3987,6 +4062,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3987 | dev_put(slave_dev); | 4062 | dev_put(slave_dev); |
3988 | } | 4063 | } |
3989 | 4064 | ||
4065 | up_write(&(bonding_rwsem)); | ||
3990 | return res; | 4066 | return res; |
3991 | } | 4067 | } |
3992 | 4068 | ||
@@ -4071,6 +4147,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) | |||
4071 | bond_for_each_slave(bond, slave, i) { | 4147 | bond_for_each_slave(bond, slave, i) { |
4072 | dprintk("s %p s->p %p c_m %p\n", slave, | 4148 | dprintk("s %p s->p %p c_m %p\n", slave, |
4073 | slave->prev, slave->dev->change_mtu); | 4149 | slave->prev, slave->dev->change_mtu); |
4150 | |||
4074 | res = dev_set_mtu(slave->dev, new_mtu); | 4151 | res = dev_set_mtu(slave->dev, new_mtu); |
4075 | 4152 | ||
4076 | if (res) { | 4153 | if (res) { |
@@ -4397,8 +4474,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); | 4474 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); |
4398 | if (!skb2) { | 4475 | if (!skb2) { |
4399 | printk(KERN_ERR DRV_NAME | 4476 | printk(KERN_ERR DRV_NAME |
4400 | ": Error: bond_xmit_broadcast(): " | 4477 | ": %s: Error: bond_xmit_broadcast(): " |
4401 | "skb_clone() failed\n"); | 4478 | "skb_clone() failed\n", |
4479 | bond_dev->name); | ||
4402 | continue; | 4480 | continue; |
4403 | } | 4481 | } |
4404 | 4482 | ||
@@ -4431,7 +4509,7 @@ out: | |||
4431 | /* | 4509 | /* |
4432 | * set bond mode specific net device operations | 4510 | * set bond mode specific net device operations |
4433 | */ | 4511 | */ |
4434 | static inline void bond_set_mode_ops(struct bonding *bond, int mode) | 4512 | void bond_set_mode_ops(struct bonding *bond, int mode) |
4435 | { | 4513 | { |
4436 | struct net_device *bond_dev = bond->dev; | 4514 | struct net_device *bond_dev = bond->dev; |
4437 | 4515 | ||
@@ -4467,7 +4545,8 @@ static inline void bond_set_mode_ops(struct bonding *bond, int mode) | |||
4467 | default: | 4545 | default: |
4468 | /* Should never happen, mode already checked */ | 4546 | /* Should never happen, mode already checked */ |
4469 | printk(KERN_ERR DRV_NAME | 4547 | printk(KERN_ERR DRV_NAME |
4470 | ": Error: Unknown bonding mode %d\n", | 4548 | ": %s: Error: Unknown bonding mode %d\n", |
4549 | bond_dev->name, | ||
4471 | mode); | 4550 | mode); |
4472 | break; | 4551 | break; |
4473 | } | 4552 | } |
@@ -4491,7 +4570,7 @@ static struct ethtool_ops bond_ethtool_ops = { | |||
4491 | * Does not allocate but creates a /proc entry. | 4570 | * Does not allocate but creates a /proc entry. |
4492 | * Allowed to fail. | 4571 | * Allowed to fail. |
4493 | */ | 4572 | */ |
4494 | static int __init bond_init(struct net_device *bond_dev, struct bond_params *params) | 4573 | static int bond_init(struct net_device *bond_dev, struct bond_params *params) |
4495 | { | 4574 | { |
4496 | struct bonding *bond = bond_dev->priv; | 4575 | struct bonding *bond = bond_dev->priv; |
4497 | 4576 | ||
@@ -4565,7 +4644,7 @@ static int __init bond_init(struct net_device *bond_dev, struct bond_params *par | |||
4565 | /* De-initialize device specific data. | 4644 | /* De-initialize device specific data. |
4566 | * Caller must hold rtnl_lock. | 4645 | * Caller must hold rtnl_lock. |
4567 | */ | 4646 | */ |
4568 | static inline void bond_deinit(struct net_device *bond_dev) | 4647 | void bond_deinit(struct net_device *bond_dev) |
4569 | { | 4648 | { |
4570 | struct bonding *bond = bond_dev->priv; | 4649 | struct bonding *bond = bond_dev->priv; |
4571 | 4650 | ||
@@ -4601,7 +4680,7 @@ static void bond_free_all(void) | |||
4601 | * Convert string input module parms. Accept either the | 4680 | * Convert string input module parms. Accept either the |
4602 | * number of the mode or its string name. | 4681 | * number of the mode or its string name. |
4603 | */ | 4682 | */ |
4604 | static inline int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) | 4683 | int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) |
4605 | { | 4684 | { |
4606 | int i; | 4685 | int i; |
4607 | 4686 | ||
@@ -4670,7 +4749,7 @@ static int bond_check_params(struct bond_params *params) | |||
4670 | if (max_bonds < 1 || max_bonds > INT_MAX) { | 4749 | if (max_bonds < 1 || max_bonds > INT_MAX) { |
4671 | printk(KERN_WARNING DRV_NAME | 4750 | printk(KERN_WARNING DRV_NAME |
4672 | ": Warning: max_bonds (%d) not in range %d-%d, so it " | 4751 | ": Warning: max_bonds (%d) not in range %d-%d, so it " |
4673 | "was reset to BOND_DEFAULT_MAX_BONDS (%d)", | 4752 | "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n", |
4674 | max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS); | 4753 | max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS); |
4675 | max_bonds = BOND_DEFAULT_MAX_BONDS; | 4754 | max_bonds = BOND_DEFAULT_MAX_BONDS; |
4676 | } | 4755 | } |
@@ -4881,81 +4960,96 @@ static int bond_check_params(struct bond_params *params) | |||
4881 | return 0; | 4960 | return 0; |
4882 | } | 4961 | } |
4883 | 4962 | ||
4963 | /* Create a new bond based on the specified name and bonding parameters. | ||
4964 | * Caller must NOT hold rtnl_lock; we need to release it here before we | ||
4965 | * set up our sysfs entries. | ||
4966 | */ | ||
4967 | int bond_create(char *name, struct bond_params *params, struct bonding **newbond) | ||
4968 | { | ||
4969 | struct net_device *bond_dev; | ||
4970 | int res; | ||
4971 | |||
4972 | rtnl_lock(); | ||
4973 | bond_dev = alloc_netdev(sizeof(struct bonding), name, ether_setup); | ||
4974 | if (!bond_dev) { | ||
4975 | printk(KERN_ERR DRV_NAME | ||
4976 | ": %s: eek! can't alloc netdev!\n", | ||
4977 | name); | ||
4978 | res = -ENOMEM; | ||
4979 | goto out_rtnl; | ||
4980 | } | ||
4981 | |||
4982 | /* bond_init() must be called after dev_alloc_name() (for the | ||
4983 | * /proc files), but before register_netdevice(), because we | ||
4984 | * need to set function pointers. | ||
4985 | */ | ||
4986 | |||
4987 | res = bond_init(bond_dev, params); | ||
4988 | if (res < 0) { | ||
4989 | goto out_netdev; | ||
4990 | } | ||
4991 | |||
4992 | SET_MODULE_OWNER(bond_dev); | ||
4993 | |||
4994 | res = register_netdevice(bond_dev); | ||
4995 | if (res < 0) { | ||
4996 | goto out_bond; | ||
4997 | } | ||
4998 | if (newbond) | ||
4999 | *newbond = bond_dev->priv; | ||
5000 | |||
5001 | rtnl_unlock(); /* allows sysfs registration of net device */ | ||
5002 | res = bond_create_sysfs_entry(bond_dev->priv); | ||
5003 | goto done; | ||
5004 | out_bond: | ||
5005 | bond_deinit(bond_dev); | ||
5006 | out_netdev: | ||
5007 | free_netdev(bond_dev); | ||
5008 | out_rtnl: | ||
5009 | rtnl_unlock(); | ||
5010 | done: | ||
5011 | return res; | ||
5012 | } | ||
5013 | |||
4884 | static int __init bonding_init(void) | 5014 | static int __init bonding_init(void) |
4885 | { | 5015 | { |
4886 | struct bond_params params; | ||
4887 | int i; | 5016 | int i; |
4888 | int res; | 5017 | int res; |
5018 | char new_bond_name[8]; /* Enough room for 999 bonds at init. */ | ||
4889 | 5019 | ||
4890 | printk(KERN_INFO "%s", version); | 5020 | printk(KERN_INFO "%s", version); |
4891 | 5021 | ||
4892 | res = bond_check_params(¶ms); | 5022 | res = bond_check_params(&bonding_defaults); |
4893 | if (res) { | 5023 | if (res) { |
4894 | return res; | 5024 | goto out; |
4895 | } | 5025 | } |
4896 | 5026 | ||
4897 | rtnl_lock(); | ||
4898 | |||
4899 | #ifdef CONFIG_PROC_FS | 5027 | #ifdef CONFIG_PROC_FS |
4900 | bond_create_proc_dir(); | 5028 | bond_create_proc_dir(); |
4901 | #endif | 5029 | #endif |
4902 | |||
4903 | for (i = 0; i < max_bonds; i++) { | 5030 | for (i = 0; i < max_bonds; i++) { |
4904 | struct net_device *bond_dev; | 5031 | sprintf(new_bond_name, "bond%d",i); |
4905 | 5032 | res = bond_create(new_bond_name,&bonding_defaults, NULL); | |
4906 | bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); | 5033 | if (res) |
4907 | if (!bond_dev) { | 5034 | 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 | } | 5035 | } |
4937 | 5036 | ||
4938 | rtnl_unlock(); | 5037 | res = bond_create_sysfs(); |
5038 | if (res) | ||
5039 | goto err; | ||
5040 | |||
4939 | register_netdevice_notifier(&bond_netdev_notifier); | 5041 | register_netdevice_notifier(&bond_netdev_notifier); |
4940 | register_inetaddr_notifier(&bond_inetaddr_notifier); | 5042 | register_inetaddr_notifier(&bond_inetaddr_notifier); |
4941 | 5043 | ||
4942 | return 0; | 5044 | goto out; |
4943 | 5045 | 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(); | 5046 | rtnl_lock(); |
4952 | |||
4953 | /* free and unregister all bonds that were successfully added */ | ||
4954 | bond_free_all(); | 5047 | bond_free_all(); |
4955 | 5048 | bond_destroy_sysfs(); | |
4956 | rtnl_unlock(); | 5049 | rtnl_unlock(); |
4957 | 5050 | out: | |
4958 | return res; | 5051 | return res; |
5052 | |||
4959 | } | 5053 | } |
4960 | 5054 | ||
4961 | static void __exit bonding_exit(void) | 5055 | static void __exit bonding_exit(void) |
@@ -4965,6 +5059,7 @@ static void __exit bonding_exit(void) | |||
4965 | 5059 | ||
4966 | rtnl_lock(); | 5060 | rtnl_lock(); |
4967 | bond_free_all(); | 5061 | bond_free_all(); |
5062 | bond_destroy_sysfs(); | ||
4968 | rtnl_unlock(); | 5063 | rtnl_unlock(); |
4969 | } | 5064 | } |
4970 | 5065 | ||
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c new file mode 100644 index 000000000000..c5f1c52863cb --- /dev/null +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -0,0 +1,1399 @@ | |||
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 | * Changes: | ||
24 | * | ||
25 | * 2004/12/12 - Mitch Williams <mitch.a.williams at intel dot com> | ||
26 | * - Initial creation of sysfs interface. | ||
27 | * | ||
28 | * 2005/06/22 - Radheka Godse <radheka.godse at intel dot com> | ||
29 | * - Added ifenslave -c type functionality to sysfs | ||
30 | * - Added sysfs files for attributes such as MII Status and | ||
31 | * 802.3ad aggregator that are displayed in /proc | ||
32 | * - Added "name value" format to sysfs "mode" and | ||
33 | * "lacp_rate", for e.g., "active-backup 1" or "slow 0" for | ||
34 | * consistency and ease of script parsing | ||
35 | * - Fixed reversal of octets in arp_ip_targets via sysfs | ||
36 | * - sysfs support to handle bond interface re-naming | ||
37 | * - Moved all sysfs entries into /sys/class/net instead of | ||
38 | * of using a standalone subsystem. | ||
39 | * - Added sysfs symlinks between masters and slaves | ||
40 | * - Corrected bugs in sysfs unload path when creating bonds | ||
41 | * with existing interface names. | ||
42 | * - Removed redundant sysfs stat file since it duplicates slave info | ||
43 | * from the proc file | ||
44 | * - Fixed errors in sysfs show/store arp targets. | ||
45 | * - For consistency with ifenslave, instead of exiting | ||
46 | * with an error, updated bonding sysfs to | ||
47 | * close and attempt to enslave an up adapter. | ||
48 | * - Fixed NULL dereference when adding a slave interface | ||
49 | * that does not exist. | ||
50 | * - Added checks in sysfs bonding to reject invalid ip addresses | ||
51 | * - Synch up with post linux-2.6.12 bonding changes | ||
52 | * - Created sysfs bond attrib for xmit_hash_policy | ||
53 | * | ||
54 | * 2005/09/19 - Mitch Williams <mitch.a.williams at intel dot com> | ||
55 | * - Changed semantics of multi-item files to be command-based | ||
56 | * instead of list-based. | ||
57 | * - Changed ARP target handler to use in_aton instead of sscanf | ||
58 | * - Style changes. | ||
59 | * 2005/09/27 - Mitch Williams <mitch.a.williams at intel dot com> | ||
60 | * - Made line endings consistent. | ||
61 | * - Removed "none" from primary output - just put blank instead | ||
62 | * - Fixed bug with long interface names | ||
63 | */ | ||
64 | #include <linux/config.h> | ||
65 | #include <linux/kernel.h> | ||
66 | #include <linux/module.h> | ||
67 | #include <linux/sched.h> | ||
68 | #include <linux/device.h> | ||
69 | #include <linux/sysdev.h> | ||
70 | #include <linux/fs.h> | ||
71 | #include <linux/types.h> | ||
72 | #include <linux/string.h> | ||
73 | #include <linux/netdevice.h> | ||
74 | #include <linux/inetdevice.h> | ||
75 | #include <linux/in.h> | ||
76 | #include <linux/sysfs.h> | ||
77 | #include <linux/string.h> | ||
78 | #include <linux/ctype.h> | ||
79 | #include <linux/inet.h> | ||
80 | #include <linux/rtnetlink.h> | ||
81 | |||
82 | /* #define BONDING_DEBUG 1 */ | ||
83 | #include "bonding.h" | ||
84 | #define to_class_dev(obj) container_of(obj,struct class_device,kobj) | ||
85 | #define to_net_dev(class) container_of(class, struct net_device, class_dev) | ||
86 | #define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) | ||
87 | |||
88 | /*---------------------------- Declarations -------------------------------*/ | ||
89 | |||
90 | |||
91 | extern struct list_head bond_dev_list; | ||
92 | extern struct bond_params bonding_defaults; | ||
93 | extern struct bond_parm_tbl bond_mode_tbl[]; | ||
94 | extern struct bond_parm_tbl bond_lacp_tbl[]; | ||
95 | extern struct bond_parm_tbl xmit_hashtype_tbl[]; | ||
96 | |||
97 | static int expected_refcount = -1; | ||
98 | static struct class *netdev_class; | ||
99 | /*--------------------------- Data Structures -----------------------------*/ | ||
100 | |||
101 | /* Bonding sysfs lock. Why can't we just use the subsytem lock? | ||
102 | * Because kobject_register tries to acquire the subsystem lock. If | ||
103 | * we already hold the lock (which we would if the user was creating | ||
104 | * a new bond through the sysfs interface), we deadlock. | ||
105 | * This lock is only needed when deleting a bond - we need to make sure | ||
106 | * that we don't collide with an ongoing ioctl. | ||
107 | */ | ||
108 | |||
109 | struct rw_semaphore bonding_rwsem; | ||
110 | |||
111 | |||
112 | |||
113 | |||
114 | /*------------------------------ Functions --------------------------------*/ | ||
115 | |||
116 | /* | ||
117 | * "show" function for the bond_masters attribute. | ||
118 | * The class parameter is ignored. | ||
119 | */ | ||
120 | static ssize_t bonding_show_bonds(struct class *cls, char *buffer) | ||
121 | { | ||
122 | int res = 0; | ||
123 | struct bonding *bond; | ||
124 | |||
125 | down_read(&(bonding_rwsem)); | ||
126 | |||
127 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | ||
128 | if (res > (PAGE_SIZE - IFNAMSIZ)) { | ||
129 | /* not enough space for another interface name */ | ||
130 | if ((PAGE_SIZE - res) > 10) | ||
131 | res = PAGE_SIZE - 10; | ||
132 | res += sprintf(buffer + res, "++more++"); | ||
133 | break; | ||
134 | } | ||
135 | res += sprintf(buffer + res, "%s ", | ||
136 | bond->dev->name); | ||
137 | } | ||
138 | res += sprintf(buffer + res, "\n"); | ||
139 | res++; | ||
140 | up_read(&(bonding_rwsem)); | ||
141 | return res; | ||
142 | } | ||
143 | |||
144 | /* | ||
145 | * "store" function for the bond_masters attribute. This is what | ||
146 | * creates and deletes entire bonds. | ||
147 | * | ||
148 | * The class parameter is ignored. | ||
149 | * | ||
150 | */ | ||
151 | |||
152 | static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t count) | ||
153 | { | ||
154 | char command[IFNAMSIZ + 1] = {0, }; | ||
155 | char *ifname; | ||
156 | int res = count; | ||
157 | struct bonding *bond; | ||
158 | struct bonding *nxt; | ||
159 | |||
160 | down_write(&(bonding_rwsem)); | ||
161 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ | ||
162 | ifname = command + 1; | ||
163 | if ((strlen(command) <= 1) || | ||
164 | !dev_valid_name(ifname)) | ||
165 | goto err_no_cmd; | ||
166 | |||
167 | if (command[0] == '+') { | ||
168 | |||
169 | /* Check to see if the bond already exists. */ | ||
170 | list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) | ||
171 | if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { | ||
172 | printk(KERN_ERR DRV_NAME | ||
173 | ": cannot add bond %s; it already exists\n", | ||
174 | ifname); | ||
175 | res = -EPERM; | ||
176 | goto out; | ||
177 | } | ||
178 | |||
179 | printk(KERN_INFO DRV_NAME | ||
180 | ": %s is being created...\n", ifname); | ||
181 | if (bond_create(ifname, &bonding_defaults, &bond)) { | ||
182 | printk(KERN_INFO DRV_NAME | ||
183 | ": %s interface already exists. Bond creation failed.\n", | ||
184 | ifname); | ||
185 | res = -EPERM; | ||
186 | } | ||
187 | goto out; | ||
188 | } | ||
189 | |||
190 | if (command[0] == '-') { | ||
191 | list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) | ||
192 | if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { | ||
193 | rtnl_lock(); | ||
194 | /* check the ref count on the bond's kobject. | ||
195 | * If it's > expected, then there's a file open, | ||
196 | * and we have to fail. | ||
197 | */ | ||
198 | if (atomic_read(&bond->dev->class_dev.kobj.kref.refcount) | ||
199 | > expected_refcount){ | ||
200 | rtnl_unlock(); | ||
201 | printk(KERN_INFO DRV_NAME | ||
202 | ": Unable remove bond %s due to open references.\n", | ||
203 | ifname); | ||
204 | res = -EPERM; | ||
205 | goto out; | ||
206 | } | ||
207 | printk(KERN_INFO DRV_NAME | ||
208 | ": %s is being deleted...\n", | ||
209 | bond->dev->name); | ||
210 | unregister_netdevice(bond->dev); | ||
211 | bond_deinit(bond->dev); | ||
212 | bond_destroy_sysfs_entry(bond); | ||
213 | rtnl_unlock(); | ||
214 | goto out; | ||
215 | } | ||
216 | |||
217 | printk(KERN_ERR DRV_NAME | ||
218 | ": unable to delete non-existent bond %s\n", ifname); | ||
219 | res = -ENODEV; | ||
220 | goto out; | ||
221 | } | ||
222 | |||
223 | err_no_cmd: | ||
224 | printk(KERN_ERR DRV_NAME | ||
225 | ": no command found in bonding_masters. Use +ifname or -ifname.\n"); | ||
226 | res = -EPERM; | ||
227 | |||
228 | /* Always return either count or an error. If you return 0, you'll | ||
229 | * get called forever, which is bad. | ||
230 | */ | ||
231 | out: | ||
232 | up_write(&(bonding_rwsem)); | ||
233 | return res; | ||
234 | } | ||
235 | /* class attribute for bond_masters file. This ends up in /sys/class/net */ | ||
236 | static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO, | ||
237 | bonding_show_bonds, bonding_store_bonds); | ||
238 | |||
239 | int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave) | ||
240 | { | ||
241 | char linkname[IFNAMSIZ+7]; | ||
242 | int ret = 0; | ||
243 | |||
244 | /* first, create a link from the slave back to the master */ | ||
245 | ret = sysfs_create_link(&(slave->class_dev.kobj), &(master->class_dev.kobj), | ||
246 | "master"); | ||
247 | if (ret) | ||
248 | return ret; | ||
249 | /* next, create a link from the master to the slave */ | ||
250 | sprintf(linkname,"slave_%s",slave->name); | ||
251 | ret = sysfs_create_link(&(master->class_dev.kobj), &(slave->class_dev.kobj), | ||
252 | linkname); | ||
253 | return ret; | ||
254 | |||
255 | } | ||
256 | |||
257 | void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave) | ||
258 | { | ||
259 | char linkname[IFNAMSIZ+7]; | ||
260 | |||
261 | sysfs_remove_link(&(slave->class_dev.kobj), "master"); | ||
262 | sprintf(linkname,"slave_%s",slave->name); | ||
263 | sysfs_remove_link(&(master->class_dev.kobj), linkname); | ||
264 | } | ||
265 | |||
266 | |||
267 | /* | ||
268 | * Show the slaves in the current bond. | ||
269 | */ | ||
270 | static ssize_t bonding_show_slaves(struct class_device *cd, char *buf) | ||
271 | { | ||
272 | struct slave *slave; | ||
273 | int i, res = 0; | ||
274 | struct bonding *bond = to_bond(cd); | ||
275 | |||
276 | read_lock_bh(&bond->lock); | ||
277 | bond_for_each_slave(bond, slave, i) { | ||
278 | if (res > (PAGE_SIZE - IFNAMSIZ)) { | ||
279 | /* not enough space for another interface name */ | ||
280 | if ((PAGE_SIZE - res) > 10) | ||
281 | res = PAGE_SIZE - 10; | ||
282 | res += sprintf(buf + res, "++more++"); | ||
283 | break; | ||
284 | } | ||
285 | res += sprintf(buf + res, "%s ", slave->dev->name); | ||
286 | } | ||
287 | read_unlock_bh(&bond->lock); | ||
288 | res += sprintf(buf + res, "\n"); | ||
289 | res++; | ||
290 | return res; | ||
291 | } | ||
292 | |||
293 | /* | ||
294 | * Set the slaves in the current bond. The bond interface must be | ||
295 | * up for this to succeed. | ||
296 | * This function is largely the same flow as bonding_update_bonds(). | ||
297 | */ | ||
298 | static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer, size_t count) | ||
299 | { | ||
300 | char command[IFNAMSIZ + 1] = { 0, }; | ||
301 | char *ifname; | ||
302 | int i, res, found, ret = count; | ||
303 | struct slave *slave; | ||
304 | struct net_device *dev = 0; | ||
305 | struct bonding *bond = to_bond(cd); | ||
306 | |||
307 | /* Quick sanity check -- is the bond interface up? */ | ||
308 | if (!(bond->dev->flags & IFF_UP)) { | ||
309 | printk(KERN_ERR DRV_NAME | ||
310 | ": %s: Unable to update slaves because interface is down.\n", | ||
311 | bond->dev->name); | ||
312 | ret = -EPERM; | ||
313 | goto out; | ||
314 | } | ||
315 | |||
316 | /* Note: We can't hold bond->lock here, as bond_create grabs it. */ | ||
317 | |||
318 | sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ | ||
319 | ifname = command + 1; | ||
320 | if ((strlen(command) <= 1) || | ||
321 | !dev_valid_name(ifname)) | ||
322 | goto err_no_cmd; | ||
323 | |||
324 | if (command[0] == '+') { | ||
325 | |||
326 | /* Got a slave name in ifname. Is it already in the list? */ | ||
327 | found = 0; | ||
328 | read_lock_bh(&bond->lock); | ||
329 | bond_for_each_slave(bond, slave, i) | ||
330 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { | ||
331 | printk(KERN_ERR DRV_NAME | ||
332 | ": %s: Interface %s is already enslaved!\n", | ||
333 | bond->dev->name, ifname); | ||
334 | ret = -EPERM; | ||
335 | read_unlock_bh(&bond->lock); | ||
336 | goto out; | ||
337 | } | ||
338 | |||
339 | read_unlock_bh(&bond->lock); | ||
340 | printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", | ||
341 | bond->dev->name, ifname); | ||
342 | dev = dev_get_by_name(ifname); | ||
343 | if (!dev) { | ||
344 | printk(KERN_INFO DRV_NAME | ||
345 | ": %s: Interface %s does not exist!\n", | ||
346 | bond->dev->name, ifname); | ||
347 | ret = -EPERM; | ||
348 | goto out; | ||
349 | } | ||
350 | else | ||
351 | dev_put(dev); | ||
352 | |||
353 | if (dev->flags & IFF_UP) { | ||
354 | printk(KERN_ERR DRV_NAME | ||
355 | ": %s: Error: Unable to enslave %s " | ||
356 | "because it is already up.\n", | ||
357 | bond->dev->name, dev->name); | ||
358 | ret = -EPERM; | ||
359 | goto out; | ||
360 | } | ||
361 | /* If this is the first slave, then we need to set | ||
362 | the master's hardware address to be the same as the | ||
363 | slave's. */ | ||
364 | if (!(*((u32 *) & (bond->dev->dev_addr[0])))) { | ||
365 | memcpy(bond->dev->dev_addr, dev->dev_addr, | ||
366 | dev->addr_len); | ||
367 | } | ||
368 | |||
369 | /* Set the slave's MTU to match the bond */ | ||
370 | if (dev->mtu != bond->dev->mtu) { | ||
371 | if (dev->change_mtu) { | ||
372 | res = dev->change_mtu(dev, | ||
373 | bond->dev->mtu); | ||
374 | if (res) { | ||
375 | ret = res; | ||
376 | goto out; | ||
377 | } | ||
378 | } else { | ||
379 | dev->mtu = bond->dev->mtu; | ||
380 | } | ||
381 | } | ||
382 | rtnl_lock(); | ||
383 | res = bond_enslave(bond->dev, dev); | ||
384 | rtnl_unlock(); | ||
385 | if (res) { | ||
386 | ret = res; | ||
387 | } | ||
388 | goto out; | ||
389 | } | ||
390 | |||
391 | if (command[0] == '-') { | ||
392 | dev = NULL; | ||
393 | bond_for_each_slave(bond, slave, i) | ||
394 | if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { | ||
395 | dev = slave->dev; | ||
396 | break; | ||
397 | } | ||
398 | if (dev) { | ||
399 | printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", | ||
400 | bond->dev->name, dev->name); | ||
401 | rtnl_lock(); | ||
402 | res = bond_release(bond->dev, dev); | ||
403 | rtnl_unlock(); | ||
404 | if (res) { | ||
405 | ret = res; | ||
406 | goto out; | ||
407 | } | ||
408 | /* set the slave MTU to the default */ | ||
409 | if (dev->change_mtu) { | ||
410 | dev->change_mtu(dev, 1500); | ||
411 | } else { | ||
412 | dev->mtu = 1500; | ||
413 | } | ||
414 | } | ||
415 | else { | ||
416 | printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n", | ||
417 | ifname, bond->dev->name); | ||
418 | ret = -ENODEV; | ||
419 | } | ||
420 | goto out; | ||
421 | } | ||
422 | |||
423 | err_no_cmd: | ||
424 | printk(KERN_ERR DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); | ||
425 | ret = -EPERM; | ||
426 | |||
427 | out: | ||
428 | return ret; | ||
429 | } | ||
430 | |||
431 | static CLASS_DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); | ||
432 | |||
433 | /* | ||
434 | * Show and set the bonding mode. The bond interface must be down to | ||
435 | * change the mode. | ||
436 | */ | ||
437 | static ssize_t bonding_show_mode(struct class_device *cd, char *buf) | ||
438 | { | ||
439 | struct bonding *bond = to_bond(cd); | ||
440 | |||
441 | return sprintf(buf, "%s %d\n", | ||
442 | bond_mode_tbl[bond->params.mode].modename, | ||
443 | bond->params.mode) + 1; | ||
444 | } | ||
445 | |||
446 | static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size_t count) | ||
447 | { | ||
448 | int new_value, ret = count; | ||
449 | struct bonding *bond = to_bond(cd); | ||
450 | |||
451 | if (bond->dev->flags & IFF_UP) { | ||
452 | printk(KERN_ERR DRV_NAME | ||
453 | ": unable to update mode of %s because interface is up.\n", | ||
454 | bond->dev->name); | ||
455 | ret = -EPERM; | ||
456 | goto out; | ||
457 | } | ||
458 | |||
459 | new_value = bond_parse_parm((char *)buf, bond_mode_tbl); | ||
460 | if (new_value < 0) { | ||
461 | printk(KERN_ERR DRV_NAME | ||
462 | ": %s: Ignoring invalid mode value %.*s.\n", | ||
463 | bond->dev->name, | ||
464 | (int)strlen(buf) - 1, buf); | ||
465 | ret = -EINVAL; | ||
466 | goto out; | ||
467 | } else { | ||
468 | bond->params.mode = new_value; | ||
469 | bond_set_mode_ops(bond, bond->params.mode); | ||
470 | printk(KERN_INFO DRV_NAME ": %s: setting mode to %s (%d).\n", | ||
471 | bond->dev->name, bond_mode_tbl[new_value].modename, new_value); | ||
472 | } | ||
473 | out: | ||
474 | return ret; | ||
475 | } | ||
476 | static CLASS_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); | ||
477 | |||
478 | /* | ||
479 | * Show and set the bonding transmit hash method. The bond interface must be down to | ||
480 | * change the xmit hash policy. | ||
481 | */ | ||
482 | static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf) | ||
483 | { | ||
484 | int count; | ||
485 | struct bonding *bond = to_bond(cd); | ||
486 | |||
487 | if ((bond->params.mode != BOND_MODE_XOR) && | ||
488 | (bond->params.mode != BOND_MODE_8023AD)) { | ||
489 | // Not Applicable | ||
490 | count = sprintf(buf, "NA\n") + 1; | ||
491 | } else { | ||
492 | count = sprintf(buf, "%s %d\n", | ||
493 | xmit_hashtype_tbl[bond->params.xmit_policy].modename, | ||
494 | bond->params.xmit_policy) + 1; | ||
495 | } | ||
496 | |||
497 | return count; | ||
498 | } | ||
499 | |||
500 | static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf, size_t count) | ||
501 | { | ||
502 | int new_value, ret = count; | ||
503 | struct bonding *bond = to_bond(cd); | ||
504 | |||
505 | if (bond->dev->flags & IFF_UP) { | ||
506 | printk(KERN_ERR DRV_NAME | ||
507 | "%s: Interface is up. Unable to update xmit policy.\n", | ||
508 | bond->dev->name); | ||
509 | ret = -EPERM; | ||
510 | goto out; | ||
511 | } | ||
512 | |||
513 | if ((bond->params.mode != BOND_MODE_XOR) && | ||
514 | (bond->params.mode != BOND_MODE_8023AD)) { | ||
515 | printk(KERN_ERR DRV_NAME | ||
516 | "%s: Transmit hash policy is irrelevant in this mode.\n", | ||
517 | bond->dev->name); | ||
518 | ret = -EPERM; | ||
519 | goto out; | ||
520 | } | ||
521 | |||
522 | new_value = bond_parse_parm((char *)buf, xmit_hashtype_tbl); | ||
523 | if (new_value < 0) { | ||
524 | printk(KERN_ERR DRV_NAME | ||
525 | ": %s: Ignoring invalid xmit hash policy value %.*s.\n", | ||
526 | bond->dev->name, | ||
527 | (int)strlen(buf) - 1, buf); | ||
528 | ret = -EINVAL; | ||
529 | goto out; | ||
530 | } else { | ||
531 | bond->params.xmit_policy = new_value; | ||
532 | bond_set_mode_ops(bond, bond->params.mode); | ||
533 | printk(KERN_INFO DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", | ||
534 | bond->dev->name, xmit_hashtype_tbl[new_value].modename, new_value); | ||
535 | } | ||
536 | out: | ||
537 | return ret; | ||
538 | } | ||
539 | static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); | ||
540 | |||
541 | /* | ||
542 | * Show and set the arp timer interval. There are two tricky bits | ||
543 | * here. First, if ARP monitoring is activated, then we must disable | ||
544 | * MII monitoring. Second, if the ARP timer isn't running, we must | ||
545 | * start it. | ||
546 | */ | ||
547 | static ssize_t bonding_show_arp_interval(struct class_device *cd, char *buf) | ||
548 | { | ||
549 | struct bonding *bond = to_bond(cd); | ||
550 | |||
551 | return sprintf(buf, "%d\n", bond->params.arp_interval) + 1; | ||
552 | } | ||
553 | |||
554 | static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *buf, size_t count) | ||
555 | { | ||
556 | int new_value, ret = count; | ||
557 | struct bonding *bond = to_bond(cd); | ||
558 | |||
559 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
560 | printk(KERN_ERR DRV_NAME | ||
561 | ": %s: no arp_interval value specified.\n", | ||
562 | bond->dev->name); | ||
563 | ret = -EINVAL; | ||
564 | goto out; | ||
565 | } | ||
566 | if (new_value < 0) { | ||
567 | printk(KERN_ERR DRV_NAME | ||
568 | ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", | ||
569 | bond->dev->name, new_value, INT_MAX); | ||
570 | ret = -EINVAL; | ||
571 | goto out; | ||
572 | } | ||
573 | |||
574 | printk(KERN_INFO DRV_NAME | ||
575 | ": %s: Setting ARP monitoring interval to %d.\n", | ||
576 | bond->dev->name, new_value); | ||
577 | bond->params.arp_interval = new_value; | ||
578 | if (bond->params.miimon) { | ||
579 | printk(KERN_INFO DRV_NAME | ||
580 | ": %s: ARP monitoring cannot be used with MII monitoring. " | ||
581 | "%s Disabling MII monitoring.\n", | ||
582 | bond->dev->name, bond->dev->name); | ||
583 | bond->params.miimon = 0; | ||
584 | /* Kill MII timer, else it brings bond's link down */ | ||
585 | if (bond->arp_timer.function) { | ||
586 | printk(KERN_INFO DRV_NAME | ||
587 | ": %s: Kill MII timer, else it brings bond's link down...\n", | ||
588 | bond->dev->name); | ||
589 | del_timer_sync(&bond->mii_timer); | ||
590 | } | ||
591 | } | ||
592 | if (!bond->params.arp_targets[0]) { | ||
593 | printk(KERN_INFO DRV_NAME | ||
594 | ": %s: ARP monitoring has been set up, " | ||
595 | "but no ARP targets have been specified.\n", | ||
596 | bond->dev->name); | ||
597 | } | ||
598 | if (bond->dev->flags & IFF_UP) { | ||
599 | /* If the interface is up, we may need to fire off | ||
600 | * the ARP timer. If the interface is down, the | ||
601 | * timer will get fired off when the open function | ||
602 | * is called. | ||
603 | */ | ||
604 | if (bond->arp_timer.function) { | ||
605 | /* The timer's already set up, so fire it off */ | ||
606 | mod_timer(&bond->arp_timer, jiffies + 1); | ||
607 | } else { | ||
608 | /* Set up the timer. */ | ||
609 | init_timer(&bond->arp_timer); | ||
610 | bond->arp_timer.expires = jiffies + 1; | ||
611 | bond->arp_timer.data = | ||
612 | (unsigned long) bond->dev; | ||
613 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { | ||
614 | bond->arp_timer.function = | ||
615 | (void *) | ||
616 | &bond_activebackup_arp_mon; | ||
617 | } else { | ||
618 | bond->arp_timer.function = | ||
619 | (void *) | ||
620 | &bond_loadbalance_arp_mon; | ||
621 | } | ||
622 | add_timer(&bond->arp_timer); | ||
623 | } | ||
624 | } | ||
625 | |||
626 | out: | ||
627 | return ret; | ||
628 | } | ||
629 | static CLASS_DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); | ||
630 | |||
631 | /* | ||
632 | * Show and set the arp targets. | ||
633 | */ | ||
634 | static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf) | ||
635 | { | ||
636 | int i, res = 0; | ||
637 | struct bonding *bond = to_bond(cd); | ||
638 | |||
639 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { | ||
640 | if (bond->params.arp_targets[i]) | ||
641 | res += sprintf(buf + res, "%u.%u.%u.%u ", | ||
642 | NIPQUAD(bond->params.arp_targets[i])); | ||
643 | } | ||
644 | if (res) | ||
645 | res--; /* eat the leftover space */ | ||
646 | res += sprintf(buf + res, "\n"); | ||
647 | res++; | ||
648 | return res; | ||
649 | } | ||
650 | |||
651 | static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *buf, size_t count) | ||
652 | { | ||
653 | u32 newtarget; | ||
654 | int i = 0, done = 0, ret = count; | ||
655 | struct bonding *bond = to_bond(cd); | ||
656 | u32 *targets; | ||
657 | |||
658 | targets = bond->params.arp_targets; | ||
659 | newtarget = in_aton(buf + 1); | ||
660 | /* look for adds */ | ||
661 | if (buf[0] == '+') { | ||
662 | if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) { | ||
663 | printk(KERN_ERR DRV_NAME | ||
664 | ": %s: invalid ARP target %u.%u.%u.%u specified for addition\n", | ||
665 | bond->dev->name, NIPQUAD(newtarget)); | ||
666 | ret = -EINVAL; | ||
667 | goto out; | ||
668 | } | ||
669 | /* look for an empty slot to put the target in, and check for dupes */ | ||
670 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { | ||
671 | if (targets[i] == newtarget) { /* duplicate */ | ||
672 | printk(KERN_ERR DRV_NAME | ||
673 | ": %s: ARP target %u.%u.%u.%u is already present\n", | ||
674 | bond->dev->name, NIPQUAD(newtarget)); | ||
675 | if (done) | ||
676 | targets[i] = 0; | ||
677 | ret = -EINVAL; | ||
678 | goto out; | ||
679 | } | ||
680 | if (targets[i] == 0 && !done) { | ||
681 | printk(KERN_INFO DRV_NAME | ||
682 | ": %s: adding ARP target %d.%d.%d.%d.\n", | ||
683 | bond->dev->name, NIPQUAD(newtarget)); | ||
684 | done = 1; | ||
685 | targets[i] = newtarget; | ||
686 | } | ||
687 | } | ||
688 | if (!done) { | ||
689 | printk(KERN_ERR DRV_NAME | ||
690 | ": %s: ARP target table is full!\n", | ||
691 | bond->dev->name); | ||
692 | ret = -EINVAL; | ||
693 | goto out; | ||
694 | } | ||
695 | |||
696 | } | ||
697 | else if (buf[0] == '-') { | ||
698 | if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) { | ||
699 | printk(KERN_ERR DRV_NAME | ||
700 | ": %s: invalid ARP target %d.%d.%d.%d specified for removal\n", | ||
701 | bond->dev->name, NIPQUAD(newtarget)); | ||
702 | ret = -EINVAL; | ||
703 | goto out; | ||
704 | } | ||
705 | |||
706 | for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { | ||
707 | if (targets[i] == newtarget) { | ||
708 | printk(KERN_INFO DRV_NAME | ||
709 | ": %s: removing ARP target %d.%d.%d.%d.\n", | ||
710 | bond->dev->name, NIPQUAD(newtarget)); | ||
711 | targets[i] = 0; | ||
712 | done = 1; | ||
713 | } | ||
714 | } | ||
715 | if (!done) { | ||
716 | printk(KERN_INFO DRV_NAME | ||
717 | ": %s: unable to remove nonexistent ARP target %d.%d.%d.%d.\n", | ||
718 | bond->dev->name, NIPQUAD(newtarget)); | ||
719 | ret = -EINVAL; | ||
720 | goto out; | ||
721 | } | ||
722 | } | ||
723 | else { | ||
724 | printk(KERN_ERR DRV_NAME ": no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n", | ||
725 | bond->dev->name); | ||
726 | ret = -EPERM; | ||
727 | goto out; | ||
728 | } | ||
729 | |||
730 | out: | ||
731 | return ret; | ||
732 | } | ||
733 | static CLASS_DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); | ||
734 | |||
735 | /* | ||
736 | * Show and set the up and down delays. These must be multiples of the | ||
737 | * MII monitoring value, and are stored internally as the multiplier. | ||
738 | * Thus, we must translate to MS for the real world. | ||
739 | */ | ||
740 | static ssize_t bonding_show_downdelay(struct class_device *cd, char *buf) | ||
741 | { | ||
742 | struct bonding *bond = to_bond(cd); | ||
743 | |||
744 | return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1; | ||
745 | } | ||
746 | |||
747 | static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf, size_t count) | ||
748 | { | ||
749 | int new_value, ret = count; | ||
750 | struct bonding *bond = to_bond(cd); | ||
751 | |||
752 | if (!(bond->params.miimon)) { | ||
753 | printk(KERN_ERR DRV_NAME | ||
754 | ": %s: Unable to set down delay as MII monitoring is disabled\n", | ||
755 | bond->dev->name); | ||
756 | ret = -EPERM; | ||
757 | goto out; | ||
758 | } | ||
759 | |||
760 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
761 | printk(KERN_ERR DRV_NAME | ||
762 | ": %s: no down delay value specified.\n", | ||
763 | bond->dev->name); | ||
764 | ret = -EINVAL; | ||
765 | goto out; | ||
766 | } | ||
767 | if (new_value < 0) { | ||
768 | printk(KERN_ERR DRV_NAME | ||
769 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | ||
770 | bond->dev->name, new_value, 1, INT_MAX); | ||
771 | ret = -EINVAL; | ||
772 | goto out; | ||
773 | } else { | ||
774 | if ((new_value % bond->params.miimon) != 0) { | ||
775 | printk(KERN_WARNING DRV_NAME | ||
776 | ": %s: Warning: down delay (%d) is not a multiple " | ||
777 | "of miimon (%d), delay rounded to %d ms\n", | ||
778 | bond->dev->name, new_value, bond->params.miimon, | ||
779 | (new_value / bond->params.miimon) * | ||
780 | bond->params.miimon); | ||
781 | } | ||
782 | bond->params.downdelay = new_value / bond->params.miimon; | ||
783 | printk(KERN_INFO DRV_NAME ": %s: Setting down delay to %d.\n", | ||
784 | bond->dev->name, bond->params.downdelay * bond->params.miimon); | ||
785 | |||
786 | } | ||
787 | |||
788 | out: | ||
789 | return ret; | ||
790 | } | ||
791 | static CLASS_DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); | ||
792 | |||
793 | static ssize_t bonding_show_updelay(struct class_device *cd, char *buf) | ||
794 | { | ||
795 | struct bonding *bond = to_bond(cd); | ||
796 | |||
797 | return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1; | ||
798 | |||
799 | } | ||
800 | |||
801 | static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, size_t count) | ||
802 | { | ||
803 | int new_value, ret = count; | ||
804 | struct bonding *bond = to_bond(cd); | ||
805 | |||
806 | if (!(bond->params.miimon)) { | ||
807 | printk(KERN_ERR DRV_NAME | ||
808 | ": %s: Unable to set up delay as MII monitoring is disabled\n", | ||
809 | bond->dev->name); | ||
810 | ret = -EPERM; | ||
811 | goto out; | ||
812 | } | ||
813 | |||
814 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
815 | printk(KERN_ERR DRV_NAME | ||
816 | ": %s: no up delay value specified.\n", | ||
817 | bond->dev->name); | ||
818 | ret = -EINVAL; | ||
819 | goto out; | ||
820 | } | ||
821 | if (new_value < 0) { | ||
822 | printk(KERN_ERR DRV_NAME | ||
823 | ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", | ||
824 | bond->dev->name, new_value, 1, INT_MAX); | ||
825 | ret = -EINVAL; | ||
826 | goto out; | ||
827 | } else { | ||
828 | if ((new_value % bond->params.miimon) != 0) { | ||
829 | printk(KERN_WARNING DRV_NAME | ||
830 | ": %s: Warning: up delay (%d) is not a multiple " | ||
831 | "of miimon (%d), updelay rounded to %d ms\n", | ||
832 | bond->dev->name, new_value, bond->params.miimon, | ||
833 | (new_value / bond->params.miimon) * | ||
834 | bond->params.miimon); | ||
835 | } | ||
836 | bond->params.updelay = new_value / bond->params.miimon; | ||
837 | printk(KERN_INFO DRV_NAME ": %s: Setting up delay to %d.\n", | ||
838 | bond->dev->name, bond->params.updelay * bond->params.miimon); | ||
839 | |||
840 | } | ||
841 | |||
842 | out: | ||
843 | return ret; | ||
844 | } | ||
845 | static CLASS_DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); | ||
846 | |||
847 | /* | ||
848 | * Show and set the LACP interval. Interface must be down, and the mode | ||
849 | * must be set to 802.3ad mode. | ||
850 | */ | ||
851 | static ssize_t bonding_show_lacp(struct class_device *cd, char *buf) | ||
852 | { | ||
853 | struct bonding *bond = to_bond(cd); | ||
854 | |||
855 | return sprintf(buf, "%s %d\n", | ||
856 | bond_lacp_tbl[bond->params.lacp_fast].modename, | ||
857 | bond->params.lacp_fast) + 1; | ||
858 | } | ||
859 | |||
860 | static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size_t count) | ||
861 | { | ||
862 | int new_value, ret = count; | ||
863 | struct bonding *bond = to_bond(cd); | ||
864 | |||
865 | if (bond->dev->flags & IFF_UP) { | ||
866 | printk(KERN_ERR DRV_NAME | ||
867 | ": %s: Unable to update LACP rate because interface is up.\n", | ||
868 | bond->dev->name); | ||
869 | ret = -EPERM; | ||
870 | goto out; | ||
871 | } | ||
872 | |||
873 | if (bond->params.mode != BOND_MODE_8023AD) { | ||
874 | printk(KERN_ERR DRV_NAME | ||
875 | ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", | ||
876 | bond->dev->name); | ||
877 | ret = -EPERM; | ||
878 | goto out; | ||
879 | } | ||
880 | |||
881 | new_value = bond_parse_parm((char *)buf, bond_lacp_tbl); | ||
882 | |||
883 | if ((new_value == 1) || (new_value == 0)) { | ||
884 | bond->params.lacp_fast = new_value; | ||
885 | printk(KERN_INFO DRV_NAME | ||
886 | ": %s: Setting LACP rate to %s (%d).\n", | ||
887 | bond->dev->name, bond_lacp_tbl[new_value].modename, new_value); | ||
888 | } else { | ||
889 | printk(KERN_ERR DRV_NAME | ||
890 | ": %s: Ignoring invalid LACP rate value %.*s.\n", | ||
891 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
892 | ret = -EINVAL; | ||
893 | } | ||
894 | out: | ||
895 | return ret; | ||
896 | } | ||
897 | static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); | ||
898 | |||
899 | /* | ||
900 | * Show and set the MII monitor interval. There are two tricky bits | ||
901 | * here. First, if MII monitoring is activated, then we must disable | ||
902 | * ARP monitoring. Second, if the timer isn't running, we must | ||
903 | * start it. | ||
904 | */ | ||
905 | static ssize_t bonding_show_miimon(struct class_device *cd, char *buf) | ||
906 | { | ||
907 | struct bonding *bond = to_bond(cd); | ||
908 | |||
909 | return sprintf(buf, "%d\n", bond->params.miimon) + 1; | ||
910 | } | ||
911 | |||
912 | static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, size_t count) | ||
913 | { | ||
914 | int new_value, ret = count; | ||
915 | struct bonding *bond = to_bond(cd); | ||
916 | |||
917 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
918 | printk(KERN_ERR DRV_NAME | ||
919 | ": %s: no miimon value specified.\n", | ||
920 | bond->dev->name); | ||
921 | ret = -EINVAL; | ||
922 | goto out; | ||
923 | } | ||
924 | if (new_value < 0) { | ||
925 | printk(KERN_ERR DRV_NAME | ||
926 | ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n", | ||
927 | bond->dev->name, new_value, 1, INT_MAX); | ||
928 | ret = -EINVAL; | ||
929 | goto out; | ||
930 | } else { | ||
931 | printk(KERN_INFO DRV_NAME | ||
932 | ": %s: Setting MII monitoring interval to %d.\n", | ||
933 | bond->dev->name, new_value); | ||
934 | bond->params.miimon = new_value; | ||
935 | if(bond->params.updelay) | ||
936 | printk(KERN_INFO DRV_NAME | ||
937 | ": %s: Note: Updating updelay (to %d) " | ||
938 | "since it is a multiple of the miimon value.\n", | ||
939 | bond->dev->name, | ||
940 | bond->params.updelay * bond->params.miimon); | ||
941 | if(bond->params.downdelay) | ||
942 | printk(KERN_INFO DRV_NAME | ||
943 | ": %s: Note: Updating downdelay (to %d) " | ||
944 | "since it is a multiple of the miimon value.\n", | ||
945 | bond->dev->name, | ||
946 | bond->params.downdelay * bond->params.miimon); | ||
947 | if (bond->params.arp_interval) { | ||
948 | printk(KERN_INFO DRV_NAME | ||
949 | ": %s: MII monitoring cannot be used with " | ||
950 | "ARP monitoring. Disabling ARP monitoring...\n", | ||
951 | bond->dev->name); | ||
952 | bond->params.arp_interval = 0; | ||
953 | /* Kill ARP timer, else it brings bond's link down */ | ||
954 | if (bond->mii_timer.function) { | ||
955 | printk(KERN_INFO DRV_NAME | ||
956 | ": %s: Kill ARP timer, else it brings bond's link down...\n", | ||
957 | bond->dev->name); | ||
958 | del_timer_sync(&bond->arp_timer); | ||
959 | } | ||
960 | } | ||
961 | |||
962 | if (bond->dev->flags & IFF_UP) { | ||
963 | /* If the interface is up, we may need to fire off | ||
964 | * the MII timer. If the interface is down, the | ||
965 | * timer will get fired off when the open function | ||
966 | * is called. | ||
967 | */ | ||
968 | if (bond->mii_timer.function) { | ||
969 | /* The timer's already set up, so fire it off */ | ||
970 | mod_timer(&bond->mii_timer, jiffies + 1); | ||
971 | } else { | ||
972 | /* Set up the timer. */ | ||
973 | init_timer(&bond->mii_timer); | ||
974 | bond->mii_timer.expires = jiffies + 1; | ||
975 | bond->mii_timer.data = | ||
976 | (unsigned long) bond->dev; | ||
977 | bond->mii_timer.function = | ||
978 | (void *) &bond_mii_monitor; | ||
979 | add_timer(&bond->mii_timer); | ||
980 | } | ||
981 | } | ||
982 | } | ||
983 | out: | ||
984 | return ret; | ||
985 | } | ||
986 | static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); | ||
987 | |||
988 | /* | ||
989 | * Show and set the primary slave. The store function is much | ||
990 | * simpler than bonding_store_slaves function because it only needs to | ||
991 | * handle one interface name. | ||
992 | * The bond must be a mode that supports a primary for this be | ||
993 | * set. | ||
994 | */ | ||
995 | static ssize_t bonding_show_primary(struct class_device *cd, char *buf) | ||
996 | { | ||
997 | int count = 0; | ||
998 | struct bonding *bond = to_bond(cd); | ||
999 | |||
1000 | if (bond->primary_slave) | ||
1001 | count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1; | ||
1002 | else | ||
1003 | count = sprintf(buf, "\n") + 1; | ||
1004 | |||
1005 | return count; | ||
1006 | } | ||
1007 | |||
1008 | static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, size_t count) | ||
1009 | { | ||
1010 | int i; | ||
1011 | struct slave *slave; | ||
1012 | struct bonding *bond = to_bond(cd); | ||
1013 | |||
1014 | write_lock_bh(&bond->lock); | ||
1015 | if (!USES_PRIMARY(bond->params.mode)) { | ||
1016 | printk(KERN_INFO DRV_NAME | ||
1017 | ": %s: Unable to set primary slave; %s is in mode %d\n", | ||
1018 | bond->dev->name, bond->dev->name, bond->params.mode); | ||
1019 | } else { | ||
1020 | bond_for_each_slave(bond, slave, i) { | ||
1021 | if (strnicmp | ||
1022 | (slave->dev->name, buf, | ||
1023 | strlen(slave->dev->name)) == 0) { | ||
1024 | printk(KERN_INFO DRV_NAME | ||
1025 | ": %s: Setting %s as primary slave.\n", | ||
1026 | bond->dev->name, slave->dev->name); | ||
1027 | bond->primary_slave = slave; | ||
1028 | bond_select_active_slave(bond); | ||
1029 | goto out; | ||
1030 | } | ||
1031 | } | ||
1032 | |||
1033 | /* if we got here, then we didn't match the name of any slave */ | ||
1034 | |||
1035 | if (strlen(buf) == 0 || buf[0] == '\n') { | ||
1036 | printk(KERN_INFO DRV_NAME | ||
1037 | ": %s: Setting primary slave to None.\n", | ||
1038 | bond->dev->name); | ||
1039 | bond->primary_slave = 0; | ||
1040 | bond_select_active_slave(bond); | ||
1041 | } else { | ||
1042 | printk(KERN_INFO DRV_NAME | ||
1043 | ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", | ||
1044 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
1045 | } | ||
1046 | } | ||
1047 | out: | ||
1048 | write_unlock_bh(&bond->lock); | ||
1049 | return count; | ||
1050 | } | ||
1051 | static CLASS_DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); | ||
1052 | |||
1053 | /* | ||
1054 | * Show and set the use_carrier flag. | ||
1055 | */ | ||
1056 | static ssize_t bonding_show_carrier(struct class_device *cd, char *buf) | ||
1057 | { | ||
1058 | struct bonding *bond = to_bond(cd); | ||
1059 | |||
1060 | return sprintf(buf, "%d\n", bond->params.use_carrier) + 1; | ||
1061 | } | ||
1062 | |||
1063 | static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, size_t count) | ||
1064 | { | ||
1065 | int new_value, ret = count; | ||
1066 | struct bonding *bond = to_bond(cd); | ||
1067 | |||
1068 | |||
1069 | if (sscanf(buf, "%d", &new_value) != 1) { | ||
1070 | printk(KERN_ERR DRV_NAME | ||
1071 | ": %s: no use_carrier value specified.\n", | ||
1072 | bond->dev->name); | ||
1073 | ret = -EINVAL; | ||
1074 | goto out; | ||
1075 | } | ||
1076 | if ((new_value == 0) || (new_value == 1)) { | ||
1077 | bond->params.use_carrier = new_value; | ||
1078 | printk(KERN_INFO DRV_NAME ": %s: Setting use_carrier to %d.\n", | ||
1079 | bond->dev->name, new_value); | ||
1080 | } else { | ||
1081 | printk(KERN_INFO DRV_NAME | ||
1082 | ": %s: Ignoring invalid use_carrier value %d.\n", | ||
1083 | bond->dev->name, new_value); | ||
1084 | } | ||
1085 | out: | ||
1086 | return count; | ||
1087 | } | ||
1088 | static CLASS_DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); | ||
1089 | |||
1090 | |||
1091 | /* | ||
1092 | * Show and set currently active_slave. | ||
1093 | */ | ||
1094 | static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf) | ||
1095 | { | ||
1096 | struct slave *curr; | ||
1097 | struct bonding *bond = to_bond(cd); | ||
1098 | int count; | ||
1099 | |||
1100 | |||
1101 | read_lock(&bond->curr_slave_lock); | ||
1102 | curr = bond->curr_active_slave; | ||
1103 | read_unlock(&bond->curr_slave_lock); | ||
1104 | |||
1105 | if (USES_PRIMARY(bond->params.mode) && curr) | ||
1106 | count = sprintf(buf, "%s\n", curr->dev->name) + 1; | ||
1107 | else | ||
1108 | count = sprintf(buf, "\n") + 1; | ||
1109 | return count; | ||
1110 | } | ||
1111 | |||
1112 | static ssize_t bonding_store_active_slave(struct class_device *cd, const char *buf, size_t count) | ||
1113 | { | ||
1114 | int i; | ||
1115 | struct slave *slave; | ||
1116 | struct slave *old_active = NULL; | ||
1117 | struct slave *new_active = NULL; | ||
1118 | struct bonding *bond = to_bond(cd); | ||
1119 | |||
1120 | write_lock_bh(&bond->lock); | ||
1121 | if (!USES_PRIMARY(bond->params.mode)) { | ||
1122 | printk(KERN_INFO DRV_NAME | ||
1123 | ": %s: Unable to change active slave; %s is in mode %d\n", | ||
1124 | bond->dev->name, bond->dev->name, bond->params.mode); | ||
1125 | } else { | ||
1126 | bond_for_each_slave(bond, slave, i) { | ||
1127 | if (strnicmp | ||
1128 | (slave->dev->name, buf, | ||
1129 | strlen(slave->dev->name)) == 0) { | ||
1130 | old_active = bond->curr_active_slave; | ||
1131 | new_active = slave; | ||
1132 | if (new_active && (new_active == old_active)) { | ||
1133 | /* do nothing */ | ||
1134 | printk(KERN_INFO DRV_NAME | ||
1135 | ": %s: %s is already the current active slave.\n", | ||
1136 | bond->dev->name, slave->dev->name); | ||
1137 | goto out; | ||
1138 | } | ||
1139 | else { | ||
1140 | if ((new_active) && | ||
1141 | (old_active) && | ||
1142 | (new_active->link == BOND_LINK_UP) && | ||
1143 | IS_UP(new_active->dev)) { | ||
1144 | printk(KERN_INFO DRV_NAME | ||
1145 | ": %s: Setting %s as active slave.\n", | ||
1146 | bond->dev->name, slave->dev->name); | ||
1147 | bond_change_active_slave(bond, new_active); | ||
1148 | } | ||
1149 | else { | ||
1150 | printk(KERN_INFO DRV_NAME | ||
1151 | ": %s: Could not set %s as active slave; " | ||
1152 | "either %s is down or the link is down.\n", | ||
1153 | bond->dev->name, slave->dev->name, | ||
1154 | slave->dev->name); | ||
1155 | } | ||
1156 | goto out; | ||
1157 | } | ||
1158 | } | ||
1159 | } | ||
1160 | |||
1161 | /* if we got here, then we didn't match the name of any slave */ | ||
1162 | |||
1163 | if (strlen(buf) == 0 || buf[0] == '\n') { | ||
1164 | printk(KERN_INFO DRV_NAME | ||
1165 | ": %s: Setting active slave to None.\n", | ||
1166 | bond->dev->name); | ||
1167 | bond->primary_slave = 0; | ||
1168 | bond_select_active_slave(bond); | ||
1169 | } else { | ||
1170 | printk(KERN_INFO DRV_NAME | ||
1171 | ": %s: Unable to set %.*s as active slave as it is not a slave.\n", | ||
1172 | bond->dev->name, (int)strlen(buf) - 1, buf); | ||
1173 | } | ||
1174 | } | ||
1175 | out: | ||
1176 | write_unlock_bh(&bond->lock); | ||
1177 | return count; | ||
1178 | |||
1179 | } | ||
1180 | static CLASS_DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); | ||
1181 | |||
1182 | |||
1183 | /* | ||
1184 | * Show link status of the bond interface. | ||
1185 | */ | ||
1186 | static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf) | ||
1187 | { | ||
1188 | struct slave *curr; | ||
1189 | struct bonding *bond = to_bond(cd); | ||
1190 | |||
1191 | read_lock(&bond->curr_slave_lock); | ||
1192 | curr = bond->curr_active_slave; | ||
1193 | read_unlock(&bond->curr_slave_lock); | ||
1194 | |||
1195 | return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1; | ||
1196 | } | ||
1197 | static CLASS_DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); | ||
1198 | |||
1199 | |||
1200 | /* | ||
1201 | * Show current 802.3ad aggregator ID. | ||
1202 | */ | ||
1203 | static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf) | ||
1204 | { | ||
1205 | int count = 0; | ||
1206 | struct bonding *bond = to_bond(cd); | ||
1207 | |||
1208 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1209 | struct ad_info ad_info; | ||
1210 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id) + 1; | ||
1211 | } | ||
1212 | else | ||
1213 | count = sprintf(buf, "\n") + 1; | ||
1214 | |||
1215 | return count; | ||
1216 | } | ||
1217 | static CLASS_DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); | ||
1218 | |||
1219 | |||
1220 | /* | ||
1221 | * Show number of active 802.3ad ports. | ||
1222 | */ | ||
1223 | static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf) | ||
1224 | { | ||
1225 | int count = 0; | ||
1226 | struct bonding *bond = to_bond(cd); | ||
1227 | |||
1228 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1229 | struct ad_info ad_info; | ||
1230 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports) + 1; | ||
1231 | } | ||
1232 | else | ||
1233 | count = sprintf(buf, "\n") + 1; | ||
1234 | |||
1235 | return count; | ||
1236 | } | ||
1237 | static CLASS_DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); | ||
1238 | |||
1239 | |||
1240 | /* | ||
1241 | * Show current 802.3ad actor key. | ||
1242 | */ | ||
1243 | static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf) | ||
1244 | { | ||
1245 | int count = 0; | ||
1246 | struct bonding *bond = to_bond(cd); | ||
1247 | |||
1248 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1249 | struct ad_info ad_info; | ||
1250 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key) + 1; | ||
1251 | } | ||
1252 | else | ||
1253 | count = sprintf(buf, "\n") + 1; | ||
1254 | |||
1255 | return count; | ||
1256 | } | ||
1257 | static CLASS_DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); | ||
1258 | |||
1259 | |||
1260 | /* | ||
1261 | * Show current 802.3ad partner key. | ||
1262 | */ | ||
1263 | static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf) | ||
1264 | { | ||
1265 | int count = 0; | ||
1266 | struct bonding *bond = to_bond(cd); | ||
1267 | |||
1268 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1269 | struct ad_info ad_info; | ||
1270 | count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key) + 1; | ||
1271 | } | ||
1272 | else | ||
1273 | count = sprintf(buf, "\n") + 1; | ||
1274 | |||
1275 | return count; | ||
1276 | } | ||
1277 | static CLASS_DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); | ||
1278 | |||
1279 | |||
1280 | /* | ||
1281 | * Show current 802.3ad partner mac. | ||
1282 | */ | ||
1283 | static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf) | ||
1284 | { | ||
1285 | int count = 0; | ||
1286 | struct bonding *bond = to_bond(cd); | ||
1287 | |||
1288 | if (bond->params.mode == BOND_MODE_8023AD) { | ||
1289 | struct ad_info ad_info; | ||
1290 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { | ||
1291 | count = sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x\n", | ||
1292 | ad_info.partner_system[0], | ||
1293 | ad_info.partner_system[1], | ||
1294 | ad_info.partner_system[2], | ||
1295 | ad_info.partner_system[3], | ||
1296 | ad_info.partner_system[4], | ||
1297 | ad_info.partner_system[5]) + 1; | ||
1298 | } | ||
1299 | } | ||
1300 | else | ||
1301 | count = sprintf(buf, "\n") + 1; | ||
1302 | |||
1303 | return count; | ||
1304 | } | ||
1305 | static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); | ||
1306 | |||
1307 | |||
1308 | |||
1309 | static struct attribute *per_bond_attrs[] = { | ||
1310 | &class_device_attr_slaves.attr, | ||
1311 | &class_device_attr_mode.attr, | ||
1312 | &class_device_attr_arp_interval.attr, | ||
1313 | &class_device_attr_arp_ip_target.attr, | ||
1314 | &class_device_attr_downdelay.attr, | ||
1315 | &class_device_attr_updelay.attr, | ||
1316 | &class_device_attr_lacp_rate.attr, | ||
1317 | &class_device_attr_xmit_hash_policy.attr, | ||
1318 | &class_device_attr_miimon.attr, | ||
1319 | &class_device_attr_primary.attr, | ||
1320 | &class_device_attr_use_carrier.attr, | ||
1321 | &class_device_attr_active_slave.attr, | ||
1322 | &class_device_attr_mii_status.attr, | ||
1323 | &class_device_attr_ad_aggregator.attr, | ||
1324 | &class_device_attr_ad_num_ports.attr, | ||
1325 | &class_device_attr_ad_actor_key.attr, | ||
1326 | &class_device_attr_ad_partner_key.attr, | ||
1327 | &class_device_attr_ad_partner_mac.attr, | ||
1328 | NULL, | ||
1329 | }; | ||
1330 | |||
1331 | static struct attribute_group bonding_group = { | ||
1332 | .name = "bonding", | ||
1333 | .attrs = per_bond_attrs, | ||
1334 | }; | ||
1335 | |||
1336 | /* | ||
1337 | * Initialize sysfs. This sets up the bonding_masters file in | ||
1338 | * /sys/class/net. | ||
1339 | */ | ||
1340 | int bond_create_sysfs(void) | ||
1341 | { | ||
1342 | int ret = 0; | ||
1343 | struct bonding *firstbond; | ||
1344 | |||
1345 | init_rwsem(&bonding_rwsem); | ||
1346 | |||
1347 | /* get the netdev class pointer */ | ||
1348 | firstbond = container_of(bond_dev_list.next, struct bonding, bond_list); | ||
1349 | if (!firstbond) | ||
1350 | return -ENODEV; | ||
1351 | |||
1352 | netdev_class = firstbond->dev->class_dev.class; | ||
1353 | if (!netdev_class) | ||
1354 | return -ENODEV; | ||
1355 | |||
1356 | ret = class_create_file(netdev_class, &class_attr_bonding_masters); | ||
1357 | |||
1358 | return ret; | ||
1359 | |||
1360 | } | ||
1361 | |||
1362 | /* | ||
1363 | * Remove /sys/class/net/bonding_masters. | ||
1364 | */ | ||
1365 | void bond_destroy_sysfs(void) | ||
1366 | { | ||
1367 | if (netdev_class) | ||
1368 | class_remove_file(netdev_class, &class_attr_bonding_masters); | ||
1369 | } | ||
1370 | |||
1371 | /* | ||
1372 | * Initialize sysfs for each bond. This sets up and registers | ||
1373 | * the 'bondctl' directory for each individual bond under /sys/class/net. | ||
1374 | */ | ||
1375 | int bond_create_sysfs_entry(struct bonding *bond) | ||
1376 | { | ||
1377 | struct net_device *dev = bond->dev; | ||
1378 | int err; | ||
1379 | |||
1380 | err = sysfs_create_group(&(dev->class_dev.kobj), &bonding_group); | ||
1381 | if (err) { | ||
1382 | printk(KERN_EMERG "eek! didn't create group!\n"); | ||
1383 | } | ||
1384 | |||
1385 | if (expected_refcount < 1) | ||
1386 | expected_refcount = atomic_read(&bond->dev->class_dev.kobj.kref.refcount); | ||
1387 | |||
1388 | return err; | ||
1389 | } | ||
1390 | /* | ||
1391 | * Remove sysfs entries for each bond. | ||
1392 | */ | ||
1393 | void bond_destroy_sysfs_entry(struct bonding *bond) | ||
1394 | { | ||
1395 | struct net_device *dev = bond->dev; | ||
1396 | |||
1397 | sysfs_remove_group(&(dev->class_dev.kobj), &bonding_group); | ||
1398 | } | ||
1399 | |||
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 1433e91db0f7..d6d085480f21 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -29,6 +29,10 @@ | |||
29 | * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov> | 29 | * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov> |
30 | * - added "xmit_policy" kernel parameter for alternate hashing policy | 30 | * - added "xmit_policy" kernel parameter for alternate hashing policy |
31 | * support for mode 2 | 31 | * support for mode 2 |
32 | * | ||
33 | * 2005/09/27 - Mitch Williams <mitch.a.williams at intel dot com> | ||
34 | * Radheka Godse <radheka.godse at intel dot com> | ||
35 | * - Added bonding sysfs interface | ||
32 | */ | 36 | */ |
33 | 37 | ||
34 | #ifndef _LINUX_BONDING_H | 38 | #ifndef _LINUX_BONDING_H |
@@ -37,11 +41,12 @@ | |||
37 | #include <linux/timer.h> | 41 | #include <linux/timer.h> |
38 | #include <linux/proc_fs.h> | 42 | #include <linux/proc_fs.h> |
39 | #include <linux/if_bonding.h> | 43 | #include <linux/if_bonding.h> |
44 | #include <linux/kobject.h> | ||
40 | #include "bond_3ad.h" | 45 | #include "bond_3ad.h" |
41 | #include "bond_alb.h" | 46 | #include "bond_alb.h" |
42 | 47 | ||
43 | #define DRV_VERSION "2.6.5" | 48 | #define DRV_VERSION "3.0.0" |
44 | #define DRV_RELDATE "November 4, 2005" | 49 | #define DRV_RELDATE "November 8, 2005" |
45 | #define DRV_NAME "bonding" | 50 | #define DRV_NAME "bonding" |
46 | #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" | 51 | #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" |
47 | 52 | ||
@@ -152,6 +157,11 @@ struct bond_params { | |||
152 | u32 arp_targets[BOND_MAX_ARP_TARGETS]; | 157 | u32 arp_targets[BOND_MAX_ARP_TARGETS]; |
153 | }; | 158 | }; |
154 | 159 | ||
160 | struct bond_parm_tbl { | ||
161 | char *modename; | ||
162 | int mode; | ||
163 | }; | ||
164 | |||
155 | struct vlan_entry { | 165 | struct vlan_entry { |
156 | struct list_head vlan_list; | 166 | struct list_head vlan_list; |
157 | u32 vlan_ip; | 167 | u32 vlan_ip; |
@@ -159,7 +169,7 @@ struct vlan_entry { | |||
159 | }; | 169 | }; |
160 | 170 | ||
161 | struct slave { | 171 | struct slave { |
162 | struct net_device *dev; /* first - usefull for panic debug */ | 172 | struct net_device *dev; /* first - useful for panic debug */ |
163 | struct slave *next; | 173 | struct slave *next; |
164 | struct slave *prev; | 174 | struct slave *prev; |
165 | s16 delay; | 175 | s16 delay; |
@@ -185,7 +195,7 @@ struct slave { | |||
185 | * beforehand. | 195 | * beforehand. |
186 | */ | 196 | */ |
187 | struct bonding { | 197 | struct bonding { |
188 | struct net_device *dev; /* first - usefull for panic debug */ | 198 | struct net_device *dev; /* first - useful for panic debug */ |
189 | struct slave *first_slave; | 199 | struct slave *first_slave; |
190 | struct slave *curr_active_slave; | 200 | struct slave *curr_active_slave; |
191 | struct slave *current_arp_slave; | 201 | struct slave *current_arp_slave; |
@@ -255,6 +265,25 @@ extern inline void bond_set_slave_active_flags(struct slave *slave) | |||
255 | 265 | ||
256 | struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); | 266 | 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); | 267 | int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); |
268 | int bond_create(char *name, struct bond_params *params, struct bonding **newbond); | ||
269 | void bond_deinit(struct net_device *bond_dev); | ||
270 | int bond_create_sysfs(void); | ||
271 | void bond_destroy_sysfs(void); | ||
272 | void bond_destroy_sysfs_entry(struct bonding *bond); | ||
273 | int bond_create_sysfs_entry(struct bonding *bond); | ||
274 | int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave); | ||
275 | void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); | ||
276 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); | ||
277 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); | ||
278 | int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev); | ||
279 | void bond_mii_monitor(struct net_device *bond_dev); | ||
280 | void bond_loadbalance_arp_mon(struct net_device *bond_dev); | ||
281 | void bond_activebackup_arp_mon(struct net_device *bond_dev); | ||
282 | void bond_set_mode_ops(struct bonding *bond, int mode); | ||
283 | int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl); | ||
284 | const char *bond_mode_name(int mode); | ||
285 | void bond_select_active_slave(struct bonding *bond); | ||
286 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); | ||
258 | 287 | ||
259 | #endif /* _LINUX_BONDING_H */ | 288 | #endif /* _LINUX_BONDING_H */ |
260 | 289 | ||
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 97bbca6b2960..07e114d48bbb 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -684,6 +684,7 @@ extern int netif_rx(struct sk_buff *skb); | |||
684 | extern int netif_rx_ni(struct sk_buff *skb); | 684 | extern int netif_rx_ni(struct sk_buff *skb); |
685 | #define HAVE_NETIF_RECEIVE_SKB 1 | 685 | #define HAVE_NETIF_RECEIVE_SKB 1 |
686 | extern int netif_receive_skb(struct sk_buff *skb); | 686 | extern int netif_receive_skb(struct sk_buff *skb); |
687 | extern int dev_valid_name(const char *name); | ||
687 | extern int dev_ioctl(unsigned int cmd, void __user *); | 688 | extern int dev_ioctl(unsigned int cmd, void __user *); |
688 | extern int dev_ethtool(struct ifreq *); | 689 | extern int dev_ethtool(struct ifreq *); |
689 | extern unsigned dev_get_flags(const struct net_device *); | 690 | extern unsigned dev_get_flags(const struct net_device *); |
diff --git a/net/core/dev.c b/net/core/dev.c index 0b48e294aafe..94e642ee6e2b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -626,7 +626,7 @@ struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mas | |||
626 | * Network device names need to be valid file names to | 626 | * Network device names need to be valid file names to |
627 | * to allow sysfs to work | 627 | * to allow sysfs to work |
628 | */ | 628 | */ |
629 | static int dev_valid_name(const char *name) | 629 | int dev_valid_name(const char *name) |
630 | { | 630 | { |
631 | return !(*name == '\0' | 631 | return !(*name == '\0' |
632 | || !strcmp(name, ".") | 632 | || !strcmp(name, ".") |
@@ -3269,6 +3269,7 @@ EXPORT_SYMBOL(__dev_get_by_index); | |||
3269 | EXPORT_SYMBOL(__dev_get_by_name); | 3269 | EXPORT_SYMBOL(__dev_get_by_name); |
3270 | EXPORT_SYMBOL(__dev_remove_pack); | 3270 | EXPORT_SYMBOL(__dev_remove_pack); |
3271 | EXPORT_SYMBOL(__skb_linearize); | 3271 | EXPORT_SYMBOL(__skb_linearize); |
3272 | EXPORT_SYMBOL(dev_valid_name); | ||
3272 | EXPORT_SYMBOL(dev_add_pack); | 3273 | EXPORT_SYMBOL(dev_add_pack); |
3273 | EXPORT_SYMBOL(dev_alloc_name); | 3274 | EXPORT_SYMBOL(dev_alloc_name); |
3274 | EXPORT_SYMBOL(dev_close); | 3275 | EXPORT_SYMBOL(dev_close); |
diff --git a/net/core/utils.c b/net/core/utils.c index 7b5970fc9e40..587eb7787deb 100644 --- a/net/core/utils.c +++ b/net/core/utils.c | |||
@@ -175,7 +175,7 @@ __u32 in_aton(const char *str) | |||
175 | if (*str != '\0') | 175 | if (*str != '\0') |
176 | { | 176 | { |
177 | val = 0; | 177 | val = 0; |
178 | while (*str != '\0' && *str != '.') | 178 | while (*str != '\0' && *str != '.' && *str != '\n') |
179 | { | 179 | { |
180 | val *= 10; | 180 | val *= 10; |
181 | val += *str - '0'; | 181 | val += *str - '0'; |