Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2
3/*
4 * Copyright (c) 2007-2017 Nicira, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA
19 */
20
21#ifndef _UAPI__LINUX_OPENVSWITCH_H
22#define _UAPI__LINUX_OPENVSWITCH_H 1
23
24#include <linux/types.h>
25#include <linux/if_ether.h>
26
27/**
28 * struct ovs_header - header for OVS Generic Netlink messages.
29 * @dp_ifindex: ifindex of local port for datapath (0 to make a request not
30 * specific to a datapath).
31 *
32 * Attributes following the header are specific to a particular OVS Generic
33 * Netlink family, but all of the OVS families use this header.
34 */
35
36struct ovs_header {
37 int dp_ifindex;
38};
39
40/* Datapaths. */
41
42#define OVS_DATAPATH_FAMILY "ovs_datapath"
43#define OVS_DATAPATH_MCGROUP "ovs_datapath"
44
45/* V2:
46 * - API users are expected to provide OVS_DP_ATTR_USER_FEATURES
47 * when creating the datapath.
48 */
49#define OVS_DATAPATH_VERSION 2
50
51/* First OVS datapath version to support features */
52#define OVS_DP_VER_FEATURES 2
53
54enum ovs_datapath_cmd {
55 OVS_DP_CMD_UNSPEC,
56 OVS_DP_CMD_NEW,
57 OVS_DP_CMD_DEL,
58 OVS_DP_CMD_GET,
59 OVS_DP_CMD_SET
60};
61
62/**
63 * enum ovs_datapath_attr - attributes for %OVS_DP_* commands.
64 * @OVS_DP_ATTR_NAME: Name of the network device that serves as the "local
65 * port". This is the name of the network device whose dp_ifindex is given in
66 * the &struct ovs_header. Always present in notifications. Required in
67 * %OVS_DP_NEW requests. May be used as an alternative to specifying
68 * dp_ifindex in other requests (with a dp_ifindex of 0).
69 * @OVS_DP_ATTR_UPCALL_PID: The Netlink socket in userspace that is initially
70 * set on the datapath port (for OVS_ACTION_ATTR_MISS). Only valid on
71 * %OVS_DP_CMD_NEW requests. A value of zero indicates that upcalls should
72 * not be sent.
73 * @OVS_DP_ATTR_MASKS_CACHE_SIZE: Number of the entries in the flow table
74 * masks cache.
75 * @OVS_DP_ATTR_PER_CPU_PIDS: Per-cpu array of PIDs for upcalls when
76 * OVS_DP_F_DISPATCH_UPCALL_PER_CPU feature is set.
77 * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the
78 * datapath. Always present in notifications.
79 * @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the
80 * datapath. Always present in notifications.
81 * @OVS_DP_ATTR_USER_FEATURES: OVS_DP_F_* flags.
82 * @OVS_DP_ATTR_IFINDEX: Interface index for a new datapath netdev. Only
83 * valid for %OVS_DP_CMD_NEW requests.
84 *
85 * These attributes follow the &struct ovs_header within the Generic Netlink
86 * payload for %OVS_DP_* commands.
87 */
88enum ovs_datapath_attr {
89 /* private: */
90 OVS_DP_ATTR_UNSPEC,
91 /* public: */
92 OVS_DP_ATTR_NAME, /* name of dp_ifindex netdev */
93 OVS_DP_ATTR_UPCALL_PID, /* Netlink PID to receive upcalls */
94 OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */
95 OVS_DP_ATTR_MEGAFLOW_STATS, /* struct ovs_dp_megaflow_stats */
96 OVS_DP_ATTR_USER_FEATURES, /* OVS_DP_F_* */
97 /* private: */
98 OVS_DP_ATTR_PAD,
99 /* public: */
100 OVS_DP_ATTR_MASKS_CACHE_SIZE,
101 OVS_DP_ATTR_PER_CPU_PIDS, /* Netlink PIDS to receive upcalls in
102 * per-cpu dispatch mode
103 */
104 OVS_DP_ATTR_IFINDEX,
105 /* private: */
106 __OVS_DP_ATTR_MAX
107};
108
109#define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1)
110
111struct ovs_dp_stats {
112 __u64 n_hit; /* Number of flow table matches. */
113 __u64 n_missed; /* Number of flow table misses. */
114 __u64 n_lost; /* Number of misses not sent to userspace. */
115 __u64 n_flows; /* Number of flows present */
116};
117
118struct ovs_dp_megaflow_stats {
119 __u64 n_mask_hit; /* Number of masks used for flow lookups. */
120 __u32 n_masks; /* Number of masks for the datapath. */
121 __u32 pad0; /* Pad for future expension. */
122 __u64 n_cache_hit; /* Number of cache matches for flow lookups. */
123 __u64 pad1; /* Pad for future expension. */
124};
125
126struct ovs_vport_stats {
127 __u64 rx_packets; /* total packets received */
128 __u64 tx_packets; /* total packets transmitted */
129 __u64 rx_bytes; /* total bytes received */
130 __u64 tx_bytes; /* total bytes transmitted */
131 __u64 rx_errors; /* bad packets received */
132 __u64 tx_errors; /* packet transmit problems */
133 __u64 rx_dropped; /* no space in linux buffers */
134 __u64 tx_dropped; /* no space available in linux */
135};
136
137/* Allow last Netlink attribute to be unaligned */
138#define OVS_DP_F_UNALIGNED (1 << 0)
139
140/* Allow datapath to associate multiple Netlink PIDs to each vport */
141#define OVS_DP_F_VPORT_PIDS (1 << 1)
142
143/* Allow tc offload recirc sharing */
144#define OVS_DP_F_TC_RECIRC_SHARING (1 << 2)
145
146/* Allow per-cpu dispatch of upcalls */
147#define OVS_DP_F_DISPATCH_UPCALL_PER_CPU (1 << 3)
148
149/* Fixed logical ports. */
150#define OVSP_LOCAL ((__u32)0)
151
152/* Packet transfer. */
153
154#define OVS_PACKET_FAMILY "ovs_packet"
155#define OVS_PACKET_VERSION 0x1
156
157enum ovs_packet_cmd {
158 OVS_PACKET_CMD_UNSPEC,
159
160 /* Kernel-to-user notifications. */
161 OVS_PACKET_CMD_MISS, /* Flow table miss. */
162 OVS_PACKET_CMD_ACTION, /* OVS_ACTION_ATTR_USERSPACE action. */
163
164 /* Userspace commands. */
165 OVS_PACKET_CMD_EXECUTE /* Apply actions to a packet. */
166};
167
168/**
169 * enum ovs_packet_attr - attributes for %OVS_PACKET_* commands.
170 * @OVS_PACKET_ATTR_PACKET: Present for all notifications. Contains the entire
171 * packet as received, from the start of the Ethernet header onward. For
172 * %OVS_PACKET_CMD_ACTION, %OVS_PACKET_ATTR_PACKET reflects changes made by
173 * actions preceding %OVS_ACTION_ATTR_USERSPACE, but %OVS_PACKET_ATTR_KEY is
174 * the flow key extracted from the packet as originally received.
175 * @OVS_PACKET_ATTR_KEY: Present for all notifications. Contains the flow key
176 * extracted from the packet as nested %OVS_KEY_ATTR_* attributes. This allows
177 * userspace to adapt its flow setup strategy by comparing its notion of the
178 * flow key against the kernel's.
179 * @OVS_PACKET_ATTR_ACTIONS: Contains actions for the packet. Used
180 * for %OVS_PACKET_CMD_EXECUTE. It has nested %OVS_ACTION_ATTR_* attributes.
181 * Also used in upcall when %OVS_ACTION_ATTR_USERSPACE has optional
182 * %OVS_USERSPACE_ATTR_ACTIONS attribute.
183 * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION
184 * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
185 * %OVS_USERSPACE_ATTR_USERDATA attribute, with the same length and content
186 * specified there.
187 * @OVS_PACKET_ATTR_EGRESS_TUN_KEY: Present for an %OVS_PACKET_CMD_ACTION
188 * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
189 * %OVS_USERSPACE_ATTR_EGRESS_TUN_PORT attribute, which is sent only if the
190 * output port is actually a tunnel port. Contains the output tunnel key
191 * extracted from the packet as nested %OVS_TUNNEL_KEY_ATTR_* attributes.
192 * @OVS_PACKET_ATTR_PROBE: Packet operation is a feature probe.
193 * @OVS_PACKET_ATTR_MRU: Present for an %OVS_PACKET_CMD_ACTION and
194 * @OVS_PACKET_ATTR_LEN: Packet size before truncation.
195 * %OVS_PACKET_ATTR_USERSPACE action specify the Maximum received fragment
196 * size.
197 * @OVS_PACKET_ATTR_HASH: Packet hash info (e.g. hash, sw_hash and l4_hash in skb).
198 * @OVS_PACKET_ATTR_UPCALL_PID: Netlink PID to use for upcalls while
199 * processing %OVS_PACKET_CMD_EXECUTE. Takes precedence over all other ways
200 * to determine the Netlink PID including %OVS_USERSPACE_ATTR_PID,
201 * %OVS_DP_ATTR_UPCALL_PID, %OVS_DP_ATTR_PER_CPU_PIDS and the
202 * %OVS_VPORT_ATTR_UPCALL_PID.
203 *
204 * These attributes follow the &struct ovs_header within the Generic Netlink
205 * payload for %OVS_PACKET_* commands.
206 */
207enum ovs_packet_attr {
208 /* private: */
209 OVS_PACKET_ATTR_UNSPEC,
210 /* public: */
211 OVS_PACKET_ATTR_PACKET, /* Packet data. */
212 OVS_PACKET_ATTR_KEY, /* Nested OVS_KEY_ATTR_* attributes. */
213 OVS_PACKET_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */
214 OVS_PACKET_ATTR_USERDATA, /* OVS_ACTION_ATTR_USERSPACE arg. */
215 OVS_PACKET_ATTR_EGRESS_TUN_KEY, /* Nested OVS_TUNNEL_KEY_ATTR_*
216 attributes. */
217 /* private: */
218 OVS_PACKET_ATTR_UNUSED1,
219 OVS_PACKET_ATTR_UNUSED2,
220 /* public: */
221 OVS_PACKET_ATTR_PROBE, /* Packet operation is a feature probe,
222 error logging should be suppressed. */
223 OVS_PACKET_ATTR_MRU, /* Maximum received IP fragment size. */
224 OVS_PACKET_ATTR_LEN, /* Packet size before truncation. */
225 OVS_PACKET_ATTR_HASH, /* Packet hash. */
226 OVS_PACKET_ATTR_UPCALL_PID, /* u32 Netlink PID. */
227 /* private: */
228 __OVS_PACKET_ATTR_MAX
229};
230
231#define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1)
232
233/* Virtual ports. */
234
235#define OVS_VPORT_FAMILY "ovs_vport"
236#define OVS_VPORT_MCGROUP "ovs_vport"
237#define OVS_VPORT_VERSION 0x1
238
239enum ovs_vport_cmd {
240 OVS_VPORT_CMD_UNSPEC,
241 OVS_VPORT_CMD_NEW,
242 OVS_VPORT_CMD_DEL,
243 OVS_VPORT_CMD_GET,
244 OVS_VPORT_CMD_SET
245};
246
247enum ovs_vport_type {
248 OVS_VPORT_TYPE_UNSPEC,
249 OVS_VPORT_TYPE_NETDEV, /* network device */
250 OVS_VPORT_TYPE_INTERNAL, /* network device implemented by datapath */
251 OVS_VPORT_TYPE_GRE, /* GRE tunnel. */
252 OVS_VPORT_TYPE_VXLAN, /* VXLAN tunnel. */
253 OVS_VPORT_TYPE_GENEVE, /* Geneve tunnel. */
254 __OVS_VPORT_TYPE_MAX
255};
256
257#define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1)
258
259/**
260 * enum ovs_vport_attr - attributes for %OVS_VPORT_* commands.
261 * @OVS_VPORT_ATTR_PORT_NO: 32-bit port number within datapath.
262 * @OVS_VPORT_ATTR_TYPE: 32-bit %OVS_VPORT_TYPE_* constant describing the type
263 * of vport.
264 * @OVS_VPORT_ATTR_NAME: Name of vport. For a vport based on a network device
265 * this is the name of the network device. Maximum length %IFNAMSIZ-1 bytes
266 * plus a null terminator.
267 * @OVS_VPORT_ATTR_OPTIONS: Vport-specific configuration information.
268 * @OVS_VPORT_ATTR_UPCALL_PID: The array of Netlink socket pids in userspace
269 * among which OVS_PACKET_CMD_MISS upcalls will be distributed for packets
270 * received on this port. If this is a single-element array of value 0,
271 * upcalls should not be sent.
272 * @OVS_VPORT_ATTR_STATS: A &struct ovs_vport_stats giving statistics for
273 * packets sent or received through the vport.
274 * @OVS_VPORT_ATTR_IFINDEX: Provides the ifindex of a vport, or sets the desired
275 * ifindex while creating a new vport with type %OVS_VPORT_TYPE_INTERNAL.
276 * @OVS_VPORT_ATTR_NETNSID: Provides the netns id of the vport if it's not local.
277 * @OVS_VPORT_ATTR_UPCALL_STATS: Provides upcall statistics for a vport.
278 * Contains nested %OVS_VPORT_UPCALL_ATTR_* attributes.
279 *
280 * These attributes follow the &struct ovs_header within the Generic Netlink
281 * payload for %OVS_VPORT_* commands.
282 *
283 * For %OVS_VPORT_CMD_NEW requests, the %OVS_VPORT_ATTR_TYPE and
284 * %OVS_VPORT_ATTR_NAME attributes are required. %OVS_VPORT_ATTR_PORT_NO is
285 * optional; if not specified a free port number is automatically selected.
286 * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type
287 * of vport.
288 *
289 * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to
290 * look up the vport to operate on; otherwise dp_idx from the &struct
291 * ovs_header plus %OVS_VPORT_ATTR_PORT_NO determine the vport.
292 */
293enum ovs_vport_attr {
294 /* private: */
295 OVS_VPORT_ATTR_UNSPEC,
296 /* public: */
297 OVS_VPORT_ATTR_PORT_NO, /* u32 port number within datapath */
298 OVS_VPORT_ATTR_TYPE, /* u32 OVS_VPORT_TYPE_* constant. */
299 OVS_VPORT_ATTR_NAME, /* string name, up to IFNAMSIZ bytes long */
300 OVS_VPORT_ATTR_OPTIONS, /* nested attributes, varies by vport type */
301 OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */
302 /* receiving upcalls */
303 OVS_VPORT_ATTR_STATS, /* struct ovs_vport_stats */
304 /* private: */
305 OVS_VPORT_ATTR_PAD,
306 /* public: */
307 OVS_VPORT_ATTR_IFINDEX,
308 OVS_VPORT_ATTR_NETNSID,
309 OVS_VPORT_ATTR_UPCALL_STATS,
310 /* private: */
311 __OVS_VPORT_ATTR_MAX
312};
313
314#define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1)
315
316/**
317 * enum ovs_vport_upcall_attr - attributes for %OVS_VPORT_ATTR_UPCALL_STATS
318 * @OVS_VPORT_UPCALL_ATTR_SUCCESS: 64-bit upcall success packets.
319 * @OVS_VPORT_UPCALL_ATTR_FAIL: 64-bit upcall fail packets.
320 */
321enum ovs_vport_upcall_attr {
322 OVS_VPORT_UPCALL_ATTR_SUCCESS,
323 OVS_VPORT_UPCALL_ATTR_FAIL,
324 /* private: */
325 __OVS_VPORT_UPCALL_ATTR_MAX
326};
327
328#define OVS_VPORT_UPCALL_ATTR_MAX (__OVS_VPORT_UPCALL_ATTR_MAX - 1)
329
330enum {
331 OVS_VXLAN_EXT_UNSPEC,
332 OVS_VXLAN_EXT_GBP, /* Flag or __u32 */
333 __OVS_VXLAN_EXT_MAX,
334};
335
336#define OVS_VXLAN_EXT_MAX (__OVS_VXLAN_EXT_MAX - 1)
337
338
339/* OVS_VPORT_ATTR_OPTIONS attributes for tunnels.
340 */
341enum {
342 OVS_TUNNEL_ATTR_UNSPEC,
343 OVS_TUNNEL_ATTR_DST_PORT, /* 16-bit UDP port, used by L4 tunnels. */
344 OVS_TUNNEL_ATTR_EXTENSION,
345 __OVS_TUNNEL_ATTR_MAX
346};
347
348#define OVS_TUNNEL_ATTR_MAX (__OVS_TUNNEL_ATTR_MAX - 1)
349
350/* Flows. */
351
352#define OVS_FLOW_FAMILY "ovs_flow"
353#define OVS_FLOW_MCGROUP "ovs_flow"
354#define OVS_FLOW_VERSION 0x1
355
356enum ovs_flow_cmd {
357 OVS_FLOW_CMD_UNSPEC,
358 OVS_FLOW_CMD_NEW,
359 OVS_FLOW_CMD_DEL,
360 OVS_FLOW_CMD_GET,
361 OVS_FLOW_CMD_SET
362};
363
364struct ovs_flow_stats {
365 __u64 n_packets; /* Number of matched packets. */
366 __u64 n_bytes; /* Number of matched bytes. */
367};
368
369enum ovs_key_attr {
370 OVS_KEY_ATTR_UNSPEC,
371 OVS_KEY_ATTR_ENCAP, /* Nested set of encapsulated attributes. */
372 OVS_KEY_ATTR_PRIORITY, /* u32 skb->priority */
373 OVS_KEY_ATTR_IN_PORT, /* u32 OVS dp port number */
374 OVS_KEY_ATTR_ETHERNET, /* struct ovs_key_ethernet */
375 OVS_KEY_ATTR_VLAN, /* be16 VLAN TCI */
376 OVS_KEY_ATTR_ETHERTYPE, /* be16 Ethernet type */
377 OVS_KEY_ATTR_IPV4, /* struct ovs_key_ipv4 */
378 OVS_KEY_ATTR_IPV6, /* struct ovs_key_ipv6 */
379 OVS_KEY_ATTR_TCP, /* struct ovs_key_tcp */
380 OVS_KEY_ATTR_UDP, /* struct ovs_key_udp */
381 OVS_KEY_ATTR_ICMP, /* struct ovs_key_icmp */
382 OVS_KEY_ATTR_ICMPV6, /* struct ovs_key_icmpv6 */
383 OVS_KEY_ATTR_ARP, /* struct ovs_key_arp */
384 OVS_KEY_ATTR_ND, /* struct ovs_key_nd */
385 OVS_KEY_ATTR_SKB_MARK, /* u32 skb mark */
386 OVS_KEY_ATTR_TUNNEL, /* Nested set of ovs_tunnel attributes */
387 OVS_KEY_ATTR_SCTP, /* struct ovs_key_sctp */
388 OVS_KEY_ATTR_TCP_FLAGS, /* be16 TCP flags. */
389 OVS_KEY_ATTR_DP_HASH, /* u32 hash value. Value 0 indicates the hash
390 is not computed by the datapath. */
391 OVS_KEY_ATTR_RECIRC_ID, /* u32 recirc id */
392 OVS_KEY_ATTR_MPLS, /* array of struct ovs_key_mpls.
393 * The implementation may restrict
394 * the accepted length of the array. */
395 OVS_KEY_ATTR_CT_STATE, /* u32 bitmask of OVS_CS_F_* */
396 OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */
397 OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */
398 OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */
399 OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4, /* struct ovs_key_ct_tuple_ipv4 */
400 OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6, /* struct ovs_key_ct_tuple_ipv6 */
401 OVS_KEY_ATTR_NSH, /* Nested set of ovs_nsh_key_* */
402
403 /* User space decided to squat on types 29 and 30. They are defined
404 * below, but should not be sent to the kernel.
405 *
406 * WARNING: No new types should be added unless they are defined
407 * for both kernel and user space (no 'ifdef's). It's hard
408 * to keep compatibility otherwise.
409 */
410 OVS_KEY_ATTR_PACKET_TYPE, /* be32 packet type */
411 OVS_KEY_ATTR_ND_EXTENSIONS, /* IPv6 Neighbor Discovery extensions */
412
413 OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info.
414 * For in-kernel use only.
415 */
416 OVS_KEY_ATTR_IPV6_EXTHDRS, /* struct ovs_key_ipv6_exthdr */
417 __OVS_KEY_ATTR_MAX
418};
419
420#define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1)
421
422enum ovs_tunnel_key_attr {
423 /* OVS_TUNNEL_KEY_ATTR_NONE, standard nl API requires this attribute! */
424 OVS_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */
425 OVS_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */
426 OVS_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */
427 OVS_TUNNEL_KEY_ATTR_TOS, /* u8 Tunnel IP ToS. */
428 OVS_TUNNEL_KEY_ATTR_TTL, /* u8 Tunnel IP TTL. */
429 OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT, /* No argument, set DF. */
430 OVS_TUNNEL_KEY_ATTR_CSUM, /* No argument. CSUM packet. */
431 OVS_TUNNEL_KEY_ATTR_OAM, /* No argument. OAM frame. */
432 OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS, /* Array of Geneve options. */
433 OVS_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. */
434 OVS_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. */
435 OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested OVS_VXLAN_EXT_* */
436 OVS_TUNNEL_KEY_ATTR_IPV6_SRC, /* struct in6_addr src IPv6 address. */
437 OVS_TUNNEL_KEY_ATTR_IPV6_DST, /* struct in6_addr dst IPv6 address. */
438 OVS_TUNNEL_KEY_ATTR_PAD,
439 OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS, /* struct erspan_metadata */
440 OVS_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE, /* No argument. IPV4_INFO_BRIDGE mode.*/
441 __OVS_TUNNEL_KEY_ATTR_MAX
442};
443
444#define OVS_TUNNEL_KEY_ATTR_MAX (__OVS_TUNNEL_KEY_ATTR_MAX - 1)
445
446/**
447 * enum ovs_frag_type - IPv4 and IPv6 fragment type
448 * @OVS_FRAG_TYPE_NONE: Packet is not a fragment.
449 * @OVS_FRAG_TYPE_FIRST: Packet is a fragment with offset 0.
450 * @OVS_FRAG_TYPE_LATER: Packet is a fragment with nonzero offset.
451 *
452 * Used as the @ipv4_frag in &struct ovs_key_ipv4 and as @ipv6_frag &struct
453 * ovs_key_ipv6.
454 */
455enum ovs_frag_type {
456 OVS_FRAG_TYPE_NONE,
457 OVS_FRAG_TYPE_FIRST,
458 OVS_FRAG_TYPE_LATER,
459 /* private: */
460 __OVS_FRAG_TYPE_MAX
461};
462
463#define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1)
464
465struct ovs_key_ethernet {
466 __u8 eth_src[ETH_ALEN];
467 __u8 eth_dst[ETH_ALEN];
468};
469
470struct ovs_key_mpls {
471 __be32 mpls_lse;
472};
473
474struct ovs_key_ipv4 {
475 __be32 ipv4_src;
476 __be32 ipv4_dst;
477 __u8 ipv4_proto;
478 __u8 ipv4_tos;
479 __u8 ipv4_ttl;
480 __u8 ipv4_frag; /* One of OVS_FRAG_TYPE_*. */
481};
482
483struct ovs_key_ipv6 {
484 __be32 ipv6_src[4];
485 __be32 ipv6_dst[4];
486 __be32 ipv6_label; /* 20-bits in least-significant bits. */
487 __u8 ipv6_proto;
488 __u8 ipv6_tclass;
489 __u8 ipv6_hlimit;
490 __u8 ipv6_frag; /* One of OVS_FRAG_TYPE_*. */
491};
492
493/* separate structure to support backward compatibility with older user space */
494struct ovs_key_ipv6_exthdrs {
495 __u16 hdrs;
496};
497
498struct ovs_key_tcp {
499 __be16 tcp_src;
500 __be16 tcp_dst;
501};
502
503struct ovs_key_udp {
504 __be16 udp_src;
505 __be16 udp_dst;
506};
507
508struct ovs_key_sctp {
509 __be16 sctp_src;
510 __be16 sctp_dst;
511};
512
513struct ovs_key_icmp {
514 __u8 icmp_type;
515 __u8 icmp_code;
516};
517
518struct ovs_key_icmpv6 {
519 __u8 icmpv6_type;
520 __u8 icmpv6_code;
521};
522
523struct ovs_key_arp {
524 __be32 arp_sip;
525 __be32 arp_tip;
526 __be16 arp_op;
527 __u8 arp_sha[ETH_ALEN];
528 __u8 arp_tha[ETH_ALEN];
529};
530
531struct ovs_key_nd {
532 __be32 nd_target[4];
533 __u8 nd_sll[ETH_ALEN];
534 __u8 nd_tll[ETH_ALEN];
535};
536
537#define OVS_CT_LABELS_LEN_32 4
538#define OVS_CT_LABELS_LEN (OVS_CT_LABELS_LEN_32 * sizeof(__u32))
539struct ovs_key_ct_labels {
540 union {
541 __u8 ct_labels[OVS_CT_LABELS_LEN];
542 __u32 ct_labels_32[OVS_CT_LABELS_LEN_32];
543 };
544};
545
546/* OVS_KEY_ATTR_CT_STATE flags */
547#define OVS_CS_F_NEW 0x01 /* Beginning of a new connection. */
548#define OVS_CS_F_ESTABLISHED 0x02 /* Part of an existing connection. */
549#define OVS_CS_F_RELATED 0x04 /* Related to an established
550 * connection. */
551#define OVS_CS_F_REPLY_DIR 0x08 /* Flow is in the reply direction. */
552#define OVS_CS_F_INVALID 0x10 /* Could not track connection. */
553#define OVS_CS_F_TRACKED 0x20 /* Conntrack has occurred. */
554#define OVS_CS_F_SRC_NAT 0x40 /* Packet's source address/port was
555 * mangled by NAT.
556 */
557#define OVS_CS_F_DST_NAT 0x80 /* Packet's destination address/port
558 * was mangled by NAT.
559 */
560
561#define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
562
563struct ovs_key_ct_tuple_ipv4 {
564 __be32 ipv4_src;
565 __be32 ipv4_dst;
566 __be16 src_port;
567 __be16 dst_port;
568 __u8 ipv4_proto;
569};
570
571struct ovs_key_ct_tuple_ipv6 {
572 __be32 ipv6_src[4];
573 __be32 ipv6_dst[4];
574 __be16 src_port;
575 __be16 dst_port;
576 __u8 ipv6_proto;
577};
578
579enum ovs_nsh_key_attr {
580 OVS_NSH_KEY_ATTR_UNSPEC,
581 OVS_NSH_KEY_ATTR_BASE, /* struct ovs_nsh_key_base. */
582 OVS_NSH_KEY_ATTR_MD1, /* struct ovs_nsh_key_md1. */
583 OVS_NSH_KEY_ATTR_MD2, /* variable-length octets for MD type 2. */
584 __OVS_NSH_KEY_ATTR_MAX
585};
586
587#define OVS_NSH_KEY_ATTR_MAX (__OVS_NSH_KEY_ATTR_MAX - 1)
588
589struct ovs_nsh_key_base {
590 __u8 flags;
591 __u8 ttl;
592 __u8 mdtype;
593 __u8 np;
594 __be32 path_hdr;
595};
596
597#define NSH_MD1_CONTEXT_SIZE 4
598
599struct ovs_nsh_key_md1 {
600 __be32 context[NSH_MD1_CONTEXT_SIZE];
601};
602
603/**
604 * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.
605 * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow
606 * key. Always present in notifications. Required for all requests (except
607 * dumps).
608 * @OVS_FLOW_ATTR_ACTIONS: Nested %OVS_ACTION_ATTR_* attributes specifying
609 * the actions to take for packets that match the key. Always present in
610 * notifications. Required for %OVS_FLOW_CMD_NEW requests, optional for
611 * %OVS_FLOW_CMD_SET requests. An %OVS_FLOW_CMD_SET without
612 * %OVS_FLOW_ATTR_ACTIONS will not modify the actions. To clear the actions,
613 * an %OVS_FLOW_ATTR_ACTIONS without any nested attributes must be given.
614 * @OVS_FLOW_ATTR_STATS: &struct ovs_flow_stats giving statistics for this
615 * flow. Present in notifications if the stats would be nonzero. Ignored in
616 * requests.
617 * @OVS_FLOW_ATTR_TCP_FLAGS: An 8-bit value giving the OR'd value of all of the
618 * TCP flags seen on packets in this flow. Only present in notifications for
619 * TCP flows, and only if it would be nonzero. Ignored in requests.
620 * @OVS_FLOW_ATTR_USED: A 64-bit integer giving the time, in milliseconds on
621 * the system monotonic clock, at which a packet was last processed for this
622 * flow. Only present in notifications if a packet has been processed for this
623 * flow. Ignored in requests.
624 * @OVS_FLOW_ATTR_CLEAR: If present in a %OVS_FLOW_CMD_SET request, clears the
625 * last-used time, accumulated TCP flags, and statistics for this flow.
626 * Otherwise ignored in requests. Never present in notifications.
627 * @OVS_FLOW_ATTR_MASK: Nested %OVS_KEY_ATTR_* attributes specifying the
628 * mask bits for wildcarded flow match. Mask bit value '1' specifies exact
629 * match with corresponding flow key bit, while mask bit value '0' specifies
630 * a wildcarded match. Omitting attribute is treated as wildcarding all
631 * corresponding fields. Optional for all requests. If not present,
632 * all flow key bits are exact match bits.
633 * @OVS_FLOW_ATTR_PROBE: Flow operation is a feature probe, error logging
634 * should be suppressed.
635 * @OVS_FLOW_ATTR_UFID: A value between 1-16 octets specifying a unique
636 * identifier for the flow. Causes the flow to be indexed by this value rather
637 * than the value of the %OVS_FLOW_ATTR_KEY attribute. Optional for all
638 * requests. Present in notifications if the flow was created with this
639 * attribute.
640 * @OVS_FLOW_ATTR_UFID_FLAGS: A 32-bit value of OR'd %OVS_UFID_F_*
641 * flags that provide alternative semantics for flow installation and
642 * retrieval. Optional for all requests.
643 *
644 * These attributes follow the &struct ovs_header within the Generic Netlink
645 * payload for %OVS_FLOW_* commands.
646 */
647enum ovs_flow_attr {
648 /* private: */
649 OVS_FLOW_ATTR_UNSPEC,
650 /* public: */
651 OVS_FLOW_ATTR_KEY, /* Sequence of OVS_KEY_ATTR_* attributes. */
652 OVS_FLOW_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */
653 OVS_FLOW_ATTR_STATS, /* struct ovs_flow_stats. */
654 OVS_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */
655 OVS_FLOW_ATTR_USED, /* u64 msecs last used in monotonic time. */
656 OVS_FLOW_ATTR_CLEAR, /* Flag to clear stats, tcp_flags, used. */
657 OVS_FLOW_ATTR_MASK, /* Sequence of OVS_KEY_ATTR_* attributes. */
658 OVS_FLOW_ATTR_PROBE, /* Flow operation is a feature probe, error
659 * logging should be suppressed. */
660 OVS_FLOW_ATTR_UFID, /* Variable length unique flow identifier. */
661 OVS_FLOW_ATTR_UFID_FLAGS,/* u32 of OVS_UFID_F_*. */
662 /* private: */
663 OVS_FLOW_ATTR_PAD,
664 __OVS_FLOW_ATTR_MAX
665};
666
667#define OVS_FLOW_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1)
668
669/*
670 * Omit attributes for notifications.
671 *
672 * If a datapath request contains an %OVS_UFID_F_OMIT_* flag, then the datapath
673 * may omit the corresponding %OVS_FLOW_ATTR_* from the response.
674 */
675#define OVS_UFID_F_OMIT_KEY (1 << 0)
676#define OVS_UFID_F_OMIT_MASK (1 << 1)
677#define OVS_UFID_F_OMIT_ACTIONS (1 << 2)
678
679/**
680 * enum ovs_sample_attr - Attributes for %OVS_ACTION_ATTR_SAMPLE action.
681 * @OVS_SAMPLE_ATTR_PROBABILITY: 32-bit fraction of packets to sample with
682 * @OVS_ACTION_ATTR_SAMPLE. A value of 0 samples no packets, a value of
683 * %UINT32_MAX samples all packets and intermediate values sample intermediate
684 * fractions of packets.
685 * @OVS_SAMPLE_ATTR_ACTIONS: Set of actions to execute in sampling event.
686 * Actions are passed as nested attributes.
687 * @OVS_SAMPLE_ATTR_ARG: For in-kernel use, passing &struct sample_arg
688 * derived from other attributes.
689 *
690 * Executes the specified actions with the given probability on a per-packet
691 * basis. Nested actions will be able to access the probability value of the
692 * parent @OVS_ACTION_ATTR_SAMPLE.
693 */
694enum ovs_sample_attr {
695 /* private: */
696 OVS_SAMPLE_ATTR_UNSPEC,
697 /* public: */
698 OVS_SAMPLE_ATTR_PROBABILITY, /* u32 number */
699 OVS_SAMPLE_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */
700 /* private: */
701 __OVS_SAMPLE_ATTR_MAX,
702
703 /* public: */
704#ifdef __KERNEL__
705 OVS_SAMPLE_ATTR_ARG /* struct sample_arg */
706#endif
707};
708
709#define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1)
710
711#ifdef __KERNEL__
712struct sample_arg {
713 bool exec; /* When true, actions in sample will not
714 * change flow keys. False otherwise.
715 */
716 u32 probability; /* Same value as
717 * 'OVS_SAMPLE_ATTR_PROBABILITY'.
718 */
719};
720#endif
721
722/**
723 * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action.
724 * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION
725 * message should be sent. Required.
726 * @OVS_USERSPACE_ATTR_USERDATA: If present, its variable-length argument is
727 * copied to the %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA.
728 * @OVS_USERSPACE_ATTR_EGRESS_TUN_PORT: If present, u32 output port to get
729 * tunnel info.
730 * @OVS_USERSPACE_ATTR_ACTIONS: If present, send actions with upcall.
731 */
732enum ovs_userspace_attr {
733 /* private: */
734 OVS_USERSPACE_ATTR_UNSPEC,
735 /* public: */
736 OVS_USERSPACE_ATTR_PID, /* u32 Netlink PID to receive upcalls. */
737 OVS_USERSPACE_ATTR_USERDATA, /* Optional user-specified cookie. */
738 OVS_USERSPACE_ATTR_EGRESS_TUN_PORT, /* Optional, u32 output port
739 * to get tunnel info. */
740 OVS_USERSPACE_ATTR_ACTIONS, /* Optional flag to get actions. */
741 /* private: */
742 __OVS_USERSPACE_ATTR_MAX
743};
744
745#define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)
746
747struct ovs_action_trunc {
748 __u32 max_len; /* Max packet size in bytes. */
749};
750
751/**
752 * struct ovs_action_push_mpls - %OVS_ACTION_ATTR_PUSH_MPLS action argument.
753 * @mpls_lse: MPLS label stack entry to push.
754 * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame.
755 *
756 * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and
757 * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected.
758 */
759struct ovs_action_push_mpls {
760 __be32 mpls_lse;
761 __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */
762};
763
764/**
765 * struct ovs_action_add_mpls - %OVS_ACTION_ATTR_ADD_MPLS action
766 * argument.
767 * @mpls_lse: MPLS label stack entry to push.
768 * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame.
769 * @tun_flags: MPLS tunnel attributes.
770 *
771 * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and
772 * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected.
773 */
774struct ovs_action_add_mpls {
775 __be32 mpls_lse;
776 __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */
777 __u16 tun_flags;
778};
779
780#define OVS_MPLS_L3_TUNNEL_FLAG_MASK (1 << 0) /* Flag to specify the place of
781 * insertion of MPLS header.
782 * When false, the MPLS header
783 * will be inserted at the start
784 * of the packet.
785 * When true, the MPLS header
786 * will be inserted at the start
787 * of the l3 header.
788 */
789
790/**
791 * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument.
792 * @vlan_tpid: Tag protocol identifier (TPID) to push.
793 * @vlan_tci: Tag control identifier (TCI) to push. The CFI bit must be set
794 * (but it will not be set in the 802.1Q header that is pushed).
795 *
796 * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
797 * The only acceptable TPID values are those that the kernel module also parses
798 * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
799 * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
800 */
801struct ovs_action_push_vlan {
802 __be16 vlan_tpid; /* 802.1Q or 802.1ad TPID. */
803 __be16 vlan_tci; /* 802.1Q TCI (VLAN ID and priority). */
804};
805
806/* Data path hash algorithm for computing Datapath hash.
807 *
808 * The algorithm type only specifies the fields in a flow
809 * will be used as part of the hash. Each datapath is free
810 * to use its own hash algorithm. The hash value will be
811 * opaque to the user space daemon.
812 */
813enum ovs_hash_alg {
814 OVS_HASH_ALG_L4,
815 OVS_HASH_ALG_SYM_L4,
816};
817
818/*
819 * struct ovs_action_hash - %OVS_ACTION_ATTR_HASH action argument.
820 * @hash_alg: Algorithm used to compute hash prior to recirculation.
821 * @hash_basis: basis used for computing hash.
822 */
823struct ovs_action_hash {
824 __u32 hash_alg; /* One of ovs_hash_alg. */
825 __u32 hash_basis;
826};
827
828/**
829 * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action.
830 * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack
831 * table. This allows future packets for the same connection to be identified
832 * as 'established' or 'related'. The flow key for the current packet will
833 * retain the pre-commit connection state.
834 * @OVS_CT_ATTR_ZONE: u16 connection tracking zone.
835 * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the
836 * mask, the corresponding bit in the value is copied to the connection
837 * tracking mark field in the connection.
838 * @OVS_CT_ATTR_LABELS: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN
839 * mask. For each bit set in the mask, the corresponding bit in the value is
840 * copied to the connection tracking label field in the connection.
841 * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG.
842 * @OVS_CT_ATTR_NAT: Nested OVS_NAT_ATTR_* for performing L3 network address
843 * translation (NAT) on the packet.
844 * @OVS_CT_ATTR_FORCE_COMMIT: Like %OVS_CT_ATTR_COMMIT, but instead of doing
845 * nothing if the connection is already committed will check that the current
846 * packet is in conntrack entry's original direction. If directionality does
847 * not match, will delete the existing conntrack entry and commit a new one.
848 * @OVS_CT_ATTR_EVENTMASK: Mask of bits indicating which conntrack event types
849 * (enum ip_conntrack_events IPCT_*) should be reported. For any bit set to
850 * zero, the corresponding event type is not generated. Default behavior
851 * depends on system configuration, but typically all event types are
852 * generated, hence listening on NFNLGRP_CONNTRACK_UPDATE events may get a lot
853 * of events. Explicitly passing this attribute allows limiting the updates
854 * received to the events of interest. The bit 1 << IPCT_NEW, 1 <<
855 * IPCT_RELATED, and 1 << IPCT_DESTROY must be set to ones for those events to
856 * be received on NFNLGRP_CONNTRACK_NEW and NFNLGRP_CONNTRACK_DESTROY groups,
857 * respectively. Remaining bits control the changes for which an event is
858 * delivered on the NFNLGRP_CONNTRACK_UPDATE group.
859 * @OVS_CT_ATTR_TIMEOUT: Variable length string defining conntrack timeout.
860 */
861enum ovs_ct_attr {
862 /* private: */
863 OVS_CT_ATTR_UNSPEC,
864 /* public: */
865 OVS_CT_ATTR_COMMIT, /* No argument, commits connection. */
866 OVS_CT_ATTR_ZONE, /* u16 zone id. */
867 OVS_CT_ATTR_MARK, /* mark to associate with this connection. */
868 OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */
869 OVS_CT_ATTR_HELPER, /* netlink helper to assist detection of
870 related connections. */
871 OVS_CT_ATTR_NAT, /* Nested OVS_NAT_ATTR_* */
872 OVS_CT_ATTR_FORCE_COMMIT, /* No argument */
873 OVS_CT_ATTR_EVENTMASK, /* u32 mask of IPCT_* events. */
874 OVS_CT_ATTR_TIMEOUT, /* Associate timeout with this connection for
875 * fine-grain timeout tuning. */
876 /* private: */
877 __OVS_CT_ATTR_MAX
878};
879
880#define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1)
881
882/**
883 * enum ovs_nat_attr - Attributes for %OVS_CT_ATTR_NAT.
884 *
885 * @OVS_NAT_ATTR_SRC: Flag for Source NAT (mangle source address/port).
886 * @OVS_NAT_ATTR_DST: Flag for Destination NAT (mangle destination
887 * address/port). Only one of (@OVS_NAT_ATTR_SRC, @OVS_NAT_ATTR_DST) may be
888 * specified. Effective only for packets for ct_state NEW connections.
889 * Packets of committed connections are mangled by the NAT action according to
890 * the committed NAT type regardless of the flags specified. As a corollary, a
891 * NAT action without a NAT type flag will only mangle packets of committed
892 * connections. The following NAT attributes only apply for NEW
893 * (non-committed) connections, and they may be included only when the CT
894 * action has the @OVS_CT_ATTR_COMMIT flag and either @OVS_NAT_ATTR_SRC or
895 * @OVS_NAT_ATTR_DST is also included.
896 * @OVS_NAT_ATTR_IP_MIN: struct in_addr or struct in6_addr
897 * @OVS_NAT_ATTR_IP_MAX: struct in_addr or struct in6_addr
898 * @OVS_NAT_ATTR_PROTO_MIN: u16 L4 protocol specific lower boundary (port)
899 * @OVS_NAT_ATTR_PROTO_MAX: u16 L4 protocol specific upper boundary (port)
900 * @OVS_NAT_ATTR_PERSISTENT: Flag for persistent IP mapping across reboots
901 * @OVS_NAT_ATTR_PROTO_HASH: Flag for pseudo random L4 port mapping (MD5)
902 * @OVS_NAT_ATTR_PROTO_RANDOM: Flag for fully randomized L4 port mapping
903 */
904enum ovs_nat_attr {
905 /* private: */
906 OVS_NAT_ATTR_UNSPEC,
907 /* public: */
908 OVS_NAT_ATTR_SRC,
909 OVS_NAT_ATTR_DST,
910 OVS_NAT_ATTR_IP_MIN,
911 OVS_NAT_ATTR_IP_MAX,
912 OVS_NAT_ATTR_PROTO_MIN,
913 OVS_NAT_ATTR_PROTO_MAX,
914 OVS_NAT_ATTR_PERSISTENT,
915 OVS_NAT_ATTR_PROTO_HASH,
916 OVS_NAT_ATTR_PROTO_RANDOM,
917 /* private: */
918 __OVS_NAT_ATTR_MAX,
919};
920
921#define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1)
922
923/**
924 * struct ovs_action_push_eth - %OVS_ACTION_ATTR_PUSH_ETH action argument.
925 * @addresses: Source and destination MAC addresses.
926 */
927struct ovs_action_push_eth {
928 struct ovs_key_ethernet addresses;
929};
930
931/**
932 * enum ovs_check_pkt_len_attr - Attributes for %OVS_ACTION_ATTR_CHECK_PKT_LEN.
933 *
934 * @OVS_CHECK_PKT_LEN_ATTR_PKT_LEN: u16 Packet length to check for.
935 * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER: Nested OVS_ACTION_ATTR_*
936 * actions to apply if the packer length is greater than the specified
937 * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
938 * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL: Nested OVS_ACTION_ATTR_*
939 * actions to apply if the packer length is lesser or equal to the specified
940 * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
941 * @OVS_CHECK_PKT_LEN_ATTR_ARG: For in-kernel use, passing &struct
942 * check_pkt_len_arg derived from other attributes.
943 */
944enum ovs_check_pkt_len_attr {
945 /* private: */
946 OVS_CHECK_PKT_LEN_ATTR_UNSPEC,
947 /* public: */
948 OVS_CHECK_PKT_LEN_ATTR_PKT_LEN,
949 OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER,
950 OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL,
951 /* private: */
952 __OVS_CHECK_PKT_LEN_ATTR_MAX,
953
954 /* public: */
955#ifdef __KERNEL__
956 OVS_CHECK_PKT_LEN_ATTR_ARG /* struct check_pkt_len_arg */
957#endif
958};
959
960#define OVS_CHECK_PKT_LEN_ATTR_MAX (__OVS_CHECK_PKT_LEN_ATTR_MAX - 1)
961
962#ifdef __KERNEL__
963struct check_pkt_len_arg {
964 u16 pkt_len; /* Same value as OVS_CHECK_PKT_LEN_ATTR_PKT_LEN'. */
965 bool exec_for_greater; /* When true, actions in IF_GREATER will
966 * not change flow keys. False otherwise.
967 */
968 bool exec_for_lesser_equal; /* When true, actions in IF_LESS_EQUAL
969 * will not change flow keys. False
970 * otherwise.
971 */
972};
973#endif
974
975#define OVS_PSAMPLE_COOKIE_MAX_SIZE 16
976/**
977 * enum ovs_psample_attr - Attributes for %OVS_ACTION_ATTR_PSAMPLE
978 * action.
979 *
980 * @OVS_PSAMPLE_ATTR_GROUP: 32-bit number to identify the source of the
981 * sample.
982 * @OVS_PSAMPLE_ATTR_COOKIE: An optional variable-length binary cookie that
983 * contains user-defined metadata. The maximum length is
984 * OVS_PSAMPLE_COOKIE_MAX_SIZE bytes.
985 *
986 * Sends the packet to the psample multicast group with the specified group and
987 * cookie. It is possible to combine this action with the
988 * %OVS_ACTION_ATTR_TRUNC action to limit the size of the sample.
989 */
990enum ovs_psample_attr {
991 OVS_PSAMPLE_ATTR_GROUP = 1, /* u32 number. */
992 OVS_PSAMPLE_ATTR_COOKIE, /* Optional, user specified cookie. */
993
994 /* private: */
995 __OVS_PSAMPLE_ATTR_MAX
996};
997
998#define OVS_PSAMPLE_ATTR_MAX (__OVS_PSAMPLE_ATTR_MAX - 1)
999
1000/**
1001 * enum ovs_action_attr - Action types.
1002 *
1003 * @OVS_ACTION_ATTR_OUTPUT: Output packet to port.
1004 * @OVS_ACTION_ATTR_TRUNC: Output packet to port with truncated packet size.
1005 * @OVS_ACTION_ATTR_USERSPACE: Send packet to userspace according to nested
1006 * %OVS_USERSPACE_ATTR_* attributes.
1007 * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header. The
1008 * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its
1009 * value.
1010 * @OVS_ACTION_ATTR_SET_MASKED: Replaces the contents of an existing header. A
1011 * nested %OVS_KEY_ATTR_* attribute specifies a header to modify, its value,
1012 * and a mask. For every bit set in the mask, the corresponding bit value
1013 * is copied from the value to the packet header field, rest of the bits are
1014 * left unchanged. The non-masked value bits must be passed in as zeroes.
1015 * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
1016 * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
1017 * onto the packet.
1018 * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
1019 * from the packet.
1020 * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
1021 * the nested %OVS_SAMPLE_ATTR_* attributes.
1022 * @OVS_ACTION_ATTR_RECIRC: Recirculate the clone of the packet through the
1023 * datapath with the new id (u32 recirc_id).
1024 * @OVS_ACTION_ATTR_HASH: Compute the packet hash, using &struct ovs_action_hash.
1025 * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
1026 * top of the packets MPLS label stack. Set the ethertype of the
1027 * encapsulating frame to either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC to
1028 * indicate the new packet contents.
1029 * @OVS_ACTION_ATTR_POP_MPLS: Pop an MPLS label stack entry off of the
1030 * packet's MPLS label stack. Set the encapsulating frame's ethertype to
1031 * indicate the new packet contents. This could potentially still be
1032 * %ETH_P_MPLS if the resulting MPLS label stack is not empty. If there
1033 * is no MPLS label stack, as determined by ethertype, no action is taken.
1034 * @OVS_ACTION_ATTR_CT: Track the connection. Populate the conntrack-related
1035 * entries in the flow key.
1036 * @OVS_ACTION_ATTR_PUSH_ETH: Push a new outermost Ethernet header onto the
1037 * packet.
1038 * @OVS_ACTION_ATTR_POP_ETH: Pop the outermost Ethernet header off the
1039 * packet.
1040 * @OVS_ACTION_ATTR_CT_CLEAR: Clear conntrack state from the packet.
1041 * @OVS_ACTION_ATTR_PUSH_NSH: push NSH header to the packet.
1042 * @OVS_ACTION_ATTR_POP_NSH: pop the outermost NSH header off the packet.
1043 * @OVS_ACTION_ATTR_METER: Run packet through a meter, which may drop the
1044 * packet, or modify the packet (e.g., change the DSCP field).
1045 * @OVS_ACTION_ATTR_CLONE: make a copy of the packet and execute a list of
1046 * actions without affecting the original packet and key.
1047 * @OVS_ACTION_ATTR_CHECK_PKT_LEN: Check the packet length and execute a set
1048 * of actions if greater than the specified packet length, else execute
1049 * another set of actions.
1050 * @OVS_ACTION_ATTR_ADD_MPLS: Push a new MPLS label stack entry at the
1051 * start of the packet or at the start of the l3 header depending on the value
1052 * of l3 tunnel flag in the tun_flags field of OVS_ACTION_ATTR_ADD_MPLS
1053 * argument.
1054 * @OVS_ACTION_ATTR_DEC_TTL: Decrement TTL or hop limit of the packet. Execute
1055 * nested %OVS_DEC_TTL_ATTR_* actions if the value is less or equal to 1.
1056 * @OVS_ACTION_ATTR_DROP: Explicit drop action.
1057 * @OVS_ACTION_ATTR_PSAMPLE: Send a sample of the packet to external observers
1058 * via psample.
1059 *
1060 * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all
1061 * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
1062 * type may not be changed.
1063 *
1064 * @OVS_ACTION_ATTR_SET_TO_MASKED: Kernel internal masked set action translated
1065 * from the @OVS_ACTION_ATTR_SET.
1066 */
1067
1068enum ovs_action_attr {
1069 /* private: */
1070 OVS_ACTION_ATTR_UNSPEC,
1071 /* public: */
1072 OVS_ACTION_ATTR_OUTPUT, /* u32 port number. */
1073 OVS_ACTION_ATTR_USERSPACE, /* Nested OVS_USERSPACE_ATTR_*. */
1074 OVS_ACTION_ATTR_SET, /* One nested OVS_KEY_ATTR_*. */
1075 OVS_ACTION_ATTR_PUSH_VLAN, /* struct ovs_action_push_vlan. */
1076 OVS_ACTION_ATTR_POP_VLAN, /* No argument. */
1077 OVS_ACTION_ATTR_SAMPLE, /* Nested OVS_SAMPLE_ATTR_*. */
1078 OVS_ACTION_ATTR_RECIRC, /* u32 recirc_id. */
1079 OVS_ACTION_ATTR_HASH, /* struct ovs_action_hash. */
1080 OVS_ACTION_ATTR_PUSH_MPLS, /* struct ovs_action_push_mpls. */
1081 OVS_ACTION_ATTR_POP_MPLS, /* __be16 ethertype. */
1082 OVS_ACTION_ATTR_SET_MASKED, /* One nested OVS_KEY_ATTR_* including
1083 * data immediately followed by a mask.
1084 * The data must be zero for the unmasked
1085 * bits. */
1086 OVS_ACTION_ATTR_CT, /* Nested OVS_CT_ATTR_* . */
1087 OVS_ACTION_ATTR_TRUNC, /* u32 struct ovs_action_trunc. */
1088 OVS_ACTION_ATTR_PUSH_ETH, /* struct ovs_action_push_eth. */
1089 OVS_ACTION_ATTR_POP_ETH, /* No argument. */
1090 OVS_ACTION_ATTR_CT_CLEAR, /* No argument. */
1091 OVS_ACTION_ATTR_PUSH_NSH, /* Nested OVS_NSH_KEY_ATTR_*. */
1092 OVS_ACTION_ATTR_POP_NSH, /* No argument. */
1093 OVS_ACTION_ATTR_METER, /* u32 meter ID. */
1094 OVS_ACTION_ATTR_CLONE, /* Nested OVS_CLONE_ATTR_*. */
1095 OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
1096 OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
1097 OVS_ACTION_ATTR_DEC_TTL, /* Nested OVS_DEC_TTL_ATTR_*. */
1098 OVS_ACTION_ATTR_DROP, /* u32 error code. */
1099 OVS_ACTION_ATTR_PSAMPLE, /* Nested OVS_PSAMPLE_ATTR_*. */
1100
1101 /* private: */
1102 __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted
1103 * from userspace. */
1104
1105 /* public: */
1106#ifdef __KERNEL__
1107 OVS_ACTION_ATTR_SET_TO_MASKED, /* Kernel module internal masked
1108 * set action converted from
1109 * OVS_ACTION_ATTR_SET. */
1110#endif
1111};
1112
1113#define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
1114
1115/* Meters. */
1116#define OVS_METER_FAMILY "ovs_meter"
1117#define OVS_METER_MCGROUP "ovs_meter"
1118#define OVS_METER_VERSION 0x1
1119
1120enum ovs_meter_cmd {
1121 OVS_METER_CMD_UNSPEC,
1122 OVS_METER_CMD_FEATURES, /* Get features supported by the datapath. */
1123 OVS_METER_CMD_SET, /* Add or modify a meter. */
1124 OVS_METER_CMD_DEL, /* Delete a meter. */
1125 OVS_METER_CMD_GET /* Get meter stats. */
1126};
1127
1128enum ovs_meter_attr {
1129 OVS_METER_ATTR_UNSPEC,
1130 OVS_METER_ATTR_ID, /* u32 meter ID within datapath. */
1131 OVS_METER_ATTR_KBPS, /* No argument. If set, units in kilobits
1132 * per second. Otherwise, units in
1133 * packets per second.
1134 */
1135 OVS_METER_ATTR_STATS, /* struct ovs_flow_stats for the meter. */
1136 OVS_METER_ATTR_BANDS, /* Nested attributes for meter bands. */
1137 OVS_METER_ATTR_USED, /* u64 msecs last used in monotonic time. */
1138 OVS_METER_ATTR_CLEAR, /* Flag to clear stats, used. */
1139 OVS_METER_ATTR_MAX_METERS, /* u32 number of meters supported. */
1140 OVS_METER_ATTR_MAX_BANDS, /* u32 max number of bands per meter. */
1141 OVS_METER_ATTR_PAD,
1142 __OVS_METER_ATTR_MAX
1143};
1144
1145#define OVS_METER_ATTR_MAX (__OVS_METER_ATTR_MAX - 1)
1146
1147enum ovs_band_attr {
1148 OVS_BAND_ATTR_UNSPEC,
1149 OVS_BAND_ATTR_TYPE, /* u32 OVS_METER_BAND_TYPE_* constant. */
1150 OVS_BAND_ATTR_RATE, /* u32 band rate in meter units (see above). */
1151 OVS_BAND_ATTR_BURST, /* u32 burst size in meter units. */
1152 OVS_BAND_ATTR_STATS, /* struct ovs_flow_stats for the band. */
1153 __OVS_BAND_ATTR_MAX
1154};
1155
1156#define OVS_BAND_ATTR_MAX (__OVS_BAND_ATTR_MAX - 1)
1157
1158enum ovs_meter_band_type {
1159 OVS_METER_BAND_TYPE_UNSPEC,
1160 OVS_METER_BAND_TYPE_DROP, /* Drop exceeding packets. */
1161 __OVS_METER_BAND_TYPE_MAX
1162};
1163
1164#define OVS_METER_BAND_TYPE_MAX (__OVS_METER_BAND_TYPE_MAX - 1)
1165
1166/* Conntrack limit */
1167#define OVS_CT_LIMIT_FAMILY "ovs_ct_limit"
1168#define OVS_CT_LIMIT_MCGROUP "ovs_ct_limit"
1169#define OVS_CT_LIMIT_VERSION 0x1
1170
1171enum ovs_ct_limit_cmd {
1172 OVS_CT_LIMIT_CMD_UNSPEC,
1173 OVS_CT_LIMIT_CMD_SET, /* Add or modify ct limit. */
1174 OVS_CT_LIMIT_CMD_DEL, /* Delete ct limit. */
1175 OVS_CT_LIMIT_CMD_GET /* Get ct limit. */
1176};
1177
1178enum ovs_ct_limit_attr {
1179 OVS_CT_LIMIT_ATTR_UNSPEC,
1180 OVS_CT_LIMIT_ATTR_ZONE_LIMIT, /* Nested struct ovs_zone_limit. */
1181 __OVS_CT_LIMIT_ATTR_MAX
1182};
1183
1184#define OVS_CT_LIMIT_ATTR_MAX (__OVS_CT_LIMIT_ATTR_MAX - 1)
1185
1186#define OVS_ZONE_LIMIT_DEFAULT_ZONE -1
1187
1188struct ovs_zone_limit {
1189 int zone_id;
1190 __u32 limit;
1191 __u32 count;
1192};
1193
1194enum ovs_dec_ttl_attr {
1195 OVS_DEC_TTL_ATTR_UNSPEC,
1196 OVS_DEC_TTL_ATTR_ACTION, /* Nested struct nlattr */
1197 __OVS_DEC_TTL_ATTR_MAX
1198};
1199
1200#define OVS_DEC_TTL_ATTR_MAX (__OVS_DEC_TTL_ATTR_MAX - 1)
1201
1202#endif /* _LINUX_OPENVSWITCH_H */