aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_3ad.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bond_3ad.c')
-rw-r--r--drivers/net/bonding/bond_3ad.c294
1 files changed, 154 insertions, 140 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index c3fa31c9f2a7..822f586d72af 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -20,6 +20,8 @@
20 * 20 *
21 */ 21 */
22 22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
23#include <linux/skbuff.h> 25#include <linux/skbuff.h>
24#include <linux/if_ether.h> 26#include <linux/if_ether.h>
25#include <linux/netdevice.h> 27#include <linux/netdevice.h>
@@ -352,7 +354,8 @@ static u16 __get_link_speed(struct port *port)
352 } 354 }
353 } 355 }
354 356
355 pr_debug("Port %d Received link speed %d update from adapter\n", port->actor_port_number, speed); 357 pr_debug("Port %d Received link speed %d update from adapter\n",
358 port->actor_port_number, speed);
356 return speed; 359 return speed;
357} 360}
358 361
@@ -378,12 +381,14 @@ static u8 __get_duplex(struct port *port)
378 switch (slave->duplex) { 381 switch (slave->duplex) {
379 case DUPLEX_FULL: 382 case DUPLEX_FULL:
380 retval=0x1; 383 retval=0x1;
381 pr_debug("Port %d Received status full duplex update from adapter\n", port->actor_port_number); 384 pr_debug("Port %d Received status full duplex update from adapter\n",
385 port->actor_port_number);
382 break; 386 break;
383 case DUPLEX_HALF: 387 case DUPLEX_HALF:
384 default: 388 default:
385 retval=0x0; 389 retval=0x0;
386 pr_debug("Port %d Received status NOT full duplex update from adapter\n", port->actor_port_number); 390 pr_debug("Port %d Received status NOT full duplex update from adapter\n",
391 port->actor_port_number);
387 break; 392 break;
388 } 393 }
389 } 394 }
@@ -446,6 +451,48 @@ static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
446///////////////////////////////////////////////////////////////////////////////// 451/////////////////////////////////////////////////////////////////////////////////
447 452
448/** 453/**
454 * __choose_matched - update a port's matched variable from a received lacpdu
455 * @lacpdu: the lacpdu we've received
456 * @port: the port we're looking at
457 *
458 * Update the value of the matched variable, using parameter values from a
459 * newly received lacpdu. Parameter values for the partner carried in the
460 * received PDU are compared with the corresponding operational parameter
461 * values for the actor. Matched is set to TRUE if all of these parameters
462 * match and the PDU parameter partner_state.aggregation has the same value as
463 * actor_oper_port_state.aggregation and lacp will actively maintain the link
464 * in the aggregation. Matched is also set to TRUE if the value of
465 * actor_state.aggregation in the received PDU is set to FALSE, i.e., indicates
466 * an individual link and lacp will actively maintain the link. Otherwise,
467 * matched is set to FALSE. LACP is considered to be actively maintaining the
468 * link if either the PDU's actor_state.lacp_activity variable is TRUE or both
469 * the actor's actor_oper_port_state.lacp_activity and the PDU's
470 * partner_state.lacp_activity variables are TRUE.
471 *
472 * Note: the AD_PORT_MATCHED "variable" is not specified by 802.3ad; it is
473 * used here to implement the language from 802.3ad 43.4.9 that requires
474 * recordPDU to "match" the LACPDU parameters to the stored values.
475 */
476static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
477{
478 // check if all parameters are alike
479 if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
480 (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
481 !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
482 (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
483 (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
484 ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
485 // or this is individual link(aggregation == FALSE)
486 ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
487 ) {
488 // update the state machine Matched variable
489 port->sm_vars |= AD_PORT_MATCHED;
490 } else {
491 port->sm_vars &= ~AD_PORT_MATCHED;
492 }
493}
494
495/**
449 * __record_pdu - record parameters from a received lacpdu 496 * __record_pdu - record parameters from a received lacpdu
450 * @lacpdu: the lacpdu we've received 497 * @lacpdu: the lacpdu we've received
451 * @port: the port we're looking at 498 * @port: the port we're looking at
@@ -459,6 +506,7 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
459 if (lacpdu && port) { 506 if (lacpdu && port) {
460 struct port_params *partner = &port->partner_oper; 507 struct port_params *partner = &port->partner_oper;
461 508
509 __choose_matched(lacpdu, port);
462 // record the new parameter values for the partner operational 510 // record the new parameter values for the partner operational
463 partner->port_number = ntohs(lacpdu->actor_port); 511 partner->port_number = ntohs(lacpdu->actor_port);
464 partner->port_priority = ntohs(lacpdu->actor_port_priority); 512 partner->port_priority = ntohs(lacpdu->actor_port_priority);
@@ -518,12 +566,12 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port)
518 const struct port_params *partner = &port->partner_oper; 566 const struct port_params *partner = &port->partner_oper;
519 567
520 // check if any parameter is different 568 // check if any parameter is different
521 if (ntohs(lacpdu->actor_port) != partner->port_number 569 if (ntohs(lacpdu->actor_port) != partner->port_number ||
522 || ntohs(lacpdu->actor_port_priority) != partner->port_priority 570 ntohs(lacpdu->actor_port_priority) != partner->port_priority ||
523 || MAC_ADDRESS_COMPARE(&lacpdu->actor_system, &partner->system) 571 MAC_ADDRESS_COMPARE(&lacpdu->actor_system, &partner->system) ||
524 || ntohs(lacpdu->actor_system_priority) != partner->system_priority 572 ntohs(lacpdu->actor_system_priority) != partner->system_priority ||
525 || ntohs(lacpdu->actor_key) != partner->key 573 ntohs(lacpdu->actor_key) != partner->key ||
526 || (lacpdu->actor_state & AD_STATE_AGGREGATION) != (partner->port_state & AD_STATE_AGGREGATION)) { 574 (lacpdu->actor_state & AD_STATE_AGGREGATION) != (partner->port_state & AD_STATE_AGGREGATION)) {
527 // update the state machine Selected variable 575 // update the state machine Selected variable
528 port->sm_vars &= ~AD_PORT_SELECTED; 576 port->sm_vars &= ~AD_PORT_SELECTED;
529 } 577 }
@@ -549,12 +597,12 @@ static void __update_default_selected(struct port *port)
549 const struct port_params *oper = &port->partner_oper; 597 const struct port_params *oper = &port->partner_oper;
550 598
551 // check if any parameter is different 599 // check if any parameter is different
552 if (admin->port_number != oper->port_number 600 if (admin->port_number != oper->port_number ||
553 || admin->port_priority != oper->port_priority 601 admin->port_priority != oper->port_priority ||
554 || MAC_ADDRESS_COMPARE(&admin->system, &oper->system) 602 MAC_ADDRESS_COMPARE(&admin->system, &oper->system) ||
555 || admin->system_priority != oper->system_priority 603 admin->system_priority != oper->system_priority ||
556 || admin->key != oper->key 604 admin->key != oper->key ||
557 || (admin->port_state & AD_STATE_AGGREGATION) 605 (admin->port_state & AD_STATE_AGGREGATION)
558 != (oper->port_state & AD_STATE_AGGREGATION)) { 606 != (oper->port_state & AD_STATE_AGGREGATION)) {
559 // update the state machine Selected variable 607 // update the state machine Selected variable
560 port->sm_vars &= ~AD_PORT_SELECTED; 608 port->sm_vars &= ~AD_PORT_SELECTED;
@@ -563,47 +611,6 @@ static void __update_default_selected(struct port *port)
563} 611}
564 612
565/** 613/**
566 * __choose_matched - update a port's matched variable from a received lacpdu
567 * @lacpdu: the lacpdu we've received
568 * @port: the port we're looking at
569 *
570 * Update the value of the matched variable, using parameter values from a
571 * newly received lacpdu. Parameter values for the partner carried in the
572 * received PDU are compared with the corresponding operational parameter
573 * values for the actor. Matched is set to TRUE if all of these parameters
574 * match and the PDU parameter partner_state.aggregation has the same value as
575 * actor_oper_port_state.aggregation and lacp will actively maintain the link
576 * in the aggregation. Matched is also set to TRUE if the value of
577 * actor_state.aggregation in the received PDU is set to FALSE, i.e., indicates
578 * an individual link and lacp will actively maintain the link. Otherwise,
579 * matched is set to FALSE. LACP is considered to be actively maintaining the
580 * link if either the PDU's actor_state.lacp_activity variable is TRUE or both
581 * the actor's actor_oper_port_state.lacp_activity and the PDU's
582 * partner_state.lacp_activity variables are TRUE.
583 */
584static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
585{
586 // validate lacpdu and port
587 if (lacpdu && port) {
588 // check if all parameters are alike
589 if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
590 (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
591 !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
592 (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
593 (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
594 ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
595 // or this is individual link(aggregation == FALSE)
596 ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
597 ) {
598 // update the state machine Matched variable
599 port->sm_vars |= AD_PORT_MATCHED;
600 } else {
601 port->sm_vars &= ~AD_PORT_MATCHED;
602 }
603 }
604}
605
606/**
607 * __update_ntt - update a port's ntt variable from a received lacpdu 614 * __update_ntt - update a port's ntt variable from a received lacpdu
608 * @lacpdu: the lacpdu we've received 615 * @lacpdu: the lacpdu we've received
609 * @port: the port we're looking at 616 * @port: the port we're looking at
@@ -978,7 +985,9 @@ static void ad_mux_machine(struct port *port)
978 985
979 // check if the state machine was changed 986 // check if the state machine was changed
980 if (port->sm_mux_state != last_state) { 987 if (port->sm_mux_state != last_state) {
981 pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_mux_state); 988 pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n",
989 port->actor_port_number, last_state,
990 port->sm_mux_state);
982 switch (port->sm_mux_state) { 991 switch (port->sm_mux_state) {
983 case AD_MUX_DETACHED: 992 case AD_MUX_DETACHED:
984 __detach_bond_from_agg(port); 993 __detach_bond_from_agg(port);
@@ -1077,7 +1086,9 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1077 1086
1078 // check if the State machine was changed or new lacpdu arrived 1087 // check if the State machine was changed or new lacpdu arrived
1079 if ((port->sm_rx_state != last_state) || (lacpdu)) { 1088 if ((port->sm_rx_state != last_state) || (lacpdu)) {
1080 pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_rx_state); 1089 pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n",
1090 port->actor_port_number, last_state,
1091 port->sm_rx_state);
1081 switch (port->sm_rx_state) { 1092 switch (port->sm_rx_state) {
1082 case AD_RX_INITIALIZE: 1093 case AD_RX_INITIALIZE:
1083 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) { 1094 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) {
@@ -1124,9 +1135,8 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1124 // detect loopback situation 1135 // detect loopback situation
1125 if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { 1136 if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
1126 // INFO_RECEIVED_LOOPBACK_FRAMES 1137 // INFO_RECEIVED_LOOPBACK_FRAMES
1127 pr_err(DRV_NAME ": %s: An illegal loopback occurred on " 1138 pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
1128 "adapter (%s). Check the configuration to verify that all " 1139 "Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
1129 "Adapters are connected to 802.3ad compliant switch ports\n",
1130 port->slave->dev->master->name, port->slave->dev->name); 1140 port->slave->dev->master->name, port->slave->dev->name);
1131 __release_rx_machine_lock(port); 1141 __release_rx_machine_lock(port);
1132 return; 1142 return;
@@ -1134,7 +1144,6 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1134 __update_selected(lacpdu, port); 1144 __update_selected(lacpdu, port);
1135 __update_ntt(lacpdu, port); 1145 __update_ntt(lacpdu, port);
1136 __record_pdu(lacpdu, port); 1146 __record_pdu(lacpdu, port);
1137 __choose_matched(lacpdu, port);
1138 port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)); 1147 port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT));
1139 port->actor_oper_port_state &= ~AD_STATE_EXPIRED; 1148 port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
1140 // verify that if the aggregator is enabled, the port is enabled too. 1149 // verify that if the aggregator is enabled, the port is enabled too.
@@ -1165,7 +1174,8 @@ static void ad_tx_machine(struct port *port)
1165 __update_lacpdu_from_port(port); 1174 __update_lacpdu_from_port(port);
1166 1175
1167 if (ad_lacpdu_send(port) >= 0) { 1176 if (ad_lacpdu_send(port) >= 0) {
1168 pr_debug("Sent LACPDU on port %d\n", port->actor_port_number); 1177 pr_debug("Sent LACPDU on port %d\n",
1178 port->actor_port_number);
1169 1179
1170 /* mark ntt as false, so it will not be sent again until 1180 /* mark ntt as false, so it will not be sent again until
1171 demanded */ 1181 demanded */
@@ -1240,7 +1250,9 @@ static void ad_periodic_machine(struct port *port)
1240 1250
1241 // check if the state machine was changed 1251 // check if the state machine was changed
1242 if (port->sm_periodic_state != last_state) { 1252 if (port->sm_periodic_state != last_state) {
1243 pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_periodic_state); 1253 pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n",
1254 port->actor_port_number, last_state,
1255 port->sm_periodic_state);
1244 switch (port->sm_periodic_state) { 1256 switch (port->sm_periodic_state) {
1245 case AD_NO_PERIODIC: 1257 case AD_NO_PERIODIC:
1246 port->sm_periodic_timer_counter = 0; // zero timer 1258 port->sm_periodic_timer_counter = 0; // zero timer
@@ -1297,7 +1309,9 @@ static void ad_port_selection_logic(struct port *port)
1297 port->next_port_in_aggregator=NULL; 1309 port->next_port_in_aggregator=NULL;
1298 port->actor_port_aggregator_identifier=0; 1310 port->actor_port_aggregator_identifier=0;
1299 1311
1300 pr_debug("Port %d left LAG %d\n", port->actor_port_number, temp_aggregator->aggregator_identifier); 1312 pr_debug("Port %d left LAG %d\n",
1313 port->actor_port_number,
1314 temp_aggregator->aggregator_identifier);
1301 // if the aggregator is empty, clear its parameters, and set it ready to be attached 1315 // if the aggregator is empty, clear its parameters, and set it ready to be attached
1302 if (!temp_aggregator->lag_ports) { 1316 if (!temp_aggregator->lag_ports) {
1303 ad_clear_agg(temp_aggregator); 1317 ad_clear_agg(temp_aggregator);
@@ -1306,9 +1320,7 @@ static void ad_port_selection_logic(struct port *port)
1306 } 1320 }
1307 } 1321 }
1308 if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list 1322 if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
1309 pr_warning(DRV_NAME ": %s: Warning: Port %d (on %s) " 1323 pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
1310 "was related to aggregator %d but was not "
1311 "on its port list\n",
1312 port->slave->dev->master->name, 1324 port->slave->dev->master->name,
1313 port->actor_port_number, 1325 port->actor_port_number,
1314 port->slave->dev->name, 1326 port->slave->dev->name,
@@ -1342,7 +1354,9 @@ static void ad_port_selection_logic(struct port *port)
1342 port->next_port_in_aggregator=aggregator->lag_ports; 1354 port->next_port_in_aggregator=aggregator->lag_ports;
1343 port->aggregator->num_of_ports++; 1355 port->aggregator->num_of_ports++;
1344 aggregator->lag_ports=port; 1356 aggregator->lag_ports=port;
1345 pr_debug("Port %d joined LAG %d(existing LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1357 pr_debug("Port %d joined LAG %d(existing LAG)\n",
1358 port->actor_port_number,
1359 port->aggregator->aggregator_identifier);
1346 1360
1347 // mark this port as selected 1361 // mark this port as selected
1348 port->sm_vars |= AD_PORT_SELECTED; 1362 port->sm_vars |= AD_PORT_SELECTED;
@@ -1379,10 +1393,11 @@ static void ad_port_selection_logic(struct port *port)
1379 // mark this port as selected 1393 // mark this port as selected
1380 port->sm_vars |= AD_PORT_SELECTED; 1394 port->sm_vars |= AD_PORT_SELECTED;
1381 1395
1382 pr_debug("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1396 pr_debug("Port %d joined LAG %d(new LAG)\n",
1397 port->actor_port_number,
1398 port->aggregator->aggregator_identifier);
1383 } else { 1399 } else {
1384 pr_err(DRV_NAME ": %s: Port %d (on %s) did not find " 1400 pr_err("%s: Port %d (on %s) did not find a suitable aggregator\n",
1385 "a suitable aggregator\n",
1386 port->slave->dev->master->name, 1401 port->slave->dev->master->name,
1387 port->actor_port_number, port->slave->dev->name); 1402 port->actor_port_number, port->slave->dev->name);
1388 } 1403 }
@@ -1459,8 +1474,7 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
1459 break; 1474 break;
1460 1475
1461 default: 1476 default:
1462 pr_warning(DRV_NAME 1477 pr_warning("%s: Impossible agg select mode %d\n",
1463 ": %s: Impossible agg select mode %d\n",
1464 curr->slave->dev->master->name, 1478 curr->slave->dev->master->name,
1465 __get_agg_selection_mode(curr->lag_ports)); 1479 __get_agg_selection_mode(curr->lag_ports));
1466 break; 1480 break;
@@ -1545,40 +1559,38 @@ static void ad_agg_selection_logic(struct aggregator *agg)
1545 // if there is new best aggregator, activate it 1559 // if there is new best aggregator, activate it
1546 if (best) { 1560 if (best) {
1547 pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", 1561 pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1548 best->aggregator_identifier, best->num_of_ports, 1562 best->aggregator_identifier, best->num_of_ports,
1549 best->actor_oper_aggregator_key, 1563 best->actor_oper_aggregator_key,
1550 best->partner_oper_aggregator_key, 1564 best->partner_oper_aggregator_key,
1551 best->is_individual, best->is_active); 1565 best->is_individual, best->is_active);
1552 pr_debug("best ports %p slave %p %s\n", 1566 pr_debug("best ports %p slave %p %s\n",
1553 best->lag_ports, best->slave, 1567 best->lag_ports, best->slave,
1554 best->slave ? best->slave->dev->name : "NULL"); 1568 best->slave ? best->slave->dev->name : "NULL");
1555 1569
1556 for (agg = __get_first_agg(best->lag_ports); agg; 1570 for (agg = __get_first_agg(best->lag_ports); agg;
1557 agg = __get_next_agg(agg)) { 1571 agg = __get_next_agg(agg)) {
1558 1572
1559 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", 1573 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1560 agg->aggregator_identifier, agg->num_of_ports, 1574 agg->aggregator_identifier, agg->num_of_ports,
1561 agg->actor_oper_aggregator_key, 1575 agg->actor_oper_aggregator_key,
1562 agg->partner_oper_aggregator_key, 1576 agg->partner_oper_aggregator_key,
1563 agg->is_individual, agg->is_active); 1577 agg->is_individual, agg->is_active);
1564 } 1578 }
1565 1579
1566 // check if any partner replys 1580 // check if any partner replys
1567 if (best->is_individual) { 1581 if (best->is_individual) {
1568 pr_warning(DRV_NAME ": %s: Warning: No 802.3ad" 1582 pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
1569 " response from the link partner for any" 1583 best->slave ? best->slave->dev->master->name : "NULL");
1570 " adapters in the bond\n",
1571 best->slave->dev->master->name);
1572 } 1584 }
1573 1585
1574 best->is_active = 1; 1586 best->is_active = 1;
1575 pr_debug("LAG %d chosen as the active LAG\n", 1587 pr_debug("LAG %d chosen as the active LAG\n",
1576 best->aggregator_identifier); 1588 best->aggregator_identifier);
1577 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", 1589 pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
1578 best->aggregator_identifier, best->num_of_ports, 1590 best->aggregator_identifier, best->num_of_ports,
1579 best->actor_oper_aggregator_key, 1591 best->actor_oper_aggregator_key,
1580 best->partner_oper_aggregator_key, 1592 best->partner_oper_aggregator_key,
1581 best->is_individual, best->is_active); 1593 best->is_individual, best->is_active);
1582 1594
1583 // disable the ports that were related to the former active_aggregator 1595 // disable the ports that were related to the former active_aggregator
1584 if (active) { 1596 if (active) {
@@ -1632,7 +1644,8 @@ static void ad_clear_agg(struct aggregator *aggregator)
1632 aggregator->lag_ports = NULL; 1644 aggregator->lag_ports = NULL;
1633 aggregator->is_active = 0; 1645 aggregator->is_active = 0;
1634 aggregator->num_of_ports = 0; 1646 aggregator->num_of_ports = 0;
1635 pr_debug("LAG %d was cleared\n", aggregator->aggregator_identifier); 1647 pr_debug("LAG %d was cleared\n",
1648 aggregator->aggregator_identifier);
1636 } 1649 }
1637} 1650}
1638 1651
@@ -1727,7 +1740,9 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
1727static void ad_enable_collecting_distributing(struct port *port) 1740static void ad_enable_collecting_distributing(struct port *port)
1728{ 1741{
1729 if (port->aggregator->is_active) { 1742 if (port->aggregator->is_active) {
1730 pr_debug("Enabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1743 pr_debug("Enabling port %d(LAG %d)\n",
1744 port->actor_port_number,
1745 port->aggregator->aggregator_identifier);
1731 __enable_port(port); 1746 __enable_port(port);
1732 } 1747 }
1733} 1748}
@@ -1740,7 +1755,9 @@ static void ad_enable_collecting_distributing(struct port *port)
1740static void ad_disable_collecting_distributing(struct port *port) 1755static void ad_disable_collecting_distributing(struct port *port)
1741{ 1756{
1742 if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) { 1757 if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
1743 pr_debug("Disabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1758 pr_debug("Disabling port %d(LAG %d)\n",
1759 port->actor_port_number,
1760 port->aggregator->aggregator_identifier);
1744 __disable_port(port); 1761 __disable_port(port);
1745 } 1762 }
1746} 1763}
@@ -1778,7 +1795,8 @@ static void ad_marker_info_send(struct port *port)
1778 1795
1779 // send the marker information 1796 // send the marker information
1780 if (ad_marker_send(port, &marker) >= 0) { 1797 if (ad_marker_send(port, &marker) >= 0) {
1781 pr_debug("Sent Marker Information on port %d\n", port->actor_port_number); 1798 pr_debug("Sent Marker Information on port %d\n",
1799 port->actor_port_number);
1782 } 1800 }
1783} 1801}
1784#endif 1802#endif
@@ -1802,7 +1820,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
1802 // send the marker response 1820 // send the marker response
1803 1821
1804 if (ad_marker_send(port, &marker) >= 0) { 1822 if (ad_marker_send(port, &marker) >= 0) {
1805 pr_debug("Sent Marker Response on port %d\n", port->actor_port_number); 1823 pr_debug("Sent Marker Response on port %d\n",
1824 port->actor_port_number);
1806 } 1825 }
1807} 1826}
1808 1827
@@ -1888,8 +1907,7 @@ int bond_3ad_bind_slave(struct slave *slave)
1888 struct aggregator *aggregator; 1907 struct aggregator *aggregator;
1889 1908
1890 if (bond == NULL) { 1909 if (bond == NULL) {
1891 pr_err(DRV_NAME ": %s: The slave %s is not attached to " 1910 pr_err("%s: The slave %s is not attached to its bond\n",
1892 "its bond\n",
1893 slave->dev->master->name, slave->dev->name); 1911 slave->dev->master->name, slave->dev->name);
1894 return -1; 1912 return -1;
1895 } 1913 }
@@ -1956,7 +1974,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
1956 struct port *port, *prev_port, *temp_port; 1974 struct port *port, *prev_port, *temp_port;
1957 struct aggregator *aggregator, *new_aggregator, *temp_aggregator; 1975 struct aggregator *aggregator, *new_aggregator, *temp_aggregator;
1958 int select_new_active_agg = 0; 1976 int select_new_active_agg = 0;
1959 1977
1960 // find the aggregator related to this slave 1978 // find the aggregator related to this slave
1961 aggregator = &(SLAVE_AD_INFO(slave).aggregator); 1979 aggregator = &(SLAVE_AD_INFO(slave).aggregator);
1962 1980
@@ -1965,13 +1983,13 @@ void bond_3ad_unbind_slave(struct slave *slave)
1965 1983
1966 // if slave is null, the whole port is not initialized 1984 // if slave is null, the whole port is not initialized
1967 if (!port->slave) { 1985 if (!port->slave) {
1968 pr_warning(DRV_NAME ": Warning: %s: Trying to " 1986 pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
1969 "unbind an uninitialized port on %s\n",
1970 slave->dev->master->name, slave->dev->name); 1987 slave->dev->master->name, slave->dev->name);
1971 return; 1988 return;
1972 } 1989 }
1973 1990
1974 pr_debug("Unbinding Link Aggregation Group %d\n", aggregator->aggregator_identifier); 1991 pr_debug("Unbinding Link Aggregation Group %d\n",
1992 aggregator->aggregator_identifier);
1975 1993
1976 /* Tell the partner that this port is not suitable for aggregation */ 1994 /* Tell the partner that this port is not suitable for aggregation */
1977 port->actor_oper_port_state &= ~AD_STATE_AGGREGATION; 1995 port->actor_oper_port_state &= ~AD_STATE_AGGREGATION;
@@ -1995,10 +2013,12 @@ void bond_3ad_unbind_slave(struct slave *slave)
1995 // if new aggregator found, copy the aggregator's parameters 2013 // if new aggregator found, copy the aggregator's parameters
1996 // and connect the related lag_ports to the new aggregator 2014 // and connect the related lag_ports to the new aggregator
1997 if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) { 2015 if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) {
1998 pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier); 2016 pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n",
2017 aggregator->aggregator_identifier,
2018 new_aggregator->aggregator_identifier);
1999 2019
2000 if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { 2020 if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
2001 pr_info(DRV_NAME ": %s: Removing an active aggregator\n", 2021 pr_info("%s: Removing an active aggregator\n",
2002 aggregator->slave->dev->master->name); 2022 aggregator->slave->dev->master->name);
2003 // select new active aggregator 2023 // select new active aggregator
2004 select_new_active_agg = 1; 2024 select_new_active_agg = 1;
@@ -2024,13 +2044,12 @@ void bond_3ad_unbind_slave(struct slave *slave)
2024 2044
2025 // clear the aggregator 2045 // clear the aggregator
2026 ad_clear_agg(aggregator); 2046 ad_clear_agg(aggregator);
2027 2047
2028 if (select_new_active_agg) { 2048 if (select_new_active_agg) {
2029 ad_agg_selection_logic(__get_first_agg(port)); 2049 ad_agg_selection_logic(__get_first_agg(port));
2030 } 2050 }
2031 } else { 2051 } else {
2032 pr_warning(DRV_NAME ": %s: Warning: unbinding aggregator, " 2052 pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
2033 "and could not find a new aggregator for its ports\n",
2034 slave->dev->master->name); 2053 slave->dev->master->name);
2035 } 2054 }
2036 } else { // in case that the only port related to this aggregator is the one we want to remove 2055 } else { // in case that the only port related to this aggregator is the one we want to remove
@@ -2038,7 +2057,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
2038 // clear the aggregator 2057 // clear the aggregator
2039 ad_clear_agg(aggregator); 2058 ad_clear_agg(aggregator);
2040 if (select_new_active_agg) { 2059 if (select_new_active_agg) {
2041 pr_info(DRV_NAME ": %s: Removing an active aggregator\n", 2060 pr_info("%s: Removing an active aggregator\n",
2042 slave->dev->master->name); 2061 slave->dev->master->name);
2043 // select new active aggregator 2062 // select new active aggregator
2044 ad_agg_selection_logic(__get_first_agg(port)); 2063 ad_agg_selection_logic(__get_first_agg(port));
@@ -2065,7 +2084,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
2065 // clear the aggregator 2084 // clear the aggregator
2066 ad_clear_agg(temp_aggregator); 2085 ad_clear_agg(temp_aggregator);
2067 if (select_new_active_agg) { 2086 if (select_new_active_agg) {
2068 pr_info(DRV_NAME ": %s: Removing an active aggregator\n", 2087 pr_info("%s: Removing an active aggregator\n",
2069 slave->dev->master->name); 2088 slave->dev->master->name);
2070 // select new active aggregator 2089 // select new active aggregator
2071 ad_agg_selection_logic(__get_first_agg(port)); 2090 ad_agg_selection_logic(__get_first_agg(port));
@@ -2075,7 +2094,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
2075 } 2094 }
2076 } 2095 }
2077 } 2096 }
2078 port->slave=NULL; 2097 port->slave=NULL;
2079} 2098}
2080 2099
2081/** 2100/**
@@ -2114,8 +2133,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
2114 // select the active aggregator for the bond 2133 // select the active aggregator for the bond
2115 if ((port = __get_first_port(bond))) { 2134 if ((port = __get_first_port(bond))) {
2116 if (!port->slave) { 2135 if (!port->slave) {
2117 pr_warning(DRV_NAME ": %s: Warning: bond's first port is " 2136 pr_warning("%s: Warning: bond's first port is uninitialized\n",
2118 "uninitialized\n", bond->dev->name); 2137 bond->dev->name);
2119 goto re_arm; 2138 goto re_arm;
2120 } 2139 }
2121 2140
@@ -2128,8 +2147,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
2128 // for each port run the state machines 2147 // for each port run the state machines
2129 for (port = __get_first_port(bond); port; port = __get_next_port(port)) { 2148 for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
2130 if (!port->slave) { 2149 if (!port->slave) {
2131 pr_warning(DRV_NAME ": %s: Warning: Found an uninitialized " 2150 pr_warning("%s: Warning: Found an uninitialized port\n",
2132 "port\n", bond->dev->name); 2151 bond->dev->name);
2133 goto re_arm; 2152 goto re_arm;
2134 } 2153 }
2135 2154
@@ -2170,15 +2189,15 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
2170 port = &(SLAVE_AD_INFO(slave).port); 2189 port = &(SLAVE_AD_INFO(slave).port);
2171 2190
2172 if (!port->slave) { 2191 if (!port->slave) {
2173 pr_warning(DRV_NAME ": %s: Warning: port of slave %s " 2192 pr_warning("%s: Warning: port of slave %s is uninitialized\n",
2174 "is uninitialized\n",
2175 slave->dev->name, slave->dev->master->name); 2193 slave->dev->name, slave->dev->master->name);
2176 return; 2194 return;
2177 } 2195 }
2178 2196
2179 switch (lacpdu->subtype) { 2197 switch (lacpdu->subtype) {
2180 case AD_TYPE_LACPDU: 2198 case AD_TYPE_LACPDU:
2181 pr_debug("Received LACPDU on port %d\n", port->actor_port_number); 2199 pr_debug("Received LACPDU on port %d\n",
2200 port->actor_port_number);
2182 ad_rx_machine(lacpdu, port); 2201 ad_rx_machine(lacpdu, port);
2183 break; 2202 break;
2184 2203
@@ -2187,17 +2206,20 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
2187 2206
2188 switch (((struct bond_marker *)lacpdu)->tlv_type) { 2207 switch (((struct bond_marker *)lacpdu)->tlv_type) {
2189 case AD_MARKER_INFORMATION_SUBTYPE: 2208 case AD_MARKER_INFORMATION_SUBTYPE:
2190 pr_debug("Received Marker Information on port %d\n", port->actor_port_number); 2209 pr_debug("Received Marker Information on port %d\n",
2210 port->actor_port_number);
2191 ad_marker_info_received((struct bond_marker *)lacpdu, port); 2211 ad_marker_info_received((struct bond_marker *)lacpdu, port);
2192 break; 2212 break;
2193 2213
2194 case AD_MARKER_RESPONSE_SUBTYPE: 2214 case AD_MARKER_RESPONSE_SUBTYPE:
2195 pr_debug("Received Marker Response on port %d\n", port->actor_port_number); 2215 pr_debug("Received Marker Response on port %d\n",
2216 port->actor_port_number);
2196 ad_marker_response_received((struct bond_marker *)lacpdu, port); 2217 ad_marker_response_received((struct bond_marker *)lacpdu, port);
2197 break; 2218 break;
2198 2219
2199 default: 2220 default:
2200 pr_debug("Received an unknown Marker subtype on slot %d\n", port->actor_port_number); 2221 pr_debug("Received an unknown Marker subtype on slot %d\n",
2222 port->actor_port_number);
2201 } 2223 }
2202 } 2224 }
2203 } 2225 }
@@ -2217,8 +2239,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
2217 2239
2218 // if slave is null, the whole port is not initialized 2240 // if slave is null, the whole port is not initialized
2219 if (!port->slave) { 2241 if (!port->slave) {
2220 pr_warning(DRV_NAME ": Warning: %s: speed " 2242 pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
2221 "changed for uninitialized port on %s\n",
2222 slave->dev->master->name, slave->dev->name); 2243 slave->dev->master->name, slave->dev->name);
2223 return; 2244 return;
2224 } 2245 }
@@ -2245,8 +2266,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
2245 2266
2246 // if slave is null, the whole port is not initialized 2267 // if slave is null, the whole port is not initialized
2247 if (!port->slave) { 2268 if (!port->slave) {
2248 pr_warning(DRV_NAME ": %s: Warning: duplex changed " 2269 pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
2249 "for uninitialized port on %s\n",
2250 slave->dev->master->name, slave->dev->name); 2270 slave->dev->master->name, slave->dev->name);
2251 return; 2271 return;
2252 } 2272 }
@@ -2274,8 +2294,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
2274 2294
2275 // if slave is null, the whole port is not initialized 2295 // if slave is null, the whole port is not initialized
2276 if (!port->slave) { 2296 if (!port->slave) {
2277 pr_warning(DRV_NAME ": Warning: %s: link status changed for " 2297 pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
2278 "uninitialized port on %s\n",
2279 slave->dev->master->name, slave->dev->name); 2298 slave->dev->master->name, slave->dev->name);
2280 return; 2299 return;
2281 } 2300 }
@@ -2301,7 +2320,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
2301} 2320}
2302 2321
2303/* 2322/*
2304 * set link state for bonding master: if we have an active 2323 * set link state for bonding master: if we have an active
2305 * aggregator, we're up, if not, we're down. Presumes that we cannot 2324 * aggregator, we're up, if not, we're down. Presumes that we cannot
2306 * have an active aggregator if there are no slaves with link up. 2325 * have an active aggregator if there are no slaves with link up.
2307 * 2326 *
@@ -2380,8 +2399,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2380 } 2399 }
2381 2400
2382 if (bond_3ad_get_active_agg_info(bond, &ad_info)) { 2401 if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
2383 pr_debug(DRV_NAME ": %s: Error: " 2402 pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n",
2384 "bond_3ad_get_active_agg_info failed\n", dev->name); 2403 dev->name);
2385 goto out; 2404 goto out;
2386 } 2405 }
2387 2406
@@ -2390,12 +2409,11 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2390 2409
2391 if (slaves_in_agg == 0) { 2410 if (slaves_in_agg == 0) {
2392 /*the aggregator is empty*/ 2411 /*the aggregator is empty*/
2393 pr_debug(DRV_NAME ": %s: Error: active aggregator is empty\n", 2412 pr_debug("%s: Error: active aggregator is empty\n", dev->name);
2394 dev->name);
2395 goto out; 2413 goto out;
2396 } 2414 }
2397 2415
2398 slave_agg_no = bond->xmit_hash_policy(skb, dev, slaves_in_agg); 2416 slave_agg_no = bond->xmit_hash_policy(skb, slaves_in_agg);
2399 2417
2400 bond_for_each_slave(bond, slave, i) { 2418 bond_for_each_slave(bond, slave, i) {
2401 struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator; 2419 struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
@@ -2409,8 +2427,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2409 } 2427 }
2410 2428
2411 if (slave_agg_no >= 0) { 2429 if (slave_agg_no >= 0) {
2412 pr_err(DRV_NAME ": %s: Error: Couldn't find a slave to tx on " 2430 pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
2413 "for aggregator ID %d\n", dev->name, agg_id); 2431 dev->name, agg_id);
2414 goto out; 2432 goto out;
2415 } 2433 }
2416 2434
@@ -2445,9 +2463,6 @@ int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct pac
2445 struct slave *slave = NULL; 2463 struct slave *slave = NULL;
2446 int ret = NET_RX_DROP; 2464 int ret = NET_RX_DROP;
2447 2465
2448 if (dev_net(dev) != &init_net)
2449 goto out;
2450
2451 if (!(dev->flags & IFF_MASTER)) 2466 if (!(dev->flags & IFF_MASTER))
2452 goto out; 2467 goto out;
2453 2468
@@ -2468,4 +2483,3 @@ out:
2468 2483
2469 return ret; 2484 return ret;
2470} 2485}
2471