2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-05 08:45:23 +00:00
Commit Graph

19894 Commits

Author SHA1 Message Date
Adrian Moreno
445dceb884 python: Introduce unit tests.
Use pytest to run unit tests as part of the standard testsuite.

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
6a71bc09bb python: Add a json encoder to flow fields.
The json encoder can be used to convert Flows to json.

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
7e588e82f0 python: Add flow filtering syntax.
Based on pyparsing, create a very simple filtering syntax.

It supports basic logic statements (and, &, or, ||, not, !), numerical
operations (<, >), equality (=, !=), and masking (~=). The latter is only
supported in certain fields (IntMask, EthMask, IPMask).

Masking operation is semantically equivalent to "includes",
therefore:

    ip_src ~= 192.168.1.1

means that ip_src field is either a host IP address equal to 192.168.1.1
or an IPMask that includes it (e.g: 192.168.1.1/24).

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
076663b31e python: Add ovs datapath flow parsing.
A ODPFlow is a Flow with the following sections:
ufid
info (e.g: bytes, packets, dp, etc)
match
actions

Only three datapath actions require special handling:
gre: because it has double parenthesis
geneve: because it supports many concatenated lists of options
nat: we reuse the decoder used for openflow actions

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
3923b9331d python: Introduce OpenFlow Flow parsing.
Introduce OFPFlow class and all its decoders.

Most of the decoders are generic (from decoders.py). Some have special
syntax and need a specific implementation.

Decoders for nat are moved to the common decoders.py because it's syntax
is shared with other types of flows (e.g: dpif flows).

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:21 +02:00
Adrian Moreno
1215cf1334 python: Add flow base class.
It simplifies the implementation of different types of flows by creating
the concept of Section (e.g: match, action) and automatic accessors for
all the provided Sections

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:13:48 +02:00
Adrian Moreno
61e040fc23 build-aux: Generate ofp field decoders.
Based on meta-field information extracted by extract_ofp_fields,
autogenerate the right decoder to be used.

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:13:38 +02:00
Adrian Moreno
d542f0ea85 build-aux: Split extract-ofp-fields.
In order to be able to reuse the core extraction logic, split the command
in two parts. The core extraction logic is moved to python/build while
the command that writes the different files out of the extracted field
info is kept in build-aux.

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 17:40:55 +02:00
Adrian Moreno
7803743a0e python: Add list parser.
Some openflow or dpif flows encode their arguments in lists, eg:
"some_action(arg1,arg2,arg3)". In order to decode this in a way that can
be then stored and queried, add ListParser and ListDecoders classes
that parse lists into KeyValue instances.

The ListParser / ListDecoders mechanism is quite similar to KVParser and
KVDecoders. Since the "key" of the different KeyValue objects is now
ommited, it has to be provided by ListDecoders.

For example, take the openflow action "resubmit" that can be written as:

    resubmit([port],[table][,ct])

Can be decoded by creating a ListDecoders instance such as:

    ListDecoders([
                  ("port", decode_default),
                  ("table", decode_int),
                  ("ct", decode_flag),
                ])

Naturally, the order of the decoders must be kept.

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 17:40:50 +02:00
Adrian Moreno
dcd17a896c python: Add mask, ip and eth decoders.
Add more decoders that can be used by KVParser.

For IPv4 and IPv6 addresses, create a new class that wraps
netaddr.IPAddress.
For Ethernet addresses, create a new class that wraps netaddr.EUI.
For Integers, create a new class that performs basic bitwise mask
comparisons

netaddr is added as a new shoft dependency:
- extras_require in setup.py
- Suggests in deb and rpm packages

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 17:40:46 +02:00
Adrian Moreno
12bc968e26 python: Add generic Key-Value parser.
Most of ofproto and dpif flows are based on key-value pairs. These
key-value pairs can be represented in several ways, eg: key:value,
key=value, key(value).

Add the following classes that allow parsing of key-value strings:
* KeyValue: holds a key-value pair
* KeyMetadata: holds some metadata associated with a KeyValue such as
  the original key and value strings and their position in the global
  string
* KVParser: is able to parse a string and extract it's key-value pairs
  as KeyValue instances. Before creating the KeyValue instance it tries
  to decode the value via the KVDecoders
* KVDecoders holds a number of decoders that KVParser can use to decode
  key-value pairs. It accepts a dictionary of keys and callables to
  allow users to specify what decoder (i.e: callable) to use for each
  key

Also, flake8 seems to be incorrectly reporting an error (E203) in:
"slice[index + offset : index + offset]" which is PEP8 compliant. So,
ignore this error.

Acked-by: Terry Wilson <twilson@redhat.com>
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 17:40:36 +02:00
Sunil Pai G
02341a1879 systemd-dpdk: Fix typo's and capitalize first word.
Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 15:01:39 +01:00
Michael Phelan
bf47829116 tests: Add OVS-DPDK MTU unit tests.
This adds 8 new unit tests to the 'check-dpdk' subsystem that will
test Maximum Transmission Unit (MTU) functionality.

Signed-off-by: Michael Phelan <michael.phelan@intel.com>
Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
Co-authored-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 14:26:08 +01:00
Michael Phelan
ddaf4fe0ed tests: Add OVS-DPDK QoS unit tests
This adds 4 new unit tests to the 'check-dpdk' subsystem that will
test Quality of Service (QoS) functionality.

Signed-off-by: Michael Phelan <michael.phelan@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 14:23:12 +01:00
Greg Rose
3476bd3932 Documentation: Remove kernel module documentation.
As of Open vSwitch release 2.18 the OVS kernel module is no longer
supported.  Pull the documentation references.

Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Greg Rose
dc433e25ee acinclude.m4: Remove support for building the OVS kernel module.
Since the openvswitch project inception it has had support for building
a Linux kernel module to support the OVS kernel datapath.  Since Linux
kernel release 5.8 support for newer kernels has been deprecated.  Now
is the time to fully discontinue support for building the openvswitch
kernel driver. Since Linux 5.9 the Linux built-in openvswitch kernel
driver supports all necessary features and functions of the kernel
datapath and the need to support this additional "out of tree" kernel
module is gone.

Remove the --with-linux configuration support from the acinclude.m4
configuration and warn user it is not supported any longer.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Greg Rose
422e904378 make: Remove the Linux datapath.
Update the necessary make and configure files to remove the Linux
datapath and then remove the datapath.

Move datapath/linux/compat/include/linux/openvswitch.h to
include/linux/openvswitch.h because it is needed to generate header
files used by the userspace switch.

Also remove references to the Linux datapath from auxiliary files
and utilities since it is no longer supported.

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Greg Rose
86642de3ad tests: Remove support for check-kmod test.
The OVS kernel module is no longer supported as of OVS 2.18

Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Greg Rose
c94ae8a754 rhel: Stop packaging OVS kernel module.
Remove the kernel driver specification for RHEL 6.x, 7.x, 8.x and Fedora.

Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Greg Rose
b6941ca7b8 ci: Stop building OVS kernel module.
Remove kernel based github workflows since the OVS kernel driver is
no longer supported since Release 2.18

Co-authored-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Ilya Maximets
16bec677aa debian: Add option to build without DPDK.
Co-authored-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Frode Nordahl
c78e7efa7b docs: Update package references in debian/ubuntu related docs.
On the back of changing the debian/ubuntu packaging, update the
docs to refer to existing packages.

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Frode Nordahl
3e31a2dafc debian: Fix generation of copyright file.
The recipe for inserting authors from AUTHORS.rst is wrong.

Fixes: 3deca69b08 ("doc: Convert AUTHORS to rST")
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Frode Nordahl
6ad3be9749 debian: Fix build of python json C extension.
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Frode Nordahl
671f93fe42 python: Allow building json C extension with static OVS library.
Allow caller of setup.py to pass in libopenvswitch.a as an object
for linking through the use of LDFLAGS environment variable when
not building a shared openvswitch library.

To accomplish this set the `enable_shared` environment variable to
'no'.

Example:
    LDFLAGS=lib/libopenvswitch.a enable_shared=no setup.py install

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Frode Nordahl
ae262ddf22 ci: Separate job for debs, ensure built pkg is tested.
Use a separate GitHub Actions job for deb test so that we can
control base image for package test.

The CI deb package test code currently attempts to use `apt` to
install local packages.  That may not produce the expected result.

Explicitly install the local packages with `dpkg` after installing
dependencies from `apt` instead.

Also enable test installation of ipsec deb package.

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Frode Nordahl
9990322610 debian: Update packaging source from Debian/Ubuntu.
* Update upstream OVS debian packaging to be on par with package
  source in Debian/Ubuntu:
  - Provide a openvswitch-switch-dpdk package that integrates with
    the dpdk package in the distributions so that end users can opt
    into a DPDK-enabled Open vSwitch binary.
  - Provide systemd service files.
  - Provide openvswitch-source package for reproducible integrated
    build of for example OVN.
  - Stop building shared library and subsequently remove
    libopenvswitch and libopenvswitch-dev binary packages.

Co-authored-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Luca Boccassi <bluca@debian.org>
Co-authored-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Co-authored-by: James Page <james.page@ubuntu.com>
Signed-off-by: James Page <james.page@ubuntu.com>
Co-authored-by: Corey Bryant <corey.bryant@canonical.com>
Signed-off-by: Corey Bryant <corey.bryant@canonical.com>
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:45:55 +02:00
Frode Nordahl
9f4f2bb7dc checkpatch: Ignore line length and leading whitespace for debian/*.
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:43:39 +02:00
Frode Nordahl
02428f7151 debian: Archive debian packaging source.
The packaging source in the OVS repository has drifted away from
what is currently in Debian and Ubuntu.  This state is problematic
because from time to time someone tries to build packages from the
upstream OVS debian package source and then expect that package to
work with up-/down-grades from-/to/ distro versions.

To support the on-going work to remove the out of tree OVS kernel
driver from the repository [0], an update to the debian packaging
is also required.  On the back of the discussion in [0] we agreed
that replacing the current version with what Debian and Ubuntu
is currently converging on would be preferable.

This commit is a first in a series to update the upstream OVS
debian packaging source to be up to date with what is currently
in Debian and Ubuntu.

0: https://mail.openvswitch.org/pipermail/ovs-dev/2022-June/394634.html

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-15 13:43:39 +02:00
Emma Finn
92eb03f7b0 odp-execute: Add ISA implementation of set_masked IPv4 action
This commit adds support for the AVX512 implementation of the
ipv4_set_addrs action as well as an AVX512 implementation of
updating the checksums.

Signed-off-by: Emma Finn <emma.finn@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:41:19 +01:00
Emma Finn
bcfe585433 odp-execute: Add ISA implementation of set_masked ETH
This commit includes infrastructure changes for enabling set_masked_X
actions and also adds support for the AVX512 implementation of the
eth_set_addrs action.

Signed-off-by: Emma Finn <emma.finn@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:41:04 +01:00
Emma Finn
277f2375c1 odp-execute: Add ISA implementation of push_vlan action.
This commit adds the AVX512 implementation of the
push_vlan action.

Signed-off-by: Emma Finn <emma.finn@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:40:52 +01:00
Emma Finn
398f80fffc odp-execute: Add ISA implementation of pop_vlan action.
This commit adds the AVX512 implementation of the
pop_vlan action.

Signed-off-by: Emma Finn <emma.finn@intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:40:37 +01:00
Emma Finn
529af67146 odp-execute: Add ISA implementation of actions.
This commit adds the AVX512 implementation of the action functionality.

Usage:
  $ ovs-appctl odp-execute/action-impl-set avx512

Signed-off-by: Emma Finn <emma.finn@intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:40:20 +01:00
Kumar Amber
b52e0b396e acinclude: Add configure option to enable actions autovalidator at build time.
This commit adds a new command to allow the user to enable the
actions autovalidator by default at build time thus allowing for
running unit test by default.

 $ ./configure --enable-actions-default-autovalidator

Signed-off-by: Kumar Amber <kumar.amber@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:40:04 +01:00
Emma Finn
1713fc0116 odp-execute: Add command to switch action implementation.
This commit adds a new command to allow the user to switch
the active action implementation at runtime.

Usage:
  $ ovs-appctl odp-execute/action-impl-set scalar

This commit also adds a new command to retrieve the list of available
action implementations. This can be used by to check what implementations
of actions are available and what implementation is active during runtime.

Usage:
   $ ovs-appctl odp-execute/action-impl-show

Added separate test-case for ovs-actions show/set commands:
odp-execute - actions implementation

Signed-off-by: Emma Finn <emma.finn@intel.com>
Signed-off-by: Kumar Amber <kumar.amber@intel.com>
Signed-off-by: Sunil Pai G <sunil.pai.g@intel.com>
Co-authored-by: Kumar Amber <kumar.amber@intel.com>
Co-authored-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:39:20 +01:00
Emma Finn
eec8227614 odp-execute: Add auto validation function for actions.
This commit introduced the auto-validation function which
allows users to compare the batch of packets obtained from
different action implementations against the linear
action implementation.

The autovalidator function can be triggered at runtime using the
following command:

$ ovs-appctl odp-execute/action-impl-set autovalidator

Signed-off-by: Emma Finn <emma.finn@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:38:54 +01:00
Emma Finn
70b559e97b odp-execute: Add function pointer for pop_vlan action.
This commit removes the pop_vlan action from the large switch
and creates a separate function for batched processing. A function
pointer is also added to call the new batched function for the pop_vlan
action.

Signed-off-by: Emma Finn <emma.finn@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:38:38 +01:00
Emma Finn
95e4a35b0a odp-execute: Add function pointers to odp-execute for different action implementations.
This commit introduces the initial infrastructure required to allow
different implementations for OvS actions. The patch introduces action
function pointers which allows user to switch between different action
implementations available. This will allow for more performance and flexibility
so the user can choose the action implementation to best suite their use case.

Signed-off-by: Emma Finn <emma.finn@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-15 11:38:16 +01:00
Ilya Maximets
d807a2bb4e AUTHORS: Add Jinjun Gao.
Jinjun Gao submitted several patches for the datapath-windows
in 2019 and 2020, but wasn't added to the list of authors.
Fixing that.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-14 15:24:07 +02:00
Ilya Maximets
c5553ce2f6 ovsdb/TODO: Update the list of tasks.
Some of the work is already done, e.g. 'diff' file format
and DNS support.

Added more items collected over time including relay and
local_config items.

Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-14 15:24:07 +02:00
Frode Nordahl
2fc29c4278 man: Fix various typos across manual pages.
As reported by Debian lintian.

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-14 15:24:07 +02:00
Frode Nordahl
0443c1557e Fix spelling error exposed in binaries.
As reported by Debian lintian.

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-07-14 15:24:07 +02:00
Kevin Traynor
70a9f9e96c system-dpdk: Add unit test for user configured mempools.
Test that user configured mempool params have been stored.

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-14 13:17:59 +01:00
Kevin Traynor
55ba0e81dc system-dpdk: Split ovsdb creation and vswitchd start.
Splitting them allows them to be reused separately. This
is useful for setting some things in ovsdb before vswitchd is
started or DPDK is initialized.

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-14 13:17:59 +01:00
Kevin Traynor
3757e9f8e9 netdev-dpdk: Add shared mempool config.
Mempools may currently be shared between DPDK ports based
on port MTU and NUMA. With some hint from the user we can
increase the sharing on MTU and hence reduce memory
consumption in many cases.

For example, a port with MTU 9000, uses a mempool with an
mbuf size based on 9000 MTU. A port with MTU 1500, uses a
different mempool with an mbuf size based on 1500 MTU.

In this case, assuming same NUMA, both these ports could
share the 9000 MTU mempool.

The user must give a hint as order of creation of ports and
setting of MTUs may vary and we need to ensure that upgrades
from older OVS versions do not require more memory.

This scheme can also prevent multiple mempools being created
for cases where a port is added picking up a default MTU and
an appropriate mempool, but later has it's MTU changed to a
different value requiring a different mempool.

Example usage:

 $ ovs-vsctl --no-wait set Open_vSwitch . \
   other_config:shared-mempool-config=9000,1500:1,6000:1

Port added on NUMA 0:
* MTU 1500, use mempool based on 9000 MTU
* MTU 5000, use mempool based on 9000 MTU
* MTU 9000, use mempool based on 9000 MTU
* MTU 9300, use mempool based on 9300 MTU (existing behaviour)

Port added on NUMA 1:
* MTU 1500, use mempool based on 1500 MTU
* MTU 5000, use mempool based on 6000 MTU
* MTU 9000, use mempool based on 9000 MTU
* MTU 9300, use mempool based on 9300 MTU (existing behaviour)

Default behaviour is unchanged and mempools are still only created
when needed.

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Sunil Pai G <sunil.pai.g@intel.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
2022-07-14 13:17:59 +01:00
Ilya Maximets
eacc544c4d tc: Fix misaligned access while creating pedit actions.
calc_offsets() function returns 'data' and 'mask' pointers, which
are pointers somewhere inside struct tc_flower_key, and they are not
aligned, causing misaligned memory access.  For example:

  ipv6.rewrite_hlimit is at 148 byte offset inside the struct
  tc_flower_key.  While the actual field is in the 7th byte of
  the IPv6 header in the actual packet.  So, pedit will need
  to write the last byte of the [4-7] range to the actual packet.
  So, data pointer is positioned to 145th byte inside the tc_flower_key
  with the 000000FF mask.  Obviously, 145th byte inside the structure
  is not 4-byte aligned.

 lib/tc.c:2879:34: runtime error:
   load of misaligned address 0x7f2802eaa321 for type 'ovs_be32' (aka
   'unsigned int'), which requires 4 byte alignment
   0x7f2802eaa321: note: pointer points here
     00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 ...
                  ^
     0 0xd7f2fb in nl_msg_put_flower_rewrite_pedits lib/tc.c:2879:34
     1 0xd7f2fb in nl_msg_put_flower_acts lib/tc.c:3141:25
     2 0xd6ae5a in nl_msg_put_flower_options lib/tc.c:3445:12
     3 0xd6a2be in tc_replace_flower lib/tc.c:3712:17
     4 0xd2bf25 in netdev_tc_flow_put lib/netdev-offload-tc.c:2224:11
     5 0x94f6b7 in netdev_flow_put lib/netdev-offload.c:316:14
     6 0xcbd19e in parse_flow_put lib/dpif-netlink.c:2289:11
     7 0xcbd19e in try_send_to_netdev lib/dpif-netlink.c:2376:15
     8 0xcbd19e in dpif_netlink_operate lib/dpif-netlink.c:2447:23
     9 0x86536e in dpif_operate lib/dpif.c:1372:13
    10 0x6bc289 in handle_upcalls ofproto/ofproto-dpif-upcall.c:1654:5
    11 0x6bc289 in recv_upcalls ofproto/ofproto-dpif-upcall.c:892:9
    12 0x6b766a in udpif_upcall_handler ofproto/ofproto-dpif-upcall.c:792:13
    13 0xb5015a in ovsthread_wrapper lib/ovs-thread.c:422:12
    14 0x7f280b2081ce in start_thread (/lib64/libpthread.so.0+0x81ce)
    15 0x7f2809e39dd2 in clone (/lib64/libc.so.6+0x39dd2)

Fix misaligned read by using appropriate functions.

Fixes: 8ada482bbe ("tc: Add header rewrite using tc pedit action")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
2022-07-14 14:58:10 +02:00
Ilya Maximets
e5162ac42a tc: Fix misaligned access to struct tcf_t for police action.
lib/tc.c:1334:44: runtime error: member access within misaligned address
  0x6210001f5a2c for type 'const struct tcf_t', which requires 8 byte alignment
  0x6210001f5a2c: note: pointer points here
      24 00 06 00 c3 00 00 00  00 00 00 00 c3 00 00 00 ...
                  ^
     0 0xd7c7ea in nl_parse_tcf lib/tc.c:1334:44
     1 0xd7bd3a in nl_parse_act_police lib/tc.c:1433:9
     2 0xd68b1a in nl_parse_single_action lib/tc.c:1922:9
     3 0xd62c7e in nl_parse_flower_actions lib/tc.c:1992:19
     4 0xd62c7e in nl_parse_flower_options lib/tc.c:2107:12
     5 0xd5fa32 in parse_netlink_to_tc_flower lib/tc.c:2155:12
     6 0xd21760 in netdev_tc_flow_dump_next lib/netdev-offload-tc.c:1158:13
     7 0x94f442 in netdev_flow_dump_next lib/netdev-offload.c:301:14
     8 0xcba2f6 in dpif_netlink_flow_dump_next lib/dpif-netlink.c:1901:20
     9 0x8665b6 in dpif_flow_dump_next lib/dpif.c:1135:9
    10 0xee5f0f in dpctl_dump_flows lib/dpctl.c:1106:12
    11 0xee27a3 in dpctl_unixctl_handler lib/dpctl.c:3035:17
    12 0xc7f78b in process_command lib/unixctl.c:310:13
    13 0xc7f78b in run_connection lib/unixctl.c:344:17
    14 0xc7f78b in unixctl_server_run lib/unixctl.c:395:21
    15 0x59acb4 in main vswitchd/ovs-vswitchd.c:130:9
    16 0x7f1be043acf2 in __libc_start_main (/lib64/libc.so.6+0x3acf2)
    17 0x47e91d in _start (vswitchd/ovs-vswitchd+0x47e91d)

Fixes: a9b8cdde69 ("tc: Add support parsing tc police action")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
2022-07-14 14:58:10 +02:00
Ilya Maximets
0d153bffbf netdev-linux: Fix leak of a tc police get/del reply.
Direct leak of 64 byte(s) in 1 object(s) allocated from:
   0 0x51b1d8 in malloc (vswitchd/ovs-vswitchd+0x51b1d8)
   1 0xc81ded in xmalloc__ lib/util.c:137:15
   2 0xc81ded in xmalloc lib/util.c:172:12
   3 0xb32153 in ofpbuf_new lib/ofpbuf.c:168:24
   4 0xd563e4 in nl_sock_transact lib/netlink-socket.c:1113:34
   5 0xd56261 in nl_transact lib/netlink-socket.c:1812:13
   6 0xd5e096 in tc_transact lib/tc.c:238:17
   7 0xd01622 in tc_del_policer_action lib/netdev-linux.c:5807:13
   8 0xd2e681 in meter_tc_del_policer lib/netdev-offload-tc.c:2827:15
   9 0x94ec21 in meter_offload_del lib/netdev-offload.c:245:23
  10 0xcc86c4 in dpif_netlink_meter_del lib/dpif-netlink.c:4288:9
  11 0x86c595 in dpif_meter_del lib/dpif.c:2014:13
  12 0x663439 in free_meter_id ofproto/ofproto-dpif.c:6789:5
  13 0xb47518 in ovsrcu_call_postponed lib/ovs-rcu.c:346:13
  14 0xb48031 in ovsrcu_postpone_thread lib/ovs-rcu.c:362:14
  15 0xb5015a in ovsthread_wrapper lib/ovs-thread.c:422:12
  16 0x7f86af4081ce in start_thread (/lib64/libpthread.so.0+0x81ce)

Fixes: 5c039ddc64 ("netdev-linux: Add functions to manipulate tc police action")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
2022-07-14 14:58:10 +02:00
Ilya Maximets
4dd68ff85b ovsdb: Add missing ovs-thread include.
MSVC doesn't have pthread_t defined by default as other compilers,
so the build fails without the header.

Fixes: 3cd2cbd684 ("ovsdb: Prepare snapshot JSON in a separate thread.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Dumitru Ceara <dceara@redhat.com>
2022-07-14 12:19:39 +02:00