]> git.proxmox.com Git - mirror_ovs.git/log
mirror_ovs.git
4 years agodatapath: add seqadj extension when NAT is used.
Flavio Leitner [Tue, 15 Oct 2019 17:27:45 +0000 (10:27 -0700)]
datapath: add seqadj extension when NAT is used.

upstream patch:

commit fa7e428c6b7ed3281610511a2b2ec716d9894be8
Author: Flavio Leitner <fbl@sysclose.org>
Date:   Mon Mar 25 15:58:31 2019 -0300

    openvswitch: add seqadj extension when NAT is used.

    When the conntrack is initialized, there is no helper attached
    yet so the nat info initialization (nf_nat_setup_info) skips
    adding the seqadj ext.

    A helper is attached later when the conntrack is not confirmed
    but is going to be committed. In this case, if NAT is needed then
    adds the seqadj ext as well.

Fixes: 16ec3d4fbb96 ("openvswitch: Fix cached ct with helper.")
Signed-off-by: Flavio Leitner <fbl@sysclose.org>
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>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodatapath: Detect upstream nf_nat change
Yi-Hung Wei [Tue, 15 Oct 2019 17:27:44 +0000 (10:27 -0700)]
datapath: Detect upstream nf_nat change

The following two upstream commits merge nf_nat_ipv4 and nf_nat_ipv6
into nf_nat core, and move some header files around.  To handle
these modifications, this patch detects the upstream changes, uses
the header files and config symbols properly.

Ideally, we should replace CONFIG_NF_NAT_IPV4 and CONFIG_NF_NAT_IPV6 with
CONFIG_NF_NAT and CONFIG_IPV6.  In order to keep backward compatibility,
we keep the checking of CONFIG_NF_NAT_IPV4/6 as is for the old kernel,
and replace them with marco for the new kernel.

upstream commits:
3bf195ae6037 ("netfilter: nat: merge nf_nat_ipv4,6 into nat core")
d2c5c103b133 ("netfilter: nat: remove nf_nat_l3proto.h and nf_nat_core.h")

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodatapath: Replace nf_ct_invert_tuplepr() with nf_ct_invert_tuple()
Yi-Hung Wei [Tue, 15 Oct 2019 17:27:43 +0000 (10:27 -0700)]
datapath: Replace nf_ct_invert_tuplepr() with nf_ct_invert_tuple()

After upstream net-next commit 303e0c558959 ("netfilter: conntrack:
avoid unneeded nf_conntrack_l4proto lookups") nf_ct_invert_tuplepr()
is no longer available in the kernel.

Ideally, we should be in sync with upstream kernel by calling
nf_ct_invert_tuple() directly in conntrack.c.  However,
nf_ct_invert_tuple() has different function signature in older kernel,
and it would be hard to replace that in the compat layer. Thus, we
use rpl_nf_ct_invert_tuple() in conntrack.c and maintain compatibility
in the compat layer so that ovs kernel module runs smoothly in both
new and old kernel.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodatapath: Fix linking without CONFIG_NF_CONNTRACK_LABELS
Arnd Bergmann [Tue, 15 Oct 2019 17:27:42 +0000 (10:27 -0700)]
datapath: Fix linking without CONFIG_NF_CONNTRACK_LABELS

upstream commit:
commit a277d516de5f498c91d91189717ef7e01102ad27
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Fri Nov 2 16:36:55 2018 +0100

    openvswitch: fix linking without CONFIG_NF_CONNTRACK_LABELS

    When CONFIG_CC_OPTIMIZE_FOR_DEBUGGING is enabled, the compiler
    fails to optimize out a dead code path, which leads to a link failure:

    net/openvswitch/conntrack.o: In function `ovs_ct_set_labels':
    conntrack.c:(.text+0x2e60): undefined reference to `nf_connlabels_replace'

    In this configuration, we can take a shortcut, and completely
    remove the contrack label code. This may also help the regular
    optimization.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodatapath: compat: drop bridge nf reset from nf_reset
Greg Rose [Wed, 9 Oct 2019 21:22:14 +0000 (14:22 -0700)]
datapath: compat: drop bridge nf reset from nf_reset

Upstream commmit:
    commit 895b5c9f206eb7d25dc1360a8ccfc5958895eb89
    Author: Florian Westphal <fw@strlen.de>
    Date:   Sun Sep 29 20:54:03 2019 +0200

    netfilter: drop bridge nf reset from nf_reset

    commit 174e23810cd31
    ("sk_buff: drop all skb extensions on free and skb scrubbing") made napi
    recycle always drop skb extensions.  The additional skb_ext_del() that is
    performed via nf_reset on napi skb recycle is not needed anymore.

    Most nf_reset() calls in the stack are there so queued skb won't block
    'rmmod nf_conntrack' indefinitely.

    This removes the skb_ext_del from nf_reset, and renames it to a more
    fitting nf_reset_ct().

    In a few selected places, add a call to skb_ext_reset to make sure that
    no active extensions remain.

    I am submitting this for "net", because we're still early in the release
    cycle.  The patch applies to net-next too, but I think the rename causes
    needless divergence between those trees.

Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Added some compat layer fixups for nf_reset_ct.  This is just a portion
of the upstream commit that applies to openvswitch.

Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
4 years agodatapath: rename flow_stats to sw_flow_stats
Pablo Neira Ayuso [Wed, 9 Oct 2019 21:22:13 +0000 (14:22 -0700)]
datapath: rename flow_stats to sw_flow_stats

Upstream commit:
    commit aef833c58d321f09ae4ce4467723542842ba9faf
    Author: Pablo Neira Ayuso <pablo@netfilter.org>
    Date:   Fri Jul 19 18:20:13 2019 +0200

    net: openvswitch: rename flow_stats to sw_flow_stats

    There is a flow_stats structure defined in include/net/flow_offload.h
    and a follow up patch adds #include <net/flow_offload.h> to
    net/sch_generic.h.

    This breaks compilation since OVS codebase includes net/sock.h which
    pulls in linux/filter.h which includes net/sch_generic.h.

    In file included from ./include/net/sch_generic.h:18:0,
                     from ./include/linux/filter.h:25,
                     from ./include/net/sock.h:59,
                     from ./include/linux/tcp.h:19,
                     from net/openvswitch/datapath.c:24

    This definition takes precedence on OVS since it is placed in the
    networking core, so rename flow_stats in OVS to sw_flow_stats since
    this structure is contained in sw_flow.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
4 years agocompat: remove the incorrect mtu limit for erspan
Haishuang Yan [Wed, 9 Oct 2019 21:22:12 +0000 (14:22 -0700)]
compat: remove the incorrect mtu limit for erspan

Upstream commit:
    commit 0e141f757b2c78c983df893e9993313e2dc21e38
    Author: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
    Date:   Fri Sep 27 14:58:20 2019 +0800

    erspan: remove the incorrect mtu limit for erspan

    erspan driver calls ether_setup(), after commit 61e84623ace3
    ("net: centralize net_device min/max MTU checking"), the range
    of mtu is [min_mtu, max_mtu], which is [68, 1500] by default.

    It causes the dev mtu of the erspan device to not be greater
    than 1500, this limit value is not correct for ipgre tap device.

    Tested:
    Before patch:
    # ip link set erspan0 mtu 1600
    Error: mtu greater than device maximum.
    After patch:
    # ip link set erspan0 mtu 1600
    # ip -d link show erspan0
    21: erspan0@NONE: <BROADCAST,MULTICAST> mtu 1600 qdisc noop state DOWN
    mode DEFAULT group default qlen 1000
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 0

Fixes: 61e84623ace3 ("net: centralize net_device min/max MTU checking")
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
4 years agodatapath: change type of UPCALL_PID attribute to NLA_UNSPEC
Li RongQing [Wed, 9 Oct 2019 21:22:11 +0000 (14:22 -0700)]
datapath: change type of UPCALL_PID attribute to NLA_UNSPEC

Upstream commit:
    commit ea8564c865299815095bebeb4b25bef474218e4c
    Author: Li RongQing <lirongqing@baidu.com>
    Date:   Tue Sep 24 19:11:52 2019 +0800

    openvswitch: change type of UPCALL_PID attribute to NLA_UNSPEC

    userspace openvswitch patch "(dpif-linux: Implement the API
    functions to allow multiple handler threads read upcall)"
    changes its type from U32 to UNSPEC, but leave the kernel
    unchanged

    and after kernel 6e237d099fac "(netlink: Relax attr validation
    for fixed length types)", this bug is exposed by the below
    warning

     [   57.215841] netlink: 'ovs-vswitchd': attribute type 5 has an invalid length.

Fixes: 5cd667b0a456 ("openvswitch: Allow each vport to have an array of 'port_id's")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Fixes: beb1c69a3 ("datapath: Allow each vport to have an array of 'port_id's.")
Cc: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
4 years agodatapath: hide clang frame-overflow warnings
Arnd Bergmann [Wed, 9 Oct 2019 21:22:10 +0000 (14:22 -0700)]
datapath: hide clang frame-overflow warnings

Upstream commit:
    commit 260637903f47f20c5918bb5c1eea52b2a28ea863
    Author: Arnd Bergmann <arnd@arndb.de>
    Date:   Mon Jul 22 17:00:01 2019 +0200

    ovs: datapath: hide clang frame-overflow warnings

    Some functions in the datapath code are factored out so that each
    one has a stack frame smaller than 1024 bytes with gcc. However,
    when compiling with clang, the functions are inlined more aggressively
    and combined again so we get

    net/openvswitch/datapath.c:1124:12: error: stack frame size of 1528 bytes in function 'ovs_flow_cmd_set' [-Werror,-Wframe-larger-than=]

    Marking both get_flow_actions() and ovs_nla_init_match_and_action()
    as 'noinline_for_stack' gives us the same behavior that we see with
    gcc, and no warning. Note that this does not mean we actually use
    less stack, as the functions call each other, and we still get
    three copies of the large 'struct sw_flow_key' type on the stack.

    The comment tells us that this was previously considered safe,
    presumably since the netlink parsing functions are called with
    a known backchain that does not also use a lot of stack space.

