mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
vlan: Introduce helper functions to check if skb is tagged
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@lab.ntt.co.jp> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8d463504c1
commit
f5a7fb88e1
2 changed files with 53 additions and 16 deletions
|
@ -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(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(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;
|
||||
}
|
||||
|
||||
#endif /* !(_LINUX_IF_VLAN_H_) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue