All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Patrick McHardy <kaber@trash.net>
Subject: [VLAN 18/18]: Move protocol determination to seperate function
Date: Sun, 20 Jan 2008 18:11:42 +0100 (MET)	[thread overview]
Message-ID: <20080120171142.7980.54350.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080120171117.7980.67072.sendpatchset@localhost.localdomain>

[VLAN]: Move protocol determination to seperate function

I think, that we can make this code flow easier to understand
by introducing the vlan_set_encap_proto() function (I hope the
name is good) to setup the skb proto and merge the paths calling
netif_rx() together.

[Patrick: Modified to apply on top of my previous patches]

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 0e185e8a940c2780362ff815cfe638e7d1269972
tree 62b8568718057b7a12375c34af01d95bae463240
parent c314238cb2135e4bb812487ed47652a5e2e4b748
author Pavel Emelyanov <xemul@openvz.org> Sun, 20 Jan 2008 17:37:32 +0100
committer Patrick McHardy <kaber@trash.net> Sun, 20 Jan 2008 17:37:32 +0100

 net/8021q/vlan_dev.c |   63 ++++++++++++++++++++++++++++----------------------
 1 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 57799af..8059fa4 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -89,6 +89,40 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
 	return skb;
 }
 
+static inline void vlan_set_encap_proto(struct sk_buff *skb,
+		struct vlan_hdr *vhdr)
+{
+	__be16 proto;
+	unsigned char *rawp;
+
+	/*
+	 * Was a VLAN packet, grab the encapsulated protocol, which the layer
+	 * three protocols care about.
+	 */
+
+	proto = vhdr->h_vlan_encapsulated_proto;
+	if (ntohs(proto) >= 1536) {
+		skb->protocol = proto;
+		return;
+	}
+
+	rawp = skb->data;
+	if (*(unsigned short *)rawp == 0xFFFF)
+		/*
+		 * This is a magic hack to spot IPX packets. Older Novell
+		 * breaks the protocol design and runs IPX over 802.3 without
+		 * an 802.2 LLC layer. We look for FFFF which isn't a used
+		 * 802.2 SSAP/DSAP. This won't work for fault tolerant netware
+		 * but does for the rest.
+		 */
+		skb->protocol = htons(ETH_P_802_3);
+	else
+		/*
+		 * Real 802.2 LLC
+		 */
+		skb->protocol = htons(ETH_P_802_2);
+}
+
 /*
  *	Determine the packet's protocol ID. The rule here is that we
  *	assume 802.3 if the type field is short enough to be a length.
@@ -114,12 +148,10 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
 int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		  struct packet_type *ptype, struct net_device *orig_dev)
 {
-	unsigned char *rawp;
 	struct vlan_hdr *vhdr;
 	unsigned short vid;
 	struct net_device_stats *stats;
 	unsigned short vlan_TCI;
-	__be16 proto;
 
 	if (dev->nd_net != &init_net)
 		goto err_free;
@@ -179,33 +211,8 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		break;
 	}
 
-	/*  Was a VLAN packet, grab the encapsulated protocol, which the layer
-	 * three protocols care about.
-	 */
-	proto = vhdr->h_vlan_encapsulated_proto;
-	if (ntohs(proto) >= 1536) {
-		skb->protocol = proto;
-		goto recv;
-	}
-
-	/*
-	 * This is a magic hack to spot IPX packets. Older Novell breaks
-	 * the protocol design and runs IPX over 802.3 without an 802.2 LLC
-	 * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
-	 * won't work for fault tolerant netware but does for the rest.
-	 */
-	rawp = skb->data;
-	if (*(unsigned short *)rawp == 0xFFFF) {
-		skb->protocol = htons(ETH_P_802_3);
-		goto recv;
-	}
-
-	/*
-	 *	Real 802.2 LLC
-	 */
-	skb->protocol = htons(ETH_P_802_2);
+	vlan_set_encap_proto(skb, vhdr);
 
-recv:
 	skb = vlan_check_reorder_header(skb);
 	if (!skb) {
 		stats->rx_errors++;

  parent reply	other threads:[~2008-01-20 17:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-20 17:11 [VLAN 00/18]: Vlan update Patrick McHardy
2008-01-20 17:11 ` [VLAN 01/18]: Remove unnecessary structure declarations Patrick McHardy
2008-01-20 17:11 ` [VLAN 02/18]: Clean up vlan_hdr/vlan_ethhdr structs Patrick McHardy
2008-01-20 17:11 ` [VLAN 03/18]: Kill useless VLAN_NAME define Patrick McHardy
2008-01-20 17:11 ` [VLAN 04/18]: Use dev->stats Patrick McHardy
2008-01-20 17:11 ` [VLAN 05/18]: Move device setup to vlan_dev.c Patrick McHardy
2008-01-20 17:11 ` [VLAN 06/18]: Kill useless check Patrick McHardy
2008-01-20 17:11 ` [ETHER 07/18]: Bring back MAC_FMT Patrick McHardy
2008-01-20 17:11 ` [VLAN 08/18]: Clean up debugging and printks Patrick McHardy
2008-01-20 17:11 ` [VLAN 09/18]: Remove non-implemented ioctls Patrick McHardy
2008-01-20 17:11 ` [VLAN 10/18]: Clean up initialization code Patrick McHardy
2008-01-20 17:11 ` [VLAN 11/18]: Clean up unregister_vlan_dev Patrick McHardy
2008-01-20 17:11 ` [VLAN 12/18]: Simplify vlan unregistration Patrick McHardy
2008-01-20 17:11 ` [VLAN 13/18]: Turn VLAN_DEV_INFO into inline function Patrick McHardy
2008-01-20 17:11 ` [VLAN 14/18]: Turn __constant_htons into htons where possible Patrick McHardy
2008-01-20 17:11 ` [VLAN 15/18]: checkpatch cleanups Patrick McHardy
2008-01-20 17:11 ` [VLAN 16/18]: Update list address Patrick McHardy
2008-01-20 17:11 ` [VLAN 17/18]: Clean up vlan_skb_recv() Patrick McHardy
2008-01-20 17:11 ` Patrick McHardy [this message]
2008-01-21  8:34 ` [VLAN 00/18]: Vlan update David Miller
2008-01-21 17:48   ` [VLAN] sparse warning fix Stephen Hemminger
2008-01-22  1:28     ` David Miller

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=20080120171142.7980.54350.sendpatchset@localhost.localdomain \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.