summaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* userspace: add vxlan gpe support to vportGeorg Schmuecking2017-06-021-1/+0
| | | | | | | | | | | | | | This patch is based on the "datapath: enable vxlangpe creation in compat mode" from Yi Yang. It introduces an extension option "gpe" to the vxlan port in the netdev-dpdk datapath. Description of vxlan gpe protocoll was added to header file lib/packets.h. In the vxlan specific methods the different packet are introduced and handled. Added VXLAN GPE tunnel push test. Signed-off-by: Yi Yang <yi.y.yang at intel.com> Signed-off-by: Georg Schmuecking <georg.schmuecking@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* userspace: Switching of L3 packets in L2 pipelineJan Scheurich2017-06-022-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ports have a new layer3 attribute if they send/receive L3 packets. The packet_type included in structs dp_packet and flow is considered in ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite. A dummy ethernet header is pushed to L3 packets received from L3 ports before the the pipeline processing starts. The ethernet header is popped before sending a packet to a L3 port. For datapath ports that can receive L2 or L3 packets, the packet_type becomes part of the flow key for datapath flows and is handled appropriately in dpif-netdev. In the 'else' branch in flow_put_on_pmd() function, the additional check flow_equal(&match.flow, &netdev_flow->flow) was removed, as a) the dpcls lookup is sufficient to uniquely identify a flow and b) it caused false negatives because the flow in netdev->flow may not properly masked. In dpif_netdev_flow_put() we now use the same method for constructing the netdev_flow_key as the one used when adding the flow to the dplcs to make sure these always match. The function netdev_flow_key_from_flow() used so far was not only inefficient but sometimes caused mismatches and subsequent flow update failures. The kernel datapath does not support the packet_type match field. Instead it encodes the packet type implictly by the presence or absence of the Ethernet attribute in the flow key and mask. This patch filters the PACKET_TYPE attribute out of netlink flow key and mask to be sent to the kernel datapath. Signed-off-by: Lorand Jakab <lojakab@cisco.com> Signed-off-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com> Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Support accepting and displaying port names in OVS tools.Ben Pfaff2017-05-316-23/+71
| | | | | | | | | | | | | | Until now, most ovs-ofctl commands have not accepted names for ports, only numbers, and have not been able to display port names either. It's a lot easier for users if they can use and see meaningful names instead of arbitrary numbers. This commit adds that support. For backward compatibility, only interactive ovs-ofctl commands by default display port names; to display them in scripts, use the new --names option. Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Aaron Conole <aconole@redhat.com>
* ofp-util: Fix tun_metadata processing in packet-outYi-Hung Wei2017-05-311-0/+1
| | | | | | | | Pass tun_table to ofputil_handle_packet_out() to correctly decode tunnel metadata in packet-out messages. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofproto: Add pipeline fields support for OF 1.5 packet-outYi-Hung Wei2017-05-312-0/+4
| | | | | | | | | | | | | | | | | | | | | | | This patch decodes pipeline fields from a packet-out message, and populates the pipeline fields into datapath. Error OFPERR_OFPBRC_PIPELINE_FIELDS_ONLY is returned if the match field of a packet-out messages contains any non pipeline fields. Currently, the supported pipeline fields are as following. * metadata fields: - in_port, in_port_oxm * tunnel fields: - tun_id, tun_src, tun_dst, tun_ipv6_src, tun_ipv6_dst - tun_gbp_id, tun_gpb_flags, tun_flags - tun_metadata0 - tun_metadata63 * register fields: - metadata - reg0 - reg-15, xreg0 - xreg7, xxreg0 - xxreg3 Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofp-util: Add OpenFlow 1.5 packet-out supportYi-Hung Wei2017-05-312-2/+18
| | | | | | | | | | | | | | | | | This patch implements the encoding and decoding of the new packet-out format defined in OpenFlow 1.5. Test cases are provided to verify the encoding and decoding. This patch is based on [1] and [2]. [1] https://github.com/jean2/openvswitch/commits/jean/ext-427 [2] https://mail.openvswitch.org/pipermail/ovs-dev/2017-April/331032.html Signed-off-by: Jean Tourrilhes <jt@labs.hpe.com> Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com> Co-authored-by: Jan Scheurich <jan.scheurich@ericsson.com> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofp-util: Add flow metadata to ofputil_packet_outYi-Hung Wei2017-05-311-1/+1
| | | | | | | | | This patch adds flow metadata to ofputil_packet_out. It does not make any functional change. The flow metadata will be useful to support new packet-out message format in OpenFlow 1.5. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* compat: Add tc compatibility headers for old kernelsPaul Blakey2017-05-305-0/+256
| | | | | | | | | | | | | | Added compatibility headers for actions vlan and tunnel key. Do not use compat code when compiling kernel datapath there is no need for it as TC compatibility is not provided there. In other words, the compat code is only used when compiling user-space code against old kernel headers. Signed-off-by: Paul Blakey <paulb@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Acked-by: Flavio Leitner <fbl@sysclose.org> Signed-off-by: Simon Horman <simon.horman@netronome.com>
* windows: add definition of getpid and getcwdAlin Serdean2017-05-251-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | getcwd - is used in lib/util.c. getcwd is deprecated on Windows but has _getcwd which is defined in <direct.h>: https://msdn.microsoft.com/en-us/library/sf98bd4y(v=vs.120).aspx getpid - is used in several files (i.e. lib/vlog.c). getpid is also and deprecated and _getpid should be used: https://msdn.microsoft.com/en-us/library/t2y34y40(v=vs.120).aspx The problem using _getpid is that the definition is in <process.h>. A file called process.h also exists in the lib folder. This will mess up includes. An option would be to use a wrapper like we use for lib/string.h(.in) but that would mean to also add it to the automake chain. A simple solution would be to map it to GetCurrentProcessId https://msdn.microsoft.com/en-us/library/windows/desktop/ms683180(v=vs.85).aspx _getpid uses GetCurrentProcessId behind the scenes, casting the result is not required. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Co-authored-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* sparse: Add rte_memcpy.h replacement header.Ben Pfaff2017-05-072-0/+40
| | | | | | | | | | | | | | | | | | Without this replacement header, building netdev-dpdk.c provokes several "sparse" warnings on i386: /usr/include/dpdk/rte_memcpy.h:515:33: warning: incorrect type in argument 1 (different type sizes) /usr/include/dpdk/rte_memcpy.h:515:33: expected long long const [usertype] *__P /usr/include/dpdk/rte_memcpy.h:515:33: got int const [usertype] *<noident> /usr/lib/gcc/i686-linux-gnu/6//include/emmintrin.h:698:20: error: undefined identifier '__builtin_ia32_loaddqu' /usr/lib/gcc/i686-linux-gnu/6//include/emmintrin.h:698:11: error: cast from unknown type /usr/lib/gcc/i686-linux-gnu/6//include/emmintrin.h:716:3: error: undefined identifier '__builtin_ia32_storedqu' /usr/lib/gcc/i686-linux-gnu/6//include/emmintrin.h:698:43: error: not a function <noident> /usr/lib/gcc/i686-linux-gnu/6//include/emmintrin.h:716:27: error: not a function <noident> ... Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Darrell Ball <dlu998@gmail.com>
* windows: Add definition for EPFNOSUPPORT.Alin Serdean2017-05-051-0/+2
| | | | | | | | | | | The Windows build is failing because EPFNOSUPPORT does not exist. An equivalent is supplied using the WinSock API: WSAEPFNOSUPPORT. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Acked-by: Sairam Venugopal <vsairam@vmware.com> Acked-by: Shashank Ram <rams@vmware.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* userspace: Add packet_type in dp_packet and flowJan Scheurich2017-05-033-9/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a packet_type attribute to the structs dp_packet and flow to explicitly carry the type of the packet as prepration for the introduction of the so-called packet type-aware pipeline (PTAP) in OVS. The packet_type is a big-endian 32 bit integer with the encoding as specified in OpenFlow verion 1.5. The upper 16 bits contain the packet type name space. Pre-defined values are defined in openflow-common.h: enum ofp_header_type_namespaces { OFPHTN_ONF = 0, /* ONF namespace. */ OFPHTN_ETHERTYPE = 1, /* ns_type is an Ethertype. */ OFPHTN_IP_PROTO = 2, /* ns_type is a IP protocol number. */ OFPHTN_UDP_TCP_PORT = 3, /* ns_type is a TCP or UDP port. */ OFPHTN_IPV4_OPTION = 4, /* ns_type is an IPv4 option number. */ }; The lower 16 bits specify the actual type in the context of the name space. Only name spaces 0 and 1 will be supported for now. For name space OFPHTN_ONF the relevant packet type is 0 (Ethernet). This is the default packet_type in OVS and the only one supported so far. Packets of type (OFPHTN_ONF, 0) are called Ethernet packets. In name space OFPHTN_ETHERTYPE the type is the Ethertype of the packet. A packet of type (OFPHTN_ETHERTYPE, <Ethertype>) is a standard L2 packet whith the Ethernet header (and any VLAN tags) removed to expose the L3 (or L2.5) payload of the packet. These will simply be called L3 packets. The Ethernet address fields dl_src and dl_dst in struct flow are not applicable for an L3 packet and must be zero. However, to maintain compatibility with the large code base, we have chosen to copy the Ethertype of an L3 packet into the the dl_type field of struct flow. This does not mean that it will be possible to match on dl_type for L3 packets with PTAP later on. Matching must be done on packet_type instead. New dp_packets are initialized with packet_type Ethernet. Ports that receive L3 packets will have to explicitly adjust the packet_type. Signed-off-by: Jean Tourrilhes <jt@labs.hpe.com> Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com> Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovn-sbctl: Add --ovs option to "lflow-list", for listing OpenFlow flows.Ben Pfaff2017-05-031-2/+2
| | | | | | | | This is like the --ovs option to ovn-trace, but it applies to every flow dumped, so it has different applications. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovn-controller: Add 'dns_lookup' actionNuman Siddique2017-05-021-1/+16
| | | | | | | | | | | | | | | | | | | | | | This patch adds a new OVN action 'dns_lookup' to support native DNS. ovn-controller parses this action and adds a NXT_PACKET_IN2 OF flow with 'pause' flag set. A new table 'DNS' is added in the SB DB to look up and resolve the DNS queries. When a valid DNS packet is received by ovn-controller, it looks up the DNS name in the 'DNS' table and if successful, it frames a DNS reply, resumes the packet and stores 1 in the 1-bit subfield. If the packet is invalid or cannot be resolved, it resumes the packet without any modifications and stores 0 in the 1-bit subfield. reg0[4] = dns_lookup(); next; An upcoming patch will use this action and adds logical flows. Signed-off-by: Numan Siddique <nusiddiq@redhat.com> Acked-by: Gurucharan Shetty <guru@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovn-controller: Remove ct_zones from lflow_run.Han Zhou2017-05-011-3/+0
| | | | | | | ct_zones is not really used in lflow_run, so remove the dependency. Signed-off-by: Han Zhou <zhouhan@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* OpenFlow: Enable OpenFlow 1.4 by default.Ben Pfaff2017-05-011-1/+2
| | | | | | | Open vSwitch now supports all OpenFlow 1.4 required features, so enable it by default. Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofp-actions: Document that learn(limit=0) is no limit.Joe Stringer2017-05-011-1/+1
| | | | | | | | | The documentation was unclear that specifying a limit of 0 is the same as specifying no limit. Controllers that wish to set a learn limit so that no more than 0 flows are learned may omit the learn action. Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
* connmgr: Fix internal packet-in reason code mask.Yi-Hung Wei2017-04-241-2/+7
| | | | | | | | | | | | | | | | Starting from OpenFlow 1.4+, OFPR_ACTION is split into four more descriptive reasons, OFPR_APPLY_ACTION, OFPR_ACTION_SET, OFPR_GROUP, and OFPR_PACKET_OUT. OVS maintains the new reason code internally, and it currently supports the first three reason code. If the version of an established OpenFlow connection is less than 1.4, OVS converts the internal reason code back to OFPR_ACTION to be backward compatible. However, the internal packet-in reason code mask is not properly maintained for the older OpenFlow version that may emit the packet-in messages wth the new reason code. It is because OVS does not enable the new reason code internally in the reason code mask for older OpenFlow version. This commit tries to address the aforementioned issue. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Add support for OpenFlow 1.6 (draft) port status and port mod messages.Ben Pfaff2017-04-079-14/+134
| | | | | | | | | OpenFlow 1.6 adds support for EUI-64 addresses for ports, and extends the maximum length of OpenFlow port names from 16 to 64 bytes. ONF-JIRA: EXT-566 Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* types: New struct eth_addr64 for EUI-64 identifiers.Ben Pfaff2017-04-071-1/+9
| | | | | | | This will see its first real user in the following commit. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* bundle: add nw_src/dst hash methodwenxu2017-04-061-1/+6
| | | | | | | Add only nw_src or nw_dst hash feature to bundle and multipath. Signed-off-by: wenxu <wenxu@ucloud.cn> Signed-off-by: Ben Pfaff <blp@ovn.org>
* meta-flow: Remove metadata prerequisite on ether type.Jarno Rajahalme2017-03-241-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conntrack original direction tuple fields depend on the conntrack state and the type of the packet that was tracked. These dependencies were encoded as OpenFlow prerequisites in commit daf4d3c18da4 ("odp: Support conntrack orig tuple key."). However, having a prerequisite from a metadata field to a packet header turned out to be problematic, since sometimes we are decoding metadata fields alone, so that the packet type field is not available. The reason for the packet type dependency is that the IP addresses in the original direction tuple can be either IPv4 or IPv6 addresses, and it would be invalid to match on IPv4 original direction tuple addresses for an IPv6 packet and vica verca. Upon closer look, however, allowing this kind of mismatched match only causes the flow to never match anything, rather than causing more severe problems. This patch removes the formal prerequisite on the packet type, but replaces that with an explicit check for the mismatch on flow install. This way we can still return an error to the controller if it tries to install a mismatched flow. Reported-by: Dong Jun <dongj@dtdream.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-March/330052.html Fixes: 7befb20d0f70 ("nx-match: Fix oxm decode.") Fixes: daf4d3c18da4 ("odp: Support conntrack orig tuple key.") Suggested-by: Numan Siddique <nusiddiq@redhat.com> Suggested-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Tested-by: Numan Siddique <nusiddiq@redhat.com> Acked-by: Numan Siddique <nusiddiq@redhat.com> Acked-by: Ben Pfaff <blp@ovn.org>
* compiler: Use C11 build assertions with new enough GCC or Clang.Ben Pfaff2017-03-161-13/+15
| | | | | | | | | | | | | | Until now, the BUILD_ASSERT and BUILD_ASSERT_DECL macros have used OVS's home-grown build assertion strategy. This commit switches them to using C11 build assertions with compilers that support them. The semantics are the same, but C11 build assertions yield clearer error messages when they fail. This commit also reorders the definitions a bit to make it easier to follow. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
* Add support for 802.1ad (QinQ tunneling)Eric Garver2017-03-163-5/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Flow key handling changes: - Add VLAN header array in struct flow, to record multiple 802.1q VLAN headers. - Add dpif multi-VLAN capability probing. If datapath supports multi-VLAN, increase the maximum depth of nested OVS_KEY_ATTR_ENCAP. Refactor VLAN handling in dpif-xlate: - Introduce 'xvlan' to track VLAN stack during flow processing. - Input and output VLAN translation according to the xbundle type. Push VLAN action support: - Allow ethertype 0x88a8 in VLAN headers and push_vlan action. - Support push_vlan on dot1q packets. Use other_config:vlan-limit in table Open_vSwitch to limit maximum VLANs that can be matched. This allows us to preserve backwards compatibility. Add test cases for VLAN depth limit, Multi-VLAN actions and QinQ VLAN handling Co-authored-by: Thomas F Herbert <thomasfherbert@gmail.com> Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com> Co-authored-by: Xiao Liang <shaw.leon@gmail.com> Signed-off-by: Xiao Liang <shaw.leon@gmail.com> Signed-off-by: Eric Garver <e@erig.me> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofp-actions: Add limit to learn action.Daniele Di Proietto2017-03-161-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new feature to the learn actions: the possibility to limit the number of learned flows. To be compatible with users of the old learn action, a new structure is introduced as well as a new OpenFlow raw action number. There's a small corner case when we have to delete the ukey. This happens when: * The learned rule has expired (or has been deleted). * The ukey that learned the rule is still in the datapath. * No packets hit the datapath flow recently. In this case we cannot relearn the rule (because there are no new packets), and the actions might depend on the learn execution, so the only option is to delete the ukey. I don't think this has big performance implications since it's done only for ukey with no traffic. We could also slowpath it, but that will cause an action upcall and the correct datapath actions will be installed later by a revalidator. If we delete the ukey, the next upcall will be a miss upcall and that will immediatedly install the correct datapath flow. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofproto: Add ref counting for variable length mf_fields.Yi-Hung Wei2017-03-153-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Currently, a controller may potentially trigger a segmentation fault if it accidentally removes a TLV mapping that is still used by an active flow. To resolve this issue, in this patch, we maintain reference counting for each dynamically allocated variable length mf_fields, so that vswitchd can use this information to properly remove a TLV mapping, and to return an error if the controller tries to remove a TLV mapping that is still used by any active flow. To keep track of the usage of tun_metadata for each flow, two 'uint64_t' bitmaps are introduce for the flow match and flow action respectively. We use 'uint64_t' as a bitmap since the 64 geneve TLV tunnel metadata are the only available variable length mf_fields for now. We shall adopt general bitmap when more variable length mf_fields are introduced. The bitmaps are configured during the flow decoding process, and vswitchd use these bitmaps to increase or decrease the ref counting when the flow is created or deleted. VMWare-BZ: #1768370 Fixes: 04f48a68c428 ("ofp-actions: Fix variable length meta-flow OXMs.") Suggested-by: Jarno Rajahalme <jarno@ovn.org> Suggested-by: Joe Stringer <joe@ovn.org> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* nx-match: Use vl_mff_map to parse match field.Yi-Hung Wei2017-03-151-2/+4
| | | | | | | | | | vl_mff_map is introduced in commit 04f48a68c428 ("ofp-actions: Fix variable length meta-flow OXMs") to account variable length mf_field, and it is used to decode variable length mf_field in ofp_action. In this patch, vl_mff_map is further used to decode the variable length match field as well. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* meta-flow: Fix conntrack field OVS version.Jarno Rajahalme2017-03-141-7/+7
| | | | | | | | New conntrack original direction fields did not make it to OVS 2.7, so change the "since" version to v2.8. Suggested-by: Joe Stringer <joe@ovn.org> Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* ofproto: Probe for sample nesting level.Andy Zhou2017-03-101-0/+3
| | | | | | | | | | | Add logics to detect the max level of nesting allowed by the sample action implemented in the datapath. Future patch allows xlate code to generate different odp actions based on this information. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* conntrack: Force commit.Jarno Rajahalme2017-03-081-1/+6
| | | | | | Userspace support for force commit. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* actions: Add resubmit with conntrack tuple.Jarno Rajahalme2017-03-081-1/+3
| | | | | | | | | | Add resubmit option to use the conntrack original direction tuple swapped with the corresponding packet header fields during the lookup. This could allow the same ACL table be used for admitting return and/or related traffic as is used for admitting the original direction traffic. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* odp: Support conntrack orig tuple key.Jarno Rajahalme2017-03-083-4/+163
| | | | | | Userspace support for datapath original direction conntrack tuple. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* flow: Make room after ct_state.Jarno Rajahalme2017-03-081-1/+2
| | | | | | | 'ct_state' currently only needs 8 bits, so we can make room for a new CT field introduced in the next patch. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* lib: Check match and action prerequisities with 'match'.Jarno Rajahalme2017-03-082-4/+5
| | | | | | | | | | | | | | | Supply the match mask to prerequisities checking when available. This allows checking for zero-valued matches. Non-zero valued matches imply the presense of corresponding mask bits, but for zero valued matches we must explicitly check the mask, too. This is required now only for conntrack validity checking due to the conntrack state having and 'invalid' bit, but not 'valid' bit. One way to match an valid conntrack state is to match on the 'tracked' bit being one and 'invalid' bit being zero. The latter requires the corresponding mask bit be verified. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* ofp-actions: Fix translation of set_field for nw_ecnEric Garver2017-03-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | When using set_field for nw_ecn with OF1.0 or OF1.1, you get an error instead of a proper translation. This use to work before 4b684612d900 ("ofp-actions: Translate mod_nw_ecn action to OF1.1 properly.") because it would fallback to using NXM. e.g. [root@rhel7 ~]# ovs-ofctl -O OpenFlow10 add-flow br0 'ip actions=set_field:2->nw_ecn' OFPT_ERROR (xid=0x4): OFPBAC_BAD_ARGUMENT NXT_FLOW_MOD (xid=0x4): ... $ ovs-ofctl -O OpenFlow11 add-flow br0 'ip actions=set_field:2->nw_ecn' ovs-ofctl: none of the usable flow formats (NXM,OXM) is among the allowed flow formats (OpenFlow11) Fixes: 4b684612d900 ("ofp-actions: Translate mod_nw_ecn action to OF1.1 properly.") Signed-off-by: Eric Garver <e@erig.me> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ofproto: Meter translation.Jarno Rajahalme2017-03-081-0/+1
| | | | | | | Translate OpenFlow METER instructions to datapath meter actions. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Signed-off-by: Andy Zhou <azhou@ovn.org>
* windows: Add definition of getrusageAlin Serdean2017-03-071-1/+3
| | | | | | | | | | | getrusage is implemented in lib/getrusage-windows.c. This patch just adds its definition to include/windows/sys/resource.h, which serves for files that include <sys/resource.h>. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Acked-by: Sairam Venugopal <vsairam@vmware.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* meta-flow: Remove cmap dependency.Yi-Hung Wei2017-02-213-23/+3
| | | | | | | | | | | | | | Previous patch 04f48a68 ("ofp-actions: Fix variable length meta-flow OXMs.") introduced dependency of an internal library (cmap.h) to ovs public interface (meta-flow.h) that may cause potential building problem. In this patch, we remove cmap from struct mf_field, and provide a wrapper struct vl_mff_map that resolve the dependency problem. Fixes: 04f48a68c428 ("ofp-actions: Fix variable length meta-flow OXMs.") Suggested-by: Joe Stringer <joe@ovn.org> Suggested-by: Daniele Di Proietto <diproiettod@vmware.com> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* ofp-msgs: Remove unnecessary #include.Yi-Hung Wei2017-02-211-1/+0
| | | | | | | Include of lib/*.h from include/openvswitch/*.h is disallowed. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* ofp-actions: Fix variable length meta-flow OXMs.Yi-Hung Wei2017-02-014-7/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if a flow action that involves a tunnel metadata meta-flow field is dumped from vswitchd, the replied field length in the OXM header is filled with the maximum possible field length, instead of the length configured in the tunnel TLV mapping table. To solve this issue, this patch introduces the following changes. In order to maintain the correct length of variable length mf_fields (i.e. tun_metadata), this patch creates a per-switch based map (struct vl_mff_map) that hosts the variable length mf_fields. This map is updated when a controller adds/deletes tlv-mapping entries to/from a switch. Although the per-swtch based vl_mff_map only hosts tun_metadata for now, it is able to support new variable length mf_fields in the future. With this commit, when a switch decodes a flow action with mf_field, the switch firstly looks up the global mf_fields map to identify the mf_field type. For the variable length mf_fields, the switch uses the vl_mff_map to get the configured mf_field entries. By lookig up vl_mff_map, the switch can check if the added flow action access beyond the configured size of a variable length mf_field, and the switch reports an ofperr if the controller adds a flow with unmapped variable length mf_field. Later on, when a controller request flows from the switch, with the per-switch based mf_fields, the switch will encode the OXM header with correct length for variable length mf_fields. To use the vl_mff_map for decoding flow actions, extract-ofp-actions is updated to pass the vl_mff_map to the required action decoding functions. Also, a new error code is introduced to identify a flow with an invalid variable length mf_field. Moreover, a testcase is added to prevent future regressions. Committer notes: - Factor out common code - Style fixups - Rename OFPERR_NXFMFC_INVALID_VL_MFF -> OFPERR_NXFMFC_INVALID_TLV_FIELD VMWare-BZ: #1768370 Reported-by: Harold Lim <haroldl@vmware.com> Suggested-by: Joe Stringer <joe@ovn.org> Suggested-by: Jarno Rajahalme <jarno@ovn.org> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* ovn: avoid snat recirc only on gateway routersMickey Spiegel2017-01-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Currently, for performance reasons on gateway routers, ct_snat that does not specify an IP address does not immediately trigger recirculation. On gateway routers, ct_snat that does not specify an IP address happens in the UNSNAT pipeline stage, which is followed by the DNAT pipeline stage that triggers recirculation for all packets. This DNAT pipeline stage recirculation takes care of the recirculation needs of UNSNAT as well as other cases such as UNDNAT. On distributed routers, UNDNAT is handled in the egress pipeline stage, separately from DNAT in the ingress pipeline stages. The DNAT pipeline stage only triggers recirculation for some packets. Due to this difference in design, UNSNAT needs to trigger its own recirculation. This patch restricts the logic that avoids recirculation for ct_snat, so that it only applies to datapaths representing gateway routers. Signed-off-by: Mickey Spiegel <mickeys.dev@gmail.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* ovs-fields: New manpage to document Open vSwitch and OpenFlow fields.Ben Pfaff2017-01-251-199/+6
| | | | | | | | | There is still plenty of opportunity for improvement, but this new ovs-fields(7) manpage is much more comprehensive than ovs-ofctl(8) could be. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* actions: Add new "ct_clear" action.Ben Pfaff2017-01-211-0/+1
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* actions: Make "next" action able to jump from egress to ingress pipeline.Ben Pfaff2017-01-211-27/+36
| | | | | | | This feature is useful for centralized gateways. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* actions: Introduce enum ovnact_pipeline.Ben Pfaff2017-01-211-0/+6
| | | | | | | | | This isn't used yet by the actions code, but an upcoming commit will introduce a user. This commit just adjusts ovn-trace to use this common type instead of its own local type. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* actions: Omit table number when possible for formatting "next" action.Ben Pfaff2017-01-211-0/+8
| | | | | | | | | | | | | | | | Until now, formatting the "next" action has always required including the table number, because the action struct didn't include enough context so that the formatter could decide whether the table number was the next table or some other table. This is more or less OK, but an upcoming commit will add a "pipeline" field to the "next" action, which means that the same policy there would require that the pipeline always be printed. That's a little obnoxious because 99+% of the time, the pipeline to be printed is the same pipeline that the flow is in and printing it would be distracting. So it's better to store some context to help with formatting. This commit begins adopting that policy for the existing table number field. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* actions: Separate action structures for "next" and "ct_next".Ben Pfaff2017-01-211-2/+8
| | | | | | | | | These actions aren't very similar but until now they both had the same action structure. These structures are going to diverge in an upcoming commit, so separate them now. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* actions: Add new OVN action "clone".Ben Pfaff2017-01-211-2/+3
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* lex: Make lexer_force_match() work for LEX_T_END.Ben Pfaff2017-01-201-2/+2
| | | | | | | | | | | | Without this change, lexer_force_match(lex, LEX_T_END) mostly works, except that in the failure case it emits an error that says "expecting `$'", which is a surprising error message. Arguably, lexer_force_end() could be removed entirely, but I don't see a real problem with the existing arrangement. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* ovn: add is_chassis_resident match expression componentMickey Spiegel2017-01-191-1/+21
| | | | | | | | | | | | | | | | | | | | | This patch introduces a new match expression component is_chassis_resident(). Unlike match expression comparisons, is_chassis_resident is not pushed down to OpenFlow. It is a conditional that is evaluated in the controller during expr_simplify(), when it is replaced by a boolean expression. The is_chassis_resident conditional evaluates to "true" when the specified string identifies a port name that is resident on this controller chassis, i.e., the corresponding southbound database Port_Binding has a chassis column that matches this chassis. Otherwise it evaluates to "false". This allows higher level features to specify flows that are only installed on some chassis rather than on all chassis with the corresponding datapath. Suggested-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Mickey Spiegel <mickeys.dev@gmail.com> Acked-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>