Skip to content

Commit d350a82

Browse files
williamtudavem330
authored andcommitted
net: erspan: create erspan metadata uapi header
The patch adds a new uapi header file, erspan.h, and moves the 'struct erspan_metadata' from internal erspan.h to it. Signed-off-by: William Tu <[email protected]> Acked-by: Pravin B Shelar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c69de58 commit d350a82

File tree

2 files changed

+54
-30
lines changed

2 files changed

+54
-30
lines changed

include/net/erspan.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
* GRE proto ERSPAN type II = 0x88BE, type III = 0x22EB
4747
*/
4848

49+
#include <uapi/linux/erspan.h>
50+
4951
#define ERSPAN_VERSION 0x1 /* ERSPAN type II */
5052
#define VER_MASK 0xf000
5153
#define VLAN_MASK 0x0fff
@@ -68,29 +70,6 @@
6870
#define HWID_OFFSET 4
6971
#define DIR_OFFSET 3
7072

71-
/* ERSPAN version 2 metadata header */
72-
struct erspan_md2 {
73-
__be32 timestamp;
74-
__be16 sgt; /* security group tag */
75-
#if defined(__LITTLE_ENDIAN_BITFIELD)
76-
__u8 hwid_upper:2,
77-
ft:5,
78-
p:1;
79-
__u8 o:1,
80-
gra:2,
81-
dir:1,
82-
hwid:4;
83-
#elif defined(__BIG_ENDIAN_BITFIELD)
84-
__u8 p:1,
85-
ft:5,
86-
hwid_upper:2;
87-
__u8 hwid:4,
88-
dir:1,
89-
gra:2,
90-
o:1;
91-
#endif
92-
};
93-
9473
enum erspan_encap_type {
9574
ERSPAN_ENCAP_NOVLAN = 0x0, /* originally without VLAN tag */
9675
ERSPAN_ENCAP_ISL = 0x1, /* originally ISL encapsulated */
@@ -100,13 +79,6 @@ enum erspan_encap_type {
10079

10180
#define ERSPAN_V1_MDSIZE 4
10281
#define ERSPAN_V2_MDSIZE 8
103-
struct erspan_metadata {
104-
union {
105-
__be32 index; /* Version 1 (type II)*/
106-
struct erspan_md2 md2; /* Version 2 (type III) */
107-
} u;
108-
int version;
109-
};
11082

11183
struct erspan_base_hdr {
11284
#if defined(__LITTLE_ENDIAN_BITFIELD)

include/uapi/linux/erspan.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
/*
3+
* ERSPAN Tunnel Metadata
4+
*
5+
* Copyright (c) 2018 VMware
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License version 2
9+
* as published by the Free Software Foundation.
10+
*
11+
* Userspace API for metadata mode ERSPAN tunnel
12+
*/
13+
#ifndef _UAPI_ERSPAN_H
14+
#define _UAPI_ERSPAN_H
15+
16+
#include <linux/types.h> /* For __beXX in userspace */
17+
#include <asm/byteorder.h>
18+
19+
/* ERSPAN version 2 metadata header */
20+
struct erspan_md2 {
21+
__be32 timestamp;
22+
__be16 sgt; /* security group tag */
23+
#if defined(__LITTLE_ENDIAN_BITFIELD)
24+
__u8 hwid_upper:2,
25+
ft:5,
26+
p:1;
27+
__u8 o:1,
28+
gra:2,
29+
dir:1,
30+
hwid:4;
31+
#elif defined(__BIG_ENDIAN_BITFIELD)
32+
__u8 p:1,
33+
ft:5,
34+
hwid_upper:2;
35+
__u8 hwid:4,
36+
dir:1,
37+
gra:2,
38+
o:1;
39+
#else
40+
#error "Please fix <asm/byteorder.h>"
41+
#endif
42+
};
43+
44+
struct erspan_metadata {
45+
int version;
46+
union {
47+
__be32 index; /* Version 1 (type II)*/
48+
struct erspan_md2 md2; /* Version 2 (type III) */
49+
} u;
50+
};
51+
52+
#endif /* _UAPI_ERSPAN_H */

0 commit comments

Comments
 (0)