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 __LINUX_OPENVSWITCH_H
22#define __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};
705
706#define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1)
707
708
709/**
710 * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action.
711 * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION
712 * message should be sent. Required.
713 * @OVS_USERSPACE_ATTR_USERDATA: If present, its variable-length argument is
714 * copied to the %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA.
715 * @OVS_USERSPACE_ATTR_EGRESS_TUN_PORT: If present, u32 output port to get
716 * tunnel info.
717 * @OVS_USERSPACE_ATTR_ACTIONS: If present, send actions with upcall.
718 */
719enum ovs_userspace_attr {
720 /* private: */
721 OVS_USERSPACE_ATTR_UNSPEC,
722 /* public: */
723 OVS_USERSPACE_ATTR_PID, /* u32 Netlink PID to receive upcalls. */
724 OVS_USERSPACE_ATTR_USERDATA, /* Optional user-specified cookie. */
725 OVS_USERSPACE_ATTR_EGRESS_TUN_PORT, /* Optional, u32 output port
726 * to get tunnel info. */
727 OVS_USERSPACE_ATTR_ACTIONS, /* Optional flag to get actions. */
728 /* private: */
729 __OVS_USERSPACE_ATTR_MAX
730};
731
732#define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)
733
734struct ovs_action_trunc {
735 __u32 max_len; /* Max packet size in bytes. */
736};
737
738/**
739 * struct ovs_action_push_mpls - %OVS_ACTION_ATTR_PUSH_MPLS action argument.
740 * @mpls_lse: MPLS label stack entry to push.
741 * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame.
742 *
743 * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and
744 * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected.
745 */
746struct ovs_action_push_mpls {
747 __be32 mpls_lse;
748 __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */
749};
750
751/**
752 * struct ovs_action_add_mpls - %OVS_ACTION_ATTR_ADD_MPLS action
753 * argument.
754 * @mpls_lse: MPLS label stack entry to push.
755 * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame.
756 * @tun_flags: MPLS tunnel attributes.
757 *
758 * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and
759 * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected.
760 */
761struct ovs_action_add_mpls {
762 __be32 mpls_lse;
763 __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */
764 __u16 tun_flags;
765};
766
767#define OVS_MPLS_L3_TUNNEL_FLAG_MASK (1 << 0) /* Flag to specify the place of
768 * insertion of MPLS header.
769 * When false, the MPLS header
770 * will be inserted at the start
771 * of the packet.
772 * When true, the MPLS header
773 * will be inserted at the start
774 * of the l3 header.
775 */
776
777/**
778 * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument.
779 * @vlan_tpid: Tag protocol identifier (TPID) to push.
780 * @vlan_tci: Tag control identifier (TCI) to push. The CFI bit must be set
781 * (but it will not be set in the 802.1Q header that is pushed).
782 *
783 * The @vlan_tpid value is typically %ETH_P_8021Q or %ETH_P_8021AD.
784 * The only acceptable TPID values are those that the kernel module also parses
785 * as 802.1Q or 802.1AD headers, to prevent %OVS_ACTION_ATTR_PUSH_VLAN followed
786 * by %OVS_ACTION_ATTR_POP_VLAN from having surprising results.
787 */
788struct ovs_action_push_vlan {
789 __be16 vlan_tpid; /* 802.1Q or 802.1ad TPID. */
790 __be16 vlan_tci; /* 802.1Q TCI (VLAN ID and priority). */
791};
792
793/* Data path hash algorithm for computing Datapath hash.
794 *
795 * The algorithm type only specifies the fields in a flow
796 * will be used as part of the hash. Each datapath is free
797 * to use its own hash algorithm. The hash value will be
798 * opaque to the user space daemon.
799 */
800enum ovs_hash_alg {
801 OVS_HASH_ALG_L4,
802 OVS_HASH_ALG_SYM_L4,
803};
804
805/*
806 * struct ovs_action_hash - %OVS_ACTION_ATTR_HASH action argument.
807 * @hash_alg: Algorithm used to compute hash prior to recirculation.
808 * @hash_basis: basis used for computing hash.
809 */
810struct ovs_action_hash {
811 __u32 hash_alg; /* One of ovs_hash_alg. */
812 __u32 hash_basis;
813};
814
815/**
816 * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action.
817 * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack
818 * table. This allows future packets for the same connection to be identified
819 * as 'established' or 'related'. The flow key for the current packet will
820 * retain the pre-commit connection state.
821 * @OVS_CT_ATTR_ZONE: u16 connection tracking zone.
822 * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the
823 * mask, the corresponding bit in the value is copied to the connection
824 * tracking mark field in the connection.
825 * @OVS_CT_ATTR_LABELS: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN
826 * mask. For each bit set in the mask, the corresponding bit in the value is
827 * copied to the connection tracking label field in the connection.
828 * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG.
829 * @OVS_CT_ATTR_NAT: Nested OVS_NAT_ATTR_* for performing L3 network address
830 * translation (NAT) on the packet.
831 * @OVS_CT_ATTR_FORCE_COMMIT: Like %OVS_CT_ATTR_COMMIT, but instead of doing
832 * nothing if the connection is already committed will check that the current
833 * packet is in conntrack entry's original direction. If directionality does
834 * not match, will delete the existing conntrack entry and commit a new one.
835 * @OVS_CT_ATTR_EVENTMASK: Mask of bits indicating which conntrack event types
836 * (enum ip_conntrack_events IPCT_*) should be reported. For any bit set to
837 * zero, the corresponding event type is not generated. Default behavior
838 * depends on system configuration, but typically all event types are
839 * generated, hence listening on NFNLGRP_CONNTRACK_UPDATE events may get a lot
840 * of events. Explicitly passing this attribute allows limiting the updates
841 * received to the events of interest. The bit 1 << IPCT_NEW, 1 <<
842 * IPCT_RELATED, and 1 << IPCT_DESTROY must be set to ones for those events to
843 * be received on NFNLGRP_CONNTRACK_NEW and NFNLGRP_CONNTRACK_DESTROY groups,
844 * respectively. Remaining bits control the changes for which an event is
845 * delivered on the NFNLGRP_CONNTRACK_UPDATE group.
846 * @OVS_CT_ATTR_TIMEOUT: Variable length string defining conntrack timeout.
847 */
848enum ovs_ct_attr {
849 /* private: */
850 OVS_CT_ATTR_UNSPEC,
851 /* public: */
852 OVS_CT_ATTR_COMMIT, /* No argument, commits connection. */
853 OVS_CT_ATTR_ZONE, /* u16 zone id. */
854 OVS_CT_ATTR_MARK, /* mark to associate with this connection. */
855 OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */
856 OVS_CT_ATTR_HELPER, /* netlink helper to assist detection of
857 related connections. */
858 OVS_CT_ATTR_NAT, /* Nested OVS_NAT_ATTR_* */
859 OVS_CT_ATTR_FORCE_COMMIT, /* No argument */
860 OVS_CT_ATTR_EVENTMASK, /* u32 mask of IPCT_* events. */
861 OVS_CT_ATTR_TIMEOUT, /* Associate timeout with this connection for
862 * fine-grain timeout tuning. */
863 /* private: */
864 __OVS_CT_ATTR_MAX
865};
866
867#define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1)
868
869/**
870 * enum ovs_nat_attr - Attributes for %OVS_CT_ATTR_NAT.
871 *
872 * @OVS_NAT_ATTR_SRC: Flag for Source NAT (mangle source address/port).
873 * @OVS_NAT_ATTR_DST: Flag for Destination NAT (mangle destination
874 * address/port). Only one of (@OVS_NAT_ATTR_SRC, @OVS_NAT_ATTR_DST) may be
875 * specified. Effective only for packets for ct_state NEW connections.
876 * Packets of committed connections are mangled by the NAT action according to
877 * the committed NAT type regardless of the flags specified. As a corollary, a
878 * NAT action without a NAT type flag will only mangle packets of committed
879 * connections. The following NAT attributes only apply for NEW
880 * (non-committed) connections, and they may be included only when the CT
881 * action has the @OVS_CT_ATTR_COMMIT flag and either @OVS_NAT_ATTR_SRC or
882 * @OVS_NAT_ATTR_DST is also included.
883 * @OVS_NAT_ATTR_IP_MIN: struct in_addr or struct in6_addr
884 * @OVS_NAT_ATTR_IP_MAX: struct in_addr or struct in6_addr
885 * @OVS_NAT_ATTR_PROTO_MIN: u16 L4 protocol specific lower boundary (port)
886 * @OVS_NAT_ATTR_PROTO_MAX: u16 L4 protocol specific upper boundary (port)
887 * @OVS_NAT_ATTR_PERSISTENT: Flag for persistent IP mapping across reboots
888 * @OVS_NAT_ATTR_PROTO_HASH: Flag for pseudo random L4 port mapping (MD5)
889 * @OVS_NAT_ATTR_PROTO_RANDOM: Flag for fully randomized L4 port mapping
890 */
891enum ovs_nat_attr {
892 /* private: */
893 OVS_NAT_ATTR_UNSPEC,
894 /* public: */
895 OVS_NAT_ATTR_SRC,
896 OVS_NAT_ATTR_DST,
897 OVS_NAT_ATTR_IP_MIN,
898 OVS_NAT_ATTR_IP_MAX,
899 OVS_NAT_ATTR_PROTO_MIN,
900 OVS_NAT_ATTR_PROTO_MAX,
901 OVS_NAT_ATTR_PERSISTENT,
902 OVS_NAT_ATTR_PROTO_HASH,
903 OVS_NAT_ATTR_PROTO_RANDOM,
904 /* private: */
905 __OVS_NAT_ATTR_MAX,
906};
907
908#define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1)
909
910/**
911 * struct ovs_action_push_eth - %OVS_ACTION_ATTR_PUSH_ETH action argument.
912 * @addresses: Source and destination MAC addresses.
913 */
914struct ovs_action_push_eth {
915 struct ovs_key_ethernet addresses;
916};
917
918/**
919 * enum ovs_check_pkt_len_attr - Attributes for %OVS_ACTION_ATTR_CHECK_PKT_LEN.
920 *
921 * @OVS_CHECK_PKT_LEN_ATTR_PKT_LEN: u16 Packet length to check for.
922 * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER: Nested OVS_ACTION_ATTR_*
923 * actions to apply if the packer length is greater than the specified
924 * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
925 * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL: Nested OVS_ACTION_ATTR_*
926 * actions to apply if the packer length is lesser or equal to the specified
927 * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
928 * @OVS_CHECK_PKT_LEN_ATTR_ARG: For in-kernel use, passing &struct
929 * check_pkt_len_arg derived from other attributes.
930 */
931enum ovs_check_pkt_len_attr {
932 /* private: */
933 OVS_CHECK_PKT_LEN_ATTR_UNSPEC,
934 /* public: */
935 OVS_CHECK_PKT_LEN_ATTR_PKT_LEN,
936 OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER,
937 OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL,
938 /* private: */
939 __OVS_CHECK_PKT_LEN_ATTR_MAX,
940
941 /* public: */
942};
943
944#define OVS_CHECK_PKT_LEN_ATTR_MAX (__OVS_CHECK_PKT_LEN_ATTR_MAX - 1)
945
946
947#define OVS_PSAMPLE_COOKIE_MAX_SIZE 16
948/**
949 * enum ovs_psample_attr - Attributes for %OVS_ACTION_ATTR_PSAMPLE
950 * action.
951 *
952 * @OVS_PSAMPLE_ATTR_GROUP: 32-bit number to identify the source of the
953 * sample.
954 * @OVS_PSAMPLE_ATTR_COOKIE: An optional variable-length binary cookie that
955 * contains user-defined metadata. The maximum length is
956 * OVS_PSAMPLE_COOKIE_MAX_SIZE bytes.
957 *
958 * Sends the packet to the psample multicast group with the specified group and
959 * cookie. It is possible to combine this action with the
960 * %OVS_ACTION_ATTR_TRUNC action to limit the size of the sample.
961 */
962enum ovs_psample_attr {
963 OVS_PSAMPLE_ATTR_GROUP = 1, /* u32 number. */
964 OVS_PSAMPLE_ATTR_COOKIE, /* Optional, user specified cookie. */
965
966 /* private: */
967 __OVS_PSAMPLE_ATTR_MAX
968};
969
970#define OVS_PSAMPLE_ATTR_MAX (__OVS_PSAMPLE_ATTR_MAX - 1)
971
972/**
973 * enum ovs_action_attr - Action types.
974 *
975 * @OVS_ACTION_ATTR_OUTPUT: Output packet to port.
976 * @OVS_ACTION_ATTR_TRUNC: Output packet to port with truncated packet size.
977 * @OVS_ACTION_ATTR_USERSPACE: Send packet to userspace according to nested
978 * %OVS_USERSPACE_ATTR_* attributes.
979 * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header. The
980 * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its
981 * value.
982 * @OVS_ACTION_ATTR_SET_MASKED: Replaces the contents of an existing header. A
983 * nested %OVS_KEY_ATTR_* attribute specifies a header to modify, its value,
984 * and a mask. For every bit set in the mask, the corresponding bit value
985 * is copied from the value to the packet header field, rest of the bits are
986 * left unchanged. The non-masked value bits must be passed in as zeroes.
987 * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
988 * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q or 802.1ad header
989 * onto the packet.
990 * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q or 802.1ad header
991 * from the packet.
992 * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
993 * the nested %OVS_SAMPLE_ATTR_* attributes.
994 * @OVS_ACTION_ATTR_RECIRC: Recirculate the clone of the packet through the
995 * datapath with the new id (u32 recirc_id).
996 * @OVS_ACTION_ATTR_HASH: Compute the packet hash, using &struct ovs_action_hash.
997 * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the
998 * top of the packets MPLS label stack. Set the ethertype of the
999 * encapsulating frame to either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC to
1000 * indicate the new packet contents.
1001 * @OVS_ACTION_ATTR_POP_MPLS: Pop an MPLS label stack entry off of the
1002 * packet's MPLS label stack. Set the encapsulating frame's ethertype to
1003 * indicate the new packet contents. This could potentially still be
1004 * %ETH_P_MPLS if the resulting MPLS label stack is not empty. If there
1005 * is no MPLS label stack, as determined by ethertype, no action is taken.
1006 * @OVS_ACTION_ATTR_CT: Track the connection. Populate the conntrack-related
1007 * entries in the flow key.
1008 * @OVS_ACTION_ATTR_PUSH_ETH: Push a new outermost Ethernet header onto the
1009 * packet.
1010 * @OVS_ACTION_ATTR_POP_ETH: Pop the outermost Ethernet header off the
1011 * packet.
1012 * @OVS_ACTION_ATTR_CT_CLEAR: Clear conntrack state from the packet.
1013 * @OVS_ACTION_ATTR_PUSH_NSH: push NSH header to the packet.
1014 * @OVS_ACTION_ATTR_POP_NSH: pop the outermost NSH header off the packet.
1015 * @OVS_ACTION_ATTR_METER: Run packet through a meter, which may drop the
1016 * packet, or modify the packet (e.g., change the DSCP field).
1017 * @OVS_ACTION_ATTR_CLONE: make a copy of the packet and execute a list of
1018 * actions without affecting the original packet and key.
1019 * @OVS_ACTION_ATTR_CHECK_PKT_LEN: Check the packet length and execute a set
1020 * of actions if greater than the specified packet length, else execute
1021 * another set of actions.
1022 * @OVS_ACTION_ATTR_ADD_MPLS: Push a new MPLS label stack entry at the
1023 * start of the packet or at the start of the l3 header depending on the value
1024 * of l3 tunnel flag in the tun_flags field of OVS_ACTION_ATTR_ADD_MPLS
1025 * argument.
1026 * @OVS_ACTION_ATTR_DEC_TTL: Decrement TTL or hop limit of the packet. Execute
1027 * nested %OVS_DEC_TTL_ATTR_* actions if the value is less or equal to 1.
1028 * @OVS_ACTION_ATTR_DROP: Explicit drop action.
1029 * @OVS_ACTION_ATTR_PSAMPLE: Send a sample of the packet to external observers
1030 * via psample.
1031 *
1032 * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all
1033 * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
1034 * type may not be changed.
1035 *
1036 * @OVS_ACTION_ATTR_SET_TO_MASKED: Kernel internal masked set action translated
1037 * from the @OVS_ACTION_ATTR_SET.
1038 */
1039
1040enum ovs_action_attr {
1041 /* private: */
1042 OVS_ACTION_ATTR_UNSPEC,
1043 /* public: */
1044 OVS_ACTION_ATTR_OUTPUT, /* u32 port number. */
1045 OVS_ACTION_ATTR_USERSPACE, /* Nested OVS_USERSPACE_ATTR_*. */
1046 OVS_ACTION_ATTR_SET, /* One nested OVS_KEY_ATTR_*. */
1047 OVS_ACTION_ATTR_PUSH_VLAN, /* struct ovs_action_push_vlan. */
1048 OVS_ACTION_ATTR_POP_VLAN, /* No argument. */
1049 OVS_ACTION_ATTR_SAMPLE, /* Nested OVS_SAMPLE_ATTR_*. */
1050 OVS_ACTION_ATTR_RECIRC, /* u32 recirc_id. */
1051 OVS_ACTION_ATTR_HASH, /* struct ovs_action_hash. */
1052 OVS_ACTION_ATTR_PUSH_MPLS, /* struct ovs_action_push_mpls. */
1053 OVS_ACTION_ATTR_POP_MPLS, /* __be16 ethertype. */
1054 OVS_ACTION_ATTR_SET_MASKED, /* One nested OVS_KEY_ATTR_* including
1055 * data immediately followed by a mask.
1056 * The data must be zero for the unmasked
1057 * bits. */
1058 OVS_ACTION_ATTR_CT, /* Nested OVS_CT_ATTR_* . */
1059 OVS_ACTION_ATTR_TRUNC, /* u32 struct ovs_action_trunc. */
1060 OVS_ACTION_ATTR_PUSH_ETH, /* struct ovs_action_push_eth. */
1061 OVS_ACTION_ATTR_POP_ETH, /* No argument. */
1062 OVS_ACTION_ATTR_CT_CLEAR, /* No argument. */
1063 OVS_ACTION_ATTR_PUSH_NSH, /* Nested OVS_NSH_KEY_ATTR_*. */
1064 OVS_ACTION_ATTR_POP_NSH, /* No argument. */
1065 OVS_ACTION_ATTR_METER, /* u32 meter ID. */
1066 OVS_ACTION_ATTR_CLONE, /* Nested OVS_CLONE_ATTR_*. */
1067 OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
1068 OVS_ACTION_ATTR_ADD_MPLS, /* struct ovs_action_add_mpls. */
1069 OVS_ACTION_ATTR_DEC_TTL, /* Nested OVS_DEC_TTL_ATTR_*. */
1070 OVS_ACTION_ATTR_DROP, /* u32 error code. */
1071 OVS_ACTION_ATTR_PSAMPLE, /* Nested OVS_PSAMPLE_ATTR_*. */
1072
1073 /* private: */
1074 __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted
1075 * from userspace. */
1076
1077 /* public: */
1078};
1079
1080#define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
1081
1082/* Meters. */
1083#define OVS_METER_FAMILY "ovs_meter"
1084#define OVS_METER_MCGROUP "ovs_meter"
1085#define OVS_METER_VERSION 0x1
1086
1087enum ovs_meter_cmd {
1088 OVS_METER_CMD_UNSPEC,
1089 OVS_METER_CMD_FEATURES, /* Get features supported by the datapath. */
1090 OVS_METER_CMD_SET, /* Add or modify a meter. */
1091 OVS_METER_CMD_DEL, /* Delete a meter. */
1092 OVS_METER_CMD_GET /* Get meter stats. */
1093};
1094
1095enum ovs_meter_attr {
1096 OVS_METER_ATTR_UNSPEC,
1097 OVS_METER_ATTR_ID, /* u32 meter ID within datapath. */
1098 OVS_METER_ATTR_KBPS, /* No argument. If set, units in kilobits
1099 * per second. Otherwise, units in
1100 * packets per second.
1101 */
1102 OVS_METER_ATTR_STATS, /* struct ovs_flow_stats for the meter. */
1103 OVS_METER_ATTR_BANDS, /* Nested attributes for meter bands. */
1104 OVS_METER_ATTR_USED, /* u64 msecs last used in monotonic time. */
1105 OVS_METER_ATTR_CLEAR, /* Flag to clear stats, used. */
1106 OVS_METER_ATTR_MAX_METERS, /* u32 number of meters supported. */
1107 OVS_METER_ATTR_MAX_BANDS, /* u32 max number of bands per meter. */
1108 OVS_METER_ATTR_PAD,
1109 __OVS_METER_ATTR_MAX
1110};
1111
1112#define OVS_METER_ATTR_MAX (__OVS_METER_ATTR_MAX - 1)
1113
1114enum ovs_band_attr {
1115 OVS_BAND_ATTR_UNSPEC,
1116 OVS_BAND_ATTR_TYPE, /* u32 OVS_METER_BAND_TYPE_* constant. */
1117 OVS_BAND_ATTR_RATE, /* u32 band rate in meter units (see above). */
1118 OVS_BAND_ATTR_BURST, /* u32 burst size in meter units. */
1119 OVS_BAND_ATTR_STATS, /* struct ovs_flow_stats for the band. */
1120 __OVS_BAND_ATTR_MAX
1121};
1122
1123#define OVS_BAND_ATTR_MAX (__OVS_BAND_ATTR_MAX - 1)
1124
1125enum ovs_meter_band_type {
1126 OVS_METER_BAND_TYPE_UNSPEC,
1127 OVS_METER_BAND_TYPE_DROP, /* Drop exceeding packets. */
1128 __OVS_METER_BAND_TYPE_MAX
1129};
1130
1131#define OVS_METER_BAND_TYPE_MAX (__OVS_METER_BAND_TYPE_MAX - 1)
1132
1133/* Conntrack limit */
1134#define OVS_CT_LIMIT_FAMILY "ovs_ct_limit"
1135#define OVS_CT_LIMIT_MCGROUP "ovs_ct_limit"
1136#define OVS_CT_LIMIT_VERSION 0x1
1137
1138enum ovs_ct_limit_cmd {
1139 OVS_CT_LIMIT_CMD_UNSPEC,
1140 OVS_CT_LIMIT_CMD_SET, /* Add or modify ct limit. */
1141 OVS_CT_LIMIT_CMD_DEL, /* Delete ct limit. */
1142 OVS_CT_LIMIT_CMD_GET /* Get ct limit. */
1143};
1144
1145enum ovs_ct_limit_attr {
1146 OVS_CT_LIMIT_ATTR_UNSPEC,
1147 OVS_CT_LIMIT_ATTR_ZONE_LIMIT, /* Nested struct ovs_zone_limit. */
1148 __OVS_CT_LIMIT_ATTR_MAX
1149};
1150
1151#define OVS_CT_LIMIT_ATTR_MAX (__OVS_CT_LIMIT_ATTR_MAX - 1)
1152
1153#define OVS_ZONE_LIMIT_DEFAULT_ZONE -1
1154
1155struct ovs_zone_limit {
1156 int zone_id;
1157 __u32 limit;
1158 __u32 count;
1159};
1160
1161enum ovs_dec_ttl_attr {
1162 OVS_DEC_TTL_ATTR_UNSPEC,
1163 OVS_DEC_TTL_ATTR_ACTION, /* Nested struct nlattr */
1164 __OVS_DEC_TTL_ATTR_MAX
1165};
1166
1167#define OVS_DEC_TTL_ATTR_MAX (__OVS_DEC_TTL_ATTR_MAX - 1)
1168
1169#endif /* _LINUX_OPENVSWITCH_H */