summaryrefslogtreecommitdiff
path: root/acinclude.m4
Commit message (Collapse)AuthorAgeFilesLines
* compat: Add skb_checksum_simple_complete()Greg Rose2018-06-041-0/+5
| | | | | | | | | | A recent patch to gre.c added a call to skb_checksum_simple_complete() which is not present in kernels before 3.16. Fix up the compatability layer to allow compile on older kernels that do not have it. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* compat: Fixups for newer kernelsGreg Rose2018-05-311-11/+4
| | | | | | | | | | | | | | | | | | | | | | A recent patch series added support for ERSPAN but left some problems remaining for kernel releases from 4.10 to 4.14. This patch addresses those problems. Of note is that the old cisco gre compat layer code is gone for good. Also, several compat defines in acinclude.m4 were looking for keys in .c source files - this does not work on distros without source code. A more reliable key was already defined so we use that instead. We have pared support for the Linux kernel releases in .travis.yml to reflect that 4.15 is no longer in the LTS list. With this patch the Out of Tree OVS datapath kernel modules can build on kernels up to 4.14.47. Support for kernels up to 4.16.x will be added later. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* rhel: Enable ERSPAN features for RHEL 7.xGreg Rose2018-05-211-1/+14
| | | | | | | | Enable ERSPAN on RHEL 7.x Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: William Tu <u9012063@gmail.com>
* gre: introduce native tunnel support for ERSPANWilliam Tu2018-05-211-1/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 84e54fe0a5eaed696dee4019c396f8396f5a908b Author: William Tu <u9012063@gmail.com> Date: Tue Aug 22 09:40:28 2017 -0700 gre: introduce native tunnel support for ERSPAN The patch adds ERSPAN type II tunnel support. The implementation is based on the draft at [1]. One of the purposes is for Linux box to be able to receive ERSPAN monitoring traffic sent from the Cisco switch, by creating a ERSPAN tunnel device. In addition, the patch also adds ERSPAN TX, so Linux virtual switch can redirect monitored traffic to the ERSPAN tunnel device. The traffic will be encapsulated into ERSPAN and sent out. The implementation reuses tunnel key as ERSPAN session ID, and field 'erspan' as ERSPAN Index fields: ./ip link add dev ers11 type erspan seq key 100 erspan 123 \ local 172.16.1.200 remote 172.16.1.100 To use the above device as ERSPAN receiver, configure Nexus 5000 switch as below: monitor session 100 type erspan-source erspan-id 123 vrf default destination ip 172.16.1.200 source interface Ethernet1/11 both source interface Ethernet1/12 both no shut monitor erspan origin ip-address 172.16.1.100 global [1] https://tools.ietf.org/html/draft-foschiano-erspan-01 [2] iproute2 patch: http://marc.info/?l=linux-netdev&m=150306086924951&w=2 [3] test script: http://marc.info/?l=linux-netdev&m=150231021807304&w=2 Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: Meenakshi Vohra <mvohra@vmware.com> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net> This commit also backports heavily from upstream gre, ip_gre and ip_tunnel modules to support the necessary erspan ip gre infrastructure as well as implementing a variety of compatability layer changes for same support. Cc: William Tu <u9012063@gmail.com> Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: William Tu <u9012063@gmail.com>
* datapath: compat: Fix build on RHEL 7.5Yi-Hung Wei2018-05-141-0/+2
| | | | | | | | | | | | | | | | | | 1) OVS datapath compat modules breaks on RHEL 7.5, because it moves ndo_change_mtu function pointer from 'struct net_device_ops' to 'struct net_device_ops_extended'. 2) RHEL 7.5 introduces the MTU range checking as mentioned in 6c0bf091 ("datapath: use core MTU range checking in core net infra"). However, the max_mtu field is defined in 'struct net_device_extended' but not in 'struct net_device' as upstream kernel. This patch defines a new symbol HAVE_RHEL7_MAX_MTU that determines the previous 2 conditions, and fixes the backport issue. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Acked-by: Lucas Alvares Gomes <lucasagomes@gmail.com> Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
* compat: Fix upstream 4.4.119 kernelGreg Rose2018-05-081-0/+2
| | | | | | | | | | | | | | | The Linux 4.4.119 kernel (and perhaps others) from kernel.org backports some dst_cache code that breaks the openvswitch kernel due to a duplicated name "dst_cache_destroy". For most cases the "USE_UPSTREAM_TUNNEL" covers this but in this case the dst_cache feature needs to be separated out. Add the necessary compatibility detection layer in acinclude.m4 and then fixup the source files so that if the built-in kernel includes dst_cache support then exclude our own compatibility code. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* netdev-tc-offloads: Add support for IP fragmentationRoi Dayan2018-03-211-3/+3
| | | | | | | | | Add support for frag no, first and later. Signed-off-by: Roi Dayan <roid@mellanox.com> Reviewed-by: Shahar Klein <shahark@mellanox.com> Reviewed-by: Paul Blakey <paulb@mellanox.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
* compat: Fix RHEL 7 compileGreg Rose2018-02-271-0/+4
| | | | | | | | | | | frag_percpu_counter_batch is a variable, not a define, so checking if it is defined is an error and causes warning messages during compile on RHEL 7 (or other 3.10 based) builds. Use a compat #define from acinclude.m4 instead. Fixes: 64d8cb7295 ("compat:inet_frag.h: Check for frag_percpu_counter_batch") Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* acinclude: Enable building for Linux kernel 4.15Greg Rose2018-02-161-2/+2
| | | | | Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* acinclude.m4: Enable Linux 4.14Greg Rose2018-02-121-2/+2
| | | | | Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath: Add meter infrastructureAndy Zhou2018-02-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 96fbc13d7e770b542d2d1fcf700d0baadc6e8063 Author: Andy Zhou <azhou@ovn.org> Date: Fri Nov 10 12:09:42 2017 -0800 openvswitch: Add meter infrastructure OVS kernel datapath so far does not support Openflow meter action. This is the first stab at adding kernel datapath meter support. This implementation supports only drop band type. Signed-off-by: Andy Zhou <azhou@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net> Added a compat layer fixup for nla_parse. Added another compat fixup for ktime_get_ns. Cc: Andy Zhou <azhou@ovn.org> Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath: reliable interface indentification in port dumpsJiri Benc2018-02-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 9354d452034273a50a4fd703bea31e5d6b1fc20b Author: Jiri Benc <jbenc@redhat.com> Date: Thu Nov 2 17:04:37 2017 -0200 openvswitch: reliable interface indentification in port dumps This patch allows reliable identification of netdevice interfaces connected to openvswitch bridges. In particular, user space queries the netdev interfaces belonging to the ports for statistics, up/down state, etc. Datapath dump needs to provide enough information for the user space to be able to do that. Currently, only interface names are returned. This is not sufficient, as openvswitch allows its ports to be in different name spaces and the interface name is valid only in its name space. What is needed and generally used in other netlink APIs, is the pair ifindex+netnsid. The solution is addition of the ifindex+netnsid pair (or only ifindex if in the same name space) to vport get/dump operation. On request side, ideally the ifindex+netnsid pair could be used to get/set/del the corresponding vport. This is not implemented by this patch and can be added later if needed. Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Added compat fixup for peernet2id. Cc: Jiri Benc <jbenc@redhat.com> Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath: use ktime_get_ts64() instead of ktime_get_ts()Arnd Bergmann2018-02-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 311af51dcb5629f04976a8e451673f77e3301041 Author: Arnd Bergmann <arnd@arndb.de> Date: Mon Nov 27 12:41:38 2017 +0100 openvswitch: use ktime_get_ts64() instead of ktime_get_ts() timespec is deprecated because of the y2038 overflow, so let's convert this one to ktime_get_ts64(). The code is already safe even on 32-bit architectures, since it uses monotonic times. On 64-bit architectures, nothing changes, while on 32-bit architectures this avoids one type conversion. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net> Additional compatability check for ktime_get_ts64() exists or not. If not, then just continue using ktime_get_ts(). I added a new compatability header file "timekeeping.h". Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* compat: Fix compiler headersGreg Rose2018-02-121-0/+3
| | | | | | | | | | Since Linux kernel upstream commit d15155824c50 ("linux/compiler.h: Split into compiler.h and compiler_types.h") this error check for the gcc compiler header is no longer valid. Remove so that openvswitch builds for linux kernels 4.14.8 and since. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath: Fix netdev_master_upper_dev_link for 4.14Greg Rose2018-02-121-0/+3
| | | | | | | | | An extended netlink ack has been added for 4.14 - add compat layer changes so that it compiles for all kernels up to and including 4.14. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* datapath: enable NSH supportYi Yang2018-02-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* acinclude: check for IP_CT_UNTRACKEDEric Garver2018-01-221-0/+2
| | | | | | | | IP_CT_UNTRACKED is fairly new, but used by the kernel datapath ct_clear action. Signed-off-by: Eric Garver <e@erig.me> Acked-by: Pravin B Shelar <pshelar@ovn.org>
* configure: New --enable-sparse option to enable sparse checking by default.Ben Pfaff2018-01-121-1/+7
| | | | | | | | | | | | Until now, "make" called sparse to do checking only if C=1 was passed on the command line. It was easy for developers to forget to specify that. This commit adds another option: specifying --enable-sparse on the configure command line enables sparse checking by default. (It can still be disabled with C=0.) Requested-by: Justin Pettit <jpettit@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* configure: Make --enable-Werror turn sparse warnings into errors.Ben Pfaff2018-01-111-2/+10
| | | | | | | | | | | Until now, when "sparse" reported a warning, it didn't fail the build for that file, even when the project was configured with --enable-Werror, which made it easy to miss warnings. This commit fixes the problem. Reported-by: "Stokes, Ian" <ian.stokes@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Ian Stokes <ian.stokes@intel.com> Tested-by: Ian Stokes <ian.stokes@intel.com>
* compat: Add act_pedit compatibility for old kernelsPaul Blakey2017-11-161-0/+7
| | | | | | | | Added compatibility for action pedit. Signed-off-by: Paul Blakey <paulb@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
* acinclude: Fix SKB_GSO_UDP check.William Tu2017-11-011-1/+1
| | | | | | | | | | | The HAVE_SKB_GSO_UDP checks whether skbuff.h defines SKB_GSO_UDP. However, it falsely returns yes because grep matches SKB_GSO_UDP_TUNNEL. Thus, add space character '[:space:]' before and after it. Fixes: ad283644f0e4 ("acinclude: Check for SKB_GSO_UDP") Signed-off-by: William Tu <u9012063@gmail.com> Cc: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* acinclude: Add support for Linux 4.13Greg Rose2017-09-221-2/+2
| | | | | | | Add configuration support for the just released 4.13 Linux kernel. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Andy Zhou <azhou@ovn.org>
* acinclude: Check for existence of nf_hook_ops member "list".Greg Rose2017-09-221-0/+3
| | | | | | | | The "list" member of the nf_hook_ops structure is removed in Linux kernel release 4.13. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Andy Zhou <azhou@ovn.org>
* acinclude: Check for extended netlink ack presenceGreg Rose2017-09-221-0/+3
| | | | | | | | | RTNL ops validate and newlink now include the extended netlink ack feature. Check for it and set HAVE_EXT_ACK_IN_RTNL_LINKOPS if found. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Andy Zhou <azhou@ovn.org>
* acinclude: Add compat define for DST_NOCACHEGreg Rose2017-09-221-0/+2
| | | | | | | | DST_NOCACHE is removed in the 4.13 Linux kernel - add check for it and if found set HAVE_DST_NOCACHE. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Andy Zhou <azhou@ovn.org>
* acinclude: Check for SKB_GSO_UDPGreg Rose2017-09-221-0/+2
| | | | | | | Removed in kernel 4.13 Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Andy Zhou <azhou@ovn.org>
* acinclude: Add missing defineGreg Rose2017-09-211-1/+2
| | | | | | | | | | The final line of a conditional search for the nf_conntrack_helper_put function does not actually define HAVE_NF_CONNTRACK_HELPER_PUT used in datapath/linux/compat/include/net/netfilter/nf_conntrack_helper.h. Fixes: ac8e3c6d14d2 ("datapath: introduce nf_conntrack_helper_put function") Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* datapath: compat: Fix build on RHEL 7.4Yi-Hung Wei2017-08-231-0/+4
| | | | | | | | RHEL 7.4 introduces netdev_master_upper_dev_link_rh() that breaks the backport of OVS kernel module on RHEL 7.4. This patch fixes that issue. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* compat: Update tc compatibility headerPaul Blakey2017-08-111-3/+3
| | | | | | | | | Update to include up to flower ttl matching. Signed-off-by: Paul Blakey <paulb@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Acked-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* acinclude: Also support pkg-config for configuring dpdk.Christian Ehrhardt2017-08-071-7/+10
| | | | | | | | | | | | If available use dpdk pkg-config info of libdpdk to set the right include paths. That for example, allows packagers to provide non default include paths in a common way (pkg-config). Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Suggested-by: Luca Boccassi <luca.boccassi@gmail.com> Acked-by: Luca Boccassi <luca.boccassi@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* acinclude.m4: Support Linux kernel 4.12Greg Rose2017-07-241-1/+1
| | | | | | | | Allow datapath kernel modules to be configured and built for kernels up to 4.12. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* compat: net: store port/representator id in metadata_dst.Joe Stringer2017-07-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit 3fcece12bc1b6dcdf0986f2cd9e8f63b1f9b6aa0 Author: Jakub Kicinski <jakub.kicinski@netronome.com> Date: Fri Jun 23 22:11:58 2017 +0200 net: store port/representator id in metadata_dst Switches and modern SR-IOV enabled NICs may multiplex traffic from Port representators and control messages over single set of hardware queues. Control messages and muxed traffic may need ordered delivery. Those requirements make it hard to comfortably use TC infrastructure today unless we have a way of attaching metadata to skbs at the upper device. Because single set of queues is used for many netdevs stopping TC/sched queues of all of them reliably is impossible and lower device has to retreat to returning NETDEV_TX_BUSY and usually has to take extra locks on the fastpath. This patch attempts to enable port/representative devs to attach metadata to skbs which carry port id. This way representatives can be queueless and all queuing can be performed at the lower netdev in the usual way. Traffic arriving on the port/representative interfaces will be have metadata attached and will subsequently be queued to the lower device for transmission. The lower device should recognize the metadata and translate it to HW specific format which is most likely either a special header inserted before the network headers or descriptor/metadata fields. Metadata is associated with the lower device by storing the netdev pointer along with port id so that if TC decides to redirect or mirror the new netdev will not try to interpret it. This is mostly for SR-IOV devices since switches don't have lower netdevs today. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: David S. Miller <davem@davemloft.net> Upstream: 3fcece12bc1b ("net: store port/representator id in metadata_dst") Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Greg Rose <gvrose8192@gmail.com>
* datapath: get rid of redundant vxlan_dev.flagsGreg Rose2017-07-241-0/+2
| | | | | | | | | | | | | | | | | | | | | Upstream commit: commit dc5321d79697db1b610c25fa4fad1aec7533ea3e Author: Matthias Schiffer <mschiffer@universe-factory.net> Date: Mon Jun 19 10:03:56 2017 +0200 vxlan: get rid of redundant vxlan_dev.flags There is no good reason to keep the flags twice in vxlan_dev and vxlan_config. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> Signed-off-by: David S. Miller <davem@davemloft.net> Applied using HAVE_VXLAN_DEV_CFG compatibility flag defined in acinclude.m4. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* compat: convert many more places to skb_put_zero().Joe Stringer2017-07-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit de77b966ce8adcb4c58d50e2f087320d5479812a Author: Johannes Berg <johannes.berg@intel.com> Date: Fri Jun 16 14:29:19 2017 +0200 networking: convert many more places to skb_put_zero() There were many places that my previous spatch didn't find, as pointed out by yuan linyu in various patches. The following spatch found many more and also removes the now unnecessary casts: @@ identifier p, p2; expression len; expression skb; type t, t2; @@ ( -p = skb_put(skb, len); +p = skb_put_zero(skb, len); | -p = (t)skb_put(skb, len); +p = skb_put_zero(skb, len); ) ... when != p ( p2 = (t2)p; -memset(p2, 0, len); | -memset(p, 0, len); ) @@ type t, t2; identifier p, p2; expression skb; @@ t *p; ... ( -p = skb_put(skb, sizeof(t)); +p = skb_put_zero(skb, sizeof(t)); | -p = (t *)skb_put(skb, sizeof(t)); +p = skb_put_zero(skb, sizeof(t)); ) ... when != p ( p2 = (t2)p; -memset(p2, 0, sizeof(*p)); | -memset(p, 0, sizeof(*p)); ) @@ expression skb, len; @@ -memset(skb_put(skb, len), 0, len); +skb_put_zero(skb, len); Apply it to the tree (with one manual fixup to keep the comment in vxlan.c, which spatch removed.) Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> Use e45a79da863c ("skbuff/mac80211: introduce and use skb_put_zero()") as the basis for the backported function. Upstream: de77b966ce8a ("networking: convert many more places to skb_put_zero()") Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Greg Rose <gvrose8192@gmail.com>
* datapath: Fix inconsistent teardown and release of private netdev state.Greg Rose2017-07-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit cf124db566e6b036b8bcbe8decbed740bdfac8c6 Author: David S. Miller <davem@davemloft.net> Date: Mon May 8 12:52:56 2017 -0400 net: Fix inconsistent teardown and release of private netdev state. Network devices can allocate reasources and private memory using netdev_ops->ndo_init(). However, the release of these resources can occur in one of two different places. Either netdev_ops->ndo_uninit() or netdev->destructor(). The decision of which operation frees the resources depends upon whether it is necessary for all netdev refs to be released before it is safe to perform the freeing. netdev_ops->ndo_uninit() presumably can occur right after the NETDEV_UNREGISTER notifier completes and the unicast and multicast address lists are flushed. netdev->destructor(), on the other hand, does not run until the netdev references all go away. Further complicating the situation is that netdev->destructor() almost universally does also a free_netdev(). This creates a problem for the logic in register_netdevice(). Because all callers of register_netdevice() manage the freeing of the netdev, and invoke free_netdev(dev) if register_netdevice() fails. If netdev_ops->ndo_init() succeeds, but something else fails inside of register_netdevice(), it does call ndo_ops->ndo_uninit(). But it is not able to invoke netdev->destructor(). This is because netdev->destructor() will do a free_netdev() and then the caller of register_netdevice() will do the same. However, this means that the resources that would normally be released by netdev->destructor() will not be. Over the years drivers have added local hacks to deal with this, by invoking their destructor parts by hand when register_netdevice() fails. Many drivers do not try to deal with this, and instead we have leaks. Let's close this hole by formalizing the distinction between what private things need to be freed up by netdev->destructor() and whether the driver needs unregister_netdevice() to perform the free_netdev(). netdev->priv_destructor() performs all actions to free up the private resources that used to be freed by netdev->destructor(), except for free_netdev(). netdev->needs_free_netdev is a boolean that indicates whether free_netdev() should be done at the end of unregister_netdevice(). Now, register_netdevice() can sanely release all resources after ndo_ops->ndo_init() succeeds, by invoking both ndo_ops->ndo_uninit() and netdev->priv_destructor(). And at the end of unregister_netdevice(), we invoke netdev->priv_destructor() and optionally call free_netdev(). Signed-off-by: David S. Miller <davem@davemloft.net> Applied the portion of the commit applicable to openvswitch. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: more accurate checksumming in queue_userspace_packet()Joe Stringer2017-07-241-0/+1
| | | | | | | | | | | | | | | | | | Upstream commit: commit 7529390d08f07fbf9b0174c5a87600b5caa1a8e8 Author: Davide Caratti <dcaratti@redhat.com> Date: Thu May 18 15:44:42 2017 +0200 openvswitch: more accurate checksumming in queue_userspace_packet() if skb carries an SCTP packet and ip_summed is CHECKSUM_PARTIAL, it needs CRC32c in place of Internet Checksum: use skb_csum_hwoffload_help to avoid corrupting such packets while queueing them towards userspace. Signed-off-by: Davide Caratti <dcaratti@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: introduce nf_conntrack_helper_put functionGreg Rose2017-07-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | Upstream commit: commit d91fc59cd77c719f33eda65c194ad8f95a055190 Author: Liping Zhang <zlpnobody@gmail.com> Date: Sun May 7 22:01:55 2017 +0800 netfilter: introduce nf_conntrack_helper_put helper function And convert module_put invocation to nf_conntrack_helper_put, this is prepared for the followup patch, which will add a refcnt for cthelper, so we can reject the deleting request when cthelper is in use. Signed-off-by: Liping Zhang <zlpnobody@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Applied with additional use of HAVE_NF_CONNTRACK_HELPER_PUT compatibility flag defined in acinclude.m4. Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* acinclude.m4: Avoid error from printf.Ben Pfaff2017-07-171-1/+1
| | | | | | | | | | GNU (at least) printf interprets -I as an option, but we want to print it literally, so use %s. CC: YAMAMOTO Takashi <yamamoto@ovn.org> Fixes: 27d41afaa446 ("acinclude.m4: Avoid echo -n") Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* acinclude.m4: Avoid echo -nYAMAMOTO Takashi2017-07-161-1/+1
| | | | | | | | -n option for echo is not portable. Use printf instead. This fixes OSX build on travis-ci. Acked-by: Ben Pfaff <blp@ovn.org> Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
* ctags: include symbols with locking annotations.Flavio Leitner2017-07-131-0/+8
| | | | | | | | | | | | | | OVS uses extensively clang annotations for thread safety checks. The ctags tool can't parse them, so they are not included in the tag file. This patch improves the configure script to generate a list of identifiers from the header compiler.h to be ignored by ctags. Signed-off-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Aaron Conole <aconole@redhat.com>
* configure: Fix check for rte_config.h to handle cross-compilation.Ben Pfaff2017-07-071-3/+4
| | | | | | | | | | | | | | The check for rte_config.h in acinclude.m4 used AC_CHECK_FILE, but this macro is intended to check for a file on the host system, not the build system, which means that it fails unconditionally in a cross-compilation environment. However, the intended check here is for a header file, which is part of the build system. To check for part of the build system, we can just use "test", so this commit makes that change. Reported-by: Hemant Agrawal <hemant.agrawal@nxp.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2017-March/329994.html Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Darrell Ball <dlu998@gmail.com>
* Makefiles: Fail build for flake8 only when configured with --enable-Werror.Ben Pfaff2017-07-071-1/+10
| | | | | | | | | | | | | | | | | | flake8 checking is useful. Until now, it always failed the build for any flake8 errors. This is too aggressive, for the same reason that always failing the build for any compiler warnings is too aggressive: compilers change over time and asynchronously from OVS itself. Thus, if we release some version of OVS today, even if it's flake8-clean today, it might not be flake8-clean tomorrow, even with the same settings. We don't want to have to track flake8 warnings on every release branch. Thus, this adopts the same policy for compiler warnings: always report them, but only fail the build if --enable-Werror was configured. Usually just developers use that configure option, and they're prepared to deal with the fallout. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* compat: Restrict __ro_after_init usageGreg Rose2017-06-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The attribute __ro_after_init was introduced in Linux kernel 4.5. If a data structure is given this attribute then after the driver module loads the memory page where the data resides will be marked read only. The compat code in cache.h always defines __ro_after_init if it is not already defined so that it can be used as an attribute for the datapath genl_family structure definitions. If __ro_after_init is defined then it is used "as-is" where it will apply the read only attribute after driver initialization. This is incorrect usage for the Generic Netlink genl_family structure definitions prior to Linux kernel 4.10. The genl_family structure in those kernels includes a list header member that will be written to when the generic netlink family is unregistered. This will cause a subsequent page fault and kernel panic because at this time the genl_family structure data has been marked read only in the page descriptor. A new compat macro is introduced in acinclude.m4 to detect when the genl_family structure has the family_list list header as a member. In this case HAVE_GENL_FAMILY_LIST is defined and if __ro_after_init is also defined then it is undefined and redefined as empty. This will prevent the genl_family data structure from being marked read only in kernels 4.5 through 4.9 and thus prevent the page fault when the generic netlink families in datapath.c are unregistered. [Committer notes] * Rolled a short explanation comment into the code. Fixes: ba63fe260bd5 ("datapath: Allow compile against current net-next.") CC: Jarno Rajahalme <jarno@ovn.org> Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* compat: Add tc compatibility headers for old kernelsPaul Blakey2017-05-301-0/+26
| | | | | | | | | | | | | | 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>
* datapath: Remove untracked CT on newer kernels.Joe Stringer2017-05-031-0/+2
| | | | | | | | | | | | | | Upstream commits cc41c84b7e7f ("netfilter: kill the fake untracked conntrack objects") and ab8bc7ed864b ("netfilter: remove nf_ct_is_untracked") removed the 'untracked' conntrack objects and functions. The latter commit removes the usage of nf_ct_is_untracked() from OVS. However, older kernels still have a representation of 'untracked' CT objects so the code needs to remain until the kernel support is bumped to Linux 4.12 or newer. Introduce a macro to detect this symbol and wrap these lines in the macro check. Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Greg Rose <gvrose8192@gmail.com>
* datapath: Fixups for MPLS GSOYi-Hung Wei2017-05-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* compat: Fix build error in kernels 4.10Greg Rose2017-04-281-1/+3
| | | | | | | | | | | | | | | | | | | Use the acinclude.m4 configuration file to check for the net parameter that was added to the ipv4 and ipv6 frags init functions in the 4.10 Linux kernel to check whether DEFRAG_ENABLE_TAKES_NET should be set and then check for that at compile time. This is an alternative solution patch for the issue reported by Raymond Burkholder and the patch submitted by Guoshuai Li. [Committer notes] Squash in "acinclude.m4: Add check for struct net parameter" which provides the HAVE_DEFRAG_ENABLE_TAKES_NET. Reported-by: Raymond Burkholder <ray@oneunified.net> CC: Guoshuai Li <ligs@dtdream.com> Signed-off-by: Greg Rose <gvrose8192@gmail.com> Signed-off-by: Joe Stringer <joe@ovn.org>
* datapath: pass extended ACK struct to parsing functionsJohannes Berg2017-04-201-0/+3
| | | | | | | | | | | | | | | | | | | | Upstream commit: commit fceb6435e85298f747fee938415057af837f5a8a Author: Johannes Berg <johannes.berg@intel.com> Date: Wed Apr 12 14:34:07 2017 +0200 netlink: pass extended ACK struct to parsing functions Pass the new extended ACK reporting struct to all of the generic netlink parsing functions. For now, pass NULL in almost all callers (except for some in the core.) Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* compat: ipv6: orphan skbs in reassembly unit.Eric Dumazet2017-04-191-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream commit: ipv6: orphan skbs in reassembly unit Andrey reported a use-after-free in IPv6 stack. Issue here is that we free the socket while it still has skb in TX path and in some queues. It happens here because IPv6 reassembly unit messes skb->truesize, breaking skb_set_owner_w() badly. We fixed a similar issue for IPV4 in commit 8282f27449bf ("inet: frag: Always orphan skbs inside ip_defrag()") Acked-by: Joe Stringer <joe@ovn.org> ================================================================== BUG: KASAN: use-after-free in sock_wfree+0x118/0x120 Read of size 8 at addr ffff880062da0060 by task a.out/4140 page:ffffea00018b6800 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0 flags: 0x100000000008100(slab|head) raw: 0100000000008100 0000000000000000 0000000000000000 0000000180130013 raw: dead000000000100 dead000000000200 ffff88006741f140 0000000000000000 page dumped because: kasan: bad access detected CPU: 0 PID: 4140 Comm: a.out Not tainted 4.10.0-rc3+ #59 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:15 dump_stack+0x292/0x398 lib/dump_stack.c:51 describe_address mm/kasan/report.c:262 kasan_report_error+0x121/0x560 mm/kasan/report.c:370 kasan_report mm/kasan/report.c:392 __asan_report_load8_noabort+0x3e/0x40 mm/kasan/report.c:413 sock_flag ./arch/x86/include/asm/bitops.h:324 sock_wfree+0x118/0x120 net/core/sock.c:1631 skb_release_head_state+0xfc/0x250 net/core/skbuff.c:655 skb_release_all+0x15/0x60 net/core/skbuff.c:668 __kfree_skb+0x15/0x20 net/core/skbuff.c:684 kfree_skb+0x16e/0x4e0 net/core/skbuff.c:705 inet_frag_destroy+0x121/0x290 net/ipv4/inet_fragment.c:304 inet_frag_put ./include/net/inet_frag.h:133 nf_ct_frag6_gather+0x1125/0x38b0 net/ipv6/netfilter/nf_conntrack_reasm.c:617 ipv6_defrag+0x21b/0x350 net/ipv6/netfilter/nf_defrag_ipv6_hooks.c:68 nf_hook_entry_hookfn ./include/linux/netfilter.h:102 nf_hook_slow+0xc3/0x290 net/netfilter/core.c:310 nf_hook ./include/linux/netfilter.h:212 __ip6_local_out+0x52c/0xaf0 net/ipv6/output_core.c:160 ip6_local_out+0x2d/0x170 net/ipv6/output_core.c:170 ip6_send_skb+0xa1/0x340 net/ipv6/ip6_output.c:1722 ip6_push_pending_frames+0xb3/0xe0 net/ipv6/ip6_output.c:1742 rawv6_push_pending_frames net/ipv6/raw.c:613 rawv6_sendmsg+0x2cff/0x4130 net/ipv6/raw.c:927 inet_sendmsg+0x164/0x5b0 net/ipv4/af_inet.c:744 sock_sendmsg_nosec net/socket.c:635 sock_sendmsg+0xca/0x110 net/socket.c:645 sock_write_iter+0x326/0x620 net/socket.c:848 new_sync_write fs/read_write.c:499 __vfs_write+0x483/0x760 fs/read_write.c:512 vfs_write+0x187/0x530 fs/read_write.c:560 SYSC_write fs/read_write.c:607 SyS_write+0xfb/0x230 fs/read_write.c:599 entry_SYSCALL_64_fastpath+0x1f/0xc2 arch/x86/entry/entry_64.S:203 RIP: 0033:0x7ff26e6f5b79 RSP: 002b:00007ff268e0ed98 EFLAGS: 00000206 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007ff268e0f9c0 RCX: 00007ff26e6f5b79 RDX: 0000000000000010 RSI: 0000000020f50fe1 RDI: 0000000000000003 RBP: 00007ff26ebc1220 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000 R13: 00007ff268e0f9c0 R14: 00007ff26efec040 R15: 0000000000000003 The buggy address belongs to the object at ffff880062da0000 which belongs to the cache RAWv6 of size 1504 The buggy address ffff880062da0060 is located 96 bytes inside of 1504-byte region [ffff880062da0000, ffff880062da05e0) Freed by task 4113: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57 save_stack+0x43/0xd0 mm/kasan/kasan.c:502 set_track mm/kasan/kasan.c:514 kasan_slab_free+0x73/0xc0 mm/kasan/kasan.c:578 slab_free_hook mm/slub.c:1352 slab_free_freelist_hook mm/slub.c:1374 slab_free mm/slub.c:2951 kmem_cache_free+0xb2/0x2c0 mm/slub.c:2973 sk_prot_free net/core/sock.c:1377 __sk_destruct+0x49c/0x6e0 net/core/sock.c:1452 sk_destruct+0x47/0x80 net/core/sock.c:1460 __sk_free+0x57/0x230 net/core/sock.c:1468 sk_free+0x23/0x30 net/core/sock.c:1479 sock_put ./include/net/sock.h:1638 sk_common_release+0x31e/0x4e0 net/core/sock.c:2782 rawv6_close+0x54/0x80 net/ipv6/raw.c:1214 inet_release+0xed/0x1c0 net/ipv4/af_inet.c:425 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:431 sock_release+0x8d/0x1e0 net/socket.c:599 sock_close+0x16/0x20 net/socket.c:1063 __fput+0x332/0x7f0 fs/file_table.c:208 ____fput+0x15/0x20 fs/file_table.c:244 task_work_run+0x19b/0x270 kernel/task_work.c:116 exit_task_work ./include/linux/task_work.h:21 do_exit+0x186b/0x2800 kernel/exit.c:839 do_group_exit+0x149/0x420 kernel/exit.c:943 SYSC_exit_group kernel/exit.c:954 SyS_exit_group+0x1d/0x20 kernel/exit.c:952 entry_SYSCALL_64_fastpath+0x1f/0xc2 arch/x86/entry/entry_64.S:203 Allocated by task 4115: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57 save_stack+0x43/0xd0 mm/kasan/kasan.c:502 set_track mm/kasan/kasan.c:514 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:605 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:544 slab_post_alloc_hook mm/slab.h:432 slab_alloc_node mm/slub.c:2708 slab_alloc mm/slub.c:2716 kmem_cache_alloc+0x1af/0x250 mm/slub.c:2721 sk_prot_alloc+0x65/0x2a0 net/core/sock.c:1334 sk_alloc+0x105/0x1010 net/core/sock.c:1396 inet6_create+0x44d/0x1150 net/ipv6/af_inet6.c:183 __sock_create+0x4f6/0x880 net/socket.c:1199 sock_create net/socket.c:1239 SYSC_socket net/socket.c:1269 SyS_socket+0xf9/0x230 net/socket.c:1249 entry_SYSCALL_64_fastpath+0x1f/0xc2 arch/x86/entry/entry_64.S:203 Memory state around the buggy address: ffff880062d9ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff880062d9ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff880062da0000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff880062da0080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff880062da0100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> This patch is a bugfix, and will be progressively backported to earlier kernels. If it is backported to any kernel 4.5 through 4.10, then users use that updated kernel with the OVS kernel module prior to this patch, it could cause a crash. The compat code here resolves such issues. Upstream: 48cac18ecf1d ("ipv6: orphan skbs in reassembly unit") Signed-off-by: Joe Stringer <joe@ovn.org> Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
* acinclude: Allow compile with Linux 4.11.Jarno Rajahalme2017-04-171-2/+2
| | | | | | | | | | Change the Linux kernel tests in OVS configuration. While the backports may still be a little behind, it is useful to be able to test the OVS tree kernel module with the upstream net-next kernel. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>