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

bonding/alb: Add helper functions to get the xmit slave

Add two helper functions to get the xmit slave of bond in alb or tlb
mode. Extract the logic of find the xmit slave from the xmit flow
to function. Xmit flow will xmit through this slave and in the
following patches the new .ndo will call to the helper function
to return the xmit slave.

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

authored by

Maor Gottlieb and committed by
Saeed Mahameed
34b37e20 ed7d4f02

+31 -10
+27 -10
drivers/net/bonding/bond_alb.c
··· 1334 1334 return NETDEV_TX_OK; 1335 1335 } 1336 1336 1337 - netdev_tx_t bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev) 1337 + struct slave *bond_xmit_tlb_slave_get(struct bonding *bond, 1338 + struct sk_buff *skb) 1338 1339 { 1339 - struct bonding *bond = netdev_priv(bond_dev); 1340 - struct ethhdr *eth_data; 1341 1340 struct slave *tx_slave = NULL; 1341 + struct ethhdr *eth_data; 1342 1342 u32 hash_index; 1343 1343 1344 1344 skb_reset_mac_header(skb); ··· 1369 1369 break; 1370 1370 } 1371 1371 } 1372 + return tx_slave; 1373 + } 1374 + 1375 + netdev_tx_t bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev) 1376 + { 1377 + struct bonding *bond = netdev_priv(bond_dev); 1378 + struct slave *tx_slave; 1379 + 1380 + tx_slave = bond_xmit_tlb_slave_get(bond, skb); 1372 1381 return bond_do_alb_xmit(skb, bond, tx_slave); 1373 1382 } 1374 1383 1375 - netdev_tx_t bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) 1384 + struct slave *bond_xmit_alb_slave_get(struct bonding *bond, 1385 + struct sk_buff *skb) 1376 1386 { 1377 - struct bonding *bond = netdev_priv(bond_dev); 1378 - struct ethhdr *eth_data; 1379 1387 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 1380 - struct slave *tx_slave = NULL; 1381 1388 static const __be32 ip_bcast = htonl(0xffffffff); 1382 - int hash_size = 0; 1383 - bool do_tx_balance = true; 1384 - u32 hash_index = 0; 1389 + struct slave *tx_slave = NULL; 1385 1390 const u8 *hash_start = NULL; 1391 + bool do_tx_balance = true; 1392 + struct ethhdr *eth_data; 1393 + u32 hash_index = 0; 1394 + int hash_size = 0; 1386 1395 1387 1396 skb_reset_mac_header(skb); 1388 1397 eth_data = eth_hdr(skb); ··· 1510 1501 count]; 1511 1502 } 1512 1503 } 1504 + return tx_slave; 1505 + } 1513 1506 1507 + netdev_tx_t bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) 1508 + { 1509 + struct bonding *bond = netdev_priv(bond_dev); 1510 + struct slave *tx_slave = NULL; 1511 + 1512 + tx_slave = bond_xmit_alb_slave_get(bond, skb); 1514 1513 return bond_do_alb_xmit(skb, bond, tx_slave); 1515 1514 } 1516 1515
+4
include/net/bond_alb.h
··· 158 158 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave); 159 159 int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); 160 160 int bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev); 161 + struct slave *bond_xmit_alb_slave_get(struct bonding *bond, 162 + struct sk_buff *skb); 163 + struct slave *bond_xmit_tlb_slave_get(struct bonding *bond, 164 + struct sk_buff *skb); 161 165 void bond_alb_monitor(struct work_struct *); 162 166 int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); 163 167 void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);