netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Veaceslav Falico <vfalico@redhat.com>
To: netdev@vger.kernel.org
Cc: Veaceslav Falico <vfalico@redhat.com>,
	Jay Vosburgh <fubar@us.ibm.com>,
	Andy Gospodarek <andy@greyhouse.net>
Subject: [PATCH net-next v3 10/13] bonding: split alb_send_learning_packets()
Date: Wed, 28 Aug 2013 18:03:59 +0200	[thread overview]
Message-ID: <1377705842-8276-11-git-send-email-vfalico@redhat.com> (raw)
In-Reply-To: <1377705842-8276-1-git-send-email-vfalico@redhat.com>

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.

v1: no change
v2: no change
v3: no change

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
 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 3a5db7b..3ca3c85 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)
 
 /*********************** tlb/rlb shared functions *********************/
 
-static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
+static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[],
+			    u16 vid)
 {
-	struct bonding *bond = bond_get_bond_by_slave(slave);
 	struct learning_pkt pkt;
+	struct sk_buff *skb;
 	int size = sizeof(struct learning_pkt);
-	int i;
+	char *data;
 
 	memset(&pkt, 0, size);
 	memcpy(pkt.mac_dst, mac_addr, ETH_ALEN);
 	memcpy(pkt.mac_src, mac_addr, ETH_ALEN);
 	pkt.type = cpu_to_be16(ETH_P_LOOP);
 
-	for (i = 0; i < MAX_LP_BURST; i++) {
-		struct sk_buff *skb;
-		char *data;
+	skb = dev_alloc_skb(size);
+	if (!skb)
+		return;
 
-		skb = dev_alloc_skb(size);
+	data = skb_put(skb, size);
+	memcpy(data, &pkt, size);
+
+	skb_reset_mac_header(skb);
+	skb->network_header = skb->mac_header + ETH_HLEN;
+	skb->protocol = pkt.type;
+	skb->priority = TC_PRIO_CONTROL;
+	skb->dev = slave->dev;
+
+	if (vid) {
+		skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vid);
 		if (!skb) {
+			pr_err("%s: Error: failed to insert VLAN tag\n",
+			       slave->bond->dev->name);
 			return;
 		}
+	}
 
-		data = skb_put(skb, size);
-		memcpy(data, &pkt, size);
+	dev_queue_xmit(skb);
+}
 
-		skb_reset_mac_header(skb);
-		skb->network_header = skb->mac_header + ETH_HLEN;
-		skb->protocol = pkt.type;
-		skb->priority = TC_PRIO_CONTROL;
-		skb->dev = slave->dev;
+
+static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
+{
+	struct bonding *bond = bond_get_bond_by_slave(slave);
+	u16 vlan_id;
+	int i;
+
+	for (i = 0; i < MAX_LP_BURST; i++) {
+		vlan_id = 0;
 
 		if (bond_vlan_used(bond)) {
 			struct vlan_entry *vlan;
@@ -1008,20 +1026,13 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
 					      bond->alb_info.current_alb_vlan);
 
 			bond->alb_info.current_alb_vlan = vlan;
-			if (!vlan) {
-				kfree_skb(skb);
+			if (!vlan)
 				continue;
-			}
 
-			skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vlan->vlan_id);
-			if (!skb) {
-				pr_err("%s: Error: failed to insert VLAN tag\n",
-				       bond->dev->name);
-				continue;
-			}
+			vlan_id = vlan->vlan_id;
 		}
 
-		dev_queue_xmit(skb);
+		alb_send_lp_vid(slave, mac_addr, vlan_id);
 	}
 }
 
-- 
1.7.1

  parent reply	other threads:[~2013-08-28 16:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-28 16:03 [PATCH net-next v3 0/13] bonding: remove vlan special handling Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 01/13] net: rename netdev_upper to netdev_adjacent Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 02/13] net: add lower_dev_list to net_device and make a full mesh Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 03/13] net: remove search_list from netdev_adjacent Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 04/13] net: add netdev_upper_get_next_dev_rcu(dev, iter) Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 05/13] net: add netdev_for_each_upper_dev_rcu() Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 06/13] bonding: use netdev_upper list in bond_vlan_used Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 07/13] bonding: make bond_arp_send_all use upper device list Veaceslav Falico
2013-08-28 16:45   ` Vlad Yasevich
2013-08-28 17:23     ` Veaceslav Falico
2013-08-28 18:11       ` Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 08/13] bonding: convert bond_has_this_ip() to use upper devices Veaceslav Falico
2013-08-28 16:03 ` [PATCH net-next v3 09/13] bonding: use vlan_uses_dev() in __bond_release_one() Veaceslav Falico
2013-08-28 16:03 ` Veaceslav Falico [this message]
2013-08-28 16:04 ` [PATCH net-next v3 11/13] bonding: make alb_send_learning_packets() use upper dev list Veaceslav Falico
2013-08-28 16:04 ` [PATCH net-next v3 12/13] bonding: remove vlan_list/current_alb_vlan Veaceslav Falico
2013-08-28 16:04 ` [PATCH net-next v3 13/13] bonding: pr_debug instead of pr_warn in bond_arp_send_all Veaceslav Falico
2013-08-28 16:15   ` Joe Perches
2013-08-28 16:22     ` Veaceslav Falico
2013-08-28 21:24 ` [PATCH net-next v3 0/13] bonding: remove vlan special handling Veaceslav Falico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377705842-8276-11-git-send-email-vfalico@redhat.com \
    --to=vfalico@redhat.com \
    --cc=andy@greyhouse.net \
    --cc=fubar@us.ibm.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).