2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 13:58:14 +00:00

19894 Commits

Author SHA1 Message Date
Miro Tomaska
1731ed43c6 python: Do not send non-zero flag for a SSL socket.
pyOpenSSL was recently switched for the Python standard library ssl
module in the cited commit.  Python SSLsocket.send() does not allow
non-zero optional flag and it will explicitly raise an exception for
that.  pyOpenSSL did nothing with this flag but kept it to be
compatible with socket API:
  https://github.com/pyca/pyopenssl/blob/main/src/OpenSSL/SSL.py#L1844

Fixes: 68543dd523bd ("python: Replace pyOpenSSL with ssl.")
Reported-at: https://bugzilla.redhat.com/2115035
Acked-By: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Miro Tomaska <mtomaska@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-12 01:23:39 +02:00
Ilya Maximets
d1864effeb ovsdb: Fix copying weak references into transaction history.
Transaction history is used only to construct row data updates for
clients, it's not used for checking data integrity, hence it doesn't
need a copy of weak references.

Not copying this data saves a lot of CPU cycles and memory in some
cases.  For example, in 250-node density-heavy scenario in ovn-heater
these references can take up to 70% of RSS, which is about 8 GB of
essentially wasted memory as reported by valgrind massif:

 -------------------------------------------------------------------------------
   n        time(i)         total(B)    useful-heap(B) extra-heap(B)   stacks(B)
 -------------------------------------------------------------------------------
  20 1,011,495,832,314  11,610,557,104  10,217,785,620 1,392,771,484        0

 88.00% (10,217,785,620B) (heap allocation functions) malloc/new/new[]
 ->70.47% (8,181,819,064B) 0x455372: xcalloc__ (util.c:121)
   ->70.07% (8,135,785,424B) 0x41609D: ovsdb_weak_ref_clone (row.c:66)
     ->70.07% (8,135,785,424B) 0x41609D: ovsdb_row_clone (row.c:151)
       ->34.74% (4,034,041,440B) 0x41B7C9: ovsdb_txn_clone (transaction.c:1124)
       | ->34.74% (4,034,041,440B) 0x41B7C9: ovsdb_txn_add_to_history (transaction.c:1163)
       |   ->34.74% (4,034,041,440B) 0x41B7C9: ovsdb_txn_replay_commit (transaction.c:1198)
       |     ->34.74% (4,034,041,440B) 0x408C35: parse_txn (ovsdb-server.c:633)
       |       ->34.74% (4,034,041,440B) 0x408C35: read_db (ovsdb-server.c:663)
       |         ->34.74% (4,034,041,440B) 0x406C9D: main_loop (ovsdb-server.c:238)
       |           ->34.74% (4,034,041,440B) 0x406C9D: main (ovsdb-server.c:500)
       |
       ->34.74% (4,034,041,440B) 0x41B7DE: ovsdb_txn_clone (transaction.c:1125)
         ->34.74% (4,034,041,440B) 0x41B7DE: ovsdb_txn_add_to_history (transaction.c:1163)
           ->34.74% (4,034,041,440B) 0x41B7DE: ovsdb_txn_replay_commit (transaction.c:1198)
             ->34.74% (4,034,041,440B) 0x408C35: parse_txn (ovsdb-server.c:633)
               ->34.74% (4,034,041,440B) 0x408C35: read_db (ovsdb-server.c:663)
                 ->34.74% (4,034,041,440B) 0x406C9D: main_loop (ovsdb-server.c:238)
                   ->34.74% (4,034,041,440B) 0x406C9D: main (ovsdb-server.c:500)

Replacing ovsdb_row_clone() with ovsdb_row_datum_clone() to avoid
cloning unnecessary metadata.  The ovsdb_txn_clone() function re-named
to avoid issues if it will be re-used in the future for some other
use-case.

Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-12 01:20:04 +02:00
Sunil Pai G
b0e8668f38 dpif-netdev: Simplify AVX512 build time checks to enhance readability.
The preprocessor comparison string to check AVX512 capabilities are
lengthy and effecting user readability. Simpify this by aliasing the checks.

