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] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 26 Mar 2015 04:53:38 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Toshiaki Makita <makita.toshiaki@....ntt.co.jp>
Cc:	"David S . Miller" <davem@...emloft.net>,
	Patrick McHardy <kaber@...sh.net>,
	Ariel Elior <ariel.elior@...gic.com>,
	Amir Vadai <amirv@...lanox.com>,
	Shahed Shaikh <shahed.shaikh@...gic.com>,
	Dept-GELinuxNICDev@...gic.com, Jay Vosburgh <j.vosburgh@...il.com>,
	Veaceslav Falico <vfalico@...il.com>,
	Andy Gospodarek <gospo@...ulusnetworks.com>,
	Jiri Pirko <jiri@...nulli.us>,
	Linux NICS <linux.nics@...el.com>,
	Vlad Yasevich <vyasevic@...hat.com>, netdev@...r.kernel.org,
	e1000-devel@...ts.sourceforge.net
Subject: Re: [PATCH net-next 2/7] vlan: Introduce helper functions to check
 if skb is tagged

On Thu, 2015-03-26 at 14:01 +0900, Toshiaki Makita wrote:
> Separate the two checks for single vlan and multiple vlans in
> netif_skb_features().  This allows us to move the check for multiple
> vlans to another function later.
> 
> Signed-off-by: Toshiaki Makita <makita.toshiaki@....ntt.co.jp>
> ---
>  include/linux/if_vlan.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  net/core/dev.c          | 24 ++++++++----------------
>  2 files changed, 53 insertions(+), 16 deletions(-)
> 
> diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
> index b11b28a..bc649dd 100644
> --- a/include/linux/if_vlan.h
> +++ b/include/linux/if_vlan.h
> @@ -561,4 +561,49 @@ static inline void vlan_set_encap_proto(struct sk_buff *skb,
>  		skb->protocol = htons(ETH_P_802_2);
>  }
>  
> +/**
> + * skb_vlan_tagged - check if skb is vlan tagged.
> + * @skb: skbuff to query
> + *
> + * Returns true if the skb is tagged, regardless of whether it is hardware
> + * accelerated or not.
> + */
> +static inline bool skb_vlan_tagged(struct sk_buff *skb)

const struct sk_buff *skb

> +{
> +	if (!skb_vlan_tag_present(skb) &&
> +	    likely(skb->protocol != htons(ETH_P_8021Q) &&
> +		   skb->protocol != htons(ETH_P_8021AD)))
> +		return false;
> +
> +	return true;
> +}
> +
> +/**
> + * skb_vlan_tagged_multi - check if skb is vlan tagged with multiple headers.
> + * @skb: skbuff to query
> + *
> + * Returns true if the skb is tagged with multiple vlan headers, regardless
> + * of whether it is hardware accelerated or not.
> + */
> +static inline bool skb_vlan_tagged_multi(struct sk_buff *skb)


const struct sk_buff *skb

> +{
> +	__be16 protocol = skb->protocol;
> +
> +	if (!skb_vlan_tag_present(skb)) {
> +		struct vlan_ethhdr *veh;
> +
> +		if (likely(protocol != htons(ETH_P_8021Q) &&
> +			   protocol != htons(ETH_P_8021AD)))
> +			return false;
> +
> +		veh = (struct vlan_ethhdr *)skb->data;
> +		protocol = veh->h_vlan_encapsulated_proto;
> +	}
> +
> +	if (protocol != htons(ETH_P_8021Q) && protocol != htons(ETH_P_8021AD))
> +		return false;
> +
> +	return true;
> +}
> +


--
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