diff options
author | Jay Vosburgh <fubar@us.ibm.com> | 2006-09-23 00:55:32 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-09-25 20:08:09 -0400 |
commit | 89cc76f95af3608d83a1d70b3c76b71ffe66e1f7 (patch) | |
tree | a2d0c16ffd5850087885287eab98d0f0feb9e6a6 /drivers | |
parent | f5b2b966f032f22d3a289045a5afd4afa09f09c6 (diff) |
[PATCH] bonding: Don't mangle LACPDUs
Fixed handling of 802.3ad LACPDUs. Do not byte swap data in
place in the packet. Updated nomenclature of "__ntohs_lacpdu" to be
"htons"; it was previously used for both ntohs and htons operations, but
only called ntohs functions.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index c24b20aaf57f..3fb354d9c515 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -100,7 +100,7 @@ static u16 __get_link_speed(struct port *port); | |||
100 | static u8 __get_duplex(struct port *port); | 100 | static u8 __get_duplex(struct port *port); |
101 | static inline void __initialize_port_locks(struct port *port); | 101 | static inline void __initialize_port_locks(struct port *port); |
102 | //conversions | 102 | //conversions |
103 | static void __ntohs_lacpdu(struct lacpdu *lacpdu); | 103 | static void __htons_lacpdu(struct lacpdu *lacpdu); |
104 | static u16 __ad_timer_to_ticks(u16 timer_type, u16 Par); | 104 | static u16 __ad_timer_to_ticks(u16 timer_type, u16 Par); |
105 | 105 | ||
106 | 106 | ||
@@ -420,23 +420,23 @@ static inline void __initialize_port_locks(struct port *port) | |||
420 | 420 | ||
421 | //conversions | 421 | //conversions |
422 | /** | 422 | /** |
423 | * __ntohs_lacpdu - convert the contents of a LACPDU to host byte order | 423 | * __htons_lacpdu - convert the contents of a LACPDU to network byte order |
424 | * @lacpdu: the speicifed lacpdu | 424 | * @lacpdu: the speicifed lacpdu |
425 | * | 425 | * |
426 | * For each multi-byte field in the lacpdu, convert its content | 426 | * For each multi-byte field in the lacpdu, convert its content |
427 | */ | 427 | */ |
428 | static void __ntohs_lacpdu(struct lacpdu *lacpdu) | 428 | static void __htons_lacpdu(struct lacpdu *lacpdu) |
429 | { | 429 | { |
430 | if (lacpdu) { | 430 | if (lacpdu) { |
431 | lacpdu->actor_system_priority = ntohs(lacpdu->actor_system_priority); | 431 | lacpdu->actor_system_priority = htons(lacpdu->actor_system_priority); |
432 | lacpdu->actor_key = ntohs(lacpdu->actor_key); | 432 | lacpdu->actor_key = htons(lacpdu->actor_key); |
433 | lacpdu->actor_port_priority = ntohs(lacpdu->actor_port_priority); | 433 | lacpdu->actor_port_priority = htons(lacpdu->actor_port_priority); |
434 | lacpdu->actor_port = ntohs(lacpdu->actor_port); | 434 | lacpdu->actor_port = htons(lacpdu->actor_port); |
435 | lacpdu->partner_system_priority = ntohs(lacpdu->partner_system_priority); | 435 | lacpdu->partner_system_priority = htons(lacpdu->partner_system_priority); |
436 | lacpdu->partner_key = ntohs(lacpdu->partner_key); | 436 | lacpdu->partner_key = htons(lacpdu->partner_key); |
437 | lacpdu->partner_port_priority = ntohs(lacpdu->partner_port_priority); | 437 | lacpdu->partner_port_priority = htons(lacpdu->partner_port_priority); |
438 | lacpdu->partner_port = ntohs(lacpdu->partner_port); | 438 | lacpdu->partner_port = htons(lacpdu->partner_port); |
439 | lacpdu->collector_max_delay = ntohs(lacpdu->collector_max_delay); | 439 | lacpdu->collector_max_delay = htons(lacpdu->collector_max_delay); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
@@ -496,11 +496,11 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port) | |||
496 | // validate lacpdu and port | 496 | // validate lacpdu and port |
497 | if (lacpdu && port) { | 497 | if (lacpdu && port) { |
498 | // record the new parameter values for the partner operational | 498 | // record the new parameter values for the partner operational |
499 | port->partner_oper_port_number = lacpdu->actor_port; | 499 | port->partner_oper_port_number = ntohs(lacpdu->actor_port); |
500 | port->partner_oper_port_priority = lacpdu->actor_port_priority; | 500 | port->partner_oper_port_priority = ntohs(lacpdu->actor_port_priority); |
501 | port->partner_oper_system = lacpdu->actor_system; | 501 | port->partner_oper_system = lacpdu->actor_system; |
502 | port->partner_oper_system_priority = lacpdu->actor_system_priority; | 502 | port->partner_oper_system_priority = ntohs(lacpdu->actor_system_priority); |
503 | port->partner_oper_key = lacpdu->actor_key; | 503 | port->partner_oper_key = ntohs(lacpdu->actor_key); |
504 | // zero partener's lase states | 504 | // zero partener's lase states |
505 | port->partner_oper_port_state = 0; | 505 | port->partner_oper_port_state = 0; |
506 | port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_ACTIVITY); | 506 | port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_ACTIVITY); |
@@ -567,11 +567,11 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port) | |||
567 | // validate lacpdu and port | 567 | // validate lacpdu and port |
568 | if (lacpdu && port) { | 568 | if (lacpdu && port) { |
569 | // check if any parameter is different | 569 | // check if any parameter is different |
570 | if ((lacpdu->actor_port != port->partner_oper_port_number) || | 570 | if ((ntohs(lacpdu->actor_port) != port->partner_oper_port_number) || |
571 | (lacpdu->actor_port_priority != port->partner_oper_port_priority) || | 571 | (ntohs(lacpdu->actor_port_priority) != port->partner_oper_port_priority) || |
572 | MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) || | 572 | MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) || |
573 | (lacpdu->actor_system_priority != port->partner_oper_system_priority) || | 573 | (ntohs(lacpdu->actor_system_priority) != port->partner_oper_system_priority) || |
574 | (lacpdu->actor_key != port->partner_oper_key) || | 574 | (ntohs(lacpdu->actor_key) != port->partner_oper_key) || |
575 | ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION)) | 575 | ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION)) |
576 | ) { | 576 | ) { |
577 | // update the state machine Selected variable | 577 | // update the state machine Selected variable |
@@ -634,11 +634,11 @@ static void __choose_matched(struct lacpdu *lacpdu, struct port *port) | |||
634 | // validate lacpdu and port | 634 | // validate lacpdu and port |
635 | if (lacpdu && port) { | 635 | if (lacpdu && port) { |
636 | // check if all parameters are alike | 636 | // check if all parameters are alike |
637 | if (((lacpdu->partner_port == port->actor_port_number) && | 637 | if (((ntohs(lacpdu->partner_port) == port->actor_port_number) && |
638 | (lacpdu->partner_port_priority == port->actor_port_priority) && | 638 | (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) && |
639 | !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) && | 639 | !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) && |
640 | (lacpdu->partner_system_priority == port->actor_system_priority) && | 640 | (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) && |
641 | (lacpdu->partner_key == port->actor_oper_port_key) && | 641 | (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) && |
642 | ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) || | 642 | ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) || |
643 | // or this is individual link(aggregation == FALSE) | 643 | // or this is individual link(aggregation == FALSE) |
644 | ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0) | 644 | ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0) |
@@ -668,11 +668,11 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port) | |||
668 | // validate lacpdu and port | 668 | // validate lacpdu and port |
669 | if (lacpdu && port) { | 669 | if (lacpdu && port) { |
670 | // check if any parameter is different | 670 | // check if any parameter is different |
671 | if ((lacpdu->partner_port != port->actor_port_number) || | 671 | if ((ntohs(lacpdu->partner_port) != port->actor_port_number) || |
672 | (lacpdu->partner_port_priority != port->actor_port_priority) || | 672 | (ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) || |
673 | MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) || | 673 | MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) || |
674 | (lacpdu->partner_system_priority != port->actor_system_priority) || | 674 | (ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) || |
675 | (lacpdu->partner_key != port->actor_oper_port_key) || | 675 | (ntohs(lacpdu->partner_key) != port->actor_oper_port_key) || |
676 | ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) || | 676 | ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) || |
677 | ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) || | 677 | ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) || |
678 | ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) || | 678 | ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) || |
@@ -856,7 +856,7 @@ static inline void __update_lacpdu_from_port(struct port *port) | |||
856 | */ | 856 | */ |
857 | 857 | ||
858 | /* Convert all non u8 parameters to Big Endian for transmit */ | 858 | /* Convert all non u8 parameters to Big Endian for transmit */ |
859 | __ntohs_lacpdu(lacpdu); | 859 | __htons_lacpdu(lacpdu); |
860 | } | 860 | } |
861 | 861 | ||
862 | ////////////////////////////////////////////////////////////////////////////////////// | 862 | ////////////////////////////////////////////////////////////////////////////////////// |
@@ -2180,7 +2180,6 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u | |||
2180 | 2180 | ||
2181 | switch (lacpdu->subtype) { | 2181 | switch (lacpdu->subtype) { |
2182 | case AD_TYPE_LACPDU: | 2182 | case AD_TYPE_LACPDU: |
2183 | __ntohs_lacpdu(lacpdu); | ||
2184 | dprintk("Received LACPDU on port %d\n", port->actor_port_number); | 2183 | dprintk("Received LACPDU on port %d\n", port->actor_port_number); |
2185 | ad_rx_machine(lacpdu, port); | 2184 | ad_rx_machine(lacpdu, port); |
2186 | break; | 2185 | break; |