lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 24 Mar 2011 12:49:14 -0700
From:	Jesse Gross <jesse@...ira.com>
To:	Andrew Strohman <astrohman@...plexinvestments.com>
Cc:	netdev@...r.kernel.org
Subject: Re: vlan_get_tag()

On Thu, Mar 24, 2011 at 12:11 PM, Andrew Strohman
<astrohman@...plexinvestments.com> wrote:
> Hello,
>
> Lately, I was messing around with the linux kernel code, and I wanted
> to look up the Vlan ID for a given sk_buff.   Instead of manually
> pulling the ID out of the sk_buff object, I used this in
> linux/include/linux/if_vlan.h
>
>
> /**
>  327 * vlan_get_tag - get the VLAN ID from the skb
>  328 * @skb: skbuff to query
>  329 * @vlan_tci: buffer to store vlaue
>  330 *
>  331 * Returns error if the skb is not VLAN tagged
>  332 */
>  333static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
>  334{
>  335        if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
>  336                return __vlan_hwaccel_get_tag(skb, vlan_tci);
>  337        } else {
>  338                return __vlan_get_tag(skb, vlan_tci);
>  339        }
>  340}
>
>
>
> Everything worked fine until I change the CoS value of my packets, and
> then all the sudden the VLAN IDs that where returned from this
> function were wrong.  I believe I see why:
>
> /**
>  306 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
>  307 * @skb: skbuff to query
>  308 * @vlan_tci: buffer to store vlaue
>  309 *
>  310 * Returns error if @skb->vlan_tci is not set correctly
>  311 */
>  312static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
>  313                                         u16 *vlan_tci)
>  314{
>  315        if (vlan_tx_tag_present(skb)) {
>  316                *vlan_tci = vlan_tx_tag_get(skb);
>  317                return 0;
>  318        } else {
>  319                *vlan_tci = 0;
>  320                return -EINVAL;
>  321        }
>  322}
>
>
> #define vlan_tx_tag_get(__skb)          ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
>
>
>
> #define VLAN_TAG_PRESENT        VLAN_CFI_MASK
> #define VLAN_CFI_MASK           0x1000 /* Canonical Format Indicator */
>
>
>
> So, to me it seems like this function really returns the entire tci
> with the CFI bit zeroed out, not the VLAN ID.  Perhaps, instead of
> doing:  ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT), it should do
> ((__skb)->vlan_tci & VLAN_VID_MASK)?

It does return the entire TCI.  It looks like some of the comments are
out of date but the code is correct.  If you want just the VID then
you should mask it yourself.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