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