Suggested-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Cian Ferriter <cian.ferriter@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-08-10 15:57:39 +01:00
Ilya Maximets
a7045017d8 github: Move CI to ubuntu 20.04 base image.
18.04 image is deprecated and will disappear soon.  Also some
slowdowns and brownouts are planned to push users away from
this deprecated version:

  https://github.com/actions/virtual-environments/issues/6002

Moving to 20.04.  Can't move to 22.04 at the moment because of
deprecation warnings from openssl 3.0.

Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-09 13:38:39 +02:00
Ilya Maximets
1fd336ccee netdev-offload-tc: Disable offload of IPv6 fragments.
OVS kernel datapath and TC are parsing IPv6 fragments differently.
For IPv6 later fragments, according to the original design [1], OVS
always sets nw_proto=44 (IPPROTO_FRAGMENT), regardless of the type
of the L4 protocol.

This leads to situation where flow for nw_proto=44 gets installed
to TC, but packets can not match on it, causing all IPv6 later
fragments to go to userspace significantly degrading performance.

Disabling offload for such packets, so the flow can be installed
to the OVS kernel datapath instead.  Disabling for all IPv6 fragments
including the first one, because it doesn't make a lot of sense to
handle them separately.  It may also cause potential problems with
conntrack trying to re-assemble a packet from fragments handled by
different datapaths (first in HW, later in OVS kernel).

Checking both 'nw_proto' and 'nw_frag' as classifier might decide
to match only on one of them and also nw_proto will not be 44 for
the first fragment.

The issue was hidden for some time due to incorrect behavior of the
OVS kernel datapath that was recently fixed in kernel commit:

 12378a5a75e3 ("net: openvswitch: fix parsing of nw_proto for IPv6 fragments")

To allow offloading in the future either flow dissector in TC
should be changed to parse packets in the same way as OVS does,
or parsing in OVS kernel and userspace should be made configurable,
so users can opt-in to the behavior change.  Silent change of the
behavior (change by default) is not an option, because existing
OpenFlow pipelines may depend on a certain behavior.

[1] https://docs.openvswitch.org/en/latest/topics/design/#fragments

Fixes: 83e866067ea6 ("netdev-tc-offloads: Add support for IP fragmentation")
Reviewed-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Marcelo Ricardo Leitner <mleitner@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-08 19:15:09 +02:00
Han Ding
269a947c7b ovs-save: Use right OpenFlow version for add-tlv-map.
When the bridge protocols is not included Openflow10, printing an error
message "version negotiation failed" when doing "Restoring saved flows".

Signed-off-by: Han Ding <handing@chinatelecom.cn>
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-08 19:03:48 +02:00
Paolo Valerio
b47ebf7186 system-traffic: Fix IPv4 fragmentation test sequence for check-kernel.
The following test sequence:

conntrack - IPv4 fragmentation incomplete reassembled packet
conntrack - IPv4 fragmentation with fragments specified

leads to a systematic failure of the latter test on the kernel
datapath (linux).  Multiple executions of the former may also lead to
multiple failures.
This is due to the fact that fragments not yet reassembled are kept in
a queue for /proc/sys/net/ipv4/ipfrag_time seconds, and if the
kernel receives a fragment already present in the queue, it returns
-EINVAL.

Below the related log message:
|00058|dpif|WARN|system@ovs-system: execute ct(commit) failed (Invalid argument)
  on packet udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,
  nw_src=10.1.1.1,nw_dst=10.1.1.2,nw_tos=0,nw_ecn=0,nw_ttl=0,nw_frag=first,tp_src=1,
  tp_dst=2 udp_csum:0

Fix the sequence by sending the second fragment in "conntrack - IPv4
fragmentation incomplete reassembled packet", once the checks are
done.

IPv6 tests are not affected as the defrag kernel code path pretends to
add the duplicate fragment to the queue returning -EINPROGRESS, when a
duplicate is detected.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-08 16:37:32 +02:00
Ilya Maximets
d6c6b216e4 system-traffic: Fix incorrect neigh entry in ipv6 header modification test.
The permanent neighbor entry for fc00::1 is added into a wrong
namespace, so in order to reply to a ping from at_ns1, the
address of fc00::1 has to be discovered.  Interfaces are attached
to OVS and we're removing flows that can forward ND requests
after initial setup.  In case ND request wasn't sent and replied
before that, at_ns1 will not be able to discover fc00:1 and won't
reply to pings.

