summaryrefslogtreecommitdiff
path: root/datapath/vlan.c
blob: 9aebecd0e64f495d902d9602ec618d7d1d464d9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * Copyright (c) 2011 Nicira Networks.
 * Distributed under the terms of the GNU GPL version 2.
 *
 * Significant portions of this file may be copied from parts of the Linux
 * kernel, by Linus Torvalds and others.
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/if_vlan.h>
#include <linux/skbuff.h>

#include "datapath.h"
#include "vlan.h"

#ifdef NEED_VLAN_FIELD
void vlan_copy_skb_tci(struct sk_buff *skb)
{
	OVS_CB(skb)->vlan_tci = 0;
}

u16 vlan_get_tci(struct sk_buff *skb)
{
	return OVS_CB(skb)->vlan_tci;
}

void vlan_set_tci(struct sk_buff *skb, u16 vlan_tci)
{
	OVS_CB(skb)->vlan_tci = vlan_tci;
}

bool vlan_tx_tag_present(struct sk_buff *skb)
{
	return OVS_CB(skb)->vlan_tci & VLAN_TAG_PRESENT;
}

u16 vlan_tx_tag_get(struct sk_buff *skb)
{
	return OVS_CB(skb)->vlan_tci & ~VLAN_TAG_PRESENT;
}

struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, u16 vlan_tci)
{
	OVS_CB(skb)->vlan_tci = vlan_tci | VLAN_TAG_PRESENT;
	return skb;
}
#endif /* NEED_VLAN_FIELD */