Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'bonding-next'

Jonathan Toppins says:

====================
bonding: various 802.3ad fixes

This patch series is a forward porting of patches we (Cumulus) are shipping
in our 3.2 series kernels. These fixes attempt to make 802.3ad bonding mode
more predictable in certian state machine transtions in addition to fixing
802.3ad bond carrier determination when bonding min_links option is changed.
Specific notes are contained within each patch.

For this patch series there are no userspace facing changes, a diff between
the modinfo output showed no difference. However, there are behavioral
facing changes, primarily in the bond carrier state. Please make sure to
review carefully.

v2:
* fixed some style issues
* dropped a portion of patch 1 in favor of more testing on my side
====================

Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

+47 -17
+42 -13
drivers/net/bonding/bond_3ad.c
··· 467 467 /* set the partner sync. to on if the partner is sync, 468 468 * and the port is matched 469 469 */ 470 - if ((port->sm_vars & AD_PORT_MATCHED) 471 - && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION)) 470 + if ((port->sm_vars & AD_PORT_MATCHED) && 471 + (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION)) { 472 472 partner->port_state |= AD_STATE_SYNCHRONIZATION; 473 - else 473 + pr_debug("%s partner sync=1\n", port->slave->dev->name); 474 + } else { 474 475 partner->port_state &= ~AD_STATE_SYNCHRONIZATION; 476 + pr_debug("%s partner sync=0\n", port->slave->dev->name); 477 + } 475 478 } 476 479 } 477 480 ··· 729 726 lacpdu->actor_port_priority = htons(port->actor_port_priority); 730 727 lacpdu->actor_port = htons(port->actor_port_number); 731 728 lacpdu->actor_state = port->actor_oper_port_state; 729 + pr_debug("update lacpdu: %s, actor port state %x\n", 730 + port->slave->dev->name, port->actor_oper_port_state); 732 731 733 732 /* lacpdu->reserved_3_1 initialized 734 733 * lacpdu->tlv_type_partner_info initialized ··· 903 898 if ((port->sm_vars & AD_PORT_SELECTED) && 904 899 (port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) && 905 900 !__check_agg_selection_timer(port)) { 906 - port->sm_mux_state = AD_MUX_COLLECTING_DISTRIBUTING; 901 + if (port->aggregator->is_active) 902 + port->sm_mux_state = 903 + AD_MUX_COLLECTING_DISTRIBUTING; 907 904 } else if (!(port->sm_vars & AD_PORT_SELECTED) || 908 905 (port->sm_vars & AD_PORT_STANDBY)) { 909 906 /* if UNSELECTED or STANDBY */ ··· 917 910 */ 918 911 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); 919 912 port->sm_mux_state = AD_MUX_DETACHED; 913 + } else if (port->aggregator->is_active) { 914 + port->actor_oper_port_state |= 915 + AD_STATE_SYNCHRONIZATION; 920 916 } 921 917 break; 922 918 case AD_MUX_COLLECTING_DISTRIBUTING: 923 919 if (!(port->sm_vars & AD_PORT_SELECTED) || 924 920 (port->sm_vars & AD_PORT_STANDBY) || 925 - !(port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION)) { 921 + !(port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) || 922 + !(port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) { 926 923 port->sm_mux_state = AD_MUX_ATTACHED; 927 924 } else { 928 925 /* if port state hasn't changed make ··· 948 937 949 938 /* check if the state machine was changed */ 950 939 if (port->sm_mux_state != last_state) { 951 - pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n", 952 - port->actor_port_number, last_state, 940 + pr_debug("Mux Machine: Port=%d (%s), Last State=%d, Curr State=%d\n", 941 + port->actor_port_number, 942 + port->slave->dev->name, 943 + last_state, 953 944 port->sm_mux_state); 954 945 switch (port->sm_mux_state) { 955 946 case AD_MUX_DETACHED: ··· 966 953 port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0); 967 954 break; 968 955 case AD_MUX_ATTACHED: 969 - port->actor_oper_port_state |= AD_STATE_SYNCHRONIZATION; 956 + if (port->aggregator->is_active) 957 + port->actor_oper_port_state |= 958 + AD_STATE_SYNCHRONIZATION; 959 + else 960 + port->actor_oper_port_state &= 961 + ~AD_STATE_SYNCHRONIZATION; 970 962 port->actor_oper_port_state &= ~AD_STATE_COLLECTING; 971 963 port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING; 972 964 ad_disable_collecting_distributing(port, ··· 981 963 case AD_MUX_COLLECTING_DISTRIBUTING: 982 964 port->actor_oper_port_state |= AD_STATE_COLLECTING; 983 965 port->actor_oper_port_state |= AD_STATE_DISTRIBUTING; 966 + port->actor_oper_port_state |= AD_STATE_SYNCHRONIZATION; 984 967 ad_enable_collecting_distributing(port, 985 968 update_slave_arr); 986 969 port->ntt = true; ··· 1063 1044 1064 1045 /* check if the State machine was changed or new lacpdu arrived */ 1065 1046 if ((port->sm_rx_state != last_state) || (lacpdu)) { 1066 - pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n", 1067 - port->actor_port_number, last_state, 1047 + pr_debug("Rx Machine: Port=%d (%s), Last State=%d, Curr State=%d\n", 1048 + port->actor_port_number, 1049 + port->slave->dev->name, 1050 + last_state, 1068 1051 port->sm_rx_state); 1069 1052 switch (port->sm_rx_state) { 1070 1053 case AD_RX_INITIALIZE: ··· 1415 1394 1416 1395 aggregator = __get_first_agg(port); 1417 1396 ad_agg_selection_logic(aggregator, update_slave_arr); 1397 + 1398 + if (!port->aggregator->is_active) 1399 + port->actor_oper_port_state &= ~AD_STATE_SYNCHRONIZATION; 1418 1400 } 1419 1401 1420 1402 /* Decide if "agg" is a better choice for the new active aggregator that ··· 2219 2195 switch (lacpdu->subtype) { 2220 2196 case AD_TYPE_LACPDU: 2221 2197 ret = RX_HANDLER_CONSUMED; 2222 - netdev_dbg(slave->bond->dev, "Received LACPDU on port %d\n", 2223 - port->actor_port_number); 2198 + netdev_dbg(slave->bond->dev, 2199 + "Received LACPDU on port %d slave %s\n", 2200 + port->actor_port_number, 2201 + slave->dev->name); 2224 2202 /* Protect against concurrent state machines */ 2225 2203 spin_lock(&slave->bond->mode_lock); 2226 2204 ad_rx_machine(lacpdu, port); ··· 2314 2288 port->actor_admin_port_key &= ~AD_DUPLEX_KEY_MASKS; 2315 2289 port->actor_oper_port_key = port->actor_admin_port_key |= 2316 2290 __get_duplex(port); 2317 - netdev_dbg(slave->bond->dev, "Port %d changed duplex\n", port->actor_port_number); 2291 + netdev_dbg(slave->bond->dev, "Port %d slave %s changed duplex\n", 2292 + port->actor_port_number, slave->dev->name); 2293 + if (port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS) 2294 + port->sm_vars |= AD_PORT_LACP_ENABLED; 2318 2295 /* there is no need to reselect a new aggregator, just signal the 2319 2296 * state machines to reinitialize 2320 2297 */
+3 -3
drivers/net/bonding/bond_main.c
··· 334 334 * 335 335 * Returns zero if carrier state does not change, nonzero if it does. 336 336 */ 337 - static int bond_set_carrier(struct bonding *bond) 337 + int bond_set_carrier(struct bonding *bond) 338 338 { 339 339 struct list_head *iter; 340 340 struct slave *slave; ··· 3066 3066 slave != rcu_access_pointer(bond->curr_active_slave)) { 3067 3067 bond_set_slave_inactive_flags(slave, 3068 3068 BOND_SLAVE_NOTIFY_NOW); 3069 - } else { 3069 + } else if (BOND_MODE(bond) != BOND_MODE_8023AD) { 3070 3070 bond_set_slave_active_flags(slave, 3071 3071 BOND_SLAVE_NOTIFY_NOW); 3072 3072 } ··· 3734 3734 * usable slave array is formed in the control path. The xmit function 3735 3735 * just calculates hash and sends the packet out. 3736 3736 */ 3737 - int bond_3ad_xor_xmit(struct sk_buff *skb, struct net_device *dev) 3737 + static int bond_3ad_xor_xmit(struct sk_buff *skb, struct net_device *dev) 3738 3738 { 3739 3739 struct bonding *bond = netdev_priv(dev); 3740 3740 struct slave *slave;
+1
drivers/net/bonding/bond_options.c
··· 1181 1181 netdev_info(bond->dev, "Setting min links value to %llu\n", 1182 1182 newval->value); 1183 1183 bond->params.min_links = newval->value; 1184 + bond_set_carrier(bond); 1184 1185 1185 1186 return 0; 1186 1187 }
-1
include/net/bond_3ad.h
··· 274 274 int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info); 275 275 int __bond_3ad_get_active_agg_info(struct bonding *bond, 276 276 struct ad_info *ad_info); 277 - int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev); 278 277 int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond, 279 278 struct slave *slave); 280 279 int bond_3ad_set_carrier(struct bonding *bond);
+1
include/net/bonding.h
··· 525 525 int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); 526 526 int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); 527 527 u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb); 528 + int bond_set_carrier(struct bonding *bond); 528 529 void bond_select_active_slave(struct bonding *bond); 529 530 void bond_change_active_slave(struct bonding *bond, struct slave *new_active); 530 531 void bond_create_debugfs(void);