2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 05:47:55 +00:00

20088 Commits

Author SHA1 Message Date
David Marchand
f01a768e95 ci: Restore vhost-user unit tests in check-dpdk.
Following a rework in the DPDK cache, the PATH variable is incorrectly
set, resulting in dpdk-testpmd not being available.
Because of this, vhost-user unit tests were skipped in GHA runs.

Fixes: 8893e24d9d09 ("dpdk: Update to use v23.11.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-07 11:43:37 +01:00
David Marchand
2efae58940 system-dpdk: Fix socket conflict when starting testpmd.
The DPDK telemetry library tries to connect to existing socket files so
that it knows whether it can take over them.

As was reported by Christian, following a fix in DPDK that got backported
in v23.11.1, vhost-user unit tests that have both OVS and testpmd running
at the same time reveal a conflict over the telemetry socket.
This conflict shows up as an error message in OVS logs which makes those
tests fail in the CI:

2024-06-06T13:03:38.351Z|00001|dpdk|ERR|TELEMETRY: Socket write base info
	to client failed

The EAL file-prefix option affects both the directory where DPDK stores
running files (like the telemetry socket) and how files backing hugepages
are named (when in non --in-memory mode).
Configure (again) this prefix so that testpmd runs in a dedicated directory.

Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2024-June/414545.html
Fixes: c488f28a0eaf ("system-dpdk: Don't require hugetlbfs.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-07 11:43:37 +01:00
David Marchand
c39a84c131 netdev-dpdk: Refactor tunnel checksum offloading.
All information required for checksum offloading can be deduced by
already tracked dp_packet l3_ofs, l4_ofs, inner_l3_ofs and inner_l4_ofs
fields.
Remove DPDK specific l[2-4]_len from generic OVS code.

netdev-dpdk code then fills mbuf specifics step by step:
- outer_l2_len and outer_l3_len are needed for tunneling (and below
  features),
- l2_len and l3_len are needed for IP and L4 checksum (and below features),
- l4_len and tso_segsz are needed when doing TSO,

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
2024-06-06 17:10:29 +01:00
David Marchand
844a7cfa6e netdev-dpdk: Use guest TSO segmentation size hint.
In a typical setup like:
guest A <-virtio-> OVS A <-vxlan-> OVS B <-virtio-> guest B

TSO packets from guest A are segmented against the OVS A physical port
mtu adjusted by the vxlan tunnel header size, regardless of guest A
interface mtu.

As an example, let's say guest A and guest B mtu are set to 1500 bytes.
OVS A and OVS B physical ports mtu are set to 1600 bytes.
Guest A will request TCP segmentation for 1448 bytes segments.
On the other hand, OVS A will request 1498 bytes segments to the HW.
This results in OVS B dropping packets because decapsulated packets
are larger than the vhost-user port (serving guest B) mtu.

2024-04-17T14:13:01.239Z|00002|netdev_dpdk(pmd-c03/id:7)|WARN|vhost0:
	Too big size 1564 max_packet_len 1518

vhost-user ports expose a guest mtu by filling mbuf->tso_segsz.
Use it as a hint.

This may result in segments (on the wire) slightly shorter than the
optimal size.

Reported-at: https://github.com/openvswitch/ovs-issues/issues/321
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
2024-06-06 17:10:11 +01:00
David Marchand
d618d09173 netdev-dpdk: Refactor TSO request code.
Every L3, L4 checksum offload or TSO requires a (outer) L3 length to be
provided.
This length is computed via dp_packet_l4(pkt) that is always set when
such offloads are requested in OVS.
Getting a th == NULL is a bug in OVS, so an assert() is more appropriate.

Besides, filling l4_len and tso_segsz only matters to TSO, so there is
no need to set it for other L4 checksum offloading requests.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
2024-06-06 17:10:05 +01:00
David Marchand
3d2c8223ab netdev-dpdk: Fix inner checksum when outer is not supported.
If outer checksum is not supported and OVS already set L3/L4 outer
checksums in the packet, no outer mark should be left in ol_flags
(as it confuses some driver, like net/ixgbe).

l2_len must be adjusted to account for the tunnel header.

Fixes: 084c8087292c ("userspace: Support VXLAN and GENEVE TSO.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
2024-06-06 17:09:58 +01:00
David Marchand
29abd07e4f netdev-dpdk: Disable outer UDP checksum for net/iavf.
Same as the commit 6f93d8e62f13 ("netdev-dpdk: Disable outer UDP checksum
offload for ice/i40e driver."), disable outer UDP checksum and related
offloads for net/iavf.

Fixes: 084c8087292c ("userspace: Support VXLAN and GENEVE TSO.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
2024-06-06 17:09:52 +01:00
David Marchand
041d6adeda netdev-dpdk: Fallback to non tunnel checksum offloading.
The outer checksum offloading API in DPDK is ambiguous and was
implemented by Intel folks in their drivers with the assumption that
any outer offloading always goes with an inner offloading request.

With net/i40e and net/ice drivers, in the case of encapsulating a ARP
packet in a vxlan tunnel (which results in requesting outer ip checksum
with a tunnel context but no inner offloading request), a Tx failure is
triggered, associated with a port MDD event.
2024-03-27T16:02:07.084Z|00018|dpdk|WARN|ice_interrupt_handler(): OICR:
	MDD event

To avoid this situation, if no checksum or segmentation offloading is
requested on the inner part of a packet, fallback to "normal" (non outer)
offloading request.

Reported-at: https://github.com/openvswitch/ovs-issues/issues/321
Fixes: 084c8087292c ("userspace: Support VXLAN and GENEVE TSO.")
Fixes: f81d782c1906 ("netdev-native-tnl: Mark all vxlan/geneve packets as tunneled.")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
2024-06-06 17:09:37 +01:00
Maor Dickman
6280f5d04a netdev-offload-tc: Reserve lower tc prio for vlan ethertype.
The cited commit reserved lower tc priorities for IP ethertypes in order
to give IP traffic higher priority than other management traffic.
In case of of vlan encap traffic, IP traffic will still get lower
priority.

Fix it by also reserving low priority tc prio for vlan.

Fixes: c230c7579c14 ("netdev-offload-tc: Reserve lower tc prios for ip ethertypes")
Signed-off-by: Maor Dickman <maord@nvidia.com>
Acked-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Simon Horman <horms@ovn.org>
2024-06-06 13:45:48 +01:00
Roi Dayan
792e8ee869 debian: Fix tabs vs spaces.
Getting the following message while trying to build a debian package.
debian/openvswitch-switch.init
debian/openvswitch-switch.postinst
See above for files that use tabs for indentation.
Please use spaces instead.
Fix it.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Simon Horman <horms@ovn.org>
2024-06-06 11:37:29 +01:00
Ilya Maximets
ac4df0c8db nsh: Add support to compose-packet and use it in system tests.
OVS can parse NSH, but can't compose.  Fix that and get rid of plain
hex NSH packets in system tests as they are hard to read or modify.

Tcpdump calls modified to write actual pcaps instead of text output,
so ovs-pcap can be used while checking the results.

While at it, replacing sleeps with more robust waiting for tcpdump
to start listening.

M4 macros are better than shell variables, because we can see the
substitution result in the test log.  So, using m4_define and m4_join
extensively.

Acked-by: Simon Horman <horms@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-06-06 00:12:37 +02:00
Ilya Maximets
cd4ea33b5b tests: Convert ND, MPLS and CT sendpkt tests to compose-packet.
These tests contain plain hex dumps that are hard to read and modify.
Replace with equivalent calls to ovs-ofctl compose-packet --bare and
ovs-pcap.

Tcpdump calls modified to write actual pcaps instead of text output,
so ovs-pcap can be used while checking the results.

While at it, replacing sleeps with more robust waiting for tcpdump
to start listening.

M4 macros are better than shell variables, because we can see the
substitution result in the test log.  So, using m4_define and m4_join
extensively.

Acked-by: Simon Horman <horms@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-06-06 00:12:37 +02:00
Ilya Maximets
40f0ac48ff tests: sendpkt: Allow different input formats.
We require python 3, so instead of manually parsing bytes on input we
can use built-in bytes.fromhex().  This function ignores whitespaces,
so we can use different input formats - the old style space-separated
bytes as well as pure hex strings provided by ovs-ofctl compose-packet
and ovs-pcap.

Acked-by: Simon Horman <horms@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-06-06 00:12:37 +02:00
Mike Pattrick
16f6885353 ipf: Handle common case of ipf defragmentation.
When conntrack is reassembling packet fragments, the same reassembly
context can be shared across multiple threads handling different packets
simultaneously. Once a full packet is assembled, it is added to a packet
batch for processing, in the case where there are multiple different pmd
threads accessing conntrack simultaneously, there is a race condition
where the reassembled packet may be added to an arbitrary batch even if
the current batch is available.

When this happens, the packet may be handled incorrectly as it is
inserted into a random openflow execution pipeline, instead of the
pipeline for that packets flow.

This change makes a best effort attempt to try to add the defragmented
packet to the current batch. directly. This should succeed most of the
time.

Fixes: 4ea96698f667 ("Userspace datapath: Add fragmentation handling.")
Reported-at: https://issues.redhat.com/browse/FDP-560
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Paolo Valerio <pvalerio@redhat.com>
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-06-05 10:38:52 -04:00
Mike Pattrick
3a6b8c8361 ipf: Only add fragments to batch of same dl_type.
When conntrack is reassembling packet fragments, the same reassembly
context can be shared across multiple threads handling different packets
simultaneously. Once a full packet is assembled, it is added to a packet
batch for processing, this is most likely the batch that added it in the
first place, but that isn't a guarantee.

The packets in these batches should be segregated by network protocol
version (ipv4 vs ipv6) for conntrack defragmentation to function
appropriately. However, there are conditions where we would add a
reassembled packet of one type to a batch of another.

This change introduces checks to make sure that reassembled or expired
fragments are only added to packet batches of the same type.

Fixes: 4ea96698f667 ("Userspace datapath: Add fragmentation handling.")
Reported-at: https://issues.redhat.com/browse/FDP-560
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Paolo Valerio <pvalerio@redhat.com>
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-06-05 10:35:32 -04:00
Simon Horman
1d681ffe3b AUTHORS: Add Ville Skyttä.
Add Ville Skyttä to AUTHORS file.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <horms@ovn.org>
2024-06-04 10:14:30 +01:00
Ville Skyttä
90b8e4d053 docs: afxdp: Fix CONFIG_HAVE_EBPF_JIT Kconfig option spelling.
Fix CONFIG_HAVE_EBPF_JIT Kconfig option spelling "EBPF" vs "BPF").

Signed-off-by: Ville Skyttä <ville.skytta@upcloud.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <horms@ovn.org>
2024-06-04 10:13:58 +01:00
Simon Horman
4a838f627c AUTHORS: Add Jun Gu.
Add Jun Gu to AUTHORS file.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <horms@ovn.org>
2024-06-04 10:13:50 +01:00
Jun Gu
8e2b06af98 ovs-ctl: Fix typo.
Correct spelling of destination in ovs-ctl.in.

Signed-off-by: Jun Gu <jun.gu@easystack.cn>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Simon Horman <horms@ovn.org>
2024-06-04 10:11:37 +01:00
Terry Wilson
4c0e1a1d70 python: ovsdb-idl: Use monitor_cond for _Server DB.
Unlike the C IDL code, the Python version still monitors the
_Server DB with "monitor" instead of "monitor_cond". This results
in receiving an entire Database row every time the "index" value
is updated which includes the 'schema' column. Using "monitor_cond"
will result in "update2" notifications which just include the
changed "index" value.

Unlike the C IDL, the Python IDL requires a SchemaHelper object
to instantiate the IDL, leaving it to the user of the library to
call "get_schema" themselves. Since the Python IDL did not have
support for retrieving the schema automatically and did not have
a state for doing so, instead of transitioning on an error response
from retrieving the _Server schema to requesting the "data" schema,
this moves directly to monitoring the "data" DB.

Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-06-03 21:40:35 +02:00
Terry Wilson
474ebd6dd5 ovsdb-idl: Add C IDL test for "monitor" fallback.
There was a Python-only test for ensuring that the library would
work when connecting to an older ovsdb-server that did not support
monitor_cond. This adds a C IDL version of that test.

Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-06-03 21:35:37 +02:00
Ilya Maximets
6003a88759 tests: Fix non-portable plus match in python vlog test.
'\+' as a one-or-more match is a GNU extension and it doesn't work
in BSD sed.  This makes the python vlog test to fail on FreeBSD 14
that recently got python 3.11 in CirrusCI:

 |  --- -   2024-06-03 10:42:26.363566000 +0000
 |  +++ /tmp/cirrus-ci-build/tests/testsuite.dir/at-groups/2541/stdout
 |  @@ -7,31 +7,37 @@
 |   Traceback (most recent call last):
 |     File <name>, line <number>, in main
 |       assert fail
 |  +           ^^^^

Remove the '\+' match to make the line removal work.  It doesn't do
much for us as we would remove the same lines either way.

This change makes CirrusCI green again.

Fixes: 9185793e7543 ("tests: Fix compatibility issue with Python 3.13 in vlog.at.")
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-06-03 14:50:46 +02:00
Eelco Chaudron
f2e4195b0c netdev-linux: Fix uninitialized gso_type case.
This patch fixes an uninitialized gso_type case in
netdev_linux_prepend_vnet_hdr() by returning an error.

Fixes: 3337e6d91c5b ("userspace: Enable L4 checksum offloading by default.")
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:27:38 +02:00
Eelco Chaudron
d97eee88e5 db-ctl-base: Initialize the output variable in the ctx structure.
Coverity was flagged that the uninitialized output variable was used
in the ctl_context_init_command() function. This patch initializes
the variable.

In addition it also destroys the ds string in ctl_context_done()
in case it's not cleared properly.

Fixes: 07ff77ccb82a ("db-ctl-base: Make common database command code into library.")
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:25:03 +02:00
Eelco Chaudron
361d7bce0f ofproto-dpif: Define age as time_t in ofproto_unixctl_fdb_add().
Fix the warning from Coverity about potential truncation of the
time_t value when copying to a local variable by changing the
local variable's type to time_t.

Fixes: ccc24fc88d59 ("ofproto-dpif: APIs and CLI option to add/delete static fdb entry.")
Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:23:41 +02:00
Eelco Chaudron
f673d0cd5f sflow: Fix check for disabled receive time.
Changed sFlowRcvrTimeout to a uint32_t to avoid time_t warnings
reported by Coverity. A uint32_t is more than large enough as
this is a (seconds) tick counter and OVS is not even using this.

Fixes: c72e245a0e2c ("Add InMon's sFlow Agent library to the build system.")
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:23:41 +02:00
Eelco Chaudron
11e48b8ca2 sflow: Use uint32_t instead of time_t for tick handling in the poller.
The sFlow library uses a uint32_t to configure timeout ticks, but
stores this value as a time_t. Although this doesn't cause functional
issues, it wastes space and confuses Coverity, potentially indicating
a Y2K38 problem when storing uint32_t values in time_t. This patch
updates the internal data structures to use uint32_t variables.

Fixes: c72e245a0e2c ("Add InMon's sFlow Agent library to the build system.")
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:23:41 +02:00
Eelco Chaudron
e42d3ed298 sflow: Replace libc's random() function with the OVS's random_range().
Coverity has flagged the use of a potentially unsafe function.
Although this is not a concern in this case since it's not used for
encryption, we should replace it with the OVS implementation to
achieve better randomness.

Fixes: c72e245a0e2c ("Add InMon's sFlow Agent library to the build system.")
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:23:41 +02:00
Eelco Chaudron
b253d74d48 cfm: Fix possible integer overflow in tc_add_matchall_policer().
Fix unintentional integer overflow reported by Coverity by adding
the LL suffix to the numerical literals used in the multiplication.

Fixes: 5767a79a4059 ("cfm: Require ccm received in demand mode.")
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:23:41 +02:00
Eelco Chaudron
18436bed85 netdev-linux: Fix possible int overflow in tc_add_matchall_policer().
Fix unintentional integer overflow reported by Coverity by adding
the ULL suffix to the numerical literals used in the multiplications.

Fixes: ed2300cca0d3 ("netdev-linux: Refactor put police action netlink message")
Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-06-03 13:23:11 +02:00
Kevin Traynor
488ad8beec dpdk: Use DPDK 23.11.1 release.
Update the CI and docs to use DPDK 23.11.1.

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
2024-05-30 17:24:52 +01:00
Emma Finn
7af0716ea6 odp-execute: Fix AVX checksum calculation.
The AVX implementation for calculating checksums was not
handling carry-over addition correctly in some cases.
This patch adds an additional shuffle to add 16-bit padding to
the final part of the calculation to handle such cases. This
commit also adds a unit test to check the checksum carry-bits
issue with actions autovalidator enabled.

Reported-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Emma Finn <emma.finn@intel.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-05-30 16:10:20 +02:00
Mike Pattrick
4d25656a23 netdev-linux: Initialize link speed in error conditions.
Clang's static analyzer noted that the output from
netdev_linux_get_speed_locked can be checked even if this function
doesn't set any values.

Now we always set those values to a sane default in all cases.

Fixes: 19cffe30cfda ("netdev-linux: Avoid deadlock in netdev_get_speed.")
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-28 22:18:55 +02:00
Mike Pattrick
0c1b9b015d netdev-linux: Return an error if device feature names are empty.
When retrieving a list of features supported by a network card, return
with an error code if the request completed without an error but the
list contains zero entries.

In practice this should never happen, but it does contribute to a
detection in Clang's static analyzer.

Fixes: 6c59c195266c ("netdev-linux: Use ethtool to detect offload support.")
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-28 22:18:55 +02:00
Mike Pattrick
4837b5fed3 socket: Fix uninitialized values in inet_parse_ functions.
Clang's static analyzer will complain about uninitialized value
dns_failure because we weren't setting a value for dns_failure in all
code paths.

Now we initialize this in the error conditions of inet_parse_passive and
inet_parse_active.

Fixes: 08e9e5337383 ("ovsdb: raft: Fix inability to read the database with DNS host names.")
Fixes: 5f219af8b3c7 ("ovsdb-server: Fix handling of DNS name for listener configuration.")
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-28 22:18:55 +02:00
Mike Pattrick
51a2476bc2 dpctl: Fix uninitialized value when deleting flows.
Clang's static analyzer will complain about an uninitialized value
because we weren't setting a value for ufid_generated in all code paths.

Now we initialize this on declaration. This patch also corrects the
reverse x-mass of variable declaration.

Fixes: bbe2e3928747 ("dpctl: Fix broken flow deletion via ovs-dpctl due to missing ufid.")
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-28 22:18:55 +02:00
Mike Pattrick
8359cc422e netdev-native-tnl: Fix use of uninitialized offset on SRv6 header pop.
Clang's static analyzer will complain about uninitialized value 'hlen'
because we weren't properly checking the error code from a function that
would have initialized the value.

Instead, add a check for that return code.

Fixes: 03fc1ad78521 ("userspace: Add SRv6 tunnel support.")
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-28 22:18:55 +02:00
Mike Pattrick
8e5a89cd04 netdev-offload: Fix null pointer dereference warning on dump creation.
Clang's static analyzer will complain about a null pointer dereference
because dumps can be set to null and then there is a loop where it could
have been written to. This is a false positive, but only because the
netdev dpif type won't change during this loop.

Instead, return early from the netdev_ports_flow_dump_create function if
dumps is NULL.

Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-28 22:18:55 +02:00
Roi Dayan
ce1663b5fe netdev-linux: Fix ethtool_cmd is partly outside array bounds.
Used Ubuntu with gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

 lib/netdev-linux.c: In function 'netdev_linux_construct':
 lib/netdev-linux.c:7003:15: error:
    array subscript 'struct ethtool_cmd[0]' is partly outside array
    bounds of ‘union <anonymous>[1]’ [-Werror=array-bounds]
  7003 |     ecmd->cmd = cmd;
       |     ~~~~~~~~~~^~~~~
 lib/netdev-linux.c:2411:7: note: while referencing ‘sset_info’
  2411 |     } sset_info;
       |       ^~~~~~~~~

Fixes: 6c59c195266c ("netdev-linux: Use ethtool to detect offload support.")
Signed-off-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-28 22:17:35 +02:00
Ilya Maximets
d4bd0a2ad5 atlocal: Replace deprecated pkg_resources.
'pkg_resources' module is deprecated and no longer available in newer
versions of python, so pytest tests are skipped:

  DeprecationWarning: pkg_resources is deprecated as an API.
  See https://setuptools.pypa.io/en/latest/pkg_resources.html

Unfortunately, there is no direct replacement for it and functionality
is scattered between different packages.

Using a new standard library importlib.metadata to find installed
packages and their versions.  Using packaging.requirements to parse
lines from the requirements file and compare versions.  This covers
all we need.

The 'packaging' is a project used by pip and a dependency for many
other libraries, so should be available for any supported verison of
python.  'importlib' was introduced in python 3.8.  Since we support
older versions of python and 'packaging' is not part of the standard
library, checking that import is possible and falling back to
'pkg_resources' if needed.  We may remove the fallback when we stop
supporting python below 3.8.

Even though 'packaging' is a common dependency, added to the test
requirements so it will not be missed in CI.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-22 23:02:00 +02:00
Ilya Maximets
4d2c64ca1b atlocal: Fix setting HAVE_PYTEST on unexpected errors.
If the python script throws an unexpected exception, the HAVE_PYTEST
variable remains undefined.  If at the same time dependencies are not
actually present, pytest tests will fail instead of being skipped.

Define the variable to 'no' on unexpected failures to skip the tests
when dependencies cannot be verified.

The issue can be reproduced on systems with python 3.12+ in case the
deprecated 'pkg_resources' module is not available.

Fixes: 445dceb88461 ("python: Introduce unit tests.")
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-22 23:01:43 +02:00
Ilya Maximets
320f7e1a40 srv6: Fix misaligned writes to segment list.
Segments list in SRv6 header is 16-bit aligned as most of other fields
in packet headers.  A little counter-intuitively, compilers are allowed
to make alignment assumptions based on the pointer type passed to
memcpy(), so they can use copy instructions that require 32-bit alignment
in case of struct in6_addr pointer.  Reported by UBsan in Clang 18:

 lib/netdev-native-tnl.c:985:16: runtime error: store to misaligned
       address 0x7fd9e97351ce for type 'struct in6_addr *', which
       requires 4 byte alignment
 0x7fd9e97351ce: note: pointer points here
 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
             ^
   0 0xc1de38 in netdev_srv6_build_header lib/netdev-native-tnl.c:985:9
   1 0x6e794b in tnl_port_build_header ofproto/tunnel.c:751:11
   2 0x6c9c0a in native_tunnel_output ofproto/ofproto-dpif-xlate.c:3887:11
   3 0x6c9c0a in compose_output_action__ ofproto/ofproto-dpif-xlate.c:4502:13
   4 0x6b6646 in compose_output_action ofproto/ofproto-dpif-xlate.c:4564:5
   5 0x6b6646 in xlate_output_action ofproto/ofproto-dpif-xlate.c:5517:13
   6 0x68cfee in do_xlate_actions ofproto/ofproto-dpif-xlate.c:7288:13
   7 0x67fed0 in xlate_actions ofproto/ofproto-dpif-xlate.c:8314:13
   8 0x6468bd in ofproto_trace__ ofproto/ofproto-dpif-trace.c:782:30
   9 0x64484a in ofproto_trace ofproto/ofproto-dpif-trace.c:851:5
  10 0x647469 in ofproto_unixctl_trace ofproto/ofproto-dpif-trace.c:490:9
  11 0xc33771 in process_command lib/unixctl.c:310:13
  12 0xc33771 in run_connection lib/unixctl.c:344:17
  13 0xc33771 in unixctl_server_run lib/unixctl.c:395:21
  14 0x53e6ef in main vswitchd/ovs-vswitchd.c:131:9
  15 0x7f61c7 in __libc_start_call_main (/lib64/libc.so.6+0x2a1c7)
  16 0x7f628a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2a28a)
  17 0x42ca24 in _start (vswitchd/ovs-vswitchd+0x42ca24)

 SUMMARY: UndefinedBehaviorSanitizer:
          undefined-behavior lib/netdev-native-tnl.c:985:16

Having misaligned pointers is also generally not allowed in C, let
alone accessing memory through them.

Fix that by using an appropriate ovs_16aligned_in6_addr pointer instead.

Fixes: 7381fd440a88 ("odp: Add SRv6 tunnel actions.")
Fixes: 03fc1ad78521 ("userspace: Add SRv6 tunnel support.")
Reviewed-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-22 23:00:27 +02:00
Eelco Chaudron
0c8e626401 utilities: Correct deletion reason in flow_reval_monitor.py.
The flow_reval_monitor.py script incorrectly reported the reasons for
FDR_PURGE and FDR_TOO_EXPENSIVE, as their descriptions were swapped.
This patch rectifies the order using a dictionary to avoid similar
problems in the future.

In addition this patch also syncs the delete reason output of the
script, with the comments in the code.

Fixes: 86b9e653ef22 ("revalidator: Add a USDT probe during flow deletion with purge reason.")
Acked-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
2024-05-21 13:31:02 +02:00
Mike Pattrick
ec405e8573 compiler: Fix errors in Clang 17 ubsan checks.
This patch attempts to fix a large number of ubsan error messages that
take the following form:

lib/netlink-notifier.c:237:13: runtime error: call to function
    route_table_change through pointer to incorrect function type
    'void (*)(const void *, void *)'

In Clang 17 the undefined behaviour sanitizer check for function
pointers was enabled by default, whereas it was previously disabled
while compiling C code. These warnings are a false positive in the case
of OVS, as our macros already check to make sure the function parameter
is the correct size.

So that check is disabled in the single function that is causing all of
the errors.

Acked-by: Jakob Meng <jmeng@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-17 15:21:48 +02:00
Ilya Maximets
8d5486b653 AUTHORS: Add Amit Prakash Shukla.
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-17 13:37:05 +02:00
Amit Prakash Shukla
325ca04550 packets: Assert for incorrect packet.
Packets that are not encapsulated but metadata of the packet contains
an offload flag set, will call dp_packet_inner_l4 to get TCP, UDP, SCTP
header pointers. dp_packet_inner_l4 for such packets would return NULL
as the inner offsets by-default are configured as UINT16_MAX. On
dereferencing such pointers, segfault is observed.

Add assert check for packets with incorrect header or incorrect offload
flag set.

[i.maximets] Note: segfault was caused by a faulty driver, not OVS logic.
Assertion will allow catching such issues earlier and get more
information from the process instead of letting it crash somewhere later.

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-17 13:35:52 +02:00
Ilya Maximets
f61e1da462 AUTHORS: Add Pengfei Sun.
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-17 13:28:23 +02:00
Pengfei Sun
ac7a10721f table: Fix freeing global variable.
In function shash_replace_nocopy, argument to free() is the address
of a global variable (argument passed by function table_print_json__),
which is not memory allocated by malloc().

ovsdb-client -f json monitor Open_vSwitch --timestamp

ASan reports:

 =================================================================
 ==1443083==ERROR: AddressSanitizer: attempting free on address
 which was not malloc()-ed: 0x000000535980 in thread T0
    0 0xfc9eac in __interceptor_free (/usr/lib64/libasan.so.6)
    1 0x4826e4 in json_destroy_object lib/json.c:445
    2 0x4826e4 in json_destroy__ lib/json.c:403
    3 0x4cc4e4 in table_print lib/table.c:633
    4 0x410650 in monitor_print_table ovsdb/ovsdb-client.c:1019
    5 0x410650 in monitor_print ovsdb/ovsdb-client.c:1040
    6 0x4110cc in monitor_print ovsdb/ovsdb-client.c:1030
    7 0x4110cc in do_monitor__ ovsdb/ovsdb-client.c:1503
    8 0x40743c in main ovsdb/ovsdb-client.c:283
    9 0xf50038  (/usr/lib64/libc.so.6+0x2b038)
   10 0xf50110 in __libc_start_main (/usr/lib64/libc.so.6)
   11 0x40906c in _start (/usr/local/bin/ovsdb-client)

Fixes: cb139fa8b3a1 ("table: New function table_format() for formatting a table as a string.")
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Pengfei Sun <sunpengfei16@huawei.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-17 13:25:25 +02:00
Peng He
90cd797da1 vlog: Destroy async_append first then close log_fd.
async_append stores log_fd, it should be destructed before log_fd
is closed.

Fixes: 81d6495fd937 ("vlog: Make thread-safe.")
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Peng He <hepeng.0320@bytedance.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-17 13:24:30 +02:00
Mike Pattrick
3833506db0 conntrack: Fully initialize conn struct before insertion.
In case packets are concurrently received in both directions, there's
a chance that the ones in the reverse direction get received right
after the connection gets added to the connection tracker but before
some of the connection's fields are fully initialized.
This could cause OVS to access potentially invalid, as the lookup may
end up retrieving the wrong offsets during CONTAINER_OF(), or
uninitialized memory.

This may happen in case of regular NAT or all-zero SNAT.

Fix it by initializing early the connections fields.

Fixes: 1116459b3ba8 ("conntrack: Remove nat_conn introducing key directionality.")
Reported-at: https://issues.redhat.com/browse/FDP-616
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Co-authored-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-13 21:00:58 +02:00