From patchwork Mon Oct 26 16:13:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 36929 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.176.167]) by ozlabs.org (Postfix) with ESMTP id 7A763B7BDD for ; Tue, 27 Oct 2009 03:14:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbZJZQOF (ORCPT ); Mon, 26 Oct 2009 12:14:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753175AbZJZQOF (ORCPT ); Mon, 26 Oct 2009 12:14:05 -0400 Received: from gw1.cosmosbay.com ([212.99.114.194]:45642 "EHLO gw1.cosmosbay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752999AbZJZQOE (ORCPT ); Mon, 26 Oct 2009 12:14:04 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by gw1.cosmosbay.com (8.13.7/8.13.7) with ESMTP id n9QGDxGb031775; Mon, 26 Oct 2009 17:13:59 +0100 Message-ID: <4AE5CAC6.4000604@gmail.com> Date: Mon, 26 Oct 2009 17:13:58 +0100 From: Eric Dumazet User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 CC: Benny Amorsen , Gertjan Hofman , Matt Carlson , "netdev@vger.kernel.org" , Patrick McHardy , "David S. Miller" Subject: [PATCH] vlan: allow VLAN ID 0 to be used References: <477963.52849.qm@web32605.mail.mud.yahoo.com> <4AE563C7.5070702@gmail.com> In-Reply-To: <4AE563C7.5070702@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gw1.cosmosbay.com [0.0.0.0]); Mon, 26 Oct 2009 17:13:59 +0100 (CET) To: unlisted-recipients:; (no To-header on input) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Eric Dumazet a écrit : > VLAN id 0 is not usable on current kernel because we use 16 bits in skb to > store vlan_tci, and vlan_tci = 0 means there is no VLAN tagging. > > > We could use high order bit (0x8000) to tell if vlan tagging is set or not. > Here is the patch I cooked that permitted VLAN 0 to be used with tg3 (and other HW accelerated vlan nics I suppose) [PATCH] vlan: allow VLAN ID 0 to be used We currently use a 16 bit field (vlan_tci) to store VLAN ID on a skb. 0 value is used a special value, meaning VLAN ID not set. This forbids use of VLAN ID 0 As VLAN ID is 12 bits, we can use high order bit as a flag, and allow VLAN ID 0 Reported-by: Gertjan Hofman Signed-off-by: Eric Dumazet --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 7ff9af1..7dfcdb5 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -105,8 +105,9 @@ static inline void vlan_group_set_device(struct vlan_group *vg, array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; } -#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci) -#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci) +#define VLAN_TAG_PRESENT 0x8000 +#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT) +#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & 0x7fff) #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); @@ -231,7 +232,7 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, u16 vlan_tci) { - skb->vlan_tci = vlan_tci; + skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci; return skb; } @@ -284,7 +285,7 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, u16 *vlan_tci) { if (vlan_tx_tag_present(skb)) { - *vlan_tci = skb->vlan_tci; + *vlan_tci = vlan_tx_tag_get(skb); return 0; } else { *vlan_tci = 0;