It's hard to catch this condition while running tests locally,
but for some reason our CI is failing consistently.

Fix the issue by removing all the unnecessary permanent entries
and just allowing all the normal traffic to flow through the
low priority OVS flow, so all addresses can be discovered.

Also adding one more wait to avoid occasional drops of the very
first packet.

Fixes: 2ff43c78c685 ("packets: Re-calculate IPv6 checksum only for first frag upon modify.")
Acked-by: Salem Sol <salems@nvidia.com>
Acked-by: Michael Phelan <michael.phelan@intel.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-08 16:36:38 +02:00
Ilya Maximets
6fcd733f75 system-traffic: Don't run IPv6 header modification test on kernels < 5.19.
OVS kernel module is incorrectly updating checksums while changing
IPv6 fields of later fragments that doesn't really have L4 headers.

This makes the 'ping6 between two ports with header modify' test
fail on most of the distribution kernels.

The issue got indirectly fixed in latest 5.19 with commit:

  12378a5a75e3 ("net: openvswitch: fix parsing of nw_proto for IPv6 fragments")

The reason is that set_ipv6() function in net/openvswitch/actions.c
is using the protocol number from the parsed flow key and not from
the packet itself, and nw_proto=44 is not a protocol where we can
update the checksum.

It was backported to all supported upstream stable trees, but didn't
find its way to most of the distributions yet.

Restricting the test to 5.19+ kernels to avoid failures on distro
kernels.  Additionally allowing the previous test for later fragments
to be executed in userspace testsuite.

Fixes: 2ff43c78c685 ("packets: Re-calculate IPv6 checksum only for first frag upon modify.")
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-08 12:36:45 +02:00
Ilya Maximets
434025a154 python: Fix E275 missing whitespace after keyword.
With just released flake8 5.0 we're getting a bunch of E275 errors:

 utilities/bugtool/ovs-bugtool.in:959:23: E275 missing whitespace after keyword
 tests/test-ovsdb.py:623:11: E275 missing whitespace after keyword
 python/setup.py:105:8: E275 missing whitespace after keyword
 python/setup.py:106:8: E275 missing whitespace after keyword
 python/ovs/db/idl.py:145:15: E275 missing whitespace after keyword
 python/ovs/db/idl.py:167:15: E275 missing whitespace after keyword
 make[2]: *** [flake8-check] Error 1

This breaks CI on branches below 2.16.  We don't see a problem right
now on newer branches because we're installing extra dependencies
that backtrack flake8 down to 4.1 or even 3.9.

Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 18:13:20 +02:00
Ilya Maximets
398623a63e tc: Use sparse hex dump while printing inconsistencies.
Instead of a very long hex string something like this will be printed:

 |DBG|tc flower compare failed mask compare:
 Expected Mask:
 00000000  ff ff 00 00 ff ff ff ff-ff ff ff ff ff ff ff ff
 00000020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 03 00
 00000090  00 00 00 00 00 00 00 00-ff ff ff ff ff ff ff ff
 000000c0  ff 00 00 00 ff ff 00 00-ff ff ff ff ff ff ff ff

 Received Mask:
 00000000  ff ff 00 00 ff ff ff ff-ff ff ff ff ff ff ff ff
 00000020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 03 00
 00000090  00 00 00 00 00 00 00 00-ff ff ff ff ff ff ff ff
 000000c0  ff 00 00 00 00 00 00 00-ff ff ff ff ff ff ff ff

It's easier to spot the difference this way and count which bytes are
to blame, since offsets are printed as well.

Using a sparse dump to avoid printing huge number of all-zero lines.

Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:18:17 +02:00
Ilya Maximets
a7680c3caf netdev-offload-tc: Print unused mask bits on failure.
This change extends the debug logging with the sparse
dump of the flow mask structure to make debug process
easier.

Sample output:

  |netdev_offload_tc|DBG|offloading isn't supported, unknown attribute
  Unused mask bits:
  00000270  00 00 00 00 00 00 00 00-00 00 00 ff 00 00 00 00

