summaryrefslogtreecommitdiffstats
path: root/include/net/vxlan.h
diff options
context:
space:
mode:
authorJiri Benc <jbenc@redhat.com>2016-02-02 12:09:13 -0500
committerDavid S. Miller <davem@davemloft.net>2016-02-07 13:51:00 -0500
commit828788ac99d5de6bae10b333d1e8ddf25928ac12 (patch)
tree3d72a36c500e24d6a9acc93425fa25c5bc97878a /include/net/vxlan.h
parent427bc465bf9fcdab749f6997ff7a4eecaef4ca40 (diff)
vxlan: restructure vxlan.h definitions
RCO and GBP are VXLAN extensions, not specified in RFC 7348. Because of that, they need to be explicitly enabled when creating vxlan interface. By default, those extensions are not used and plain VXLAN header is sent and received. Reflect this in vxlan.h: first, the plain VXLAN header is defined. Following it, RCO is documented and defined, and likewise for GBP. Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/vxlan.h')
-rw-r--r--include/net/vxlan.h104
1 files changed, 63 insertions, 41 deletions
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index 234bf1ef2737..25bd919c9ef0 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -9,14 +9,71 @@
9#include <linux/udp.h> 9#include <linux/udp.h>
10#include <net/dst_metadata.h> 10#include <net/dst_metadata.h>
11 11
12/* VXLAN protocol (RFC 7348) header:
13 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
14 * |R|R|R|R|I|R|R|R| Reserved |
15 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16 * | VXLAN Network Identifier (VNI) | Reserved |
17 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
18 *
19 * I = VXLAN Network Identifier (VNI) present.
20 */
21struct vxlanhdr {
22 __be32 vx_flags;
23 __be32 vx_vni;
24};
25
26/* VXLAN header flags. */
27#define VXLAN_HF_VNI BIT(27)
28
29#define VXLAN_N_VID (1u << 24)
30#define VXLAN_VID_MASK (VXLAN_N_VID - 1)
31#define VXLAN_VNI_MASK (VXLAN_VID_MASK << 8)
32#define VXLAN_HLEN (sizeof(struct udphdr) + sizeof(struct vxlanhdr))
33
34#define VNI_HASH_BITS 10
35#define VNI_HASH_SIZE (1<<VNI_HASH_BITS)
36#define FDB_HASH_BITS 8
37#define FDB_HASH_SIZE (1<<FDB_HASH_BITS)
38
39/* Remote checksum offload for VXLAN (VXLAN_F_REMCSUM_[RT]X):
40 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * |R|R|R|R|I|R|R|R|R|R|C| Reserved |
42 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 * | VXLAN Network Identifier (VNI) |O| Csum start |
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 *
46 * C = Remote checksum offload bit. When set indicates that the
47 * remote checksum offload data is present.
48 *
49 * O = Offset bit. Indicates the checksum offset relative to
50 * checksum start.
51 *
52 * Csum start = Checksum start divided by two.
53 *
54 * http://tools.ietf.org/html/draft-herbert-vxlan-rco
55 */
56
57/* VXLAN-RCO header flags. */
58#define VXLAN_HF_RCO BIT(21)
59
60/* Remote checksum offload header option */
61#define VXLAN_RCO_MASK 0x7f /* Last byte of vni field */
62#define VXLAN_RCO_UDP 0x80 /* Indicate UDP RCO (TCP when not set *) */
63#define VXLAN_RCO_SHIFT 1 /* Left shift of start */
64#define VXLAN_RCO_SHIFT_MASK ((1 << VXLAN_RCO_SHIFT) - 1)
65#define VXLAN_MAX_REMCSUM_START (VXLAN_RCO_MASK << VXLAN_RCO_SHIFT)
66
12/* 67/*
13 * VXLAN Group Based Policy Extension: 68 * VXLAN Group Based Policy Extension (VXLAN_F_GBP):
14 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 69 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
15 * |1|-|-|-|1|-|-|-|R|D|R|R|A|R|R|R| Group Policy ID | 70 * |G|R|R|R|I|R|R|R|R|D|R|R|A|R|R|R| Group Policy ID |
16 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 71 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
17 * | VXLAN Network Identifier (VNI) | Reserved | 72 * | VXLAN Network Identifier (VNI) | Reserved |
18 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19 * 74 *
75 * G = Group Policy ID present.
76 *
20 * D = Don't Learn bit. When set, this bit indicates that the egress 77 * D = Don't Learn bit. When set, this bit indicates that the egress
21 * VTEP MUST NOT learn the source address of the encapsulated frame. 78 * VTEP MUST NOT learn the source address of the encapsulated frame.
22 * 79 *
@@ -24,7 +81,7 @@
24 * this packet. Policies MUST NOT be applied by devices when the 81 * this packet. Policies MUST NOT be applied by devices when the
25 * A bit is set. 82 * A bit is set.
26 * 83 *
27 * [0] https://tools.ietf.org/html/draft-smith-vxlan-group-policy 84 * https://tools.ietf.org/html/draft-smith-vxlan-group-policy
28 */ 85 */
29struct vxlanhdr_gbp { 86struct vxlanhdr_gbp {
30 u8 vx_flags; 87 u8 vx_flags;
@@ -47,6 +104,9 @@ struct vxlanhdr_gbp {
47 __be32 vx_vni; 104 __be32 vx_vni;
48}; 105};
49 106
107/* VXLAN-GBP header flags. */
108#define VXLAN_HF_GBP BIT(31)
109
50#define VXLAN_GBP_USED_BITS (VXLAN_HF_GBP | 0xFFFFFF) 110#define VXLAN_GBP_USED_BITS (VXLAN_HF_GBP | 0xFFFFFF)
51 111
52/* skb->mark mapping 112/* skb->mark mapping
@@ -59,44 +119,6 @@ struct vxlanhdr_gbp {
59#define VXLAN_GBP_POLICY_APPLIED (BIT(3) << 16) 119#define VXLAN_GBP_POLICY_APPLIED (BIT(3) << 16)
60#define VXLAN_GBP_ID_MASK (0xFFFF) 120#define VXLAN_GBP_ID_MASK (0xFFFF)
61 121
62/* VXLAN protocol header:
63 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 * |G|R|R|R|I|R|R|C| Reserved |
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 * | VXLAN Network Identifier (VNI) | Reserved |
67 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 *
69 * G = 1 Group Policy (VXLAN-GBP)
70 * I = 1 VXLAN Network Identifier (VNI) present
71 * C = 1 Remote checksum offload (RCO)
72 */
73struct vxlanhdr {
74 __be32 vx_flags;
75 __be32 vx_vni;
76};
77
78/* VXLAN header flags. */
79#define VXLAN_HF_RCO BIT(21)
80#define VXLAN_HF_VNI BIT(27)
81#define VXLAN_HF_GBP BIT(31)
82
83/* Remote checksum offload header option */
84#define VXLAN_RCO_MASK 0x7f /* Last byte of vni field */
85#define VXLAN_RCO_UDP 0x80 /* Indicate UDP RCO (TCP when not set *) */
86#define VXLAN_RCO_SHIFT 1 /* Left shift of start */
87#define VXLAN_RCO_SHIFT_MASK ((1 << VXLAN_RCO_SHIFT) - 1)
88#define VXLAN_MAX_REMCSUM_START (VXLAN_RCO_MASK << VXLAN_RCO_SHIFT)
89
90#define VXLAN_N_VID (1u << 24)
91#define VXLAN_VID_MASK (VXLAN_N_VID - 1)
92#define VXLAN_VNI_MASK (VXLAN_VID_MASK << 8)
93#define VXLAN_HLEN (sizeof(struct udphdr) + sizeof(struct vxlanhdr))
94
95#define VNI_HASH_BITS 10
96#define VNI_HASH_SIZE (1<<VNI_HASH_BITS)
97#define FDB_HASH_BITS 8
98#define FDB_HASH_SIZE (1<<FDB_HASH_BITS)
99
100struct vxlan_metadata { 122struct vxlan_metadata {
101 u32 gbp; 123 u32 gbp;
102}; 124};