aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorMahesh Bandewar <maheshb@google.com>2014-04-22 19:30:18 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-24 13:04:34 -0400
commit9a49aba1ad7bb7351f1878155f3e8c6719b5e751 (patch)
tree7a6affb1fab16f2835fc606b907ced20c6bf6117 /drivers/net
parentee62e868139b96f73f3d01268ca1c39f7c6f4cd7 (diff)
bonding: Reorg bond_alb_xmit code
Separating the actual xmit part from the function in a separate function that can be used in the tlb_xmit in the next patch. Also there is no reason do_tx_balance to be an int so changing it to bool type. Change-Id: I9c48ff30487810f68587e621a191db616f49bd3b Signed-off-by: Mahesh Bandewar <maheshb@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_alb.c79
1 files changed, 44 insertions, 35 deletions
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 9f69e818b000..5cd36016c393 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1347,6 +1347,40 @@ void bond_alb_deinitialize(struct bonding *bond)
1347 rlb_deinitialize(bond); 1347 rlb_deinitialize(bond);
1348} 1348}
1349 1349
1350static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
1351 struct slave *tx_slave)
1352{
1353 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1354 struct ethhdr *eth_data = eth_hdr(skb);
1355
1356 if (!tx_slave) {
1357 /* unbalanced or unassigned, send through primary */
1358 tx_slave = rcu_dereference(bond->curr_active_slave);
1359 bond_info->unbalanced_load += skb->len;
1360 }
1361
1362 if (tx_slave && SLAVE_IS_OK(tx_slave)) {
1363 if (tx_slave != rcu_dereference(bond->curr_active_slave)) {
1364 ether_addr_copy(eth_data->h_source,
1365 tx_slave->dev->dev_addr);
1366 }
1367
1368 bond_dev_queue_xmit(bond, skb, tx_slave->dev);
1369 goto out;
1370 }
1371
1372 if (tx_slave) {
1373 _lock_tx_hashtbl(bond);
1374 __tlb_clear_slave(bond, tx_slave, 0);
1375 _unlock_tx_hashtbl(bond);
1376 }
1377
1378 /* no suitable interface, frame not sent */
1379 dev_kfree_skb_any(skb);
1380out:
1381 return NETDEV_TX_OK;
1382}
1383
1350int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) 1384int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1351{ 1385{
1352 struct bonding *bond = netdev_priv(bond_dev); 1386 struct bonding *bond = netdev_priv(bond_dev);
@@ -1355,7 +1389,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1355 struct slave *tx_slave = NULL; 1389 struct slave *tx_slave = NULL;
1356 static const __be32 ip_bcast = htonl(0xffffffff); 1390 static const __be32 ip_bcast = htonl(0xffffffff);
1357 int hash_size = 0; 1391 int hash_size = 0;
1358 int do_tx_balance = 1; 1392 bool do_tx_balance = true;
1359 u32 hash_index = 0; 1393 u32 hash_index = 0;
1360 const u8 *hash_start = NULL; 1394 const u8 *hash_start = NULL;
1361 struct ipv6hdr *ip6hdr; 1395 struct ipv6hdr *ip6hdr;
@@ -1370,7 +1404,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1370 if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast) || 1404 if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast) ||
1371 (iph->daddr == ip_bcast) || 1405 (iph->daddr == ip_bcast) ||
1372 (iph->protocol == IPPROTO_IGMP)) { 1406 (iph->protocol == IPPROTO_IGMP)) {
1373 do_tx_balance = 0; 1407 do_tx_balance = false;
1374 break; 1408 break;
1375 } 1409 }
1376 hash_start = (char *)&(iph->daddr); 1410 hash_start = (char *)&(iph->daddr);
@@ -1382,7 +1416,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1382 * that here just in case. 1416 * that here just in case.
1383 */ 1417 */
1384 if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast)) { 1418 if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast)) {
1385 do_tx_balance = 0; 1419 do_tx_balance = false;
1386 break; 1420 break;
1387 } 1421 }
1388 1422
@@ -1390,7 +1424,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1390 * broadcasts in IPv4. 1424 * broadcasts in IPv4.
1391 */ 1425 */
1392 if (ether_addr_equal_64bits(eth_data->h_dest, mac_v6_allmcast)) { 1426 if (ether_addr_equal_64bits(eth_data->h_dest, mac_v6_allmcast)) {
1393 do_tx_balance = 0; 1427 do_tx_balance = false;
1394 break; 1428 break;
1395 } 1429 }
1396 1430
@@ -1400,7 +1434,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1400 */ 1434 */
1401 ip6hdr = ipv6_hdr(skb); 1435 ip6hdr = ipv6_hdr(skb);
1402 if (ipv6_addr_any(&ip6hdr->saddr)) { 1436 if (ipv6_addr_any(&ip6hdr->saddr)) {
1403 do_tx_balance = 0; 1437 do_tx_balance = false;
1404 break; 1438 break;
1405 } 1439 }
1406 1440
@@ -1410,7 +1444,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1410 case ETH_P_IPX: 1444 case ETH_P_IPX:
1411 if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) { 1445 if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) {
1412 /* something is wrong with this packet */ 1446 /* something is wrong with this packet */
1413 do_tx_balance = 0; 1447 do_tx_balance = false;
1414 break; 1448 break;
1415 } 1449 }
1416 1450
@@ -1419,7 +1453,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1419 * this family since it has an "ARP" like 1453 * this family since it has an "ARP" like
1420 * mechanism 1454 * mechanism
1421 */ 1455 */
1422 do_tx_balance = 0; 1456 do_tx_balance = false;
1423 break; 1457 break;
1424 } 1458 }
1425 1459
@@ -1427,12 +1461,12 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1427 hash_size = ETH_ALEN; 1461 hash_size = ETH_ALEN;
1428 break; 1462 break;
1429 case ETH_P_ARP: 1463 case ETH_P_ARP:
1430 do_tx_balance = 0; 1464 do_tx_balance = false;
1431 if (bond_info->rlb_enabled) 1465 if (bond_info->rlb_enabled)
1432 tx_slave = rlb_arp_xmit(skb, bond); 1466 tx_slave = rlb_arp_xmit(skb, bond);
1433 break; 1467 break;
1434 default: 1468 default:
1435 do_tx_balance = 0; 1469 do_tx_balance = false;
1436 break; 1470 break;
1437 } 1471 }
1438 1472
@@ -1441,32 +1475,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1441 tx_slave = tlb_choose_channel(bond, hash_index, skb->len); 1475 tx_slave = tlb_choose_channel(bond, hash_index, skb->len);
1442 } 1476 }
1443 1477
1444 if (!tx_slave) { 1478 return bond_do_alb_xmit(skb, bond, tx_slave);
1445 /* unbalanced or unassigned, send through primary */
1446 tx_slave = rcu_dereference(bond->curr_active_slave);
1447 bond_info->unbalanced_load += skb->len;
1448 }
1449
1450 if (tx_slave && SLAVE_IS_OK(tx_slave)) {
1451 if (tx_slave != rcu_dereference(bond->curr_active_slave)) {
1452 ether_addr_copy(eth_data->h_source,
1453 tx_slave->dev->dev_addr);
1454 }
1455
1456 bond_dev_queue_xmit(bond, skb, tx_slave->dev);
1457 goto out;
1458 }
1459
1460 if (tx_slave) {
1461 _lock_tx_hashtbl(bond);
1462 __tlb_clear_slave(bond, tx_slave, 0);
1463 _unlock_tx_hashtbl(bond);
1464 }
1465
1466 /* no suitable interface, frame not sent */
1467 dev_kfree_skb_any(skb);
1468out:
1469 return NETDEV_TX_OK;
1470} 1479}
1471 1480
1472void bond_alb_monitor(struct work_struct *work) 1481void bond_alb_monitor(struct work_struct *work)