summaryrefslogtreecommitdiff
path: root/datapath/actions.c
Commit message (Collapse)AuthorAgeFilesLines
* datapath: enable NSH supportYi Yang2018-02-071-0/+116
| | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit b2d0f5d5dc53532e6f07bc546a476a55ebdfe0f3 Author: Yi Yang <yi.y.yang@intel.com> Date: Tue Nov 7 21:07:02 2017 +0800 openvswitch: enable NSH support OVS master and 2.8 branch has merged NSH userspace patch series, this patch is to enable NSH support in kernel data path in order that OVS can support NSH in compat mode by porting this. Signed-off-by: Yi Yang <yi.y.yang@intel.com> Acked-by: Jiri Benc <jbenc@redhat.com> Acked-by: Eric Garver <e@erig.me> Acked-by: Pravin Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Greg Rose <gvrose8192@gmail.com>
* datapath: add ct_clear actionEric Garver2018-01-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit b8226962b1c49c784aeddb9d2fafbf53dfdc2190 Author: Eric Garver <e@erig.me> Date: Tue Oct 10 16:54:44 2017 -0400 openvswitch: add ct_clear action This adds a ct_clear action for clearing conntrack state. ct_clear is currently implemented in OVS userspace, but is not backed by an action in the kernel datapath. This is useful for flows that may modify a packet tuple after a ct lookup has already occurred. Signed-off-by: Eric Garver <e@erig.me> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Notes: - hunk from include/uapi/linux/openvswitch.h is missing because it was added with userspace support in 1fe178d251c8 ("dpif: Add support for OVS_ACTION_ATTR_CT_CLEAR") - if IP_CT_UNTRACKED is not available use 0 as other nf_ct_set() calls do. Since we're setting ct to NULL this is okay. Signed-off-by: Eric Garver <e@erig.me> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath: fix skb_panic due to the incorrect actions attrlenGreg Rose2017-09-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 494bea39f3201776cdfddc232705f54a0bd210c4 Author: Liping Zhang <zlpnobody@gmail.com> Date: Wed Aug 16 13:30:07 2017 +0800 openvswitch: fix skb_panic due to the incorrect actions attrlen For sw_flow_actions, the actions_len only represents the kernel part's size, and when we dump the actions to the userspace, we will do the convertions, so it's true size may become bigger than the actions_len. But unfortunately, for OVS_PACKET_ATTR_ACTIONS, we use the actions_len to alloc the skbuff, so the user_skb's size may become insufficient and oops will happen like this: skbuff: skb_over_panic: text:ffffffff8148fabf len:1749 put:157 head: ffff881300f39000 data:ffff881300f39000 tail:0x6d5 end:0x6c0 dev:<NULL> ------------[ cut here ]------------ kernel BUG at net/core/skbuff.c:129! [...] Call Trace: <IRQ> [<ffffffff8148be82>] skb_put+0x43/0x44 [<ffffffff8148fabf>] skb_zerocopy+0x6c/0x1f4 [<ffffffffa0290d36>] queue_userspace_packet+0x3a3/0x448 [openvswitch] [<ffffffffa0292023>] ovs_dp_upcall+0x30/0x5c [openvswitch] [<ffffffffa028d435>] output_userspace+0x132/0x158 [openvswitch] [<ffffffffa01e6890>] ? ip6_rcv_finish+0x74/0x77 [ipv6] [<ffffffffa028e277>] do_execute_actions+0xcc1/0xdc8 [openvswitch] [<ffffffffa028e3f2>] ovs_execute_actions+0x74/0x106 [openvswitch] [<ffffffffa0292130>] ovs_dp_process_packet+0xe1/0xfd [openvswitch] [<ffffffffa0292b77>] ? key_extract+0x63c/0x8d5 [openvswitch] [<ffffffffa029848b>] ovs_vport_receive+0xa1/0xc3 [openvswitch] [...] Also we can find that the actions_len is much little than the orig_len: crash> struct sw_flow_actions 0xffff8812f539d000 struct sw_flow_actions { rcu = { next = 0xffff8812f5398800, func = 0xffffe3b00035db32 }, orig_len = 1384, actions_len = 592, actions = 0xffff8812f539d01c } So as a quick fix, use the orig_len instead of the actions_len to alloc the user_skb. Last, this oops happened on our system running a relative old kernel, but the same risk still exists on the mainline, since we use the wrong actions_len from the beginning. Fixes: ccea74457bbd ("openvswitch: include datapath actions with sampled-pac Cc: Neil McKee <neil.mckee@inmon.com> Signed-off-by: Liping Zhang <zlpnobody@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Fixes: 0e469d3b380c ("datapath: Include datapath actions with sampled-packet upcall to userspace.") Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Andy Zhou <azhou@ovn.org>
* datapath: correctly fragment packet with mpls headersYi-Hung Wei2017-05-031-4/+20
| | | | | | | | | | | | | | | | | | | | | Upstream commit: commit c66549ffd666605831abf6cf19ce0571ad868e39 Author: Jiri Benc <jbenc@redhat.com> Date: Wed Oct 5 15:01:57 2016 +0200 openvswitch: correctly fragment packet with mpls headers If mpls headers were pushed to a defragmented packet, the refragmentation no longer works correctly after 48d2ab609b6b ("net: mpls: Fixups for GSO"). The network header has to be shifted after the mpls headers for the fragmentation and restored afterwards. Fixes: 48d2ab609b6b ("net: mpls: Fixups for GSO") Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
* datapath: Fixups for MPLS GSOYi-Hung Wei2017-05-031-13/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch backports the following two upstream commits to fix MPLS GSO in ovs datapath. Starting from upstream commit 48d2ab609b6b ("net: mpls: Fixups for GSO"), the mpls_gso kernel module relies on the fact that skb_network_header() points to the mpls header and skb_inner_network_header() points to the L3 header so that it can derive the length of mpls header correctly, and the upstream commit updates how ovs datapath marks the skb header when push and pop mpls. However, the old mpls_gso kernel module assumes that the skb_network_header() points to the L3 header, and the old mpls_gso kernel module will misbehave if the ovs datapath marks the skb_network_header() in the new way since it will treat mpls header as the L3 header. Because of the functional signature of mpls_gso_segment() does not change, this backport patch uses the new mpls_hdr() to determine if the kernel that ovs datapath is compiled with has the new or legacy mpls_gso kernel module. It has been tested on kernel 4.4 and 4.9. Upstream commit: commit 48d2ab609b6bbecb7698487c8579bc40de9d6dfa Author: David Ahern <dsa@cumulusnetworks.com> Date: Wed Aug 24 20:10:44 2016 -0700 net: mpls: Fixups for GSO As reported by Lennert the MPLS GSO code is failing to properly segment large packets. There are a couple of problems: 1. the inner protocol is not set so the gso segment functions for inner protocol layers are not getting run, and 2 MPLS labels for packets that use the "native" (non-OVS) MPLS code are not properly accounted for in mpls_gso_segment. The MPLS GSO code was added for OVS. It is re-using skb_mac_gso_segment to call the gso segment functions for the higher layer protocols. That means skb_mac_gso_segment is called twice -- once with the network protocol set to MPLS and again with the network protocol set to the inner protocol. This patch sets the inner skb protocol addressing item 1 above and sets the network_header and inner_network_header to mark where the MPLS labels start and end. The MPLS code in OVS is also updated to set the two network markers. >From there the MPLS GSO code uses the difference between the network header and the inner network header to know the size of the MPLS header that was pushed. It then pulls the MPLS header, resets the mac_len and protocol for the inner protocol and then calls skb_mac_gso_segment to segment the skb. Afterward the inner protocol segmentation is done the skb protocol is set to mpls for each segment and the network and mac headers restored. Reported-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream commit: commit 85de4a2101acb85c3b1dde465e84596ccca99f2c Author: Jiri Benc <jbenc@redhat.com> Date: Fri Sep 30 19:08:07 2016 +0200 openvswitch: use mpls_hdr skb_mpls_header is equivalent to mpls_hdr now. Use the existing helper instead. Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
* datapath: Openvswitch: Refactor sample and recirc actions implementationAndy Zhou2017-04-191-79/+93
| | | | | | | | | | | | | | | | Upstream commit: Openvswitch: Refactor sample and recirc actions implementation Added clone_execute() that both the sample and the recirc action implementation can use. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: bef7f7567a10 ("Openvswitch: Refactor sample and recirc actions implementation") Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* datapath: openvswitch: Optimize sample action for the clone use casesAndy Zhou2017-04-191-52/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: openvswitch: Optimize sample action for the clone use cases With the introduction of open flow 'clone' action, the OVS user space can now translate the 'clone' action into kernel datapath 'sample' action, with 100% probability, to ensure that the clone semantics, which is that the packet seen by the clone action is the same as the packet seen by the action after clone, is faithfully carried out in the datapath. While the sample action in the datpath has the matching semantics, its implementation is only optimized for its original use. Specifically, there are two limitation: First, there is a 3 level of nesting restriction, enforced at the flow downloading time. This limit turns out to be too restrictive for the 'clone' use case. Second, the implementation avoid recursive call only if the sample action list has a single userspace action. The main optimization implemented in this series removes the static nesting limit check, instead, implement the run time recursion limit check, and recursion avoidance similar to that of the 'recirc' action. This optimization solve both #1 and #2 issues above. One related optimization attempts to avoid copying flow key as long as the actions enclosed does not change the flow key. The detection is performed only once at the flow downloading time. Another related optimization is to rewrite the action list at flow downloading time in order to save the fast path from parsing the sample action list in its original form repeatedly. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: 798c166173ff ("openvswitch: Optimize sample action for the clone use cases") Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* datapath: openvswitch: Refactor recirc key allocation.Andy Zhou2017-04-191-26/+40
| | | | | | | | | | | | | | | | | Upstream commit: openvswitch: Refactor recirc key allocation. The logic of allocating and copy key for each 'exec_actions_level' was specific to execute_recirc(). However, future patches will reuse as well. Refactor the logic into its own function clone_key(). Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: 4572ef52a00b ("openvswitch: Refactor recirc key allocation.") Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* datapath: openvswitch: Deferred fifo API change.Andy Zhou2017-04-191-7/+11
| | | | | | | | | | | | | | | | | | | | | Upstream commit: openvswitch: Deferred fifo API change. add_deferred_actions() API currently requires actions to be passed in as a fully encoded netlink message. So far both 'sample' and 'recirc' actions happens to carry actions as fully encoded netlink messages. However, this requirement is more restrictive than necessary, future patch will need to pass in action lists that are not fully encoded by themselves. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: 47c697aa2d07 ("openvswitch: Deferred fifo API change.") Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* datapath: actions: fixed a brace coding style warning.Peter Downs2017-04-191-2/+1
| | | | | | | | | | | | | | Upstream commit: openvswitch: actions: fixed a brace coding style warning Fixed a brace coding style warning reported by checkpatch.pl Signed-off-by: Peter Downs <padowns@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: f1304f7ba398 ("openvswitch: actions: fixed a brace coding style warning") Signed-off-by: Joe Stringer <joe@ovn.org> Signed-off-by: Andy Zhou <azhou@ovn.org>
* datapath: Add original direction conntrack tuple to sw_flow_key.Jarno Rajahalme2017-03-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 9dd7f8907c3705dc7a7a375d1c6e30b06e6daffc Author: Jarno Rajahalme <jarno@ovn.org> Date: Thu Feb 9 11:21:59 2017 -0800 openvswitch: Add original direction conntrack tuple to sw_flow_key. Add the fields of the conntrack original direction 5-tuple to struct sw_flow_key. The new fields are initially marked as non-existent, and are populated whenever a conntrack action is executed and either finds or generates a conntrack entry. This means that these fields exist for all packets that were not rejected by conntrack as untrackable. The original tuple fields in the sw_flow_key are filled from the original direction tuple of the conntrack entry relating to the current packet, or from the original direction tuple of the master conntrack entry, if the current conntrack entry has a master. Generally, expected connections of connections having an assigned helper (e.g., FTP), have a master conntrack entry. The main purpose of the new conntrack original tuple fields is to allow matching on them for policy decision purposes, with the premise that the admissibility of tracked connections reply packets (as well as original direction packets), and both direction packets of any related connections may be based on ACL rules applying to the master connection's original direction 5-tuple. This also makes it easier to make policy decisions when the actual packet headers might have been transformed by NAT, as the original direction 5-tuple represents the packet headers before any such transformation. When using the original direction 5-tuple the admissibility of return and/or related packets need not be based on the mere existence of a conntrack entry, allowing separation of admission policy from the established conntrack state. While existence of a conntrack entry is required for admission of the return or related packets, policy changes can render connections that were initially admitted to be rejected or dropped afterwards. If the admission of the return and related packets was based on mere conntrack state (e.g., connection being in an established state), a policy change that would make the connection rejected or dropped would need to find and delete all conntrack entries affected by such a change. When using the original direction 5-tuple matching the affected conntrack entries can be allowed to time out instead, as the established state of the connection would not need to be the basis for packet admission any more. It should be noted that the directionality of related connections may be the same or different than that of the master connection, and neither the original direction 5-tuple nor the conntrack state bits carry this information. If needed, the directionality of the master connection can be stored in master's conntrack mark or labels, which are automatically inherited by the expected related connections. The fact that neither ARP nor ND packets are trackable by conntrack allows mutual exclusion between ARP/ND and the new conntrack original tuple fields. Hence, the IP addresses are overlaid in union with ARP and ND fields. This allows the sw_flow_key to not grow much due to this patch, but it also means that we must be careful to never use the new key fields with ARP or ND packets. ARP is easy to distinguish and keep mutually exclusive based on the ethernet type, but ND being an ICMPv6 protocol requires a bit more attention. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> This patch squashes in minimal amount of OVS userspace code to not break the build. Later patches contain the full userspace support. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* datapath: Simplify do_execute_actions().andy zhou2017-03-031-22/+20
| | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 5b8784aaf29be20ba8d363e1124d7436d42ef9bf Author: Andy Zhou <azhou@ovn.org> Date: Fri Jan 27 13:45:28 2017 -0800 openvswitch: Simplify do_execute_actions(). do_execute_actions() implements a worthwhile optimization: in case an output action is the last action in an action list, skb_clone() can be avoided by outputing the current skb. However, the implementation is more complicated than necessary. This patch simplify this logic. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: 5b8784aaf29b ("openvswitch: Simplify do_execute_actions().") Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
* datapath: add Ethernet push and pop actionsYang, Yi Y2017-03-021-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 91820da6ae85904d95ed53bf3a83f9ec44a6b80a Author: Jiri Benc <jbenc@redhat.com> Date: Thu Nov 10 16:28:23 2016 +0100 openvswitch: add Ethernet push and pop actions It's not allowed to push Ethernet header in front of another Ethernet header. It's not allowed to pop Ethernet header if there's a vlan tag. This preserves the invariant that L3 packet never has a vlan tag. Based on previous versions by Lorand Jakab and Simon Horman. 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> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> [Committer notes] Fix build with the upstream commit by folding in the required switch case enum handlers. Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: support MPLS push and pop for L3 packetsYang, Yi Y2017-03-021-7/+11
| | | | | | | | | | | | | | | | | | Upstream commit: commit 1560a074df6297e76278e459ca3eb9ff83a6f878 Author: Jiri Benc <jbenc@redhat.com> Date: Thu Nov 10 16:28:20 2016 +0100 openvswitch: support MPLS push and pop for L3 packets Update Ethernet header only if there is one. Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: pass mac_proto to ovs_vport_sendYang, Yi Y2017-03-021-12/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit e2d9d8358cb961340ef88620b6a25ba4557033d5 Author: Jiri Benc <jbenc@redhat.com> Date: Thu Nov 10 16:28:19 2016 +0100 openvswitch: pass mac_proto to ovs_vport_send We'll need it to alter packets sent to ARPHRD_NONE interfaces. Change do_output() to use the actual L2 header size of the packet when deciding on the minimum cutlen. The assumption here is that what matters is not the output interface hard_header_len but rather the L2 header of the particular packet. For example, ARPHRD_NONE tunnels that encapsulate Ethernet should get at least the Ethernet header. Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> [Committer notes] This is not identical to upstream, because the OVS tree is missing upstream commit c66549ffd666 ("openvswitch: correctly fragment packet with mpls headers") Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: add mac_proto field to the flow keyYang, Yi Y2017-03-021-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 329f45bc4f191c663dc156c510816411a4310578 Author: Jiri Benc <jbenc@redhat.com> Date: Thu Nov 10 16:28:18 2016 +0100 openvswitch: add mac_proto field to the flow key Use a hole in the structure. We support only Ethernet so far and will add a support for L2-less packets shortly. We could use a bool to indicate whether the Ethernet header is present or not but the approach with the mac_proto field is more generic and occupies the same number of bytes in the struct, while allowing later extensibility. It also makes the code in the next patches more self explaining. It would be nice to use ARPHRD_ constants but those are u16 which would be waste. Thus define our own constants. Another upside of this is that we can overload this new field to also denote whether the flow key is valid. This has the advantage that on refragmentation, we don't have to reparse the packet but can rely on the stored eth.type. This is especially important for the next patches in this series - instead of adding another branch for L2-less packets before calling ovs_fragment, we can just remove all those branches completely. Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: use hard_header_len instead of hardcoded ETH_HLENYang, Yi Y2017-03-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 738314a084aae5f76ff760279034b39d52c42e8b Author: Jiri Benc <jbenc@redhat.com> Date: Thu Nov 10 16:28:17 2016 +0100 openvswitch: use hard_header_len instead of hardcoded ETH_HLEN On tx, use hard_header_len while deciding whether to refragment or drop the packet. That way, all combinations are calculated correctly: * L2 packet going to L2 interface (the L2 header len is subtracted), * L2 packet going to L3 interface (the L2 header is included in the packet lenght), * L3 packet going to L3 interface. Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: 802.1AD Flow handling, actions, vlan parsing, netlink attributesYang, Yi Y2017-03-021-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 018c1dda5ff1e7bd1fe2d9fd1d0f5b82dc6fc0cd Author: Eric Garver <e@erig.me> Date: Wed Sep 7 12:56:59 2016 -0400 openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink attributes Add support for 802.1ad including the ability to push and pop double tagged vlans. Add support for 802.1ad to netlink parsing and flow conversion. Uses double nested encap attributes to represent double tagged vlan. Inner TPID encoded along with ctci in nested attributes. This is based on Thomas F Herbert's original v20 patch. I made some small clean ups and bug fixes. Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com> Signed-off-by: Eric Garver <e@erig.me> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream commit: commit 20ecf1e4e30005ad50f561a92c888b6477f99341 Author: Jiri Benc <jbenc@redhat.com> Date: Mon Oct 10 17:02:42 2016 +0200 openvswitch: vlan: remove wrong likely statement This code is called whenever flow key is being extracted from the packet. The packet may be as likely vlan tagged as not. Fixes: 018c1dda5ff1 ("openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink attributes") Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Eric Garver <e@erig.me> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream commit: commit 72ec108d701506fa6cd2f66ec5b15ea71df3c464 Author: Jiri Benc <jbenc@redhat.com> Date: Mon Oct 10 17:02:43 2016 +0200 openvswitch: fix vlan subtraction from packet length When the packet has its vlan tag in skb->vlan_tci, the length of the VLAN header is not counted in skb->len. It doesn't make sense to subtract it. Fixes: 018c1dda5ff1 ("openvswitch: 802.1AD Flow handling, actions, vlan parsing, netlink attributes") Signed-off-by: Jiri Benc <jbenc@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Eric Garver <e@erig.me> Signed-off-by: David S. Miller <davem@davemloft.net> [Committer notes] The following commits upstream fix bugs in this patch, so to retain bisectability of the OVS tree they were rolled into this commit: 20ecf1e4e300 openvswitch: vlan: remove wrong likely statement 72ec108d7015 openvswitch: fix vlan subtraction from packet length Signed-off-by: Yi Yang <yi.y.yang@intel.com> Acked-by: Eric Garver <e@erig.me> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: avoid deferred execution of recirc actionsLance Richardson2016-09-201-3/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Port upstream fix to datapath module. The only notable difference between this patch and the upstream version is that the value of ovs_recursion_limit (5 for upstream kernel, 4 for out-of-tree module) is maintained in this patch. Upstream commit: commit f43e6dfb056b58628e43179d8f6b59eae417754d Author: Lance Richardson <lrichard@redhat.com> Date: Mon Sep 12 17:07:23 2016 -0400 openvswitch: avoid deferred execution of recirc actions The ovs kernel data path currently defers the execution of all recirc actions until stack utilization is at a minimum. This is too limiting for some packet forwarding scenarios due to the small size of the deferred action FIFO (10 entries). For example, broadcast traffic sent out more than 10 ports with recirculation results in packet drops when the deferred action FIFO becomes full, as reported here: http://openvswitch.org/pipermail/dev/2016-March/067672.html Since the current recursion depth is available (it is already tracked by the exec_actions_level pcpu variable), we can use it to determine whether to execute recirculation actions immediately (safe when recursion depth is low) or defer execution until more stack space is available. With this change, the deferred action fifo size becomes a non-issue for currently failing scenarios because it is no longer used when there are three or fewer recursions through ovs_execute_actions(). Suggested-by: Pravin Shelar <pshelar@ovn.org> Signed-off-by: Lance Richardson <lrichard@redhat.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath: Add support for kernel 4.4Pravin B Shelar2016-07-181-3/+4
| | | | | | | | Most of changes are related to ip-fragment API and genetlink API changes. Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: Sync OVS recursive loop counter with upstream.Pravin B Shelar2016-07-181-19/+12
| | | | | Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: openvswitch: update checksum in {push,pop}_mplsPravin B Shelar2016-07-171-4/+15
| | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit bc7cc5999fd392cc799630d7e375b2f4e29cc398 Author: Simon Horman <simon.horman@netronome.com> openvswitch: update checksum in {push,pop}_mpls In the case of CHECKSUM_COMPLETE the skb checksum should be updated in {push,pop}_mpls() as they the type in the ethernet header. As suggested by Pravin Shelar. Cc: Pravin Shelar <pshelar@ovn.org> Fixes: 25cd9ba0abc0 ("openvswitch: Add basic MPLS support to kernel") Signed-off-by: Simon Horman <simon.horman@netronome.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: remove get_pcpu_ptrPravin B Shelar2016-07-171-2/+2
| | | | | | | | There is no need to support old kernel so now we can use newer api to access per cpu data. Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: Use skb_postpush_rcsum()Pravin B Shelar2016-07-171-5/+3
| | | | | | | Use kernel function to update checksum. Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: compat: Refactor egress tunnel infoPravin B Shelar2016-07-081-8/+9
| | | | | | | | | | | | | upstream tunnel egress info is retrieved using ndo_fill_metadata_dst. Since we do not have it on older kernel we need to keep vport operation to do same on these kernels. Following patch try to merge these to operations into one to avoid code duplication. This commit backports fc4099f1 ("openvswitch: Fix egress tunnel info.") Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* compat: ipv4: Pass struct net through ip_fragment.Eric W. Biederman2016-06-271-1/+1
| | | | | | | | | | | Upstream commit: ipv4: Pass struct net through ip_fragment Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Upstream: 694869b3c544 ("ipv4: Pass struct net through ip_fragment") Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: Pass net into ovs_fragment.Eric W. Biederman2016-06-271-3/+4
| | | | | | | | | | | | | | | Upstream commit: openvswitch: Pass net into ovs_fragment In preparation for the ipv4 and ipv6 fragmentation code taking a net parameter pass a struct net into ovs_fragment where the v4 and v6 fragmentation code is called. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Upstream: c559cd3ad32b ("openvswitch: Pass net into ovs_fragment") Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath:backport: openvswitch: Add packet truncation support.William Tu2016-06-241-4/+36
| | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit f2a4d086ed4c588d32fe9b7aa67fead7280e7bf1 Author: William Tu <u9012063@gmail.com> Date: Fri Jun 10 11:49:33 2016 -0700 openvswitch: Add packet truncation support. The patch adds a new OVS action, OVS_ACTION_ATTR_TRUNC, in order to truncate packets. A 'max_len' is added for setting up the maximum packet size, and a 'cutlen' field is to record the number of bytes to trim the packet when the packet is outputting to a port, or when the packet is sent to userspace. Signed-off-by: William Tu <u9012063@gmail.com> Cc: Pravin Shelar <pshelar@nicira.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: William Tu <u9012063@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath:backport: openvswitch: use flow protocol when recalculating ipv6 ↵Pravin B Shelar2016-06-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | checksums Upstream commit: commit b4f70527f052b0c00be4d7cac562baa75b212df5 Author: Simon Horman <simon.horman@netronome.com> Date: Thu Apr 21 11:49:15 2016 +1000 openvswitch: use flow protocol when recalculating ipv6 checksums When using masked actions the ipv6_proto field of an action to set IPv6 fields may be zero rather than the prevailing protocol which will result in skipping checksum recalculation. This patch resolves the problem by relying on the protocol in the flow key rather than that in the set field action. Fixes: 83d2b9ba1abc ("net: openvswitch: Support masked set actions.") Cc: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: Drop support for kernel older than 3.10Pravin B Shelar2016-03-141-21/+7
| | | | | | | | | | | | | | | | Currently OVS out of tree datapath supports a large number of kernel versions. From 2.6.32 to 4.3 and various distribution-specific kernels. But at this point major features are only available on more recent kernels. For example, stateful services are only available starting in kernel 3.10 and STT is available on starting with 3.5. Since these features are becoming essential to many OVS deployments, and the effort of maintaining the backports is high. We have decided to drop support for older kernel. Following patch drops supports for kernel older than 3.10. Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: Fix panic sending IP frags over tunnels.Joe Stringer2016-01-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The entire OVS_GSO_CB was not preserved when handling IP fragments, leading to the following NULL pointer dereference in ovs_stt_xmit(). Fix this in the fragmentation handling code by preserving the whole CB. BUG: unable to handle kernel NULL pointer dereference at 000000000000001c IP: [<ffffffffa0cfc5b1>] ovs_stt_xmit+0x61/0x260 [openvswitch] Call Trace: [<ffffffff815f682e>] ? __alloc_skb+0x7e/0x2b0 [<ffffffffa0cf1134>] ovs_vport_send+0x44/0xb0 [openvswitch] [<ffffffffa0ce241f>] ovs_vport_output+0x10f/0x190 [openvswitch] [<ffffffff8163fe98>] ip_fragment+0x238/0x870 [<ffffffffa0ce2310>] ? do_output.isra.35+0x120/0x120 [openvswitch] [<ffffffffa0d02093>] ovs_fragment+0x283/0x292 [openvswitch] [<ffffffff81073ff7>] ? mod_timer_pending+0x67/0x1b0 [<ffffffff8160e2d0>] ? dst_ifdown+0x90/0x90 [<ffffffff8160e2d0>] ? dst_ifdown+0x90/0x90 [<ffffffffa0b30165>] ? nfnetlink_has_listeners+0x15/0x20 [nfnetlink] [<ffffffffa0cdb164>] ? ctnetlink_conntrack_event+0x74/0x7ee [nf_conntrack_netlink] [<ffffffffa0b873cd>] ? nf_ct_deliver_cached_events+0xad/0xf0 [nf_conntrack] [<ffffffff81360331>] ? csum_partial+0x11/0x20 [<ffffffffa0ce2747>] ? execute_masked_set_action+0x2a7/0xa60 [openvswitch] [<ffffffffa0ce22a8>] do_output.isra.35+0xb8/0x120 [openvswitch] [<ffffffffa0ce2ff4>] do_execute_actions+0xf4/0x7f0 [openvswitch] [<ffffffffa0ce3730>] ovs_execute_actions+0x40/0x130 [openvswitch] [<ffffffffa0ce7c69>] ovs_packet_cmd_execute+0x2b9/0x2e0 [openvswitch] [<ffffffff81634fad>] genl_family_rcv_msg+0x18d/0x370 [<ffffffff81635190>] ? genl_family_rcv_msg+0x370/0x370 [<ffffffff81635221>] genl_rcv_msg+0x91/0xd0 [<ffffffff816332c9>] netlink_rcv_skb+0xa9/0xc0 [<ffffffff816337c8>] genl_rcv+0x28/0x40 [<ffffffff816329b5>] netlink_unicast+0xd5/0x1b0 [<ffffffff81632d9e>] netlink_sendmsg+0x30e/0x680 [<ffffffff8162fc84>] ? netlink_rcv_wake+0x44/0x60 [<ffffffff81630d12>] ? netlink_recvmsg+0x1a2/0x3a0 [<ffffffff815ed7fb>] sock_sendmsg+0x8b/0xc0 [<ffffffff8114d06d>] ? __alloc_pages_nodemask+0x16d/0xac0 [<ffffffff8101c4b9>] ? sched_clock+0x9/0x10 [<ffffffff815edbc9>] ___sys_sendmsg+0x349/0x360 [<ffffffff811f8a39>] ? ep_scan_ready_list.isra.7+0x199/0x1c0 [<ffffffff8110705c>] ? acct_account_cputime+0x1c/0x20 [<ffffffff811cd90f>] ? fget_light+0x8f/0xf0 [<ffffffff815ee922>] __sys_sendmsg+0x42/0x80 [<ffffffff815ee972>] SyS_sendmsg+0x12/0x20 [<ffffffff8170f22f>] tracesys+0xe1/0xe6 VMware-BZ: #1587324 Fixes: a94ebc39996b ("datapath: Add conntrack action") Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* compat: Backport conntrack strictly to v3.10+.Joe Stringer2015-12-181-3/+3
| | | | | | | | | | | The conntrack/ipfrag backport was previously not entirely consistent in its include for versions 3.9 and 3.10. The intention was to build it for all kernels 3.10 and newer, so fix the version checks. Reported-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Pravin B Shelar <pshelar@nicira.com> Tested-by: Simon Horman <simon.horman@netronome.com>
* datapath: Avoid warning for unused static data on Linux <=3.9.0.Ben Pfaff2015-12-081-0/+2
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Backport conntrack fixes.Joe Stringer2015-12-031-7/+16
| | | | | | | | | | | | | | | | | | | | | | | Backport the following fixes for conntrack from upstream. 9723e6abc70a openswitch: fix typo CONFIG_NF_CONNTRACK_LABEL 0d5cdef8d5dd openvswitch: Fix conntrack compilation without mark. 982b52700482 openvswitch: Fix mask generation for nested attributes. cc5706056baa openvswitch: Fix IPv6 exthdr handling with ct helpers. 33db4125ec74 openvswitch: Rename LABEL->LABELS b8f2257069f1 openvswitch: Fix skb leak in ovs_fragment() ec0d043d05e6 openvswitch: Ensure flow is valid before executing ct 6f225952461b openvswitch: Reject ct_state unsupported bits fbccce5965a5 openvswitch: Extend ct_state match field to 32 bits ab38a7b5a449 openvswitch: Change CT_ATTR_FLAGS to CT_ATTR_COMMIT 9e384715e9e7 openvswitch: Reject ct_state masks for unknown bits 4f0909ee3d8e openvswitch: Mark connections new when not confirmed. e754ec69ab69 openvswitch: Serialize nested ct actions if provided 74c16618137f openvswitch: Fix double-free on ip_defrag() errors 6f5cadee44d8 openvswitch: Fix skb leak using IPv6 defrag Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Allow matching on conntrack labelJoe Stringer2015-12-031-0/+1
| | | | | | | | | | | | | | Allow matching and setting the ct_label field. As with ct_mark, this is populated by executing the CT action. The label field may be modified by specifying a label and mask nested under the CT action. It is stored as metadata attached to the connection. Label modification occurs after lookup, and will only persist when the conntrack entry is committed by providing the COMMIT flag to the CT action. Labels are currently fixed to 128 bits in size. Upstream: c2ac667 "openvswitch: Allow matching on conntrack label" Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Allow matching on conntrack markJoe Stringer2015-12-031-0/+1
| | | | | | | | | | | | | | | Allow matching and setting the ct_mark field. As with ct_state and ct_zone, these fields are populated when the CT action is executed. To write to this field, a value and mask can be specified as a nested attribute under the CT action. This data is stored with the conntrack entry, and is executed after the lookup occurs for the CT action. The conntrack entry itself must be committed using the COMMIT flag in the CT action flags for this change to persist. Upstream: 182e304 "openvswitch: Allow matching on conntrack mark" Signed-off-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Add conntrack actionJoe Stringer2015-12-031-6/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Expose the kernel connection tracker via OVS. Userspace components can make use of the CT action to populate the connection state (ct_state) field for a flow. This state can be subsequently matched. Exposed connection states are OVS_CS_F_*: - NEW (0x01) - Beginning of a new connection. - ESTABLISHED (0x02) - Part of an existing connection. - RELATED (0x04) - Related to an established connection. - INVALID (0x20) - Could not track the connection for this packet. - REPLY_DIR (0x40) - This packet is in the reply direction for the flow. - TRACKED (0x80) - This packet has been sent through conntrack. When the CT action is executed by itself, it will send the packet through the connection tracker and populate the ct_state field with one or more of the connection state flags above. The CT action will always set the TRACKED bit. When the COMMIT flag is passed to the conntrack action, this specifies that information about the connection should be stored. This allows subsequent packets for the same (or related) connections to be correlated with this connection. Sending subsequent packets for the connection through conntrack allows the connection tracker to consider the packets as ESTABLISHED, RELATED, and/or REPLY_DIR. The CT action may optionally take a zone to track the flow within. This allows connections with the same 5-tuple to be kept logically separate from connections in other zones. If the zone is specified, then the "ct_zone" match field will be subsequently populated with the zone id. IP fragments are handled by transparently assembling them as part of the CT action. The maximum received unit (MRU) size is tracked so that refragmentation can occur during output. IP frag handling contributed by Andy Zhou. Based on original design by Justin Pettit. Upstream: 7f8a436 "openvswitch: Add conntrack action" Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Move MASKED* macros to datapath.hJoe Stringer2015-12-031-27/+25
| | | | | | | | This will allow the ovs-conntrack code to reuse these macros. Upstream: be26b9a "openvswitch: Move MASKED* macros to datapath.h" Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Add support for lwtunnelPravin B Shelar2015-12-031-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Following patch adds support for lwtunnel to OVS datapath. With this change OVS datapath detect lwtunnel support and make use of new APIs if available. On older kernel where the support is not there the backported tunnel modules are used. These backported tunnel devices acts as lwtunnel devices. I tried to keep backported module same as upstream for easier bug-fix backport. Since STT and LISP are not upstream OVS always needs to use respective modules from tunnel compat layer. To make it work on kernel 4.3 I have converted STT and LISP modules to lwtunnel API model. lwtunnel make use of skb-dst to pass tunnel information to the tunnel module. On older kernel this is not possible. So the in case of old kernel metadata ref is stored in OVS_CB and direct call to tunnel transmit function is made by respective tunnel vport modules. Similarly on receive side tunnel recv directly call netdev-vport-receive to pass the skb to OVS. Major backported components include: Geneve, GRE, VXLAN, ip_tunnel, udp-tunnels GRO. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Joe Stringer <joe@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
* datapath: Make 100 percents packets sampled when sampling rate is 1.Wenyu Zhang2015-08-251-1/+4
| | | | | | | | | | | | | | | When sampling rate is 1, the sampling probability is UINT32_MAX. The packet should be sampled even the prandom32() generate the number of UINT32_MAX. And none packet need be sampled when the probability is 0. Signed-off-by: Wenyu Zhang <wenyuz@vmware.com> Acked-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: e05176a3283 ("openvswitch: Make 100 percents packets sampled when sampling rate is 1.") Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Fix L4 checksum handling when dealing with IP fragmentsGlenn Griffin2015-08-171-4/+13
| | | | | | | | | | | | | | | | | | openvswitch modifies the L4 checksum of a packet when modifying the ip address. When an IP packet is fragmented only the first fragment contains an L4 header and checksum. Prior to this change openvswitch would modify all fragments, modifying application data in non-first fragments, causing checksum failures in the reassembled packet. Signed-off-by: Glenn Griffin <ggriffin.kernel@gmail.com> Acked-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: 3576fd794b3 ("openvswitch: Fix L4 checksum handling when dealing with IP fragments"). Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Use skb_postpull_rcsum().Joe Stringer2015-07-301-4/+1
| | | | | Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
* datapath: Whitespace fixes.Joe Stringer2015-07-301-5/+1
| | | | | Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
* datapath: Include datapath actions with sampled-packet upcall to userspace.Neil McKee2015-07-171-8/+15
| | | | | | | | | | | | | | | | | | | If new optional attribute OVS_USERSPACE_ATTR_ACTIONS is added to an OVS_ACTION_ATTR_USERSPACE action, then include the datapath actions in the upcall. This Directly associates the sampled packet with the path it takes through the virtual switch. Path information currently includes mangling, encapsulation and decapsulation actions for tunneling protocols GRE, VXLAN, Geneve, MPLS and QinQ, but this extension requires no further changes to accommodate datapath actions that may be added in the future. Adding path information enhances visibility into complex virtual networks. Signed-off-by: Neil McKee <neil.mckee@inmon.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Support masked set actions.Jarno Rajahalme2015-05-221-137/+237
| | | | | | | | | | | | | | | | | | | | | | | | | | | | OVS kernel module support for masked set actions in already upstream in Linux (commit 83d2b9ba1abca241df44a502b6da950a25856b5b). This patch adds the same for the OVS tree kernel module. The existing set action sets many fields at once. When only a subset of the IP header fields, for example, should be modified, all the IP fields need to be exact matched so that the other field values can be copied to the set action. A masked set action allows modification of an arbitrary subset of the supported header bits without requiring the rest to be matched. Masked set action is now supported for all writeable key types, except for the tunnel key. The set tunnel action is an exception as any input tunnel info is cleared before action processing starts, so there is no tunnel info to mask. The kernel module converts all (non-tunnel) set actions to masked set actions. This makes action processing more uniform, and results in less branching and duplicating the action processing code. When returning actions to userspace, the conversion is inverted. We use a kernel internal action code to be able to tell the userspace provided and converted masked set actions apart. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
* datapath: Account for "rename vlan_tx_* helpers since "tx" is misleading there"Thomas Graf2015-02-031-2/+2
| | | | | | | | | | | | | | Upstream commit: net: rename vlan_tx_* helpers since "tx" is misleading there The same macros are used for rx as well. So rename it. Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: df8a39d ("net: rename vlan_tx_* helpers since "tx" is misleading there") Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: move vlan pop/push functions into common codeThomas Graf2015-01-071-73/+10
| | | | | | | | | | | | | | | So it can be used from out of openvswitch code. Did couple of cosmetic changes on the way, namely variable naming and adding support for 8021AD proto. Note on backwards compatability: Unlike the upstream version, the backport of skb_vlan_push() does not support translating a hardware accelerated 8021AD tag to software. This is not a problem though as it preserves existing behaviour. Upstream: 93515d53 ("net: move vlan pop/push functions into common code") Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: move make_writable helper into common codeThomas Graf2015-01-071-25/+14
| | | | | | | | | note that skb_make_writable already exists in net/netfilter/core.c but does something slightly different. Upstream: e219512 ("net: move make_writable helper into common code") Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: Account for rename to vlan_insert_tag_set_proto()Thomas Graf2015-01-071-1/+1
| | | | | | | | | __vlan_put_tag() was renamed to vlan_insert_tag_set_proto() with the argument list kept intact. Upstream: 62749e ("vlan: rename __vlan_put_tag to vlan_insert_tag_set_proto") Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* datapath: fix coding style.Pravin B Shelar2014-11-091-8/+9
| | | | | | | | | Kernel datapath code has diverged from upstream code. This makes porting patches between these two code bases harder than it needs to be. Following patch fixes this by fixing coding style issues on this branch. Signed-off-by: Pravin B Shelar <pshelar@nicira.com>