In this example, 0x270 + 11 = 635, which is an offset of
the nsh.mdtype in the struct flow.

Suggested-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:18:09 +02:00
Ilya Maximets
823d4f6bc8 dynamic-string: Add function for a sparse hex dump.
New function to dump large and sparsely populated data structures
like struct flow.

Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:18:05 +02:00
Ilya Maximets
050dc8fed2 system-offloads-traffic: Fix waiting for netcat indefinitely.
$NC_EOF_OPT should be used to avoid some netcat implementations
to wait indefinitely.

This fixes the check-offloads testsuite hanging in Ubuntu 22.04.

Fixes: 5660b89a309d ("dpif-netlink: Offloading meter to tc police action")
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:10:03 +02:00
Ilya Maximets
01edbc3add dpif-netlink: Fix incorrect bit shift in compat mode.
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior in
 lib/dpif-netlink.c:1077:40: runtime error:
   left shift of 1 by 31 places cannot be represented in type 'int'

     #0  0x73fc31 in dpif_netlink_port_add_compat lib/dpif-netlink.c:1077:40
     #1  0x73fc31 in dpif_netlink_port_add lib/dpif-netlink.c:1132:17
     #2  0x2c1745 in dpif_port_add lib/dpif.c:597:13
     #3  0x07b279 in port_add ofproto/ofproto-dpif.c:3957:17
     #4  0x01b209 in ofproto_port_add ofproto/ofproto.c:2124:13
     #5  0xfdbfce in iface_do_create vswitchd/bridge.c:2066:13
     #6  0xfdbfce in iface_create vswitchd/bridge.c:2109:13
     #7  0xfdbfce in bridge_add_ports__ vswitchd/bridge.c:1173:21
     #8  0xfb5319 in bridge_add_ports vswitchd/bridge.c:1189:5
     #9  0xfb5319 in bridge_reconfigure vswitchd/bridge.c:901:9
     #10 0xfae0f9 in bridge_run vswitchd/bridge.c:3334:9
     #11 0xfe67dd in main vswitchd/ovs-vswitchd.c:129:9
     #12 0x4b6d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
     #13 0x4b6e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
     #14 0x562594eed024 in _start (vswitchd/ovs-vswitchd+0x787024)

Fixes: 526df7d8543f ("tunnel: Provide framework for tunnel extensions for VXLAN-GBP and others")
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:07:37 +02:00
Ilya Maximets
91b41af0d9 checkpatch: Add check for a Fixes tag.
A new check for common mistakes while formatting a 'Fixes:' tag.

Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:06:37 +02:00
Timothy Redaelli
6a9ec13aa3 python: Use setuptools instead of distutils.
On Python 3.12, distutils will be removed and it's currently (3.10+)
deprecated (see PEP 632).

Since the suggested and simplest replacement is setuptools, this commit
replaces distutils to use setuptools instead.

setuptools < 59.0 doesn't have setuptools.errors and so, in this case,
distutils.errors is still used.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:01:23 +02:00
Ilya Maximets
47cfa89412 AUTHORS: Add Salem Sol.
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 14:01:23 +02:00
Salem Sol
2ff43c78c6 packets: Re-calculate IPv6 checksum only for first frag upon modify.
In case of modifying an IPv6 packet src/dst address the L4 checksum
should be recalculated only for the first frag.  Currently it's done
for all frags, leading to incorrect reassembled packet checksum.
Fix it by adding a new flag to recalculate the checksum only for the
first frag.

Fixes: bc7a5acdff08 ("datapath: add ipv6 'set' action")
Signed-off-by: Salem Sol <salems@nvidia.com>
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-08-04 13:32:44 +02:00
Vlad Buslov
d9268782af netdev-linux: set correct action for packets that passed policer
Referenced commit changed policer action type from TC_ACT_UNSPEC (continue)
to TC_ACT_PIPE. However, since neither TC hardware offload layer nor mlx5
driver at the time validated action type and always assumed 'continue', the
breakage wasn't caught until later validation code was added. The change
also broke valid configuration when sending from offload-capable device to
non-offload capable. For example, when sending from mlx5 VF to OvS bridge
netdevice the traffic that passed matchall classifier with policer could no
longer match the following flower rule in software:

