122e3880aSThomas Graf 222e3880aSThomas Graf /* 303f0d916SAndy Zhou * Copyright (c) 2007-2013 Nicira, Inc. 422e3880aSThomas Graf * 522e3880aSThomas Graf * This program is free software; you can redistribute it and/or 622e3880aSThomas Graf * modify it under the terms of version 2 of the GNU General Public 722e3880aSThomas Graf * License as published by the Free Software Foundation. 822e3880aSThomas Graf * 922e3880aSThomas Graf * This program is distributed in the hope that it will be useful, but 1022e3880aSThomas Graf * WITHOUT ANY WARRANTY; without even the implied warranty of 1122e3880aSThomas Graf * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1222e3880aSThomas Graf * General Public License for more details. 1322e3880aSThomas Graf * 1422e3880aSThomas Graf * You should have received a copy of the GNU General Public License 1522e3880aSThomas Graf * along with this program; if not, write to the Free Software 1622e3880aSThomas Graf * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 1722e3880aSThomas Graf * 02110-1301, USA 1822e3880aSThomas Graf */ 1922e3880aSThomas Graf 2022e3880aSThomas Graf #ifndef _UAPI__LINUX_OPENVSWITCH_H 2122e3880aSThomas Graf #define _UAPI__LINUX_OPENVSWITCH_H 1 2222e3880aSThomas Graf 2322e3880aSThomas Graf #include <linux/types.h> 2422e3880aSThomas Graf #include <linux/if_ether.h> 2522e3880aSThomas Graf 2622e3880aSThomas Graf /** 2722e3880aSThomas Graf * struct ovs_header - header for OVS Generic Netlink messages. 2822e3880aSThomas Graf * @dp_ifindex: ifindex of local port for datapath (0 to make a request not 2922e3880aSThomas Graf * specific to a datapath). 3022e3880aSThomas Graf * 3122e3880aSThomas Graf * Attributes following the header are specific to a particular OVS Generic 3222e3880aSThomas Graf * Netlink family, but all of the OVS families use this header. 3322e3880aSThomas Graf */ 3422e3880aSThomas Graf 3522e3880aSThomas Graf struct ovs_header { 3622e3880aSThomas Graf int dp_ifindex; 3722e3880aSThomas Graf }; 3822e3880aSThomas Graf 3922e3880aSThomas Graf /* Datapaths. */ 4022e3880aSThomas Graf 4122e3880aSThomas Graf #define OVS_DATAPATH_FAMILY "ovs_datapath" 4222e3880aSThomas Graf #define OVS_DATAPATH_MCGROUP "ovs_datapath" 4344da5ae5SThomas Graf 4444da5ae5SThomas Graf /* V2: 4544da5ae5SThomas Graf * - API users are expected to provide OVS_DP_ATTR_USER_FEATURES 4644da5ae5SThomas Graf * when creating the datapath. 4744da5ae5SThomas Graf */ 4844da5ae5SThomas Graf #define OVS_DATAPATH_VERSION 2 4944da5ae5SThomas Graf 5044da5ae5SThomas Graf /* First OVS datapath version to support features */ 5144da5ae5SThomas Graf #define OVS_DP_VER_FEATURES 2 5222e3880aSThomas Graf 5322e3880aSThomas Graf enum ovs_datapath_cmd { 5422e3880aSThomas Graf OVS_DP_CMD_UNSPEC, 5522e3880aSThomas Graf OVS_DP_CMD_NEW, 5622e3880aSThomas Graf OVS_DP_CMD_DEL, 5722e3880aSThomas Graf OVS_DP_CMD_GET, 5822e3880aSThomas Graf OVS_DP_CMD_SET 5922e3880aSThomas Graf }; 6022e3880aSThomas Graf 6122e3880aSThomas Graf /** 6222e3880aSThomas Graf * enum ovs_datapath_attr - attributes for %OVS_DP_* commands. 6322e3880aSThomas Graf * @OVS_DP_ATTR_NAME: Name of the network device that serves as the "local 6422e3880aSThomas Graf * port". This is the name of the network device whose dp_ifindex is given in 6522e3880aSThomas Graf * the &struct ovs_header. Always present in notifications. Required in 6622e3880aSThomas Graf * %OVS_DP_NEW requests. May be used as an alternative to specifying 6722e3880aSThomas Graf * dp_ifindex in other requests (with a dp_ifindex of 0). 6822e3880aSThomas Graf * @OVS_DP_ATTR_UPCALL_PID: The Netlink socket in userspace that is initially 6922e3880aSThomas Graf * set on the datapath port (for OVS_ACTION_ATTR_MISS). Only valid on 7022e3880aSThomas Graf * %OVS_DP_CMD_NEW requests. A value of zero indicates that upcalls should 7122e3880aSThomas Graf * not be sent. 7222e3880aSThomas Graf * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the 7322e3880aSThomas Graf * datapath. Always present in notifications. 741bd7116fSAndy Zhou * @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the 751bd7116fSAndy Zhou * datapath. Always present in notifications. 7622e3880aSThomas Graf * 7722e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 7822e3880aSThomas Graf * payload for %OVS_DP_* commands. 7922e3880aSThomas Graf */ 8022e3880aSThomas Graf enum ovs_datapath_attr { 8122e3880aSThomas Graf OVS_DP_ATTR_UNSPEC, 8222e3880aSThomas Graf OVS_DP_ATTR_NAME, /* name of dp_ifindex netdev */ 8322e3880aSThomas Graf OVS_DP_ATTR_UPCALL_PID, /* Netlink PID to receive upcalls */ 8422e3880aSThomas Graf OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */ 851bd7116fSAndy Zhou OVS_DP_ATTR_MEGAFLOW_STATS, /* struct ovs_dp_megaflow_stats */ 8643d4be9cSThomas Graf OVS_DP_ATTR_USER_FEATURES, /* OVS_DP_F_* */ 8766c7a5eeSNicolas Dichtel OVS_DP_ATTR_PAD, 8822e3880aSThomas Graf __OVS_DP_ATTR_MAX 8922e3880aSThomas Graf }; 9022e3880aSThomas Graf 9122e3880aSThomas Graf #define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1) 9222e3880aSThomas Graf 9322e3880aSThomas Graf struct ovs_dp_stats { 9422e3880aSThomas Graf __u64 n_hit; /* Number of flow table matches. */ 9522e3880aSThomas Graf __u64 n_missed; /* Number of flow table misses. */ 9622e3880aSThomas Graf __u64 n_lost; /* Number of misses not sent to userspace. */ 9722e3880aSThomas Graf __u64 n_flows; /* Number of flows present */ 9822e3880aSThomas Graf }; 9922e3880aSThomas Graf 1001bd7116fSAndy Zhou struct ovs_dp_megaflow_stats { 1011bd7116fSAndy Zhou __u64 n_mask_hit; /* Number of masks used for flow lookups. */ 1021bd7116fSAndy Zhou __u32 n_masks; /* Number of masks for the datapath. */ 1031bd7116fSAndy Zhou __u32 pad0; /* Pad for future expension. */ 1041bd7116fSAndy Zhou __u64 pad1; /* Pad for future expension. */ 1051bd7116fSAndy Zhou __u64 pad2; /* Pad for future expension. */ 1061bd7116fSAndy Zhou }; 1071bd7116fSAndy Zhou 10822e3880aSThomas Graf struct ovs_vport_stats { 10922e3880aSThomas Graf __u64 rx_packets; /* total packets received */ 11022e3880aSThomas Graf __u64 tx_packets; /* total packets transmitted */ 11122e3880aSThomas Graf __u64 rx_bytes; /* total bytes received */ 11222e3880aSThomas Graf __u64 tx_bytes; /* total bytes transmitted */ 11322e3880aSThomas Graf __u64 rx_errors; /* bad packets received */ 11422e3880aSThomas Graf __u64 tx_errors; /* packet transmit problems */ 11522e3880aSThomas Graf __u64 rx_dropped; /* no space in linux buffers */ 11622e3880aSThomas Graf __u64 tx_dropped; /* no space available in linux */ 11722e3880aSThomas Graf }; 11822e3880aSThomas Graf 11943d4be9cSThomas Graf /* Allow last Netlink attribute to be unaligned */ 12043d4be9cSThomas Graf #define OVS_DP_F_UNALIGNED (1 << 0) 12143d4be9cSThomas Graf 1225cd667b0SAlex Wang /* Allow datapath to associate multiple Netlink PIDs to each vport */ 1235cd667b0SAlex Wang #define OVS_DP_F_VPORT_PIDS (1 << 1) 1245cd667b0SAlex Wang 12522e3880aSThomas Graf /* Fixed logical ports. */ 12622e3880aSThomas Graf #define OVSP_LOCAL ((__u32)0) 12722e3880aSThomas Graf 12822e3880aSThomas Graf /* Packet transfer. */ 12922e3880aSThomas Graf 13022e3880aSThomas Graf #define OVS_PACKET_FAMILY "ovs_packet" 13122e3880aSThomas Graf #define OVS_PACKET_VERSION 0x1 13222e3880aSThomas Graf 13322e3880aSThomas Graf enum ovs_packet_cmd { 13422e3880aSThomas Graf OVS_PACKET_CMD_UNSPEC, 13522e3880aSThomas Graf 13622e3880aSThomas Graf /* Kernel-to-user notifications. */ 13722e3880aSThomas Graf OVS_PACKET_CMD_MISS, /* Flow table miss. */ 13822e3880aSThomas Graf OVS_PACKET_CMD_ACTION, /* OVS_ACTION_ATTR_USERSPACE action. */ 13922e3880aSThomas Graf 14022e3880aSThomas Graf /* Userspace commands. */ 14122e3880aSThomas Graf OVS_PACKET_CMD_EXECUTE /* Apply actions to a packet. */ 14222e3880aSThomas Graf }; 14322e3880aSThomas Graf 14422e3880aSThomas Graf /** 14522e3880aSThomas Graf * enum ovs_packet_attr - attributes for %OVS_PACKET_* commands. 14622e3880aSThomas Graf * @OVS_PACKET_ATTR_PACKET: Present for all notifications. Contains the entire 14722e3880aSThomas Graf * packet as received, from the start of the Ethernet header onward. For 14822e3880aSThomas Graf * %OVS_PACKET_CMD_ACTION, %OVS_PACKET_ATTR_PACKET reflects changes made by 14922e3880aSThomas Graf * actions preceding %OVS_ACTION_ATTR_USERSPACE, but %OVS_PACKET_ATTR_KEY is 15022e3880aSThomas Graf * the flow key extracted from the packet as originally received. 15122e3880aSThomas Graf * @OVS_PACKET_ATTR_KEY: Present for all notifications. Contains the flow key 15222e3880aSThomas Graf * extracted from the packet as nested %OVS_KEY_ATTR_* attributes. This allows 15322e3880aSThomas Graf * userspace to adapt its flow setup strategy by comparing its notion of the 15422e3880aSThomas Graf * flow key against the kernel's. 15522e3880aSThomas Graf * @OVS_PACKET_ATTR_ACTIONS: Contains actions for the packet. Used 15622e3880aSThomas Graf * for %OVS_PACKET_CMD_EXECUTE. It has nested %OVS_ACTION_ATTR_* attributes. 157ccea7445SNeil McKee * Also used in upcall when %OVS_ACTION_ATTR_USERSPACE has optional 158ccea7445SNeil McKee * %OVS_USERSPACE_ATTR_ACTIONS attribute. 15922e3880aSThomas Graf * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION 16022e3880aSThomas Graf * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an 16122e3880aSThomas Graf * %OVS_USERSPACE_ATTR_USERDATA attribute, with the same length and content 16222e3880aSThomas Graf * specified there. 1638f0aad6fSWenyu Zhang * @OVS_PACKET_ATTR_EGRESS_TUN_KEY: Present for an %OVS_PACKET_CMD_ACTION 1648f0aad6fSWenyu Zhang * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an 1658f0aad6fSWenyu Zhang * %OVS_USERSPACE_ATTR_EGRESS_TUN_PORT attribute, which is sent only if the 1668f0aad6fSWenyu Zhang * output port is actually a tunnel port. Contains the output tunnel key 1678f0aad6fSWenyu Zhang * extracted from the packet as nested %OVS_TUNNEL_KEY_ATTR_* attributes. 1687f8a436eSJoe Stringer * @OVS_PACKET_ATTR_MRU: Present for an %OVS_PACKET_CMD_ACTION and 1697f8a436eSJoe Stringer * %OVS_PACKET_ATTR_USERSPACE action specify the Maximum received fragment 1707f8a436eSJoe Stringer * size. 17122e3880aSThomas Graf * 17222e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 17322e3880aSThomas Graf * payload for %OVS_PACKET_* commands. 17422e3880aSThomas Graf */ 17522e3880aSThomas Graf enum ovs_packet_attr { 17622e3880aSThomas Graf OVS_PACKET_ATTR_UNSPEC, 17722e3880aSThomas Graf OVS_PACKET_ATTR_PACKET, /* Packet data. */ 17822e3880aSThomas Graf OVS_PACKET_ATTR_KEY, /* Nested OVS_KEY_ATTR_* attributes. */ 17922e3880aSThomas Graf OVS_PACKET_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */ 18022e3880aSThomas Graf OVS_PACKET_ATTR_USERDATA, /* OVS_ACTION_ATTR_USERSPACE arg. */ 1818f0aad6fSWenyu Zhang OVS_PACKET_ATTR_EGRESS_TUN_KEY, /* Nested OVS_TUNNEL_KEY_ATTR_* 1828f0aad6fSWenyu Zhang attributes. */ 1831ba39804SThomas Graf OVS_PACKET_ATTR_UNUSED1, 1841ba39804SThomas Graf OVS_PACKET_ATTR_UNUSED2, 1851ba39804SThomas Graf OVS_PACKET_ATTR_PROBE, /* Packet operation is a feature probe, 1861ba39804SThomas Graf error logging should be suppressed. */ 1877f8a436eSJoe Stringer OVS_PACKET_ATTR_MRU, /* Maximum received IP fragment size. */ 18822e3880aSThomas Graf __OVS_PACKET_ATTR_MAX 18922e3880aSThomas Graf }; 19022e3880aSThomas Graf 19122e3880aSThomas Graf #define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1) 19222e3880aSThomas Graf 19322e3880aSThomas Graf /* Virtual ports. */ 19422e3880aSThomas Graf 19522e3880aSThomas Graf #define OVS_VPORT_FAMILY "ovs_vport" 19622e3880aSThomas Graf #define OVS_VPORT_MCGROUP "ovs_vport" 19722e3880aSThomas Graf #define OVS_VPORT_VERSION 0x1 19822e3880aSThomas Graf 19922e3880aSThomas Graf enum ovs_vport_cmd { 20022e3880aSThomas Graf OVS_VPORT_CMD_UNSPEC, 20122e3880aSThomas Graf OVS_VPORT_CMD_NEW, 20222e3880aSThomas Graf OVS_VPORT_CMD_DEL, 20322e3880aSThomas Graf OVS_VPORT_CMD_GET, 20422e3880aSThomas Graf OVS_VPORT_CMD_SET 20522e3880aSThomas Graf }; 20622e3880aSThomas Graf 20722e3880aSThomas Graf enum ovs_vport_type { 20822e3880aSThomas Graf OVS_VPORT_TYPE_UNSPEC, 20922e3880aSThomas Graf OVS_VPORT_TYPE_NETDEV, /* network device */ 21022e3880aSThomas Graf OVS_VPORT_TYPE_INTERNAL, /* network device implemented by datapath */ 211aa310701SPravin B Shelar OVS_VPORT_TYPE_GRE, /* GRE tunnel. */ 21258264848SPravin B Shelar OVS_VPORT_TYPE_VXLAN, /* VXLAN tunnel. */ 213f5796684SJesse Gross OVS_VPORT_TYPE_GENEVE, /* Geneve tunnel. */ 21422e3880aSThomas Graf __OVS_VPORT_TYPE_MAX 21522e3880aSThomas Graf }; 21622e3880aSThomas Graf 21722e3880aSThomas Graf #define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1) 21822e3880aSThomas Graf 21922e3880aSThomas Graf /** 22022e3880aSThomas Graf * enum ovs_vport_attr - attributes for %OVS_VPORT_* commands. 22122e3880aSThomas Graf * @OVS_VPORT_ATTR_PORT_NO: 32-bit port number within datapath. 22222e3880aSThomas Graf * @OVS_VPORT_ATTR_TYPE: 32-bit %OVS_VPORT_TYPE_* constant describing the type 22322e3880aSThomas Graf * of vport. 22422e3880aSThomas Graf * @OVS_VPORT_ATTR_NAME: Name of vport. For a vport based on a network device 22522e3880aSThomas Graf * this is the name of the network device. Maximum length %IFNAMSIZ-1 bytes 22622e3880aSThomas Graf * plus a null terminator. 22722e3880aSThomas Graf * @OVS_VPORT_ATTR_OPTIONS: Vport-specific configuration information. 2285cd667b0SAlex Wang * @OVS_VPORT_ATTR_UPCALL_PID: The array of Netlink socket pids in userspace 2295cd667b0SAlex Wang * among which OVS_PACKET_CMD_MISS upcalls will be distributed for packets 2305cd667b0SAlex Wang * received on this port. If this is a single-element array of value 0, 2315cd667b0SAlex Wang * upcalls should not be sent. 23222e3880aSThomas Graf * @OVS_VPORT_ATTR_STATS: A &struct ovs_vport_stats giving statistics for 23322e3880aSThomas Graf * packets sent or received through the vport. 23422e3880aSThomas Graf * 23522e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 23622e3880aSThomas Graf * payload for %OVS_VPORT_* commands. 23722e3880aSThomas Graf * 23822e3880aSThomas Graf * For %OVS_VPORT_CMD_NEW requests, the %OVS_VPORT_ATTR_TYPE and 23922e3880aSThomas Graf * %OVS_VPORT_ATTR_NAME attributes are required. %OVS_VPORT_ATTR_PORT_NO is 24022e3880aSThomas Graf * optional; if not specified a free port number is automatically selected. 24122e3880aSThomas Graf * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type 24222e3880aSThomas Graf * of vport. 24322e3880aSThomas Graf * 24422e3880aSThomas Graf * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to 24522e3880aSThomas Graf * look up the vport to operate on; otherwise dp_idx from the &struct 24622e3880aSThomas Graf * ovs_header plus %OVS_VPORT_ATTR_PORT_NO determine the vport. 24722e3880aSThomas Graf */ 24822e3880aSThomas Graf enum ovs_vport_attr { 24922e3880aSThomas Graf OVS_VPORT_ATTR_UNSPEC, 25022e3880aSThomas Graf OVS_VPORT_ATTR_PORT_NO, /* u32 port number within datapath */ 25122e3880aSThomas Graf OVS_VPORT_ATTR_TYPE, /* u32 OVS_VPORT_TYPE_* constant. */ 25222e3880aSThomas Graf OVS_VPORT_ATTR_NAME, /* string name, up to IFNAMSIZ bytes long */ 25322e3880aSThomas Graf OVS_VPORT_ATTR_OPTIONS, /* nested attributes, varies by vport type */ 2545cd667b0SAlex Wang OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */ 2555cd667b0SAlex Wang /* receiving upcalls */ 25622e3880aSThomas Graf OVS_VPORT_ATTR_STATS, /* struct ovs_vport_stats */ 25766c7a5eeSNicolas Dichtel OVS_VPORT_ATTR_PAD, 25822e3880aSThomas Graf __OVS_VPORT_ATTR_MAX 25922e3880aSThomas Graf }; 26022e3880aSThomas Graf 26122e3880aSThomas Graf #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1) 26222e3880aSThomas Graf 2631dd144cfSThomas Graf enum { 2641dd144cfSThomas Graf OVS_VXLAN_EXT_UNSPEC, 2651dd144cfSThomas Graf OVS_VXLAN_EXT_GBP, /* Flag or __u32 */ 2661dd144cfSThomas Graf __OVS_VXLAN_EXT_MAX, 2671dd144cfSThomas Graf }; 2681dd144cfSThomas Graf 2691dd144cfSThomas Graf #define OVS_VXLAN_EXT_MAX (__OVS_VXLAN_EXT_MAX - 1) 2701dd144cfSThomas Graf 2711dd144cfSThomas Graf 27258264848SPravin B Shelar /* OVS_VPORT_ATTR_OPTIONS attributes for tunnels. 27358264848SPravin B Shelar */ 27458264848SPravin B Shelar enum { 27558264848SPravin B Shelar OVS_TUNNEL_ATTR_UNSPEC, 27658264848SPravin B Shelar OVS_TUNNEL_ATTR_DST_PORT, /* 16-bit UDP port, used by L4 tunnels. */ 2771dd144cfSThomas Graf OVS_TUNNEL_ATTR_EXTENSION, 27858264848SPravin B Shelar __OVS_TUNNEL_ATTR_MAX 27958264848SPravin B Shelar }; 28058264848SPravin B Shelar 28158264848SPravin B Shelar #define OVS_TUNNEL_ATTR_MAX (__OVS_TUNNEL_ATTR_MAX - 1) 28258264848SPravin B Shelar 28322e3880aSThomas Graf /* Flows. */ 28422e3880aSThomas Graf 28522e3880aSThomas Graf #define OVS_FLOW_FAMILY "ovs_flow" 28622e3880aSThomas Graf #define OVS_FLOW_MCGROUP "ovs_flow" 28722e3880aSThomas Graf #define OVS_FLOW_VERSION 0x1 28822e3880aSThomas Graf 28922e3880aSThomas Graf enum ovs_flow_cmd { 29022e3880aSThomas Graf OVS_FLOW_CMD_UNSPEC, 29122e3880aSThomas Graf OVS_FLOW_CMD_NEW, 29222e3880aSThomas Graf OVS_FLOW_CMD_DEL, 29322e3880aSThomas Graf OVS_FLOW_CMD_GET, 29422e3880aSThomas Graf OVS_FLOW_CMD_SET 29522e3880aSThomas Graf }; 29622e3880aSThomas Graf 29722e3880aSThomas Graf struct ovs_flow_stats { 29822e3880aSThomas Graf __u64 n_packets; /* Number of matched packets. */ 29922e3880aSThomas Graf __u64 n_bytes; /* Number of matched bytes. */ 30022e3880aSThomas Graf }; 30122e3880aSThomas Graf 30222e3880aSThomas Graf enum ovs_key_attr { 30322e3880aSThomas Graf OVS_KEY_ATTR_UNSPEC, 30422e3880aSThomas Graf OVS_KEY_ATTR_ENCAP, /* Nested set of encapsulated attributes. */ 30522e3880aSThomas Graf OVS_KEY_ATTR_PRIORITY, /* u32 skb->priority */ 30622e3880aSThomas Graf OVS_KEY_ATTR_IN_PORT, /* u32 OVS dp port number */ 30722e3880aSThomas Graf OVS_KEY_ATTR_ETHERNET, /* struct ovs_key_ethernet */ 30822e3880aSThomas Graf OVS_KEY_ATTR_VLAN, /* be16 VLAN TCI */ 30922e3880aSThomas Graf OVS_KEY_ATTR_ETHERTYPE, /* be16 Ethernet type */ 31022e3880aSThomas Graf OVS_KEY_ATTR_IPV4, /* struct ovs_key_ipv4 */ 31122e3880aSThomas Graf OVS_KEY_ATTR_IPV6, /* struct ovs_key_ipv6 */ 31222e3880aSThomas Graf OVS_KEY_ATTR_TCP, /* struct ovs_key_tcp */ 31322e3880aSThomas Graf OVS_KEY_ATTR_UDP, /* struct ovs_key_udp */ 31422e3880aSThomas Graf OVS_KEY_ATTR_ICMP, /* struct ovs_key_icmp */ 31522e3880aSThomas Graf OVS_KEY_ATTR_ICMPV6, /* struct ovs_key_icmpv6 */ 31622e3880aSThomas Graf OVS_KEY_ATTR_ARP, /* struct ovs_key_arp */ 31722e3880aSThomas Graf OVS_KEY_ATTR_ND, /* struct ovs_key_nd */ 31822e3880aSThomas Graf OVS_KEY_ATTR_SKB_MARK, /* u32 skb mark */ 3197d5437c7SPravin B Shelar OVS_KEY_ATTR_TUNNEL, /* Nested set of ovs_tunnel attributes */ 320a175a723SJoe Stringer OVS_KEY_ATTR_SCTP, /* struct ovs_key_sctp */ 3215eb26b15SJarno Rajahalme OVS_KEY_ATTR_TCP_FLAGS, /* be16 TCP flags. */ 322971427f3SAndy Zhou OVS_KEY_ATTR_DP_HASH, /* u32 hash value. Value 0 indicates the hash 323971427f3SAndy Zhou is not computed by the datapath. */ 324971427f3SAndy Zhou OVS_KEY_ATTR_RECIRC_ID, /* u32 recirc id */ 32525cd9ba0SSimon Horman OVS_KEY_ATTR_MPLS, /* array of struct ovs_key_mpls. 32625cd9ba0SSimon Horman * The implementation may restrict 32725cd9ba0SSimon Horman * the accepted length of the array. */ 328fbccce59SJoe Stringer OVS_KEY_ATTR_CT_STATE, /* u32 bitmask of OVS_CS_F_* */ 3297f8a436eSJoe Stringer OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */ 330182e3042SJoe Stringer OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */ 33133db4125SJoe Stringer OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */ 3327d5437c7SPravin B Shelar 3337d5437c7SPravin B Shelar #ifdef __KERNEL__ 3341d8fff90SThomas Graf OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info */ 3357d5437c7SPravin B Shelar #endif 33622e3880aSThomas Graf __OVS_KEY_ATTR_MAX 33722e3880aSThomas Graf }; 33822e3880aSThomas Graf 33922e3880aSThomas Graf #define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1) 34022e3880aSThomas Graf 3417d5437c7SPravin B Shelar enum ovs_tunnel_key_attr { 3427d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */ 3437d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */ 3447d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */ 3457d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_TOS, /* u8 Tunnel IP ToS. */ 3467d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_TTL, /* u8 Tunnel IP TTL. */ 3477d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT, /* No argument, set DF. */ 3487d5437c7SPravin B Shelar OVS_TUNNEL_KEY_ATTR_CSUM, /* No argument. CSUM packet. */ 34967fa0341SJesse Gross OVS_TUNNEL_KEY_ATTR_OAM, /* No argument. OAM frame. */ 350f5796684SJesse Gross OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS, /* Array of Geneve options. */ 3518f0aad6fSWenyu Zhang OVS_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. */ 3528f0aad6fSWenyu Zhang OVS_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. */ 3531dd144cfSThomas Graf OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested OVS_VXLAN_EXT_* */ 3546b26ba3aSJiri Benc OVS_TUNNEL_KEY_ATTR_IPV6_SRC, /* struct in6_addr src IPv6 address. */ 3556b26ba3aSJiri Benc OVS_TUNNEL_KEY_ATTR_IPV6_DST, /* struct in6_addr dst IPv6 address. */ 356b46f6dedSNicolas Dichtel OVS_TUNNEL_KEY_ATTR_PAD, 3577d5437c7SPravin B Shelar __OVS_TUNNEL_KEY_ATTR_MAX 3587d5437c7SPravin B Shelar }; 3597d5437c7SPravin B Shelar 3607d5437c7SPravin B Shelar #define OVS_TUNNEL_KEY_ATTR_MAX (__OVS_TUNNEL_KEY_ATTR_MAX - 1) 3617d5437c7SPravin B Shelar 36222e3880aSThomas Graf /** 36322e3880aSThomas Graf * enum ovs_frag_type - IPv4 and IPv6 fragment type 36422e3880aSThomas Graf * @OVS_FRAG_TYPE_NONE: Packet is not a fragment. 36522e3880aSThomas Graf * @OVS_FRAG_TYPE_FIRST: Packet is a fragment with offset 0. 36622e3880aSThomas Graf * @OVS_FRAG_TYPE_LATER: Packet is a fragment with nonzero offset. 36722e3880aSThomas Graf * 36822e3880aSThomas Graf * Used as the @ipv4_frag in &struct ovs_key_ipv4 and as @ipv6_frag &struct 36922e3880aSThomas Graf * ovs_key_ipv6. 37022e3880aSThomas Graf */ 37122e3880aSThomas Graf enum ovs_frag_type { 37222e3880aSThomas Graf OVS_FRAG_TYPE_NONE, 37322e3880aSThomas Graf OVS_FRAG_TYPE_FIRST, 37422e3880aSThomas Graf OVS_FRAG_TYPE_LATER, 37522e3880aSThomas Graf __OVS_FRAG_TYPE_MAX 37622e3880aSThomas Graf }; 37722e3880aSThomas Graf 37822e3880aSThomas Graf #define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1) 37922e3880aSThomas Graf 38022e3880aSThomas Graf struct ovs_key_ethernet { 38122e3880aSThomas Graf __u8 eth_src[ETH_ALEN]; 38222e3880aSThomas Graf __u8 eth_dst[ETH_ALEN]; 38322e3880aSThomas Graf }; 38422e3880aSThomas Graf 38525cd9ba0SSimon Horman struct ovs_key_mpls { 38625cd9ba0SSimon Horman __be32 mpls_lse; 38725cd9ba0SSimon Horman }; 38825cd9ba0SSimon Horman 38922e3880aSThomas Graf struct ovs_key_ipv4 { 39022e3880aSThomas Graf __be32 ipv4_src; 39122e3880aSThomas Graf __be32 ipv4_dst; 39222e3880aSThomas Graf __u8 ipv4_proto; 39322e3880aSThomas Graf __u8 ipv4_tos; 39422e3880aSThomas Graf __u8 ipv4_ttl; 39522e3880aSThomas Graf __u8 ipv4_frag; /* One of OVS_FRAG_TYPE_*. */ 39622e3880aSThomas Graf }; 39722e3880aSThomas Graf 39822e3880aSThomas Graf struct ovs_key_ipv6 { 39922e3880aSThomas Graf __be32 ipv6_src[4]; 40022e3880aSThomas Graf __be32 ipv6_dst[4]; 40122e3880aSThomas Graf __be32 ipv6_label; /* 20-bits in least-significant bits. */ 40222e3880aSThomas Graf __u8 ipv6_proto; 40322e3880aSThomas Graf __u8 ipv6_tclass; 40422e3880aSThomas Graf __u8 ipv6_hlimit; 40522e3880aSThomas Graf __u8 ipv6_frag; /* One of OVS_FRAG_TYPE_*. */ 40622e3880aSThomas Graf }; 40722e3880aSThomas Graf 40822e3880aSThomas Graf struct ovs_key_tcp { 40922e3880aSThomas Graf __be16 tcp_src; 41022e3880aSThomas Graf __be16 tcp_dst; 41122e3880aSThomas Graf }; 41222e3880aSThomas Graf 41322e3880aSThomas Graf struct ovs_key_udp { 41422e3880aSThomas Graf __be16 udp_src; 41522e3880aSThomas Graf __be16 udp_dst; 41622e3880aSThomas Graf }; 41722e3880aSThomas Graf 418a175a723SJoe Stringer struct ovs_key_sctp { 419a175a723SJoe Stringer __be16 sctp_src; 420a175a723SJoe Stringer __be16 sctp_dst; 421a175a723SJoe Stringer }; 422a175a723SJoe Stringer 42322e3880aSThomas Graf struct ovs_key_icmp { 42422e3880aSThomas Graf __u8 icmp_type; 42522e3880aSThomas Graf __u8 icmp_code; 42622e3880aSThomas Graf }; 42722e3880aSThomas Graf 42822e3880aSThomas Graf struct ovs_key_icmpv6 { 42922e3880aSThomas Graf __u8 icmpv6_type; 43022e3880aSThomas Graf __u8 icmpv6_code; 43122e3880aSThomas Graf }; 43222e3880aSThomas Graf 43322e3880aSThomas Graf struct ovs_key_arp { 43422e3880aSThomas Graf __be32 arp_sip; 43522e3880aSThomas Graf __be32 arp_tip; 43622e3880aSThomas Graf __be16 arp_op; 43722e3880aSThomas Graf __u8 arp_sha[ETH_ALEN]; 43822e3880aSThomas Graf __u8 arp_tha[ETH_ALEN]; 43922e3880aSThomas Graf }; 44022e3880aSThomas Graf 44122e3880aSThomas Graf struct ovs_key_nd { 4421a4e96a0SJarno Rajahalme __be32 nd_target[4]; 44322e3880aSThomas Graf __u8 nd_sll[ETH_ALEN]; 44422e3880aSThomas Graf __u8 nd_tll[ETH_ALEN]; 44522e3880aSThomas Graf }; 44622e3880aSThomas Graf 44733db4125SJoe Stringer #define OVS_CT_LABELS_LEN 16 44833db4125SJoe Stringer struct ovs_key_ct_labels { 44933db4125SJoe Stringer __u8 ct_labels[OVS_CT_LABELS_LEN]; 450c2ac6673SJoe Stringer }; 451c2ac6673SJoe Stringer 4527f8a436eSJoe Stringer /* OVS_KEY_ATTR_CT_STATE flags */ 4537f8a436eSJoe Stringer #define OVS_CS_F_NEW 0x01 /* Beginning of a new connection. */ 4547f8a436eSJoe Stringer #define OVS_CS_F_ESTABLISHED 0x02 /* Part of an existing connection. */ 4557f8a436eSJoe Stringer #define OVS_CS_F_RELATED 0x04 /* Related to an established 4567f8a436eSJoe Stringer * connection. */ 457fbccce59SJoe Stringer #define OVS_CS_F_REPLY_DIR 0x08 /* Flow is in the reply direction. */ 458fbccce59SJoe Stringer #define OVS_CS_F_INVALID 0x10 /* Could not track connection. */ 459fbccce59SJoe Stringer #define OVS_CS_F_TRACKED 0x20 /* Conntrack has occurred. */ 46005752523SJarno Rajahalme #define OVS_CS_F_SRC_NAT 0x40 /* Packet's source address/port was 46105752523SJarno Rajahalme * mangled by NAT. 46205752523SJarno Rajahalme */ 46305752523SJarno Rajahalme #define OVS_CS_F_DST_NAT 0x80 /* Packet's destination address/port 46405752523SJarno Rajahalme * was mangled by NAT. 46505752523SJarno Rajahalme */ 46605752523SJarno Rajahalme 46705752523SJarno Rajahalme #define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT) 4687f8a436eSJoe Stringer 46922e3880aSThomas Graf /** 47022e3880aSThomas Graf * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands. 47122e3880aSThomas Graf * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow 47222e3880aSThomas Graf * key. Always present in notifications. Required for all requests (except 47322e3880aSThomas Graf * dumps). 47422e3880aSThomas Graf * @OVS_FLOW_ATTR_ACTIONS: Nested %OVS_ACTION_ATTR_* attributes specifying 47522e3880aSThomas Graf * the actions to take for packets that match the key. Always present in 47622e3880aSThomas Graf * notifications. Required for %OVS_FLOW_CMD_NEW requests, optional for 477be52c9e9SJarno Rajahalme * %OVS_FLOW_CMD_SET requests. An %OVS_FLOW_CMD_SET without 478be52c9e9SJarno Rajahalme * %OVS_FLOW_ATTR_ACTIONS will not modify the actions. To clear the actions, 479be52c9e9SJarno Rajahalme * an %OVS_FLOW_ATTR_ACTIONS without any nested attributes must be given. 48022e3880aSThomas Graf * @OVS_FLOW_ATTR_STATS: &struct ovs_flow_stats giving statistics for this 48122e3880aSThomas Graf * flow. Present in notifications if the stats would be nonzero. Ignored in 48222e3880aSThomas Graf * requests. 48322e3880aSThomas Graf * @OVS_FLOW_ATTR_TCP_FLAGS: An 8-bit value giving the OR'd value of all of the 48422e3880aSThomas Graf * TCP flags seen on packets in this flow. Only present in notifications for 48522e3880aSThomas Graf * TCP flows, and only if it would be nonzero. Ignored in requests. 48622e3880aSThomas Graf * @OVS_FLOW_ATTR_USED: A 64-bit integer giving the time, in milliseconds on 48722e3880aSThomas Graf * the system monotonic clock, at which a packet was last processed for this 48822e3880aSThomas Graf * flow. Only present in notifications if a packet has been processed for this 48922e3880aSThomas Graf * flow. Ignored in requests. 49022e3880aSThomas Graf * @OVS_FLOW_ATTR_CLEAR: If present in a %OVS_FLOW_CMD_SET request, clears the 49122e3880aSThomas Graf * last-used time, accumulated TCP flags, and statistics for this flow. 49222e3880aSThomas Graf * Otherwise ignored in requests. Never present in notifications. 49303f0d916SAndy Zhou * @OVS_FLOW_ATTR_MASK: Nested %OVS_KEY_ATTR_* attributes specifying the 49403f0d916SAndy Zhou * mask bits for wildcarded flow match. Mask bit value '1' specifies exact 49503f0d916SAndy Zhou * match with corresponding flow key bit, while mask bit value '0' specifies 49603f0d916SAndy Zhou * a wildcarded match. Omitting attribute is treated as wildcarding all 49703f0d916SAndy Zhou * corresponding fields. Optional for all requests. If not present, 49803f0d916SAndy Zhou * all flow key bits are exact match bits. 49974ed7ab9SJoe Stringer * @OVS_FLOW_ATTR_UFID: A value between 1-16 octets specifying a unique 50074ed7ab9SJoe Stringer * identifier for the flow. Causes the flow to be indexed by this value rather 50174ed7ab9SJoe Stringer * than the value of the %OVS_FLOW_ATTR_KEY attribute. Optional for all 50274ed7ab9SJoe Stringer * requests. Present in notifications if the flow was created with this 50374ed7ab9SJoe Stringer * attribute. 50474ed7ab9SJoe Stringer * @OVS_FLOW_ATTR_UFID_FLAGS: A 32-bit value of OR'd %OVS_UFID_F_* 50574ed7ab9SJoe Stringer * flags that provide alternative semantics for flow installation and 50674ed7ab9SJoe Stringer * retrieval. Optional for all requests. 50722e3880aSThomas Graf * 50822e3880aSThomas Graf * These attributes follow the &struct ovs_header within the Generic Netlink 50922e3880aSThomas Graf * payload for %OVS_FLOW_* commands. 51022e3880aSThomas Graf */ 51122e3880aSThomas Graf enum ovs_flow_attr { 51222e3880aSThomas Graf OVS_FLOW_ATTR_UNSPEC, 51322e3880aSThomas Graf OVS_FLOW_ATTR_KEY, /* Sequence of OVS_KEY_ATTR_* attributes. */ 51422e3880aSThomas Graf OVS_FLOW_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */ 51522e3880aSThomas Graf OVS_FLOW_ATTR_STATS, /* struct ovs_flow_stats. */ 51622e3880aSThomas Graf OVS_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */ 51722e3880aSThomas Graf OVS_FLOW_ATTR_USED, /* u64 msecs last used in monotonic time. */ 51822e3880aSThomas Graf OVS_FLOW_ATTR_CLEAR, /* Flag to clear stats, tcp_flags, used. */ 51903f0d916SAndy Zhou OVS_FLOW_ATTR_MASK, /* Sequence of OVS_KEY_ATTR_* attributes. */ 52005da5898SJarno Rajahalme OVS_FLOW_ATTR_PROBE, /* Flow operation is a feature probe, error 52105da5898SJarno Rajahalme * logging should be suppressed. */ 52274ed7ab9SJoe Stringer OVS_FLOW_ATTR_UFID, /* Variable length unique flow identifier. */ 52374ed7ab9SJoe Stringer OVS_FLOW_ATTR_UFID_FLAGS,/* u32 of OVS_UFID_F_*. */ 5240238b720SNicolas Dichtel OVS_FLOW_ATTR_PAD, 52522e3880aSThomas Graf __OVS_FLOW_ATTR_MAX 52622e3880aSThomas Graf }; 52722e3880aSThomas Graf 52822e3880aSThomas Graf #define OVS_FLOW_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1) 52922e3880aSThomas Graf 53022e3880aSThomas Graf /** 53174ed7ab9SJoe Stringer * Omit attributes for notifications. 53274ed7ab9SJoe Stringer * 53374ed7ab9SJoe Stringer * If a datapath request contains an %OVS_UFID_F_OMIT_* flag, then the datapath 53474ed7ab9SJoe Stringer * may omit the corresponding %OVS_FLOW_ATTR_* from the response. 53574ed7ab9SJoe Stringer */ 53674ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_KEY (1 << 0) 53774ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_MASK (1 << 1) 53874ed7ab9SJoe Stringer #define OVS_UFID_F_OMIT_ACTIONS (1 << 2) 53974ed7ab9SJoe Stringer 54074ed7ab9SJoe Stringer /** 54122e3880aSThomas Graf * enum ovs_sample_attr - Attributes for %OVS_ACTION_ATTR_SAMPLE action. 54222e3880aSThomas Graf * @OVS_SAMPLE_ATTR_PROBABILITY: 32-bit fraction of packets to sample with 54322e3880aSThomas Graf * @OVS_ACTION_ATTR_SAMPLE. A value of 0 samples no packets, a value of 54422e3880aSThomas Graf * %UINT32_MAX samples all packets and intermediate values sample intermediate 54522e3880aSThomas Graf * fractions of packets. 54622e3880aSThomas Graf * @OVS_SAMPLE_ATTR_ACTIONS: Set of actions to execute in sampling event. 54722e3880aSThomas Graf * Actions are passed as nested attributes. 54822e3880aSThomas Graf * 54922e3880aSThomas Graf * Executes the specified actions with the given probability on a per-packet 55022e3880aSThomas Graf * basis. 55122e3880aSThomas Graf */ 55222e3880aSThomas Graf enum ovs_sample_attr { 55322e3880aSThomas Graf OVS_SAMPLE_ATTR_UNSPEC, 55422e3880aSThomas Graf OVS_SAMPLE_ATTR_PROBABILITY, /* u32 number */ 55522e3880aSThomas Graf OVS_SAMPLE_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */ 55622e3880aSThomas Graf __OVS_SAMPLE_ATTR_MAX, 55722e3880aSThomas Graf }; 55822e3880aSThomas Graf 55922e3880aSThomas Graf #define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1) 56022e3880aSThomas Graf 56122e3880aSThomas Graf /** 56222e3880aSThomas Graf * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action. 56322e3880aSThomas Graf * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION 56422e3880aSThomas Graf * message should be sent. Required. 56522e3880aSThomas Graf * @OVS_USERSPACE_ATTR_USERDATA: If present, its variable-length argument is 56622e3880aSThomas Graf * copied to the %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA. 5678f0aad6fSWenyu Zhang * @OVS_USERSPACE_ATTR_EGRESS_TUN_PORT: If present, u32 output port to get 5688f0aad6fSWenyu Zhang * tunnel info. 569ccea7445SNeil McKee * @OVS_USERSPACE_ATTR_ACTIONS: If present, send actions with upcall. 57022e3880aSThomas Graf */ 57122e3880aSThomas Graf enum ovs_userspace_attr { 57222e3880aSThomas Graf OVS_USERSPACE_ATTR_UNSPEC, 57322e3880aSThomas Graf OVS_USERSPACE_ATTR_PID, /* u32 Netlink PID to receive upcalls. */ 57422e3880aSThomas Graf OVS_USERSPACE_ATTR_USERDATA, /* Optional user-specified cookie. */ 5758f0aad6fSWenyu Zhang OVS_USERSPACE_ATTR_EGRESS_TUN_PORT, /* Optional, u32 output port 5768f0aad6fSWenyu Zhang * to get tunnel info. */ 577ccea7445SNeil McKee OVS_USERSPACE_ATTR_ACTIONS, /* Optional flag to get actions. */ 57822e3880aSThomas Graf __OVS_USERSPACE_ATTR_MAX 57922e3880aSThomas Graf }; 58022e3880aSThomas Graf 58122e3880aSThomas Graf #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1) 58222e3880aSThomas Graf 583*f2a4d086SWilliam Tu struct ovs_action_trunc { 584*f2a4d086SWilliam Tu uint32_t max_len; /* Max packet size in bytes. */ 585*f2a4d086SWilliam Tu }; 586*f2a4d086SWilliam Tu 58722e3880aSThomas Graf /** 58825cd9ba0SSimon Horman * struct ovs_action_push_mpls - %OVS_ACTION_ATTR_PUSH_MPLS action argument. 58925cd9ba0SSimon Horman * @mpls_lse: MPLS label stack entry to push. 59025cd9ba0SSimon Horman * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame. 59125cd9ba0SSimon Horman * 59225cd9ba0SSimon Horman * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and 59325cd9ba0SSimon Horman * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected. 59425cd9ba0SSimon Horman */ 59525cd9ba0SSimon Horman struct ovs_action_push_mpls { 59625cd9ba0SSimon Horman __be32 mpls_lse; 59725cd9ba0SSimon Horman __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */ 59825cd9ba0SSimon Horman }; 59925cd9ba0SSimon Horman 60025cd9ba0SSimon Horman /** 60122e3880aSThomas Graf * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument. 60222e3880aSThomas Graf * @vlan_tpid: Tag protocol identifier (TPID) to push. 60322e3880aSThomas Graf * @vlan_tci: Tag control identifier (TCI) to push. The CFI bit must be set 60422e3880aSThomas Graf * (but it will not be set in the 802.1Q header that is pushed). 60522e3880aSThomas Graf * 60622e3880aSThomas Graf * The @vlan_tpid value is typically %ETH_P_8021Q. The only acceptable TPID 60722e3880aSThomas Graf * values are those that the kernel module also parses as 802.1Q headers, to 60822e3880aSThomas Graf * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN 60922e3880aSThomas Graf * from having surprising results. 61022e3880aSThomas Graf */ 61122e3880aSThomas Graf struct ovs_action_push_vlan { 61222e3880aSThomas Graf __be16 vlan_tpid; /* 802.1Q TPID. */ 61322e3880aSThomas Graf __be16 vlan_tci; /* 802.1Q TCI (VLAN ID and priority). */ 61422e3880aSThomas Graf }; 61522e3880aSThomas Graf 616971427f3SAndy Zhou /* Data path hash algorithm for computing Datapath hash. 617971427f3SAndy Zhou * 618971427f3SAndy Zhou * The algorithm type only specifies the fields in a flow 619971427f3SAndy Zhou * will be used as part of the hash. Each datapath is free 620971427f3SAndy Zhou * to use its own hash algorithm. The hash value will be 621971427f3SAndy Zhou * opaque to the user space daemon. 622971427f3SAndy Zhou */ 623971427f3SAndy Zhou enum ovs_hash_alg { 624971427f3SAndy Zhou OVS_HASH_ALG_L4, 625971427f3SAndy Zhou }; 626971427f3SAndy Zhou 627971427f3SAndy Zhou /* 628971427f3SAndy Zhou * struct ovs_action_hash - %OVS_ACTION_ATTR_HASH action argument. 629971427f3SAndy Zhou * @hash_alg: Algorithm used to compute hash prior to recirculation. 630971427f3SAndy Zhou * @hash_basis: basis used for computing hash. 631971427f3SAndy Zhou */ 632971427f3SAndy Zhou struct ovs_action_hash { 633971427f3SAndy Zhou uint32_t hash_alg; /* One of ovs_hash_alg. */ 634971427f3SAndy Zhou uint32_t hash_basis; 635971427f3SAndy Zhou }; 636971427f3SAndy Zhou 63722e3880aSThomas Graf /** 6387f8a436eSJoe Stringer * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action. 639ab38a7b5SJoe Stringer * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack 640ab38a7b5SJoe Stringer * table. This allows future packets for the same connection to be identified 6411d008a1dSJoe Stringer * as 'established' or 'related'. The flow key for the current packet will 6421d008a1dSJoe Stringer * retain the pre-commit connection state. 6437f8a436eSJoe Stringer * @OVS_CT_ATTR_ZONE: u16 connection tracking zone. 644182e3042SJoe Stringer * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the 645182e3042SJoe Stringer * mask, the corresponding bit in the value is copied to the connection 646182e3042SJoe Stringer * tracking mark field in the connection. 647e5f5d747SPaolo Abeni * @OVS_CT_ATTR_LABELS: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN 648c2ac6673SJoe Stringer * mask. For each bit set in the mask, the corresponding bit in the value is 649c2ac6673SJoe Stringer * copied to the connection tracking label field in the connection. 650cae3a262SJoe Stringer * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG. 65105752523SJarno Rajahalme * @OVS_CT_ATTR_NAT: Nested OVS_NAT_ATTR_* for performing L3 network address 65205752523SJarno Rajahalme * translation (NAT) on the packet. 6537f8a436eSJoe Stringer */ 6547f8a436eSJoe Stringer enum ovs_ct_attr { 6557f8a436eSJoe Stringer OVS_CT_ATTR_UNSPEC, 656ab38a7b5SJoe Stringer OVS_CT_ATTR_COMMIT, /* No argument, commits connection. */ 6577f8a436eSJoe Stringer OVS_CT_ATTR_ZONE, /* u16 zone id. */ 658182e3042SJoe Stringer OVS_CT_ATTR_MARK, /* mark to associate with this connection. */ 65933db4125SJoe Stringer OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */ 660cae3a262SJoe Stringer OVS_CT_ATTR_HELPER, /* netlink helper to assist detection of 661cae3a262SJoe Stringer related connections. */ 66205752523SJarno Rajahalme OVS_CT_ATTR_NAT, /* Nested OVS_NAT_ATTR_* */ 6637f8a436eSJoe Stringer __OVS_CT_ATTR_MAX 6647f8a436eSJoe Stringer }; 6657f8a436eSJoe Stringer 6667f8a436eSJoe Stringer #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1) 6677f8a436eSJoe Stringer 6687f8a436eSJoe Stringer /** 66905752523SJarno Rajahalme * enum ovs_nat_attr - Attributes for %OVS_CT_ATTR_NAT. 67005752523SJarno Rajahalme * 67105752523SJarno Rajahalme * @OVS_NAT_ATTR_SRC: Flag for Source NAT (mangle source address/port). 67205752523SJarno Rajahalme * @OVS_NAT_ATTR_DST: Flag for Destination NAT (mangle destination 67305752523SJarno Rajahalme * address/port). Only one of (@OVS_NAT_ATTR_SRC, @OVS_NAT_ATTR_DST) may be 67405752523SJarno Rajahalme * specified. Effective only for packets for ct_state NEW connections. 67505752523SJarno Rajahalme * Packets of committed connections are mangled by the NAT action according to 67605752523SJarno Rajahalme * the committed NAT type regardless of the flags specified. As a corollary, a 67705752523SJarno Rajahalme * NAT action without a NAT type flag will only mangle packets of committed 67805752523SJarno Rajahalme * connections. The following NAT attributes only apply for NEW 67905752523SJarno Rajahalme * (non-committed) connections, and they may be included only when the CT 68005752523SJarno Rajahalme * action has the @OVS_CT_ATTR_COMMIT flag and either @OVS_NAT_ATTR_SRC or 68105752523SJarno Rajahalme * @OVS_NAT_ATTR_DST is also included. 68205752523SJarno Rajahalme * @OVS_NAT_ATTR_IP_MIN: struct in_addr or struct in6_addr 68305752523SJarno Rajahalme * @OVS_NAT_ATTR_IP_MAX: struct in_addr or struct in6_addr 68405752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_MIN: u16 L4 protocol specific lower boundary (port) 68505752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_MAX: u16 L4 protocol specific upper boundary (port) 68605752523SJarno Rajahalme * @OVS_NAT_ATTR_PERSISTENT: Flag for persistent IP mapping across reboots 68705752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_HASH: Flag for pseudo random L4 port mapping (MD5) 68805752523SJarno Rajahalme * @OVS_NAT_ATTR_PROTO_RANDOM: Flag for fully randomized L4 port mapping 68905752523SJarno Rajahalme */ 69005752523SJarno Rajahalme enum ovs_nat_attr { 69105752523SJarno Rajahalme OVS_NAT_ATTR_UNSPEC, 69205752523SJarno Rajahalme OVS_NAT_ATTR_SRC, 69305752523SJarno Rajahalme OVS_NAT_ATTR_DST, 69405752523SJarno Rajahalme OVS_NAT_ATTR_IP_MIN, 69505752523SJarno Rajahalme OVS_NAT_ATTR_IP_MAX, 69605752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_MIN, 69705752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_MAX, 69805752523SJarno Rajahalme OVS_NAT_ATTR_PERSISTENT, 69905752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_HASH, 70005752523SJarno Rajahalme OVS_NAT_ATTR_PROTO_RANDOM, 70105752523SJarno Rajahalme __OVS_NAT_ATTR_MAX, 70205752523SJarno Rajahalme }; 70305752523SJarno Rajahalme 70405752523SJarno Rajahalme #define OVS_NAT_ATTR_MAX (__OVS_NAT_ATTR_MAX - 1) 70505752523SJarno Rajahalme 70605752523SJarno Rajahalme /** 70722e3880aSThomas Graf * enum ovs_action_attr - Action types. 70822e3880aSThomas Graf * 70922e3880aSThomas Graf * @OVS_ACTION_ATTR_OUTPUT: Output packet to port. 710*f2a4d086SWilliam Tu * @OVS_ACTION_ATTR_TRUNC: Output packet to port with truncated packet size. 71122e3880aSThomas Graf * @OVS_ACTION_ATTR_USERSPACE: Send packet to userspace according to nested 71222e3880aSThomas Graf * %OVS_USERSPACE_ATTR_* attributes. 71322e3880aSThomas Graf * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header. The 71422e3880aSThomas Graf * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its 71522e3880aSThomas Graf * value. 71683d2b9baSJarno Rajahalme * @OVS_ACTION_ATTR_SET_MASKED: Replaces the contents of an existing header. A 71783d2b9baSJarno Rajahalme * nested %OVS_KEY_ATTR_* attribute specifies a header to modify, its value, 71883d2b9baSJarno Rajahalme * and a mask. For every bit set in the mask, the corresponding bit value 71983d2b9baSJarno Rajahalme * is copied from the value to the packet header field, rest of the bits are 72083d2b9baSJarno Rajahalme * left unchanged. The non-masked value bits must be passed in as zeroes. 72183d2b9baSJarno Rajahalme * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute. 72222e3880aSThomas Graf * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the 72322e3880aSThomas Graf * packet. 72422e3880aSThomas Graf * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet. 72522e3880aSThomas Graf * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in 72622e3880aSThomas Graf * the nested %OVS_SAMPLE_ATTR_* attributes. 72725cd9ba0SSimon Horman * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry onto the 72825cd9ba0SSimon Horman * top of the packets MPLS label stack. Set the ethertype of the 72925cd9ba0SSimon Horman * encapsulating frame to either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC to 73025cd9ba0SSimon Horman * indicate the new packet contents. 73125cd9ba0SSimon Horman * @OVS_ACTION_ATTR_POP_MPLS: Pop an MPLS label stack entry off of the 73225cd9ba0SSimon Horman * packet's MPLS label stack. Set the encapsulating frame's ethertype to 73325cd9ba0SSimon Horman * indicate the new packet contents. This could potentially still be 73425cd9ba0SSimon Horman * %ETH_P_MPLS if the resulting MPLS label stack is not empty. If there 73525cd9ba0SSimon Horman * is no MPLS label stack, as determined by ethertype, no action is taken. 7367f8a436eSJoe Stringer * @OVS_ACTION_ATTR_CT: Track the connection. Populate the conntrack-related 7377f8a436eSJoe Stringer * entries in the flow key. 73822e3880aSThomas Graf * 73922e3880aSThomas Graf * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all 74022e3880aSThomas Graf * fields within a header are modifiable, e.g. the IPv4 protocol and fragment 74122e3880aSThomas Graf * type may not be changed. 74283d2b9baSJarno Rajahalme * 74383d2b9baSJarno Rajahalme * @OVS_ACTION_ATTR_SET_TO_MASKED: Kernel internal masked set action translated 74483d2b9baSJarno Rajahalme * from the @OVS_ACTION_ATTR_SET. 74522e3880aSThomas Graf */ 74622e3880aSThomas Graf 74722e3880aSThomas Graf enum ovs_action_attr { 74822e3880aSThomas Graf OVS_ACTION_ATTR_UNSPEC, 74922e3880aSThomas Graf OVS_ACTION_ATTR_OUTPUT, /* u32 port number. */ 75022e3880aSThomas Graf OVS_ACTION_ATTR_USERSPACE, /* Nested OVS_USERSPACE_ATTR_*. */ 75122e3880aSThomas Graf OVS_ACTION_ATTR_SET, /* One nested OVS_KEY_ATTR_*. */ 75222e3880aSThomas Graf OVS_ACTION_ATTR_PUSH_VLAN, /* struct ovs_action_push_vlan. */ 75322e3880aSThomas Graf OVS_ACTION_ATTR_POP_VLAN, /* No argument. */ 75422e3880aSThomas Graf OVS_ACTION_ATTR_SAMPLE, /* Nested OVS_SAMPLE_ATTR_*. */ 755971427f3SAndy Zhou OVS_ACTION_ATTR_RECIRC, /* u32 recirc_id. */ 756971427f3SAndy Zhou OVS_ACTION_ATTR_HASH, /* struct ovs_action_hash. */ 75725cd9ba0SSimon Horman OVS_ACTION_ATTR_PUSH_MPLS, /* struct ovs_action_push_mpls. */ 75825cd9ba0SSimon Horman OVS_ACTION_ATTR_POP_MPLS, /* __be16 ethertype. */ 75983d2b9baSJarno Rajahalme OVS_ACTION_ATTR_SET_MASKED, /* One nested OVS_KEY_ATTR_* including 76083d2b9baSJarno Rajahalme * data immediately followed by a mask. 76183d2b9baSJarno Rajahalme * The data must be zero for the unmasked 76283d2b9baSJarno Rajahalme * bits. */ 7630a7cc172SJoe Stringer OVS_ACTION_ATTR_CT, /* Nested OVS_CT_ATTR_* . */ 764*f2a4d086SWilliam Tu OVS_ACTION_ATTR_TRUNC, /* u32 struct ovs_action_trunc. */ 76525cd9ba0SSimon Horman 76683d2b9baSJarno Rajahalme __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted 76783d2b9baSJarno Rajahalme * from userspace. */ 76883d2b9baSJarno Rajahalme 76983d2b9baSJarno Rajahalme #ifdef __KERNEL__ 77083d2b9baSJarno Rajahalme OVS_ACTION_ATTR_SET_TO_MASKED, /* Kernel module internal masked 77183d2b9baSJarno Rajahalme * set action converted from 77283d2b9baSJarno Rajahalme * OVS_ACTION_ATTR_SET. */ 77383d2b9baSJarno Rajahalme #endif 77422e3880aSThomas Graf }; 77522e3880aSThomas Graf 77622e3880aSThomas Graf #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1) 77722e3880aSThomas Graf 77822e3880aSThomas Graf #endif /* _LINUX_OPENVSWITCH_H */ 779