Fixes: 9cc9a5cb176c ("datapath: Avoid using stack larger than 1024.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
4 years agotc: Limit the max action number to 16
Chris Mi [Wed, 16 Oct 2019 08:37:14 +0000 (11:37 +0300)]
tc: Limit the max action number to 16

Currently, ovs supports to offload max TCA_ACT_MAX_PRIO(32) actions.
But net sched api has a limit of 4K message size which is not enough
for 32 actions when echo flag is set.

After a lot of testing, we find that 16 actions is a reasonable number.
So in this commit, we introduced a new define to limit the max actions.

Fixes: 0c70132cd288("tc: Make the actions order consistent")
Signed-off-by: Chris Mi <chrism@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
4 years agocompat: Fix small naming issue
Greg Rose [Wed, 16 Oct 2019 20:21:11 +0000 (13:21 -0700)]
compat: Fix small naming issue

In commit 057772cf2477 the function is missing the rpl_ prefix
and the define that replaces the original function should come
after the function definition.

Fixes: 057772cf2477 ("compat: Backport nf_ct_tmpl_alloc().")
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: William Tu <u9012063@gmail.com>
4 years agoconfigure: Properly handle case where libunwind.h is not available.
Yi-Hung Wei [Thu, 17 Oct 2019 04:35:55 +0000 (21:35 -0700)]
configure: Properly handle case where libunwind.h is not available.

It is possible that user install libunwind but not libunwind-devel,
and it will run into a compilation error.  So we need to check the
existence of the library and the header file.

Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: William Tu <u9012063@gmail.com>
4 years agotests: Get rid of timeout options for control utilities.
Ilya Maximets [Thu, 10 Oct 2019 14:23:57 +0000 (16:23 +0200)]
tests: Get rid of timeout options for control utilities.

'OVS_CTL_TIMEOUT' environment variable is exported in tests/atlocal.in
and controls timeouts for all OVS utilities in testsuite.

There should be no manual tweaks for each single command.

This helps with running tests under valgrind where commands could
take really long time as you only need to change 'OVS_CTL_TIMEOUT'
in a single place.

Few manual timeouts were left in places where they make sense.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Acked-by: Ben Pfaff <blp@ovn.org>
4 years agoAUTHORS: Add Alessandro Pilotti.
Alin Gabriel Serdean [Tue, 15 Oct 2019 10:15:02 +0000 (13:15 +0300)]
AUTHORS: Add Alessandro Pilotti.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
4 years agoovs container build.sh requires python3
Aliasgar Ginwala [Fri, 11 Oct 2019 21:56:46 +0000 (14:56 -0700)]
ovs container build.sh requires python3

Building ovn/ovs container breaks while configure:
checking for Python 3 (version 3.4 or later)... no
configure: error: Python 3.4 or later is required but not found in
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,
please install it or set  to point to it

As per ovs commit 1ca0323e7c29dc7ef5a615c265df0460208f92de
Require Python 3 and remove support for Python 2.

Signed-off-by: Aliasgar Ginwala <aginwala@ebay.com>
Signed-off-by: Han Zhou <hzhou@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovs-vlan-bug-workaround: Remove.
Ben Pfaff [Thu, 10 Oct 2019 19:07:27 +0000 (12:07 -0700)]
ovs-vlan-bug-workaround: Remove.

This workaround only applied to kernels earlier than 2.6.37, but OVS
only supports 3.10 and later.

As the original author of this code, I won't miss it.

Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodpif-netlink: Fix some variable naming.
Ben Pfaff [Mon, 14 Oct 2019 18:10:47 +0000 (11:10 -0700)]
dpif-netlink: Fix some variable naming.

Usually a plural name refers to an array, but 'socks' and 'socksp' were
only single objects, so this changes their names to 'sock' and 'sockp'.

Usually a 'p' suffix means that a variable is an output argument, but
that was only true in one place here, so this changes the names of the
other variables to plain 'sock'.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
4 years agolib: packets: export compose_ipv6 routine to OVN
Lorenzo Bianconi [Fri, 11 Oct 2019 10:23:12 +0000 (12:23 +0200)]
lib: packets: export compose_ipv6 routine to OVN

Remove static qualifier from compose_ipv6 definition and export it to
OVN. compose_ipv6 will be used in order to add IPv6 prefix delegation
support to OVN

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodpif-netlink: Free leaked nl_sock
Yifeng Sun [Fri, 11 Oct 2019 22:50:47 +0000 (15:50 -0700)]
dpif-netlink: Free leaked nl_sock

Valgrind reports:
20 bytes in 1 blocks are definitely lost in loss record 94 of 353
    by 0x532594: xmalloc (util.c:138)
    by 0x553EAD: nl_sock_create (netlink-socket.c:146)
    by 0x54331D: create_nl_sock (dpif-netlink.c:255)
    by 0x54331D: dpif_netlink_port_add__ (dpif-netlink.c:756)
    by 0x5435F6: dpif_netlink_port_add_compat (dpif-netlink.c:876)
    by 0x5435F6: dpif_netlink_port_add (dpif-netlink.c:922)
    by 0x47EC1D: dpif_port_add (dpif.c:584)
    by 0x42B35F: port_add (ofproto-dpif.c:3721)
    by 0x41E64A: ofproto_port_add (ofproto.c:2032)
    by 0x40B3FE: iface_do_create (bridge.c:1817)
    by 0x40B3FE: iface_create (bridge.c:1855)
    by 0x40B3FE: bridge_add_ports__ (bridge.c:943)
    by 0x40D14A: bridge_add_ports (bridge.c:959)
    by 0x40D14A: bridge_reconfigure (bridge.c:673)
    by 0x410D75: bridge_run (bridge.c:3050)
    by 0x407614: main (ovs-vswitchd.c:127)

This leak is because when vport_add_channel() returns 0, it is expected
to take the ownership of 'socksp'. This patch fixes this issue.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-server: Don't drop all connections on read/write status change.
Numan Siddique [Mon, 14 Oct 2019 15:20:02 +0000 (20:50 +0530)]
ovsdb-server: Don't drop all connections on read/write status change.

The commit [1] force drops all connections when the db read/write status changes.
Prior to the commit [1], when there was read/write status change, the existing
jsonrpc sessions with 'db_change_aware' set to true, were not updated with the
changed 'read_only' value. If the db status was changed to 'standby', the existing
clients could still write to the db.

In the case of pacemaker OVN HA, OVN OCF script 'start' action starts the
ovsdb-servers in read-only state and later, it sets to read-write in the
'promote' action. We have observed that if some ovn-controllers connect to
the SB ovsdb-server (in read-only state) just before the 'promote' action,
the connection is not reset all the times and these ovn-controllers remain connected
to the SB ovsdb-server in read-only state all the time. Even though
the commit [1] calls 'ovsdb_jsonrpc_server_reconnect()' with 'forced' flag
set to true when the db read/write status changes, somehow the FSM misses resetting
the connections of these ovn-controllers.

I think this needs to be addressed in the FSM. This patch doesn't address
this FSM issue. Instead it changes the behavior of 'ovsdb_jsonrpc_server_set_read_only()'
by setting the 'read_only' flag of all the jsonrpc sessions instead of forcefully
resetting the connection.

I think there is no need to reset the connection. In large scale production
deployements with OVN, this results in unnecessary waste of CPU cycles as ovn-controllers
will have to connect twice - once during 'start' action and again during 'promote'.

[1] - 2a9679e3b2c6("ovsdb-server: drop all connections on read/write status change")

Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agonetdev-afxdp: Update memory locking limits unconditionally.
Ilya Maximets [Wed, 9 Oct 2019 14:23:31 +0000 (16:23 +0200)]
netdev-afxdp: Update memory locking limits unconditionally.

Any type of AF_XDP socket in all modes implies creation of BPF map of
type BPF_MAP_TYPE_XSKMAP.  This leads to BPF_MAP_CREATE syscall and
subsequently 'xsk_map_alloc()' function that will charge required
memory from the memlock limit and fail with EPERM if we're trying
to allocate more.

On my system with 64K bytes of max locked memory by default, OVS
frequently starts to fail after addition of 3rd afxdp port in SKB
mode:

  netdev_afxdp|ERR|xsk_socket__create failed (Operation not permitted)
                   mode: SKB qid: 0

Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: William Tu <u9012063@gmail.com>
4 years agonetdev-afxdp: Fix umem creation failure due to uninitialized config.
Ilya Maximets [Wed, 9 Oct 2019 14:17:58 +0000 (16:17 +0200)]
netdev-afxdp: Fix umem creation failure due to uninitialized config.

Later version of 'struct xsk_umem_config' contains additional field
'flags'.  OVS doesn't use that field passing uninitialized stack
memory to the 'xsk_umem__create()' call that could fail with
'Invalid argument' if 'flags' are non-zero or, even worse, create
umem with unexpected properties.

We need to clear the whole structure explicitly to avoid this kind
of issues.

Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: William Tu <u9012063@gmail.com>
4 years agocirrus: Use latest stable FreeBSD images.
Ilya Maximets [Tue, 1 Oct 2019 11:28:45 +0000 (14:28 +0300)]
cirrus: Use latest stable FreeBSD images.

CirrusCI recently introduced [1] new feature to use image families
instead of bare image names for gCloud based instances.
This allows us to use most recent stable builds. All the stable builds
are in the same image family in gCloud and it will run instances using
the most recent one.
This also allows us to simply use 11.3 image instead of 11.2.  There
was no such ability previously, because base freebsd-11-3-release-amd64
image has issues[2] that doesn't allow CirrusCI to use it.  However,
later stable 11.3 images from freebsd-11-3-snap family works fine.

[1] https://github.com/cirruslabs/cirrus-ci-docs/issues/422
[2] https://github.com/cirruslabs/cirrus-ci-docs/issues/359

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
4 years agoflow: Fix using pointer to member of packed struct icmp6_hdr.
Ilya Maximets [Tue, 1 Oct 2019 15:18:23 +0000 (18:18 +0300)]
flow: Fix using pointer to member of packed struct icmp6_hdr.

OVS has no structure definition for ICMPv6 header with additional
data. More precisely, it has, but this structure named as
'icmp6_error_header' and only suitable to store error related
extended information.  'flow_compose_l4' stores additional
information in reserved bits by using system defined structure
'icmp6_hdr', which is marked as 'packed' and this leads to
build failure with gcc >= 9:

  lib/flow.c:3041:34: error:
    taking address of packed member of 'struct icmp6_hdr' may result
    in an unaligned pointer value [-Werror=address-of-packed-member]

        uint32_t *reserved = &icmp->icmp6_dataun.icmp6_un_data32[0];
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix that by renaming 'icmp6_error_header' to 'icmp6_data_header'
and allowing it to store not only errors, but any type of additional
information by analogue with 'struct icmp6_hdr'.
All the usages of 'struct icmp6_hdr' replaced with this new structure.
Removed redundant conversions between network and host representations.
Now fields are always in be.

This also, probably, makes flow_compose_l4 more robust by avoiding
possible unaligned accesses to 32 bit value.

Fixes: 9b2b84973db7 ("Support for match & set ICMPv6 reserved and options type fields")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: William Tu <u9012063@gmail.com>
Acked-by: Ben Pfaff <blp@ovn.org>
4 years agoappveyor: Update OpenSSL link and python3 to path
Alin Gabriel Serdean [Wed, 9 Oct 2019 14:10:08 +0000 (17:10 +0300)]
appveyor: Update OpenSSL link and python3 to path

This patch fixes the appveyor build by adding the python version 3 to path
as per:
https://www.appveyor.com/docs/windows-images-software/#python

We also create a hardlink for python3 in the same directory to ease up scripts
which checks for its existence.

This patch also bumps the OpenSSL version from 1.0.2n to 1.0.2t.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: William Tu <u9012063@gmail.com>
4 years agotests: Allow valgrind check for afxdp testsuite.
Ilya Maximets [Wed, 9 Oct 2019 14:36:49 +0000 (16:36 +0200)]
tests: Allow valgrind check for afxdp testsuite.

New 'make' target 'check-afxdp-valgrind'.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: William Tu <u9012063@gmail.com>
4 years agoFix "the the" typo in two places.
Ben Pfaff [Wed, 9 Oct 2019 21:30:48 +0000 (14:30 -0700)]
Fix "the the" typo in two places.

Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoofproto: Fix for frequent invalidation of mega flows for push actions
Vishal Deep Ajmera [Wed, 9 Oct 2019 08:36:30 +0000 (14:06 +0530)]
ofproto: Fix for frequent invalidation of mega flows for push actions

When a packet is processed by the slow path and the matching OpenFlow
rule has actions like push_mpls/set_field and push_vlan/set_field, the
ofproto layer un-wildcards the MPLS and VLAN match fields in the megaflow
entry that it plans to install. However, when the megaflow entry is
actually installed, all protocol match fields that are not present in the
packet are wildcarded. Thus, the wildcard bits in the installed megaflow
entry could be different from the bits originally generated by the ofproto
layer.

When the revalidator thread validates a megaflow, it will first query the
ofproto layer to get the wildcard bits and then compare it against the
wildcard bits in the megaflow. If the bits are different the entry will be
removed.  A subsequent packet will again result in the same megaflow entry
being installed only for it to be removed by the revalidator thread. This
cycle will continue and will significantly degrade performance.

This patch fixes the issue by wildcarding flow fields which are not present
in the incoming packet.

Signed-off-by: Vishal Deep Ajmera <vishal.deep.ajmera@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoAvoid clobbered variable warning on ppc64le.
David Wilder [Tue, 8 Oct 2019 19:40:19 +0000 (12:40 -0700)]
Avoid clobbered variable warning on ppc64le.

Since commit e2ed6fbeb1, Ci on ppc64le with Ubuntu 16.04.6 LTS throws
this error:

lib/fatal-signal.c: In function 'send_backtrace_to_monitor':
lib/fatal-signal.c:168:9: error: variable 'dep' might be clobbered by
'longjmp' or 'vfork' [-Werror=clobbered]
     int dep;

Declaring dep as a volatile int.

Signed-off-by: David Wilder <dwilder@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-client: fix memory leak while executing database backup
Damijan Skvarc [Wed, 9 Oct 2019 06:34:24 +0000 (08:34 +0200)]
ovsdb-client: fix memory leak while executing database backup

valgrind detects this leak while running functional test "ovsdb-client backup and restore"

==25401== 1,068 (240 direct, 828 indirect) bytes in 6 blocks are definitely lost in loss record 22 of 22
==25401==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25401==    by 0x449DA4: xmalloc (util.c:138)
==25401==    by 0x43012D: json_create (json.c:1451)
==25401==    by 0x43012D: json_array_create_empty (json.c:186)
==25401==    by 0x43012D: json_parser_push_array (json.c:1279)
==25401==    by 0x4303CF: json_parser_input (json.c:1407)
==25401==    by 0x4312F1: json_lex_input (json.c:991)
==25401==    by 0x43193B: json_parser_feed (json.c:1149)
==25401==    by 0x4329FA: jsonrpc_recv.part.7 (jsonrpc.c:332)
==25401==    by 0x432D3B: jsonrpc_recv (jsonrpc.c:297)
==25401==    by 0x432D3B: jsonrpc_recv_block (jsonrpc.c:402)
==25401==    by 0x4330EB: jsonrpc_transact_block (jsonrpc.c:436)
==25401==    by 0x409246: do_backup (ovsdb-client.c:2008)
==25401==    by 0x405F76: main (ovsdb-client.c:282)

the problem was in db_backup() function, where _uuid json node was detached from
its parent "row" json node, but never destroyed afterwards.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agonetdev-offload: replace netdev_hmap_mutex to netdev_hmap_rwlock
wenxu [Wed, 9 Oct 2019 07:01:00 +0000 (15:01 +0800)]
netdev-offload: replace netdev_hmap_mutex to netdev_hmap_rwlock

All the kmap lookup operations netdev_ports_flow_del, netdev_ports_get
netdev_ifindex_to_odp_port should protected by rdlock without
affect each other in the handlers and revalidators

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoacinclude: Fix false positive search for prandom_u32
Greg Rose [Tue, 8 Oct 2019 16:21:15 +0000 (09:21 -0700)]
acinclude: Fix false positive search for prandom_u32

Searching random.h for prandom_u32 will also match when prandom_u32_max
is present and cause a false positive HAVE_PRANDOM_U32.  Fix this up
by looking for the parenthesis following prandom_u32 so it won't
match on prandom_u32_max.

Passes Travis:
https://travis-ci.org/gvrose8192/ovs-experimental/builds/595171808

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-tool: fix memory leak while converting cluster into standalone database
Damijan Skvarc [Mon, 7 Oct 2019 08:10:34 +0000 (10:10 +0200)]
ovsdb-tool: fix memory leak while converting cluster into standalone database

memory leak is reported by valgrind while executing functional test
"ovsdb-tool convert-to-standalone"

==13842== 2,850 (280 direct, 2,570 indirect) bytes in 7 blocks are definitely lost in loss record 20 of 20
==13842==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13842==    by 0x45EE2E: xmalloc (util.c:138)
==13842==    by 0x43E386: json_create (json.c:1451)
==13842==    by 0x43BDD2: json_object_create (json.c:254)
==13842==    by 0x43DEE3: json_parser_push_object (json.c:1273)
==13842==    by 0x43E167: json_parser_input (json.c:1371)
==13842==    by 0x43D6EA: json_lex_input (json.c:991)
==13842==    by 0x43DAC1: json_parser_feed (json.c:1149)
==13842==    by 0x40D108: parse_body (log.c:411)
==13842==    by 0x40D386: ovsdb_log_read (log.c:476)
==13842==    by 0x406A0B: do_convert_to_standalone (ovsdb-tool.c:1571)
==13842==    by 0x406A0B: do_cluster_standalone (ovsdb-tool.c:1606)
==13842==    by 0x438670: ovs_cmdl_run_command__ (command-line.c:223)
==13842==    by 0x438720: ovs_cmdl_run_command (command-line.c:254)
==13842==    by 0x405A4C: main (ovsdb-tool.c:79)

The problem was in do_convert_to_standalone() function which while reading log file
allocate json object which was not deallocated at the end.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-tool: fix memory leak while running "db-is-standalone" command
Damijan Skvarc [Mon, 7 Oct 2019 08:30:07 +0000 (10:30 +0200)]
ovsdb-tool: fix memory leak while running "db-is-standalone" command

problem is reported by valgrind while running functional tests:

==21043== 160 (88 direct, 72 indirect) bytes in 1 blocks are definitely lost in loss record 7 of 8
==21043==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21043==    by 0x45EE2E: xmalloc (util.c:138)
==21043==    by 0x40CB81: ovsdb_log_open (log.c:270)
==21043==    by 0x406B4F: do_db_has_magic.isra.9 (ovsdb-tool.c:563)
==21043==    by 0x438670: ovs_cmdl_run_command__ (command-line.c:223)
==21043==    by 0x438720: ovs_cmdl_run_command (command-line.c:254)
==21043==    by 0x405A4C: main (ovsdb-tool.c:79)

problem was in do_db_has_magic() which opens log file which is never closed.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoofproto: fix a typo for ttl in dpif_sflow_actions
Martin Zhang [Mon, 7 Oct 2019 04:34:55 +0000 (00:34 -0400)]
ofproto: fix a typo for ttl in dpif_sflow_actions

Signed-off-by: Martin Zhang <martinbj2008@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agotravis: Fix 32-bit libunwind system build.
William Tu [Fri, 4 Oct 2019 21:21:15 +0000 (14:21 -0700)]
travis: Fix 32-bit libunwind system build.

32-bit and 64-bit libunwind can not be installed at the same time.
For 32-bit build, this patch removes the 64-bit libunwind and install
32-bit version.

Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
4 years agobacktrace: Fix 32-bit libunwind build.
William Tu [Fri, 4 Oct 2019 21:21:16 +0000 (14:21 -0700)]
backtrace: Fix 32-bit libunwind build.

The libunwind unw_word_t type is defined as uint32_t for 32-bit
system and uint64_t for 64-bit system.  The patch fixes the
compile error using PRIxPTR to print this value.

Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
Signed-off-by: William Tu <u9012063@gmail.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
4 years agodoc: Added OVS Extensions document
Ashish Varma [Wed, 2 Oct 2019 17:23:05 +0000 (10:23 -0700)]
doc: Added OVS Extensions document

OVS supports OVS Extensions as various vendor messages or as vendor
types in stats or multipart messages. Added a document to describe the
extensions as currently supported by OVS.

Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoci: Get rid of OVS_CFLAGS in CI scripts.
Ilya Maximets [Thu, 3 Oct 2019 11:45:29 +0000 (13:45 +0200)]
ci: Get rid of OVS_CFLAGS in CI scripts.

Our CI scripts uses OVS_CFLAGS variable that is intended for internal
usage by 'configure' script only.  Usual CFLAGS should be used instead
to avoid giving bad example to users.

Additionally, '-m32' flag passed directly to CC variable to avoid
splitting it from the compiler invocations and force same API/ABI for
invocations of 'configure' and 'make'.
'BUILD_ENV' dropped as not needed anymore.

Before this patch 'configure' always checked for 64bit libraries
regardless of fact that we're going to build 32bit binary.  This
caused issues if only 64bit version of desired library was available.

Suggested-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
4 years agotests: Only run test on kernel datapath
Greg Rose [Fri, 4 Oct 2019 16:49:57 +0000 (09:49 -0700)]
tests: Only run test on kernel datapath

The recently added test to check for the correct L3 L4 protocol
information after conntrack reassembles a packet should not run
in the userspace datapath.  It is specific to a kernel datapath
regression.

Also change the name of the test to make it more informative and
less redundant and add comments with a short explanation.

Fixes: d7fd61a ("tests: Add check for correct l3l4 conntrack frag reassembly")
Suggested-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodoc: Fix incorrect reference for dpdk-testpmd.
David Marchand [Thu, 3 Oct 2019 18:45:20 +0000 (20:45 +0200)]
doc: Fix incorrect reference for dpdk-testpmd.

Move back the dpdk-testpmd reference to the right section of this
document so that the link in howto/dpdk does not point to
"vhost-user-client tx retries config".

Fixes: 080f080c3bc1 ("netdev-dpdk: Enable tx-retries-max config.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
4 years agotests: Add check for correct l3l4 conntrack frag reassembly
Greg Rose [Thu, 3 Oct 2019 17:46:09 +0000 (10:46 -0700)]
tests: Add check for correct l3l4 conntrack frag reassembly

Two commits recently fixed an issue with setting the corrrect l3 and l4
flow information when conntrack reassembles packet fragments.

c98f776 datapath: Clear the L4 portion of the key for "later" fragments
2609173 datapath: Properly set L4 keys on "later" IP fragments

This test checks for regressions that might break this feature.  It
counts on the fact that when the bug is present the udp src port
will not be correct.  It will either be zero or else some other
garbage value.  So the test feeds some fragments through for
reassembly and then checks to make sure that the udp srce port
is actually the correct value of 5001.

Tested by reverting the above commits and observing that the test
then fails.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoofproto-dpif-xlate: Fix memory leak in is_neighbor_reply_correct() function
Damijan Skvarc [Thu, 3 Oct 2019 08:15:59 +0000 (10:15 +0200)]
ofproto-dpif-xlate: Fix memory leak in is_neighbor_reply_correct() function

Memory leak happens while calling netdev_get_addr_list() function. This
function allocates memory for ip_addr and mask output arguments, but
this memory is never freed.

CC: Yifeng Sun <pkusunyifeng@gmail.com>
Fixes: dc0bd12f5b04 ("userspace: Enable non-bridge port as tunnel endpoint.")
Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agovlog: fix memory leak in vlog_set_log_file() function
Damijan Skvarc [Wed, 2 Oct 2019 11:44:49 +0000 (13:44 +0200)]
vlog: fix memory leak in vlog_set_log_file() function

memory leak happens in case previously closed log file was reopened again,
for example:

ovs-appctl vlog/close
ovs-appctl vlog/reopen

memory leak is reported by valgrind in a form:

==4463== 76 bytes in 1 blocks are definitely lost in loss record 322 of 344
==4463==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4463==    by 0x534314: xmalloc (util.c:138)
==4463==    by 0x534384: xmemdup0 (util.c:168)
==4463==    by 0x53ACB9: vlog_set_log_file (vlog.c:403)
==4463==    by 0x53AEDC: vlog_reopen_log_file (vlog.c:434)
==4463==    by 0x53AF22: vlog_unixctl_reopen (vlog.c:683)
==4463==    by 0x533730: process_command (unixctl.c:308)
==4463==    by 0x533730: run_connection (unixctl.c:342)
==4463==    by 0x533730: unixctl_server_run (unixctl.c:393)
==4463==    by 0x4073AE: main (ovs-vswitchd.c:128)

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-client: fix memory leak to prevent valgrind reporting memory leaks while runnin...
Damijan Skvarc [Wed, 2 Oct 2019 09:37:52 +0000 (11:37 +0200)]
ovsdb-client: fix memory leak to prevent valgrind reporting memory leaks while running test suite

memory leaks are reported in several tests and are expressed in a following way:

==29840== 208 (48 direct, 160 indirect) bytes in 1 blocks are definitely lost in
 loss record 43 of 44
==29840==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64
-linux.so)
==29840==    by 0x449D12: xcalloc (util.c:121)
==29840==    by 0x432949: jsonrpc_msg_from_json (jsonrpc.c:697)
==29840==    by 0x432A8F: jsonrpc_parse_received_message (jsonrpc.c:472)
==29840==    by 0x432A8F: jsonrpc_recv.part.7 (jsonrpc.c:338)
==29840==    by 0x4338F7: jsonrpc_recv (jsonrpc.c:1139)
==29840==    by 0x4338F7: jsonrpc_session_recv (jsonrpc.c:1112)
==29840==    by 0x40719B: do_wait (ovsdb-client.c:2463)
==29840==    by 0x405F76: main (ovsdb-client.c:282)

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoodp-util: calc checksum of ip hdr for tunnel encap
Martin Zhang [Tue, 1 Oct 2019 07:04:01 +0000 (15:04 +0800)]
odp-util: calc checksum of ip hdr for tunnel encap

Signed-off-by: Martin Zhang <martinbj2008@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoDocumentation: Document a useful pre-push hook for committers.
Ben Pfaff [Wed, 25 Sep 2019 20:02:31 +0000 (13:02 -0700)]
Documentation: Document a useful pre-push hook for committers.

Someone else wrote this script originally, I think, but I've extended
it quite a bit.

Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoMAINTAINERS: Add William Tu.
Ben Pfaff [Mon, 30 Sep 2019 20:50:53 +0000 (13:50 -0700)]
MAINTAINERS: Add William Tu.

William was elected by the Open vSwitch committers today.  Welcome to
the team, William!

Acked-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-client: fix memory leak in do_needs_conversion() and do_convert()
Damijan Skvarc [Mon, 30 Sep 2019 08:21:00 +0000 (10:21 +0200)]
ovsdb-client: fix memory leak in do_needs_conversion() and do_convert()

Memory leak itself is not so important, however the problem is that
it is caused by forgetting to close rpc channel which might in
a long term lead to the leak of system resources.

Memory leak is reported by Valgrin running test suite and is expressed as:

==29472== 784 (600 direct, 184 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 23
==29472==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29472==    by 0x449D32: xcalloc (util.c:121)
==29472==    by 0x432147: jsonrpc_open (jsonrpc.c:87)
==29472==    by 0x40ABBE: open_jsonrpc (ovsdb-client.c:528)
==29472==    by 0x40ABBE: open_rpc (ovsdb-client.c:143)
==29472==    by 0x40AE50: do_needs_conversion (ovsdb-client.c:1670)
==29472==    by 0x405F76: main (ovsdb-client.c:282)

==29464== 784 (600 direct, 184 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 23
==29464==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29464==    by 0x449D32: xcalloc (util.c:121)
==29464==    by 0x432147: jsonrpc_open (jsonrpc.c:87)
==29464==    by 0x40ABBE: open_jsonrpc (ovsdb-client.c:528)
==29464==    by 0x40ABBE: open_rpc (ovsdb-client.c:143)
==29464==    by 0x40AF5A: do_convert (ovsdb-client.c:1644)
==29464==    by 0x405F76: main (ovsdb-client.c:282)

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agocirrus: Fix typo in the name of sphinx package.
Ilya Maximets [Tue, 1 Oct 2019 09:02:57 +0000 (12:02 +0300)]
cirrus: Fix typo in the name of sphinx package.

This fixes broken build on CirrusCI:
https://cirrus-ci.com/build/4677435792031744

CC: Ben Pfaff <blp@ovn.org>
Fixes: 1ca0323e7c29 ("Require Python 3 and remove support for Python 2.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
4 years agoovsdb-client: fix memory leak in is_database_clustered() function.
Damijan Skvarc [Mon, 30 Sep 2019 07:40:48 +0000 (09:40 +0200)]
ovsdb-client: fix memory leak in is_database_clustered() function.

Memory leak is reported while running test suite. It is evidenced with the
following report:

==18447== 1,868 (48 direct, 1,820 indirect) bytes in 1 blocks are definitely lost in loss record 45 of 45
==18447==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18447==    by 0x449C02: xcalloc (util.c:121)
==18447==    by 0x432949: jsonrpc_msg_from_json (jsonrpc.c:697)
==18447==    by 0x432A8F: jsonrpc_parse_received_message (jsonrpc.c:472)
==18447==    by 0x432A8F: jsonrpc_recv.part.7 (jsonrpc.c:338)
==18447==    by 0x432D0B: jsonrpc_recv (jsonrpc.c:297)
==18447==    by 0x432D0B: jsonrpc_recv_block (jsonrpc.c:402)
==18447==    by 0x4330BB: jsonrpc_transact_block (jsonrpc.c:436)
==18447==    by 0x40A7C1: is_database_clustered (ovsdb-client.c:1624)
==18447==    by 0x40AE3F: do_needs_conversion (ovsdb-client.c:1670)
==18447==    by 0x405F76: main (ovsdb-client.c:282)

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoAUTHORS: Add Liu Chang.
Ben Pfaff [Mon, 30 Sep 2019 20:17:35 +0000 (13:17 -0700)]
AUTHORS: Add Liu Chang.

Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agouserspace-tunnelling.rst: Fix a typo in the userspace tunnel guide
Liu Chang [Sun, 29 Sep 2019 02:07:27 +0000 (10:07 +0800)]
userspace-tunnelling.rst: Fix a typo in the userspace tunnel guide

This commit fixes potential unintended mistake in userspace-tunneling guide: for the example in userspace-tunneling guide, there is no bridge named "br-eth1", but only a bridge name "br-phy" which has a port named "eth1"

Signed-off-by: Liu Chang <liuchang@cmss.chinamobile.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovn: Remove remaining pieces.
Ben Pfaff [Fri, 27 Sep 2019 16:21:57 +0000 (09:21 -0700)]
ovn: Remove remaining pieces.

A preceding commit removed the last remaining dependencies on OVN code,
so remove the OVN code.

Acked-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-cluster: Use ovs-vsctl instead of ovn-nbctl and ovn-sbctl.
Ben Pfaff [Fri, 27 Sep 2019 15:44:16 +0000 (08:44 -0700)]
ovsdb-cluster: Use ovs-vsctl instead of ovn-nbctl and ovn-sbctl.

This removes a dependency on OVN from the tests.

This adds some options to ovs-vsctl to allow it to be used for testing
the clustering feature.  The new options are undocumented because
they're really just useful for testing clustering.

Acked-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agodatapath: Fix conntrack cache with timeout
Yi-Hung Wei [Fri, 27 Sep 2019 21:14:17 +0000 (14:14 -0700)]
datapath: Fix conntrack cache with timeout

This patch is from the following upstream net-next commit along with
an updated system traffic test to avoid regression.

Upstream commit:
    commit 7177895154e6a35179d332f4a584d396c50d0612
    Author: Yi-Hung Wei <yihung.wei@gmail.com>
    Date:   Thu Aug 22 13:17:50 2019 -0700

        openvswitch: Fix conntrack cache with timeout

        This patch addresses a conntrack cache issue with timeout policy.
        Currently, we do not check if the timeout extension is set properly in the
        cached conntrack entry.  Thus, after packet recirculate from conntrack
        action, the timeout policy is not applied properly.  This patch fixes the
        aforementioned issue.

Fixes: 06bd2bdf19d2 ("openvswitch: Add timeout support to ct action")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.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>
4 years agoAUTHORS: Add Lukasz Pawlik.
Ian Stokes [Mon, 30 Sep 2019 12:23:29 +0000 (13:23 +0100)]
AUTHORS: Add Lukasz Pawlik.

Signed-off-by: Ian Stokes <ian.stokes@intel.com>
4 years agofatal-signal: Catch SIGSEGV and print backtrace.
William Tu [Fri, 27 Sep 2019 17:22:55 +0000 (10:22 -0700)]
fatal-signal: Catch SIGSEGV and print backtrace.

The patch catches the SIGSEGV signal and prints the backtrace
using libunwind at the monitor daemon. This makes debugging easier
when there is no debug symbol package or gdb installed on production
systems.

The patch works when the ovs-vswitchd compiles even without debug symbol
(no -g option), because the object files still have function symbols.
For example:
 |daemon_unix(monitor)|WARN|SIGSEGV detected, backtrace:
 |daemon_unix(monitor)|WARN|0x0000000000482752 <fatal_signal_handler+0x52>
 |daemon_unix(monitor)|WARN|0x00007fb4900734b0 <killpg+0x40>
 |daemon_unix(monitor)|WARN|0x00007fb49013974d <__poll+0x2d>
 |daemon_unix(monitor)|WARN|0x000000000052b348 <time_poll+0x108>
 |daemon_unix(monitor)|WARN|0x00000000005153ec <poll_block+0x8c>
 |daemon_unix(monitor)|WARN|0x000000000058630a <clean_thread_main+0x1aa>
 |daemon_unix(monitor)|WARN|0x00000000004ffd1d <ovsthread_wrapper+0x7d>
 |daemon_unix(monitor)|WARN|0x00007fb490b3b6ba <start_thread+0xca>
 |daemon_unix(monitor)|WARN|0x00007fb49014541d <clone+0x6d>
 |daemon_unix(monitor)|ERR|1 crashes: pid 122849 died, killed \
    (Segmentation fault), core dumped, restarting

However, if the object files' symbols are stripped, then we can only
get init function plus offset value. This is still useful when trying
to see if two bugs have the same root cause, Example:
 |daemon_unix(monitor)|WARN|SIGSEGV detected, backtrace:
 |daemon_unix(monitor)|WARN|0x0000000000482752 <_init+0x7d68a>
 |daemon_unix(monitor)|WARN|0x00007f5f7c8cf4b0 <killpg+0x40>
 |daemon_unix(monitor)|WARN|0x00007f5f7c99574d <__poll+0x2d>
 |daemon_unix(monitor)|WARN|0x000000000052b348 <_init+0x126280>
 |daemon_unix(monitor)|WARN|0x00000000005153ec <_init+0x110324>
 |daemon_unix(monitor)|WARN|0x0000000000407439 <_init+0x2371>
 |daemon_unix(monitor)|WARN|0x00007f5f7c8ba830 <__libc_start_main+0xf0>
 |daemon_unix(monitor)|WARN|0x0000000000408329 <_init+0x3261>
 |daemon_unix(monitor)|ERR|1 crashes: pid 106155 died, killed \
(Segmentation fault), core dumped, restarting

Most C library functions are not async-signal-safe, meaning that
it is not safe to call them from a signal handler, for example
printf() or fflush(). To be async-signal-safe, the handler only
collects the stack info using libunwind, which is signal-safe, and
issues 'write' to the pipe, where the monitor thread reads and
prints to ovs-vswitchd.log.

Tested-at: https://travis-ci.org/williamtu/ovs-travis/builds/590503433
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoRequire Python 3 and remove support for Python 2.
Ben Pfaff [Fri, 20 Sep 2019 15:30:42 +0000 (08:30 -0700)]
Require Python 3 and remove support for Python 2.

Python 2 reaches end-of-life on January 1, 2020, which is only
a few months away.  This means that OVS needs to stop depending
on in the next release that should occur roughly that same time.
Therefore, this commit removes all support for Python 2.  It
also makes Python 3 a mandatory build dependency.

Some of the interesting consequences:

- HAVE_PYTHON, HAVE_PYTHON2, and HAVE_PYTHON3 conditionals have
  been removed, since we now know that Python3 is available.

- $PYTHON and $PYTHON2 are removed, and $PYTHON3 is always
  available.

- Many tests for Python 2 support have been removed, and the ones
  that depended on Python 3 now run unconditionally.  This allowed
  several macros in the testsuite to be removed, making the code
  clearer.  This does make some of the changes to the testsuite
  files large due to indentation level changes.

- #! lines for Python now use /usr/bin/python3 instead of
  /usr/bin/python.

- Packaging depends on Python 3 packages.

Acked-by: Numan Siddique <nusiddiq@redhat.com>
Tested-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoofproto-dpif-xlate: Translate timeout policy in ct action
Yi-Hung Wei [Wed, 28 Aug 2019 22:14:29 +0000 (15:14 -0700)]
ofproto-dpif-xlate: Translate timeout policy in ct action

This patch derives the timeout policy based on ct zone from the
internal data structure that we maintain on dpif layer.

It also adds a system traffic test to verify the zone-based conntrack
timeout feature.  The test uses ovs-vsctl commands to configure
the customized ICMP and UDP timeout on zone 5 to a shorter period.
It then injects ICMP and UDP traffic to conntrack, and checks if the
corresponding conntrack entry expires after the predefined timeout.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
ofproto-dpif: Checks if datapath supports OVS_CT_ATTR_TIMEOUT

This patch checks whether datapath supports OVS_CT_ATTR_TIMEOUT. With this
check, ofproto-dpif-xlate can use this information to decide whether to
translate the ct timeout policy.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agodatapath: Add support for conntrack timeout policy
Yi-Hung Wei [Wed, 28 Aug 2019 22:14:28 +0000 (15:14 -0700)]
datapath: Add support for conntrack timeout policy

This patch adds support for specifying a timeout policy for a
connection in connection tracking system in kernel datapath.
The timeout policy will be attached to a connection when the
connection is committed to conntrack.

This patch introduces a new odp field OVS_CT_ATTR_TIMEOUT in the
ct action that specifies the timeout policy in the datapath.
In the following patch, during the upcall process, the vswitchd will use
the ct_zone to look up the corresponding timeout policy and fill
OVS_CT_ATTR_TIMEOUT if it is available.

The datapath code is from the following two net-next upstream commits.

Upstream commit:
commit 06bd2bdf19d2f3d22731625e1a47fa1dff5ac407
Author: Yi-Hung Wei <yihung.wei@gmail.com>
Date:   Tue Mar 26 11:31:14 2019 -0700

    openvswitch: Add timeout support to ct action

    Add support for fine-grain timeout support to conntrack action.
    The new OVS_CT_ATTR_TIMEOUT attribute of the conntrack action
    specifies a timeout to be associated with this connection.
    If no timeout is specified, it acts as is, that is the default
    timeout for the connection will be automatically applied.

    Example usage:
    $ nfct timeout add timeout_1 inet tcp syn_sent 100 established 200
    $ ovs-ofctl add-flow br0 in_port=1,ip,tcp,action=ct(commit,timeout=timeout_1)

CC: Pravin Shelar <pshelar@ovn.org>
CC: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
commit 6d670497e01803b486aa72cc1a718401ab986896
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Apr 2 09:53:14 2019 +0300

    openvswitch: use after free in __ovs_ct_free_action()

    We free "ct_info->ct" and then use it on the next line when we pass it
    to nf_ct_destroy_timeout().  This patch swaps the order to avoid the use
    after free.

Fixes: 06bd2bdf19d2 ("openvswitch: Add timeout support to ct action")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agodatapath: compat: Backport nf_conntrack_timeout support
Yi-Hung Wei [Wed, 28 Aug 2019 22:14:27 +0000 (15:14 -0700)]
datapath: compat: Backport nf_conntrack_timeout support

This patch brings in nf_ct_timeout_put() and nf_ct_set_timeout()
when it is not available in the kernel.

Three symbols are created in acinclude.m4.

* HAVE_NF_CT_SET_TIMEOUT is used to determine if upstream net-next commit
717700d183d65 ("netfilter: Export nf_ct_{set,destroy}_timeout()") is
availabe.  If it is defined, the kernel should have all the
nf_conntrack_timeout support that OVS needs.

* HAVE_NF_CT_TIMEOUT is used to check if upstream net-next commit
6c1fd7dc489d9 ("netfilter: cttimeout: decouple timeout policy from
nfnetlink_cttimeout object") is there.  If it is not defined, we
will use the old ctnl_timeout interface rather than the nf_ct_timeout
interface that is introduced in this commit.

* HAVE_NF_CT_TIMEOUT_FIND_GET_HOOK_NET is used to check if upstream
commit 19576c9478682 ("netfilter: cttimeout: add netns support") is
there, so that we pass different arguement based on whether the kernel
has netns support.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agoofproto-dpif: Consume CT_Zone, and CT_Timeout_Policy tables
Yi-Hung Wei [Wed, 28 Aug 2019 22:14:26 +0000 (15:14 -0700)]
ofproto-dpif: Consume CT_Zone, and CT_Timeout_Policy tables

This patch consumes the CT_Zone and CT_Timeout_Policy tables, maintains
the zone-based configuration in the vswitchd.  Whenever there is a
database change, vswitchd will read the datapath, CT_Zone, and
CT_Timeout_Policy tables from ovsdb, builds an internal snapshot of the
database configuration in bridge.c, and pushes down the change into
ofproto and dpif layer.

If a new zone-based timeout policy is added, it updates the zone to
timeout policy mapping in the per datapath type datapath structure in
dpif-backer, and pushes down the timeout policy into the datapath via
dpif interface.

If a timeout policy is no longer used, for kernel datapath, vswitchd
may not be able to remove it from datapath immediately since
datapath flows can still reference the to-be-deleted timeout policies.
Thus, we keep an timeout policy kill list, that vswitchd will go
back to the list periodically and try to kill the unused timeout policies.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agosimap: Add utility function to help compare two simaps.
Ben Pfaff [Wed, 28 Aug 2019 22:14:25 +0000 (15:14 -0700)]
simap: Add utility function to help compare two simaps.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agoct-dpif, dpif-netlink: Add conntrack timeout policy support
Yi-Hung Wei [Wed, 28 Aug 2019 22:14:24 +0000 (15:14 -0700)]
ct-dpif, dpif-netlink: Add conntrack timeout policy support

This patch first defines the dpif interface for a datapath to support
adding, deleting, getting and dumping conntrack timeout policy.
The timeout policy is identified by a 4 bytes unsigned integer in
datapath, and it currently support timeout for TCP, UDP, and ICMP
protocols.

Moreover, this patch provides the implementation for Linux kernel
datapath in dpif-netlink.

In Linux kernel, the timeout policy is maintained per L3/L4 protocol,
and it is identified by 32 bytes null terminated string.  On the other
hand, in vswitchd, the timeout policy is a generic one that consists of
all the supported L4 protocols.  Therefore, one of the main task in
dpif-netlink is to break down the generic timeout policy into 6
sub policies (ipv4 tcp, udp, icmp, and ipv6 tcp, udp, icmp),
and push down the configuration using the netlink API in
netlink-conntrack.c.

This patch also adds missing symbols in the windows datapath so
that the build on windows can pass.

Appveyor CI:
* https://ci.appveyor.com/project/YiHungWei/ovs/builds/26387754

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agoct-dpif: Export ct_dpif_format_ipproto()
Yi-Hung Wei [Wed, 28 Aug 2019 22:14:23 +0000 (15:14 -0700)]
ct-dpif: Export ct_dpif_format_ipproto()

This function will be useful for following patches.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Acked-by: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agoovs-vsctl: Add conntrack zone commands.
William Tu [Wed, 28 Aug 2019 22:14:22 +0000 (15:14 -0700)]
ovs-vsctl: Add conntrack zone commands.

The patch adds commands creating/deleting/listing conntrack zone
timeout policies:
  $ ovs-vsctl {add,del,list}-zone-tp dp zone=zone_id ...

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
4 years agotravis: Drop -MD related workaround for sparse.
Ilya Maximets [Thu, 26 Sep 2019 09:03:09 +0000 (12:03 +0300)]
travis: Drop -MD related workaround for sparse.

The issue was fixed in upstream sparse by the following commit:
d90c0838c101 ("cgcc: fix wrong processing of -MD & -MMD")

This patch is required to fix our travis build.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Ian Stokes <ian.stokes@intel.com>
4 years agodpdk: Remove unneeded log message copy.
David Marchand [Fri, 6 Sep 2019 11:26:02 +0000 (13:26 +0200)]
dpdk: Remove unneeded log message copy.

No need to duplicate and null-terminate the passed buffer.
We can directly give it to the vlog subsystem using a dynamic precision
in the format string.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
4 years agoflow: fix incorrect padding length checking in ipv6_sanity_check
Yanqin Wei [Mon, 2 Sep 2019 08:36:47 +0000 (16:36 +0800)]
flow: fix incorrect padding length checking in ipv6_sanity_check

The padding length is (packet size - ipv6 header length - ipv6 plen).  This
patch fixes incorrect padding size checking in ipv6_sanity_check.

Acked-by: William Tu <u9012063@gmail.com>
Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoshow "rx_missed_errors" counter in interface statisics
txfh2007 [Tue, 3 Sep 2019 11:28:26 +0000 (19:28 +0800)]
show "rx_missed_errors" counter in interface statisics

Hi all:

    Currently OVS maintains several Statistics counters per interface. "rx_missed_errors" counter is amount them and collects pkts not received due to local resource constaints. Many ovs netdevs support collecting this counter, such as netdev-linux, netdev-dpdk, netdev-bsd and so on. But as far as I know, this counter can't be read by command "ovs-vsctl list interface <int-name>|grep statistics". I have found the root cause(may be I was wrong) is in task "iface_refresh_stats", the "rx_missed_errors" is not in the macro IFACE_STATS. So even if this counter is updated by netdev, it woundn't be read by users.

    This simple patch tries to solve this problem, many thanks for your kindly reminder.

Signed-off-by: Liu Chang <liuchang@cmss.chinamobile.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agotreewide: Use packet batch APIs
Paul Chaignon [Sun, 1 Sep 2019 13:10:05 +0000 (15:10 +0200)]
treewide: Use packet batch APIs

This patch replaces direct accesses to dp_packet_batch and dp_packet
internal components by the appropriate API calls.  It extends commit
1270b6e52 (treewide: Wider use of packet batch APIs).

This patch was generated using the following semantic patch (cf.
http://coccinelle.lip6.fr).

// <smpl>
@ dp_packet @
struct dp_packet_batch *b1;
struct dp_packet_batch b2;
struct dp_packet *p;
expression e;
@@

(
- b1->packets[b1->count++] = p;
+ dp_packet_batch_add(b1, p);
|
- b2.packets[b2.count++] = p;
+ dp_packet_batch_add(&b2, p);
|
- p->packet_type == htonl(PT_ETH)
+ dp_packet_is_eth(p)
|
- p->packet_type != htonl(PT_ETH)
+ !dp_packet_is_eth(p)
|
- b1->count == 0
+ dp_packet_batch_is_empty(b1)
|
- !b1->count
+ dp_packet_batch_is_empty(b1)
|
  b1->count = e;
|
  b1->count++
|
  b2.count = e;
|
  b2.count++
|
- b1->count
+ dp_packet_batch_size(b1)
|
- b2.count
+ dp_packet_batch_size(&b2)
)
// </smpl>

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoAdd a __str__ method to idl.Row
Terry Wilson [Tue, 3 Sep 2019 23:27:18 +0000 (18:27 -0500)]
Add a __str__ method to idl.Row

It's sometimes handy to log an entire Row object, so this just
adds a string representation of the object as:

   Tablename(col1=val1, col2=val2, ..., coln=valn)

Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agouserspace: Enable non-bridge port as tunnel endpoint.
Yifeng Sun [Thu, 5 Sep 2019 17:40:28 +0000 (10:40 -0700)]
userspace: Enable non-bridge port as tunnel endpoint.

For userspace datapath, currently only the bridge itself, the LOCAL port,
can be the tunnel endpoint to encap/decap tunnel packets.  This patch
enables non-bridge port as tunnel endpoint.  One use case is for users to
create a bridge and a vtep port as tap, and configure underlay IP at vtep
port as the tunnel endpoint.

This patch causes failure for test "ptap - L3 over patch port". This is
because this test is already using non-bridge port gre1 as tunnel endpoint.
In this test, a flow is added to redirect tunnel packets to gre1 port,
as shown below:
  ovs-ofctl add-flow br1 in_port=p1,actions=output=gre1

It later generates a datapath flow which matches an extra eth field:
  - recirc_id(0),...,eth_type(0x0800),...
  + recirc_id(0),...,eth(dst=1e:2c:e9:2a:66:9e),eth_type(0x0800),...

With this patch, this flow need only a NORMAL action.

Signed-off-by: William Tu <u9012063@gmail.com>
Co-authored-by: William Tu <u9012063@gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agovswitchd: update bond-rebalance-interval maxInteger in vswtich.xml
Eelco Chaudron [Wed, 11 Sep 2019 08:33:57 +0000 (10:33 +0200)]
vswitchd: update bond-rebalance-interval maxInteger in vswtich.xml

According to the documentation in the vswtich.xml the maximum
configurable bond-rebalance-interval is 10000ms. However, this is not
enforced anywhere in the code and people are using larger values in
the field.

To avoid confusion this change changes the maximum value the
2147483647 which will fit in 32bit integer. This will allow a value of
~25 days, which should be enough to cover everybody's needs. Note that
a value of 0 disables the automatic rebalancing anyway.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoconntrack: Add option to disable TCP sequence checking.
Darrell Ball [Wed, 25 Sep 2019 21:09:41 +0000 (14:09 -0700)]
conntrack: Add option to disable TCP sequence checking.

This may be needed in some special cases, such as to support some hardware
offload implementations.  Note that disabling TCP sequence number
verification is not an optimization in itself, but supporting some
hardware offload implementations may offer better performance.  TCP
sequence number verification is enabled by default.  This option is only
available for the userspace datapath.  Access to this option is presently
provided via 'dpctl' commands as the need for this option is quite node
specific, by virtue of which nics are in use on a given node.  A test is
added to verify this option.

Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2019-May/359188.html
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoExclude ovn-nb/ovn-sb man and OVN schema files during compilation.
Numan Siddique [Tue, 10 Sep 2019 09:40:42 +0000 (15:10 +0530)]
Exclude ovn-nb/ovn-sb man and OVN schema files during compilation.

The commit [1] removed OVN, but had to leave out some OVN bits
for the ovsdb-server raft testing. But "make install" is installing
ovn-nb/ovn-sb man entries and OVN schema files.

This patch excludes these.

"make install" is also installing ovn-nbctl/ovn-sbctl and this still needs to
be addressed.

[1] - f3e24610ea8("Remove OVN.")

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoflake8: also check the ovs-check-dead-ifs script
Aaron Conole [Fri, 13 Sep 2019 17:29:03 +0000 (13:29 -0400)]
flake8: also check the ovs-check-dead-ifs script

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovs-check-dead-ifs: unshadow pid variable
Aaron Conole [Fri, 13 Sep 2019 17:29:02 +0000 (13:29 -0400)]
ovs-check-dead-ifs: unshadow pid variable

The pid variable is being shadowed by the list comprehension in the
os.execvp() call.  This can generate flakes / warnings in some environments
so fix it.

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovs-check-dead-ifs: python3 print format
Aaron Conole [Fri, 13 Sep 2019 17:29:01 +0000 (13:29 -0400)]
ovs-check-dead-ifs: python3 print format

The print call changed in python3, so update it.

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoconntrack: Optimize recirculations.
Darrell Ball [Mon, 26 Aug 2019 16:05:44 +0000 (09:05 -0700)]
conntrack: Optimize recirculations.

Cache the 'conn' context and use it when it is valid.  The cached 'conn'
context will get reset if it is not expected to be valid; the cost to do
this is negligible.  Besides being most optimal, this also handles corner
cases, such as decapsulation leading to the same tuple, as in tunnel VPN
cases.  A negative test is added to check the resetting of the cached
'conn'.

Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoconntrack: Fix 'reverse_nat_packet()' variable datatype.
Darrell Ball [Fri, 30 Aug 2019 16:13:19 +0000 (09:13 -0700)]
conntrack: Fix 'reverse_nat_packet()' variable datatype.

The datatype 'pad' in the function 'reverse_nat_packet()' was incorrectly
declared as 'char' instead of 'uint8_t'. This can affect reverse natting
of icmpX packets with padding > 127 bytes.  At the same time, add some
comments regarding 'extract_l3_ipvX' usage in this function.  Found by
inspection.

Fixes: edd1bef468c0 ("dpdk: Add more ICMP Related NAT support.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-idlc.in: fix dict change during iteration.
Flavio Leitner [Sat, 14 Sep 2019 23:17:28 +0000 (20:17 -0300)]
ovsdb-idlc.in: fix dict change during iteration.

Python3 complains if a dict key is changed during the
iteration.

Use list() to create a copy of it.

Traceback (most recent call last):
  File "./ovsdb/ovsdb-idlc.in", line 1581, in <module>
    func(*args[1:])
  File "./ovsdb/ovsdb-idlc.in", line 185, in printCIDLHeader
    replace_cplusplus_keyword(schema)
  File "./ovsdb/ovsdb-idlc.in", line 179, in replace_cplusplus_keyword
    for columnName in table.columns:
RuntimeError: dictionary keys changed during iteration

Signed-off-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoconntrack: Fix 'check_orig_tuple()' Valgrind false positive.
Darrell Ball [Mon, 23 Sep 2019 23:44:33 +0000 (16:44 -0700)]
conntrack: Fix 'check_orig_tuple()' Valgrind false positive.

Valgrind reported that 'pkt->md.ct_orig_tuple.ipv4.ipv4_proto' is
uninitialized in 'check_orig_tuple()', if 'ct_state' is zero.  Although
this is true, the check is superceded, as even if it succeeds the check
for natted packets based on 'ct_state' is an ORed condition and is intended
to catch this case.
The check is '!(pkt->md.ct_state & (CS_SRC_NAT | CS_DST_NAT))' which
filters out all packets excepted natted ones.  Move this check up to
prevent the Valgrind complaint, which also helps performance and also remove
recenlty added redundant check adding extra cycles.

Fixes: f44733c527da ("conntrack: Validate accessing of conntrack data in pkt_metadata.")
CC: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoAUTHORS: Add Martin Zhang and Dujie.
Ben Pfaff [Tue, 24 Sep 2019 19:51:05 +0000 (12:51 -0700)]
AUTHORS: Add Martin Zhang and Dujie.

Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoodp-util: fill IPv4 ver and head length for tnl_push
Martin Zhang [Mon, 23 Sep 2019 17:26:42 +0000 (01:26 +0800)]
odp-util: fill IPv4 ver and head length for tnl_push

    When parse tnl_push, if IPv4 is used,
    we forget to fill the ipv4 version and ip header length fields.

    so there is a wrong ip header in the header of "struct ovs_action_push_tnl",
    which will caused wrong packdet sent by dpcl.

    test command:
    ovs-appctl dpctl/add-flow "in_port(1),eth_type(0x0800),ipv4(dst=9.9.9.6)" \
    "tnl_push(tnl_port(2),header(size=50,type=4,eth(dst=08:00:27:2e:87:0d,src=98:03:9b:c6:d1:7c,dl_type=0x0800), \
    ipv4(src=10.97.240.147,dst=10.96.74.33,proto=17,tos=0,ttl=64,frag=0x4000), \
    udp(src=0,dst=4789,csum=0x0),vxlan(flags=0x8000000,vni=0x270f)),out_port(3)),4"

Signed-off-by: Martin Zhang <martinbj2008@gmail.com>
Signed-off-by: Dujie <dujie@didiglobal.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovs-ofctl: fix memory leak in open_vconn__() function
Damijan Skvarc [Tue, 24 Sep 2019 13:41:22 +0000 (15:41 +0200)]
ovs-ofctl: fix memory leak in open_vconn__() function

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoDocumentation: Fix security mailing list address.
Ben Pfaff [Mon, 23 Sep 2019 19:38:56 +0000 (12:38 -0700)]
Documentation: Fix security mailing list address.

We don't own ovs.org, and I doubt Ojai Valley School would enjoy
receiving our email.

Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agovswitchd: Make packet-in controller queue size configurable
Dumitru Ceara [Fri, 2 Aug 2019 08:29:52 +0000 (10:29 +0200)]
vswitchd: Make packet-in controller queue size configurable

The ofconn packet-in queue for packets that can't be immediately sent
on the rconn connection was limited to 100 packets (hardcoded value).
While increasing this limit is usually not recommended as it might
create buffer bloat and increase latency, in scaled scenarios it is
useful if the administrator (or CMS) can adjust the queue size.

One such situation was noticed while performing scale testing of the
OVN IGMP functionality: triggering ~200 simultaneous IGMP reports
was causing tail drops on the packet-in queue towards ovn-controller.

This commit adds the possibility to configure the queue size for:
- management controller (br-int.mgmt): through the
  other_config:controller-queue-size column of the Bridge table. This
  value is limited to 512 as large queues definitely affect latency. If
  not present the default value of 100 is used. This is done in order to
  maintain the same default behavior as before the commit.
- other controllers: through the controller_queue_size column of the
  Controller table. This value is also limited to 512. If not present
  the code uses the Bridge:other_config:controller-queue-size
  configuration.

Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoovsdb-tool: Convert clustered db to standalone db.
Aliasgar Ginwala [Fri, 30 Aug 2019 15:28:34 +0000 (08:28 -0700)]
ovsdb-tool: Convert clustered db to standalone db.

Add support in ovsdb-tool for migrating clustered dbs to standalone dbs.
E.g. usage to migrate nb/sb db to standalone db from raft:
ovsdb-tool cluster-to-standalone ovnnb_db.db ovnnb_db_cluster.db

Acked-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Aliasgar Ginwala <aginwala@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agovswitch: ratelimit the device add log
Aaron Conole [Mon, 16 Sep 2019 15:16:57 +0000 (11:16 -0400)]
vswitch: ratelimit the device add log

It's possible that a port added to the system with certain kinds
of invalid parameters will cause the 'could not add' log to be
triggered.  When this happens, the vswitch run loop can continually
re-attempt adding the port.  While the parameters remain invalid
the vswitch run loop will re-trigger the warning, flooding the
syslog.

This patch adds a simple rate limit to the log.

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agostream_ssl: fix important memory leak in ssl_connect() function
Damijan Skvarc [Fri, 20 Sep 2019 16:51:54 +0000 (09:51 -0700)]
stream_ssl: fix important memory leak in ssl_connect() function

While checking valgrind reports after running "make check-valgrind" I have noticed
reports for several tests similar to the following:

....
==5345== Memcheck, a memory error detector
==5345== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==5345== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==5345== Command: ovsdb-client --private-key=/home/damijan.skvarc/doma/ovs/tests/testpki-privkey.pem --certificate=/home/damijan.skvarc/doma/ovs/tests/testpki-cert.pem --ca-cert=/home/damijan.skvarc/doma/ovs/tests/testpki-cacert.pem transact ssl:127.0.0.1:40111 \ \ \ ["ordinals",
==5345== \ \ \ \ \ \ {"op":\ "update",
==5345== \ \ \ \ \ \ \ "table":\ "ordinals",
==5345== \ \ \ \ \ \ \ "where":\ [["number",\ "==",\ 1]],
==5345== \ \ \ \ \ \ \ "row":\ {"number":\ 2,\ "name":\ "old\ two"}},
==5345== \ \ \ \ \ \ {"op":\ "update",
==5345== \ \ \ \ \ \ \ "table":\ "ordinals",
==5345== \ \ \ \ \ \ \ "where":\ [["name",\ "==",\ "two"]],
==5345== \ \ \ \ \ \ \ "row":\ {"number":\ 1,\ "name":\ "old\ one"}}]
==5345== Parent PID: 5344
==5345==
==5345==
==5345== HEAP SUMMARY:
==5345==     in use at exit: 116,551 bytes in 3,341 blocks
==5345==   total heap usage: 5,134 allocs, 1,793 frees, 412,290 bytes allocated
==5345==
==5345== 6,221 (184 direct, 6,037 indirect) bytes in 1 blocks are definitely lost in loss record 498 of 500
==5345==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5345==    by 0x5105E77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5345==    by 0x51E1D23: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5345==    by 0x51E4861: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5345==    by 0x51E5414: ASN1_item_ex_d2i (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5345==    by 0x51E546A: ASN1_item_d2i (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5345==    by 0x4E56B27: ??? (in /lib/x86_64-linux-gnu/libssl.so.1.0.0)
==5345==    by 0x4E5BA11: ??? (in /lib/x86_64-linux-gnu/libssl.so.1.0.0)
==5345==    by 0x4E65145: ??? (in /lib/x86_64-linux-gnu/libssl.so.1.0.0)
==5345==    by 0x4522DF: ssl_connect (stream-ssl.c:530)
==5345==    by 0x443D38: scs_connecting (stream.c:315)
==5345==    by 0x443D38: stream_connect (stream.c:338)
==5345==    by 0x443FA1: stream_open_block (stream.c:266)
==5345==    by 0x40AB79: open_jsonrpc (ovsdb-client.c:507)
==5345==    by 0x40AB79: open_rpc (ovsdb-client.c:143)
==5345==    by 0x40B06B: do_transact__ (ovsdb-client.c:871)
==5345==    by 0x40B245: do_transact (ovsdb-client.c:893)
==5345==    by 0x405F76: main (ovsdb-client.c:282)
==5345==
==5345== LEAK SUMMARY:
==5345==    definitely lost: 184 bytes in 1 blocks
==5345==    indirectly lost: 6,037 bytes in 117 blocks
==5345==      possibly lost: 0 bytes in 0 blocks
==5345==    still reachable: 110,330 bytes in 3,223 blocks
==5345==         suppressed: 0 bytes in 0 blocks
==5345== Reachable blocks (those to which a pointer was found) are not shown.
==5345== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==5345==
==5345== For counts of detected and suppressed errors, rerun with: -v
==5345== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
....

This report was extracted from "index uniqueness checking" test and complains about
leaking memory in ovsdb-client application. The problem is not huge, since ovsdb-client
is CLI tool which is constantly reinvoked/restarted, thus leaked memory is not accumulated.

More problematic issue is that for the same test valgrind reports the similar problem also for
ovsdb-server:

....
==5290== Memcheck, a memory error detector
==5290== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==5290== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==5290== Command: ovsdb-server --log-file --detach --no-chdir --pidfile --private-key=/home/damijan.skvarc/doma/ovs/tests/testpki-privkey2.pem --certificate=/home/damijan.skvarc/doma/ovs/tests/testpki-cert2.pem --ca-cert=/home/damijan.skvarc/doma/ovs/tests/testpki-cacert.pem --remote=pssl:0:127.0.0.1 db
==5290== Parent PID: 5289
==5290==
==5292== Warning: noted but unhandled ioctl 0x2403 with no size/direction hints.
==5292==    This could cause spurious value errors to appear.
==5292==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==5292== Warning: noted but unhandled ioctl 0x2400 with no size/direction hints.
==5292==    This could cause spurious value errors to appear.
==5292==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==5290==
==5290== HEAP SUMMARY:
==5290==     in use at exit: 2,066 bytes in 48 blocks
==5290==   total heap usage: 87 allocs, 39 frees, 14,152 bytes allocated
==5290==
==5290== LEAK SUMMARY:
==5290==    definitely lost: 0 bytes in 0 blocks
==5290==    indirectly lost: 0 bytes in 0 blocks
==5290==      possibly lost: 0 bytes in 0 blocks
==5290==    still reachable: 2,066 bytes in 48 blocks
==5290==         suppressed: 0 bytes in 0 blocks
==5290== Reachable blocks (those to which a pointer was found) are not shown.
==5290== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==5290==
==5290== For counts of detected and suppressed errors, rerun with: -v
==5290== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1)
==5292== Warning: noted but unhandled ioctl 0x2401 with no size/direction hints.
==5292==    This could cause spurious value errors to appear.
==5292==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==5292==
==5292== HEAP SUMMARY:
==5292==     in use at exit: 164,018 bytes in 4,252 blocks
==5292==   total heap usage: 17,910 allocs, 13,658 frees, 1,907,468 bytes allocated
==5292==
==5292== 49,720 (1,472 direct, 48,248 indirect) bytes in 8 blocks are definitely lost in loss record 580 of 580
==5292==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5292==    by 0x5105E77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5292==    by 0x51E1D23: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5292==    by 0x51E4861: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5292==    by 0x51E5414: ASN1_item_ex_d2i (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5292==    by 0x51E546A: ASN1_item_d2i (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==5292==    by 0x4E53E00: ??? (in /lib/x86_64-linux-gnu/libssl.so.1.0.0)
==5292==    by 0x4E55727: ??? (in /lib/x86_64-linux-gnu/libssl.so.1.0.0)
==5292==    by 0x452C4B: ssl_connect (stream-ssl.c:530)
==5292==    by 0x445B18: scs_connecting (stream.c:315)
==5292==    by 0x445B18: stream_connect (stream.c:338)
==5292==    by 0x445B91: stream_recv (stream.c:369)
==5292==    by 0x432A9C: jsonrpc_recv.part.7 (jsonrpc.c:310)
==5292==    by 0x433977: jsonrpc_recv (jsonrpc.c:1139)
==5292==    by 0x433977: jsonrpc_session_recv (jsonrpc.c:1112)
==5292==    by 0x40CCE3: ovsdb_jsonrpc_session_run (jsonrpc-server.c:553)
==5292==    by 0x40CCE3: ovsdb_jsonrpc_session_run_all (jsonrpc-server.c:586)
==5292==    by 0x40CCE3: ovsdb_jsonrpc_server_run (jsonrpc-server.c:401)
==5292==    by 0x40682E: main_loop (ovsdb-server.c:209)
==5292==    by 0x40682E: main (ovsdb-server.c:460)
==5292==
==5292== LEAK SUMMARY:
==5292==    definitely lost: 1,472 bytes in 8 blocks
==5292==    indirectly lost: 48,248 bytes in 936 blocks
==5292==      possibly lost: 0 bytes in 0 blocks
==5292==    still reachable: 114,298 bytes in 3,308 blocks
==5292==         suppressed: 0 bytes in 0 blocks
==5292== Reachable blocks (those to which a pointer was found) are not shown.
==5292== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==5292==
==5292== For counts of detected and suppressed errors, rerun with: -v
==5292== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 1 from 1)
....

In this case ovsdb-server is running as daemon process (--detach option) and leaking memory is
accumulated whenever ovsdb-client is reconnected. Within observed test ovsdb-client CLI tool
connects 8 times to ovsdb-server. Leaked memory in ovsdb-client (for each invocation) is approx.
6K bytes, while leaked memory in ovsdb-server is aprox. 48Kbytes what is actually 8*6K. Thus per
each connection both ovsdb-client and ovsdb-server leak approx. 6K bytes.

I have done a small manual test to check if ovsdb-server is indeed accumulating leaked memory
by dumping ovsdb-server in a loop:

console1:
ovsdb-server \
--log-file \
--detach --no-chdir --pidfile \
--private-key=testpki-privkey2.pem \
--certificate=testpki-cert2.pem \
--ca-cert=testpki-cacert.pem \
--remote=pssl:0:127.0.0.1 \
db

while (true); do \
ovsdb-client \
--private-key=testpki-privkey.pem \
--certificate=testpki-cert.pem \
--ca-cert=testpki-cacert.pem \
dump ssl:127.0.0.1:42067; \
done

console2:
watch -n 0.5 'cat /proc/$(pidof ovsdb-server)/status | grep VmSize'

In console2 it was evidently seen ovsdb-server is constantly leaking memory. After a while
(i.e. after a certain number of reconnections) the OOM killer jumps out and kills ovsdb-server.

Very similar situation was already noticed and described in
https://github.com/openvswitch/ovs-issues/issues/168. There, the problem pops up while connecting
controller to ovs-vswitchd daemon.

Valgrind reports point to a problem in openssl library, however after studying openssl code for
a while I have found out the problem is actually in ovs. When connection through SSL channel is
taken place openssl library allocates memory for keeping track of certificate. Reference to this
memory works very similar as std::shared_ptr pointer in recent C++ dialects. i.e. when allocated
memory is referenced its reference counter is incremented and decremented after the memory is
derefered. When reference counter becomes zero allocated memory is automatically deallocated.

In openssl library environment certificate is retrieved by calling SSL_get_peer_certificate()
where its reference counter is incremented. After retrieved certificate is not used any more its
reference counter must be decremented by calling X509_free(). If not, allocated memory is never
freed despite the ssl connection is properly closed.

The problem was caused in stream-ssl.c in function ssl_connect(), which retrieves common peer name
by calling SSL_get_peer_certificate() function and without calling X509_free() function afterwards.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agofaq: Update OVS/DPDK version table for OVS 2.12.
Kevin Traynor [Mon, 23 Sep 2019 15:59:11 +0000 (16:59 +0100)]
faq: Update OVS/DPDK version table for OVS 2.12.

Indicate that OVS 2.12 uses DPDK 18.11.2.

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoconfigure: Properly handle case where sphinx-build is not available.
Ben Pfaff [Fri, 20 Sep 2019 19:00:13 +0000 (12:00 -0700)]
configure: Properly handle case where sphinx-build is not available.

Fixes: ab4514890587 ("Recommend Sphinx from Python 3 in documentation and packaging.")
Reported-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoxenserver: Make Python files parse in Python 3 also.
Ben Pfaff [Wed, 18 Sep 2019 15:01:40 +0000 (08:01 -0700)]
xenserver: Make Python files parse in Python 3 also.

I don't actually have any idea whether XenServer has moved
forward to Python 3 these days, but these files are still
OK in Python 2.x as well.

The rest of the Python files in OVS seem to already be OK in
Python 3.

Acked-by: Numan Siddique <nusididq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoRecommend Sphinx from Python 3 in documentation and packaging.
Ben Pfaff [Mon, 16 Sep 2019 19:05:36 +0000 (12:05 -0700)]
Recommend Sphinx from Python 3 in documentation and packaging.

Acked-by: Numan Siddique <nusididq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoDocumentation: Work with sphinx-build for Python 3 also.
Ben Pfaff [Mon, 16 Sep 2019 18:56:59 +0000 (11:56 -0700)]
Documentation: Work with sphinx-build for Python 3 also.

There's nothing in OVS specific to Sphinx for Python 2, but the
compile-time check only looked for a binary named "sphinx-build", which is
typically provided only for Python 2.  With Python 3, the binary is
typically called "sphinx-build-3".  With this commit, either name is
accepted.

Acked-by: Numan Siddique <nusididq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agotravis: Dump config.log if make fails.
Ben Pfaff [Wed, 18 Sep 2019 21:34:17 +0000 (14:34 -0700)]
travis: Dump config.log if make fails.

This is sometimes useful for debugging.

Acked-by: Numan Siddique <nusididq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agotravis: Obtain testsuite logs from the correct directory.
Ben Pfaff [Wed, 18 Sep 2019 16:23:36 +0000 (09:23 -0700)]
travis: Obtain testsuite logs from the correct directory.

These days Automake uses _build/sub for its distcheck builds, not
plain _build.  (I don't know whether that is a change from previous
versions.)

Acked-by: Numan Siddique <nusididq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
4 years agoconntrack: Validate accessing of conntrack data in pkt_metadata
Yifeng Sun [Wed, 11 Sep 2019 21:18:36 +0000 (14:18 -0700)]
conntrack: Validate accessing of conntrack data in pkt_metadata

Valgrind reported:

1305: ofproto-dpif - conntrack - ipv6

==26942== Conditional jump or move depends on uninitialised value(s)
==26942==    at 0x587C00: check_orig_tuple (conntrack.c:1006)
==26942==    by 0x587C00: process_one (conntrack.c:1141)
==26942==    by 0x587C00: conntrack_execute (conntrack.c:1220)
==26942==    by 0x47B00F: dp_execute_cb (dpif-netdev.c:7305)
==26942==    by 0x4AF756: odp_execute_actions (odp-execute.c:794)
==26942==    by 0x477532: dp_netdev_execute_actions (dpif-netdev.c:7349)
==26942==    by 0x477532: handle_packet_upcall (dpif-netdev.c:6630)
==26942==    by 0x477532: fast_path_processing (dpif-netdev.c:6726)
==26942==    by 0x47933C: dp_netdev_input__ (dpif-netdev.c:6814)
==26942==    by 0x479AB8: dp_netdev_input (dpif-netdev.c:6852)
==26942==    by 0x479AB8: dp_netdev_process_rxq_port (dpif-netdev.c:4287)
==26942==    by 0x47A6A9: dpif_netdev_run (dpif-netdev.c:5264)
==26942==    by 0x4324E7: type_run (ofproto-dpif.c:342)
==26942==    by 0x41C5FE: ofproto_type_run (ofproto.c:1734)
==26942==    by 0x40BAAC: bridge_run__ (bridge.c:2965)
==26942==    by 0x410CF3: bridge_run (bridge.c:3029)
==26942==    by 0x407614: main (ovs-vswitchd.c:127)
==26942==  Uninitialised value was created by a heap allocation
==26942==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26942==    by 0x532574: xmalloc (util.c:138)
==26942==    by 0x46CD62: dp_packet_new (dp-packet.c:153)
==26942==    by 0x4A0431: eth_from_flow_str (netdev-dummy.c:1644)
==26942==    by 0x4A0431: netdev_dummy_receive (netdev-dummy.c:1783)
==26942==    by 0x531990: process_command (unixctl.c:308)
==26942==    by 0x531990: run_connection (unixctl.c:342)
==26942==    by 0x531990: unixctl_server_run (unixctl.c:393)
==26942==    by 0x40761E: main (ovs-vswitchd.c:128)

1316: ofproto-dpif - conntrack - tcp port reuse

==24039== Conditional jump or move depends on uninitialised value(s)
==24039==    at 0x587BF5: check_orig_tuple (conntrack.c:1004)
==24039==    by 0x587BF5: process_one (conntrack.c:1141)
==24039==    by 0x587BF5: conntrack_execute (conntrack.c:1220)
==24039==    by 0x47B02F: dp_execute_cb (dpif-netdev.c:7306)
==24039==    by 0x4AF7A6: odp_execute_actions (odp-execute.c:794)
==24039==    by 0x47755B: dp_netdev_execute_actions (dpif-netdev.c:7350)
==24039==    by 0x47755B: handle_packet_upcall (dpif-netdev.c:6631)
==24039==    by 0x47755B: fast_path_processing (dpif-netdev.c:6727)
==24039==    by 0x47935C: dp_netdev_input__ (dpif-netdev.c:6815)
==24039==    by 0x479AD8: dp_netdev_input (dpif-netdev.c:6853)
==24039==    by 0x479AD8: dp_netdev_process_rxq_port
(dpif-netdev.c:4287)
==24039==    by 0x47A6C9: dpif_netdev_run (dpif-netdev.c:5264)
==24039==    by 0x4324F7: type_run (ofproto-dpif.c:342)
==24039==    by 0x41C5FE: ofproto_type_run (ofproto.c:1734)
==24039==    by 0x40BAAC: bridge_run__ (bridge.c:2965)
==24039==    by 0x410CF3: bridge_run (bridge.c:3029)
==24039==    by 0x407614: main (ovs-vswitchd.c:127)
==24039==  Uninitialised value was created by a heap allocation
==24039==    at 0x4C2DB8F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24039==    by 0x5325C4: xmalloc (util.c:138)
==24039==    by 0x46D144: dp_packet_new (dp-packet.c:153)
==24039==    by 0x46D144: dp_packet_new_with_headroom (dp-packet.c:163)
==24039==    by 0x51191E: eth_from_hex (packets.c:498)
==24039==    by 0x4A03B9: eth_from_packet (netdev-dummy.c:1609)
==24039==    by 0x4A03B9: netdev_dummy_receive (netdev-dummy.c:1765)
==24039==    by 0x5319E0: process_command (unixctl.c:308)
==24039==    by 0x5319E0: run_connection (unixctl.c:342)
==24039==    by 0x5319E0: unixctl_server_run (unixctl.c:393)
==24039==    by 0x40761E: main (ovs-vswitchd.c:128)

According to comments in pkt_metadata_init(), conntrack data is valid
only if pkt_metadata.ct_state != 0. This patch prevents
check_orig_tuple() get called when conntrack data is uninitialized.

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>