filter protocol all pref 1 matchall chain 0
filter protocol all pref 1 matchall chain 0 handle 0x1
  in_hw (rule hit 7863)
        action order 1:  police 0x1 rate 32Mbit burst 1000Kb mtu 64Kb action drop/pipe overhead 0b
        ref 1 bind 1  installed 17 sec firstused 17 sec
        Action statistics:
        Sent 152199634 bytes 102550 pkt (dropped 1315, overlimits 1315 requeues 0)
        Sent software 74612172 bytes 51275 pkt
        Sent hardware 77587462 bytes 51275 pkt
        backlog 0b 0p requeues 0
        used_hw_stats delayed

filter protocol ip pref 3 flower chain 0
filter protocol ip pref 3 flower chain 0 handle 0x1
  dst_mac aa:94:1f:f2:f8:44
  src_mac e4:00:01:08:00:02
  eth_type ipv4
  ip_flags nofrag
  not_in_hw
        action order 1: skbedit  ptype host pipe
         index 1 ref 1 bind 1 installed 6 sec used 6 sec
        Action statistics:
        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0

        action order 2: mirred (Ingress Redirect to device br-ovs) stolen
        index 1 ref 1 bind 1 installed 6 sec used 6 sec
        Action statistics:
        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0
        cookie 401a9c8b3d403c62240d3eb5e21c1604
        no_percpu

Fix the issue by restoring matchall and basic policers action type to
'continue'.

Fixes: c2567e533f8a ("add port-based ingress policing based packet-per-second rate-limiting")
Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
2022-08-04 10:04:28 +01:00
Ilya Maximets
c43da842fb test-ovsdb: Fix false-positive leaks from LeakSanitizer.
LeakSanitizer for some reason reports these json objects as leaked,
even though we do have references to them at the moment ovs_fatal()
called from check_ovsdb_error().

Previously it complained only with -O2, but with newer versions of
clang/llvm it started complaining even with -O1.  For example, negative
ovsdb parsing tests are failing on ubuntu 22.04 with clang 14 if built
with ASan and detect_leaks=1.

Fix that by destroying the json object before aborting the process.
And we may also build with default -O2 in CI with that change.

Alternative implementation might be to just pass the json to destroy
to every check_ovsdb_error() call, but indirect registering of the
pointer seems a bit less invasive.

Acked-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:22:02 +02:00
Ilya Maximets
7670c7c2e1 m4: Update ax_func_posix_memalign to the latest version.
This fixes the obsolescence warning for AC_TRY_RUN with autoconf 2.70+:

  $ ./boot.sh
  configure.ac:141: warning: The macro `AC_TRY_RUN' is obsolete.
  configure.ac:141: You should run autoupdate.
  ./lib/autoconf/general.m4:2997: AC_TRY_RUN is expanded from...
  lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
  lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
  ./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
  ./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
  m4/ax_func_posix_memalign.m4:27: AX_FUNC_POSIX_MEMALIGN is expanded from...
  configure.ac:141: the top level

Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:14:55 +02:00
Ilya Maximets
97adbe9437 m4: Replace obsolete AC_HELP_STRING with AS_HELP_STRING.
AS_HELP_STRING is a direct replacement for AC_HELP_STRING.
It is available since autoconf 2.57a.  OVS requires 2.63,
so AS_HELP_STRING can be freely used.

This fixes the following warning on systems with 2.70+:

  $ ./boot.sh
  ...
  configure.ac:92: warning: The macro `AC_HELP_STRING' is obsolete.
  configure.ac:92: You should run autoupdate.
  ...

Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:14:39 +02:00
Ilya Maximets
593b26e525 debian: Fix incorrect linkage of the python C extension.
Current version of debian/rules simply passes the libopenvswitch.a
as a command line argument via LDFLAGS, but that doesn't actually
lead to this library being statically linked into python extension,
which is a shared library.  Instead, the build "succeeds", but the
resulted extension is not usable, because most of the symbols are
missing:

  from ovs import _json

  ImportError:
    /usr/lib/python3/dist-packages/ovs/_json.cpython-310-x86_64-linux-gnu.so:
      undefined symbol: json_parser_finish

