diff options
author | Veaceslav Falico <vfalico@redhat.com> | 2013-08-28 17:25:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-29 16:19:43 -0400 |
commit | 7aa6498123a67001e950808ce6eb5930a4c5945f (patch) | |
tree | 7b516d3d2e4fe71e11ef1269ba9517c4aff066de /drivers/net/bonding | |
parent | a59d3d21ea7636d4cc7fb921104b9b4a59196839 (diff) |
bonding: split alb_send_learning_packets()
Create alb_send_lp_vid(), which will handle the skb/lp creation, vlan
tagging and sending, and use it in alb_send_learning_packets().
This way all the logic remains in alb_send_learning_packets(), which
becomes a lot more cleaner and easier to understand.
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 3a5db7b1df68..3ca3c85d6f24 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -971,35 +971,53 @@ static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id) | |||
971 | 971 | ||
972 | /*********************** tlb/rlb shared functions *********************/ | 972 | /*********************** tlb/rlb shared functions *********************/ |
973 | 973 | ||
974 | static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) | 974 | static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[], |
975 | u16 vid) | ||
975 | { | 976 | { |
976 | struct bonding *bond = bond_get_bond_by_slave(slave); | ||
977 | struct learning_pkt pkt; | 977 | struct learning_pkt pkt; |
978 | struct sk_buff *skb; | ||
978 | int size = sizeof(struct learning_pkt); | 979 | int size = sizeof(struct learning_pkt); |
979 | int i; | 980 | char *data; |
980 | 981 | ||
981 | memset(&pkt, 0, size); | 982 | memset(&pkt, 0, size); |
982 | memcpy(pkt.mac_dst, mac_addr, ETH_ALEN); | 983 | memcpy(pkt.mac_dst, mac_addr, ETH_ALEN); |
983 | memcpy(pkt.mac_src, mac_addr, ETH_ALEN); | 984 | memcpy(pkt.mac_src, mac_addr, ETH_ALEN); |
984 | pkt.type = cpu_to_be16(ETH_P_LOOP); | 985 | pkt.type = cpu_to_be16(ETH_P_LOOP); |
985 | 986 | ||
986 | for (i = 0; i < MAX_LP_BURST; i++) { | 987 | skb = dev_alloc_skb(size); |
987 | struct sk_buff *skb; | 988 | if (!skb) |
988 | char *data; | 989 | return; |
989 | 990 | ||
990 | skb = dev_alloc_skb(size); | 991 | data = skb_put(skb, size); |
992 | memcpy(data, &pkt, size); | ||
993 | |||
994 | skb_reset_mac_header(skb); | ||
995 | skb->network_header = skb->mac_header + ETH_HLEN; | ||
996 | skb->protocol = pkt.type; | ||
997 | skb->priority = TC_PRIO_CONTROL; | ||
998 | skb->dev = slave->dev; | ||
999 | |||
1000 | if (vid) { | ||
1001 | skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vid); | ||
991 | if (!skb) { | 1002 | if (!skb) { |
1003 | pr_err("%s: Error: failed to insert VLAN tag\n", | ||
1004 | slave->bond->dev->name); | ||
992 | return; | 1005 | return; |
993 | } | 1006 | } |
1007 | } | ||
994 | 1008 | ||
995 | data = skb_put(skb, size); | 1009 | dev_queue_xmit(skb); |
996 | memcpy(data, &pkt, size); | 1010 | } |
997 | 1011 | ||
998 | skb_reset_mac_header(skb); | 1012 | |
999 | skb->network_header = skb->mac_header + ETH_HLEN; | 1013 | static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) |
1000 | skb->protocol = pkt.type; | 1014 | { |
1001 | skb->priority = TC_PRIO_CONTROL; | 1015 | struct bonding *bond = bond_get_bond_by_slave(slave); |
1002 | skb->dev = slave->dev; | 1016 | u16 vlan_id; |
1017 | int i; | ||
1018 | |||
1019 | for (i = 0; i < MAX_LP_BURST; i++) { | ||
1020 | vlan_id = 0; | ||
1003 | 1021 | ||
1004 | if (bond_vlan_used(bond)) { | 1022 | if (bond_vlan_used(bond)) { |
1005 | struct vlan_entry *vlan; | 1023 | struct vlan_entry *vlan; |
@@ -1008,20 +1026,13 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) | |||
1008 | bond->alb_info.current_alb_vlan); | 1026 | bond->alb_info.current_alb_vlan); |
1009 | 1027 | ||
1010 | bond->alb_info.current_alb_vlan = vlan; | 1028 | bond->alb_info.current_alb_vlan = vlan; |
1011 | if (!vlan) { | 1029 | if (!vlan) |
1012 | kfree_skb(skb); | ||
1013 | continue; | 1030 | continue; |
1014 | } | ||
1015 | 1031 | ||
1016 | skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vlan->vlan_id); | 1032 | vlan_id = vlan->vlan_id; |
1017 | if (!skb) { | ||
1018 | pr_err("%s: Error: failed to insert VLAN tag\n", | ||
1019 | bond->dev->name); | ||
1020 | continue; | ||
1021 | } | ||
1022 | } | 1033 | } |
1023 | 1034 | ||
1024 | dev_queue_xmit(skb); | 1035 | alb_send_lp_vid(slave, mac_addr, vlan_id); |
1025 | } | 1036 | } |
1026 | } | 1037 | } |
1027 | 1038 | ||