From patchwork Sat Dec 3 18:38:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Gross X-Patchwork-Id: 129106 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0BAAD1007D5 for ; Sun, 4 Dec 2011 05:39:13 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754352Ab1LCSjF (ORCPT ); Sat, 3 Dec 2011 13:39:05 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:36442 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754002Ab1LCSjC (ORCPT ); Sat, 3 Dec 2011 13:39:02 -0500 Received: by mail-iy0-f174.google.com with SMTP id e36so6004137iag.19 for ; Sat, 03 Dec 2011 10:39:01 -0800 (PST) Received: by 10.231.82.131 with SMTP id b3mr836983ibl.74.1322937541834; Sat, 03 Dec 2011 10:39:01 -0800 (PST) Received: from umstead.nicira.com (173-167-111-49-sfba.hfc.comcastbusiness.net. [173.167.111.49]) by mx.google.com with ESMTPS id eh34sm51441513ibb.5.2011.12.03.10.39.00 (version=SSLv3 cipher=OTHER); Sat, 03 Dec 2011 10:39:01 -0800 (PST) From: Jesse Gross To: "David S. Miller" Cc: netdev@vger.kernel.org, dev@openvswitch.org, Pravin B Shelar Subject: [PATCH v3 4/6] vlan: Move vlan_set_encap_proto() to vlan header file Date: Sat, 3 Dec 2011 10:38:49 -0800 Message-Id: <1322937531-8071-5-git-send-email-jesse@nicira.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1322937531-8071-1-git-send-email-jesse@nicira.com> References: <1322937531-8071-1-git-send-email-jesse@nicira.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Pravin B Shelar Open vSwitch needs this function for vlan handling. Signed-off-by: Pravin B Shelar Signed-off-by: Jesse Gross --- v2/v3: Unchanged. --- include/linux/if_vlan.h | 34 ++++++++++++++++++++++++++++++++++ net/8021q/vlan_core.c | 33 --------------------------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 12d5543..070ac50 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -310,6 +310,40 @@ static inline __be16 vlan_get_protocol(const struct sk_buff *skb) return protocol; } + +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); +} #endif /* __KERNEL__ */ /* VLAN IOCTLs are found in sockios.h */ diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index f5ffc02..9c95e8e 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -110,39 +110,6 @@ static struct sk_buff *vlan_reorder_header(struct sk_buff *skb) return skb; } -static 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); -} - struct sk_buff *vlan_untag(struct sk_buff *skb) { struct vlan_hdr *vhdr;