'-lopenvswitch' with a path to a static library should be passed
instead to make it actually statically linked.  But even that is not
enough as all the libraries that libopenvswitch.a was built with also
has to be passed.  Otherwise, we'll have unresolved symbols like ssl,
cap-ng, etc.

The most convenient way to get all the required libraries and cflags
seems to be by using pkg-config.

Setting several environment variables for pkg-config, so it can find
the libopenvswitch.pc in non-standard directory, not skip default
locations and also report them with the right base directory.

Extra '-Wl,-Bstatic -lopenvswitch -Wl,-Bdynamic' is added before all
the libs to ensure static linking of libopenvswitch even if the
dynamic library is available in a system.

One more problem here is that it is not possible to link static
library into dynamic library if the static one is not position
independent.  So, we have to build everything with -fPIC, otherwise
it's not possible to build C extensions.

Also added a simple CI script to check that we're able to use python
C extension after installing a package.

Fixes: 6ad3be9749ab ("debian: Fix build of python json C extension.")
Acked-by: Frode Nordahl <frode.nordahl@canonical.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:08:35 +02:00
Ilya Maximets
791c472739 python: Add ability to pass extra libs and cflags for C extension.
In order to correctly link with static libopenvswitch.a library,
users should also provide required cflags and all the libraries
libopenvswitch.a was actually built with and depends on.  Otherwise,
it's not possible to link correctly.

Fixes: 671f93fe42d3 ("python: Allow building json C extension with static OVS library.")
Acked-by: Frode Nordahl <frode.nordahl@canonical.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:08:28 +02:00
Ilya Maximets
66824fb8da libopenvswitch.pc: Add missing libs for a static build.
SSL, BPF, lcap-ng and other libraries are in use by a static library,
so they has to be linked while building applications with that static
library, i.e. 'pkg-config --libs --static libopenvswitch' must return
-lssl, -lcap-ng, etc. in the output for a successful build.

For dynamic library (non-private Libs) all these libraries will be
dynamically linked to libopenvswitch.so, so the application will
pick them up without having a direct dependency.

Acked-by: Frode Nordahl <frode.nordahl@canonical.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:07:25 +02:00
Ilya Maximets
a68002cd9a rhel: Stop installing internal headers.
Currently, openvswitch-devel installs following header tree:

  /usr/include
              /openflow/*.h
              /openvswitch
                           /*.h
                           /openflow/*.h
                           /openvswitch/*.h
                           /sparse/*.h
                           /lib/*.h

Few issues with that:

1. openflow and openvswitch headers are installed twice.  Once in the
   main /usr/include and second time in the /usr/include/openvswitch/.

2. For some reason internal headers such as lib/*.h and fairly useless
   headers such as sparse/*.h are installed as well.

One more issue is that current pkg-config files doesn't work with
builds installed with 'make install', because 'make install' doesn't
create this weird header tree.

While double install of same headers is not a huge problem, it doesn't
seem right.  Installation of the internal headers is a bigger issue.
They are not part of API/ABI and we do not provide any stability
guarantees for them.  We are making incompatible changes constantly in
minor updates, so users should not rely on these headers.

If it's necessary for some external application to use them, this
external application should not link with libopenvswitch dynamically
and also it can't expect the static library to not break these API/ABI,
hence there is no real point installing them.  Application should use
OVS as a submodule like OVN does or compile itself by obtaining
required version of OVS sources otherwise.  Another option is to
properly export and install required headers.

pkg-config configuration files updated as necessary.

Fixes: 4886d4d2495b ("debian, rhel: Ship ovs shared libraries and header files")
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:05:42 +02:00
Ilya Maximets
099d1c7454 python-c-ext: Handle initialization failures.
PyModule_AddObject() may fail and it doesn't steal references
in this case.  The error condition should be handled to avoid
possible memory leaks.

And while it's not strictly specified if PyModule_Create may
fail, most of the examples in python documentation include
handling of a NULL case.

Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-29 17:00:12 +02:00
Ilya Maximets
318adf3f33 AUTHORS: Add Tao Liu.
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-26 12:50:26 +02:00
Tao Liu
8166c066a7 netdev-linux: Do not touch LAG members if master is not attached to OVS.
Bond master netdev may be created without a classification type, due
to routing or tunneling code.

If bond master is not attached to ovs, the ingress block on LAG members
should not be updated.

Simple reproducer:
  tc q ls dev net3 ingress
  ip a add 10.1.1.1/30 dev bond0
  ip l set net3 master bond0
  tc q ls dev net3 ingress

Fixes: d22f8927c3c9 ("netdev-linux: monitor and offload LAG slaves to TC")
Signed-off-by: Tao Liu <thomas.liu@ucloud.cn>
Acked-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-26 12:48:14 +02:00
Tao Liu
378b51c6b0 netdev: Clear auto_classified if netdev reopened with the type specified.
When netdev first opened by netdev_open(..., NULL, ...), netdev_class sets
to system by default, and auto_classified sets to true.

If netdev reopens by netdev_open(..., "system", ...), auto_classified
should be cleared.  This will be used in next patch to fix lag issue.

Fixes: 8c2c225e481d ("netdev: Fix netdev_open() to track and recreate classless interfaces")
Signed-off-by: Tao Liu <thomas.liu@ucloud.cn>
Acked-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-26 12:41:41 +02:00
David Marchand
1cecd385f4 system-offloads-traffic: Avoid check_pkt_len action test random failures.
On my Fedora 36, the test with enabled offloads often fails with one of
those ping failing.
By chance (?), the previous tcpdumps are not stopped and I can see for
example:
10:04:02.534492 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 2, length 72
10:04:02.639443 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 3, length 72
10:04:02.743447 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 4, length 72
10:04:02.846447 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 5, length 72
10:04:02.950519 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 6, length 72
10:04:03.054697 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 7, length 72
10:04:03.158448 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 8, length 72
10:04:03.262541 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 9, length 72
10:04:03.366444 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 10, length 72
10:04:03.466501 IP 10.1.1.1 > 10.1.1.2: ICMP echo request, id 62835, seq 11, length 72

The first ping request has not been handled correctly.

Adding a sleep 1 (like other offloads unit tests) seems to be enough to
avoid this situation.

Fixes: 02dabb21f243 ("tests: Add check_pkt_len action test to system-offload-traffic.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-25 18:45:53 +02:00
Ilya Maximets
f36acef00d system-traffic: Properly stop dangling ping after geneve test.
Ping process remains in the system after the test.  Using a proper
macro that will correctly register it for stopping at cleanup stage.

Fixes: 134e6831acca ("system-traffic: Check frozen state handling with TLV map change")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Reviewed-by: David Marchand <david.marchand@redhat.com>
2022-07-25 18:43:40 +02:00
Eli Britstein
97211927f1 conntrack: Fix conntrack multiple new state.
A connection is established if we see packets from both directions.
The cited commit fixed the issue of sending twice in one direction,
but still an issue if more than that.
Fix it.

Fixes: a867c010ee91 ("conntrack: Fix conntrack new state")
Signed-off-by: Eli Britstein <elibr@nvidia.com>
Acked-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-25 18:42:14 +02:00
Timothy Redaelli
d3c14abf47 python-c-ext: Fix a couple of build warnings.
ovs/_json.c:67:20: warning: assignment discards ‘const’ qualifier from pointer
target type [-Wdiscarded-qualifiers]

ovs/_json.c:132:27: warning: comparison of integer expressions of different
signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-22 17:08:03 +02:00
Timothy Redaelli
54ebc235ae python-c-ext: Remove Python 2 support.
Since Python 2 is not supported anymore, remove Python 2 support from C
extension too

Fixes: 1ca0323e7c29 ("Require Python 3 and remove support for Python 2.")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-22 15:22:01 +02:00
Ilya Maximets
2f4eb2d8c8 odp-execute: Avoid unnecessary logging for action implementations.
There is no need to log if the implementation didn't change.
Scalar one is default, any change will be logged.  And availability
is not really important to log at INFO level.  Moving these logs
to DBG level to avoid littering the log file and confusing users.
We do the same for miniflow_extract and datapath interface
implementations.

Additionally text of the log message made more readable and uniform
with the one used for miniflow_extract.

Fixes: 95e4a35b0a1d ("odp-execute: Add function pointers to odp-execute for different action implementations.")
Acked-by: Emma Finn <emma.finn@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-22 15:19:26 +02:00
Michael Phelan
ad026f40da system-dpdk: Add testpmd clean up in MTU unit tests.
The MTU vport unit tests do not clean up testpmd after use which causes
them to fail randomly.  This commit amends the MTU vport unit tests to
clean up testpmd after running.

Fixes: bf47829116a8 ("tests: Add OVS-DPDK MTU unit tests.")
Reported-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Kumar Amber <kumar.amber@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Michael Phelan <michael.phelan@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-22 15:16:31 +02:00
Ilya Maximets
5cd03632d0 AUTHORS: Add Harold Huang.
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-19 19:55:19 +02:00
Harold Huang
48ae7b802b netdev-offload-dpdk: Setting RSS hash types in RSS action.
When we send parallel flows such as VXLAN to a PF[1] port in OVS with
multiple PMDs. OVS will create a RTE flow with Mark and RSS actions to
send flows to the software data path. But the RSS action does not work
well and all the flows are forwarded to a single PMD. This is because
RSS hash types should be set in RSS action.

[1]: In our testbed, a Mellanox ConnectX-6 is used as a PF port.

[i.maximets]
DPDK PMD drivers supposed to provide "best-effort" RSS configuration
if the type is set to zero.  However, they are very inconsistent in
practice and barely put any effort to provide a good configuration.
For example, mlx5 driver seems to use just RTE_ETH_RSS_IP, which is
not enough for most deployments.
Setting the types the same way we configure them for a normal RSS
in netdev-dpdk to workaround the scalability issue.

Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-19 19:55:19 +02:00
Rosemarie O'Riorden
fcdf8ae4a3 lib: Print nw_frag in flow key.
nw_frag was not being printed in the flow key because it was improperly
masked and printed. Since this field is only two bits, it needs to use a
different macro to be masked. During printing, the switch statement
switched on the whole 8 bits rather than just the two that are relevant.
This caused nw_frag to often not be printed at all.

Signed-off-by: Rosemarie O'Riorden <roriorden@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-19 19:55:19 +02:00
Ilya Maximets
b31ed07b7c ovsdb: Remove extra make target dependency for local-config.5.
ovsdb/ directory should not be a dependency, otherwise the man
page is getting re-built every time unrelated files are changed.

Fixes: 6f24c2bc769a ("ovsdb: Add Local_Config schema.")
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-19 19:55:14 +02:00
David Marchand
81d186c1c2 ci: Prefer pip3 to install unit test dependencies.
While it looks like the right python3 versions of those dependencies
seems to be installed in the CI, prefer calling this via pip3 like the
rest of the script.

Fixes: 445dceb88461 ("python: Introduce unit tests.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-19 17:02:36 +02:00
Ilya Maximets
99587921c7 Prepare for post-3.0.0 (3.0.90).
Acked-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 23:18:54 +02:00
Ilya Maximets
e2e8d7cd31 Prepare for 3.0.0.
Acked-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 23:18:54 +02:00
Christophe Fontaine
1b53826d6c ofproto/bond: Add knob 'all-members-active'.
This config param allows the delivery of broadcast and multicast
packets to the secondary interface of non-lacp bonds, equivalent
to the option 'all_slaves_active' for Linux kernel bonds.

Reported-at: https://bugzilla.redhat.com/1720935
Signed-off-by: Christophe Fontaine <cfontain@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 23:08:38 +02:00
Adrian Moreno
73ba04fd77 python: Add unit tests for filtering engine.
Add unit test for OFFilter class.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 20:14:24 +02:00
Adrian Moreno
686bb5e729 python: Add unit tests to datapath parsing.
Add unit tests to datapath flow parsing.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 20:14:24 +02:00
Adrian Moreno
7448cbb4ee python: Add unit tests for openflow parsing.
Add unit tests for OFPFlow class and ip-port range decoder

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 20:14:24 +02:00
Adrian Moreno
3425d01a9c python: Add unit tests for ListParser.
Add unit tests for ListParser class.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 20:14:24 +02:00