net: openvswitch: fix a feature leak on a failed change
Subsystems (5)
v4 cover net: openvswitch: fix a feature leak on a failed change
The datapath records the user features before it applies the change, so a request that fails leaves it claiming a bit whose reference count was never taken. The first patch records the features last. The second adds a selftest that drives the failing request and reads back what the datapath reports.
v4:
- Rebased onto current main.
- The skip message is one printf again. Splitting it made shellcheck report SC2182 and dropped a word and the newline from the output.
- The new tests say why they failed on stdout. info() writes debug.log and a failing run deletes that file, so CI showed a FAIL with no reason.
- A datapath that cannot be read is reported as that instead of as a feature mismatch.
- The outdated add-dp request is checked instead of discarded.
- The errno numbers come from python rather than from a literal, and a lookup that cannot answer says so rather than comparing against an empty string.
v3: https://lore.kernel.org/netdev/[email protected]/
- Cover the recirc bit as well as the dispatch bit.
v2: https://lore.kernel.org/netdev/[email protected]/
- Name the two paths that leaked a reference and fix both.
v1: https://lore.kernel.org/netdev/[email protected]/
Neither leak has a test of its own. The reference count behind the bit is not visible from user space, so the tests read back the features a datapath reports: the reset drops them to zero where a test can see it, and a datapath freed after a failed creation leaves no state to check.
One thing this series leaves alone: ovs_add_dp() returns the status of the last command in its body rather than of the add, so the || return 1 that follows its calls cannot fail. That predates this series and every OVS test shares it. The two tests here do not depend on it.
Minxi Hou (2):
net: openvswitch: do not record user features when the change fails selftests/net/openvswitch: check that a failed set keeps the features
net/openvswitch/datapath.c | 34 ++-- net/openvswitch/datapath.h | 5 +- .../testing/selftests/net/openvswitch/config | 3 + .../selftests/net/openvswitch/openvswitch.sh | 173 ++++++++++++++++++ .../selftests/net/openvswitch/ovs-dpctl.py | 61 ++++++ 5 files changed, 262 insertions(+), 14 deletions(-)
base-commit: 6964ff21c5d8b75649211a52dbfd92753e605649
Signature · 1 line
2.56.1
PATCH v4 1/2 net: openvswitch: do not record user features when the change fails
ovs_dp_change() stores the new features in dp->user_features before it updates the per-cpu upcall port IDs, and that update fails when the per-cpu-pids attribute is empty or its length is not a multiple of four. The request returns -EINVAL with the new features already recorded, while the code that enables or disables the tc skb extension key never ran.
The datapath then claims TC_RECIRC_SHARING without holding the reference the bit stands for. A later request that clears the bit drops a reference that was never taken, and a datapath destroyed with the bit clear never drops the one it did take. The key is shared with the other users of recirc sharing, so the count can reach zero while one of them still reads it, and a disable on a count of zero warns from static_key_dec_not_one(), which panics a host that runs with panic_on_warn.
The request only needs CAP_NET_ADMIN, which a user namespace that owns a network namespace provides. datapath_policy has no entry for OVS_DP_ATTR_PER_CPU_PIDS and the operation skips strict validation, so an empty attribute reaches the check that fails.
Record the features last, in one setter that also takes and drops the reference, and use it from every place that changes or clears the bit. Two of those places leaked a reference: a datapath that fails after ovs_dp_change() enabled the key was freed without a disable, and ovs_dp_reset_user_features() cleared the bit without one. The reset runs when an outdated user space instance sends OVS_DP_CMD_NEW for a name that already exists, and after it the datapath's packets no longer share the tc skb extension.
--- net/openvswitch/datapath.c | 34 +++++++++++++++++++++------------- net/openvswitch/datapath.h | 5 ++++- 2 files changed, 25 insertions(+), 14 deletions(-)
net/openvswitch/datapath.c +21 -13
@@ -1704,6 +1704,20 @@ static struct datapath *lookup_datapath(struct net *net,return dp ? dp :ERR_PTR (-ENODEV ); } +/* Called with ovs_mutex. */ +static void ovs_dp_set_user_features (struct datapath *dp,u32 features) +{ +bool was = dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ; +bool now = features &OVS_DP_F_TC_RECIRC_SHARING ; + +if (now && !was) +tc_skb_ext_tc_enable (); +else if (!now && was) +tc_skb_ext_tc_disable (); + + dp->user_features = features; +} +static void ovs_dp_reset_user_features (struct sk_buff *skb,struct genl_info *info) {
@@ -1716,7 +1730,7 @@ static void ovs_dp_reset_user_features(struct sk_buff *skb,pr_warn ("%s: Dropping previously announced user features\n" ,ovs_dp_name (dp)); - dp->user_features =0 ; +ovs_dp_set_user_features (dp,0 ); } static int ovs_dp_set_upcall_portids(struct datapath *dp,
@@ -1773,7 +1787,7 @@ u32 ovs_dp_get_upcall_portid(const struct datapath *dp, uint32_t cpu_id)static int ovs_dp_change (struct datapath *dp,struct nlattr *a[]) { -u32 user_features =0 , old_features = dp->user_features; +u32 user_features =0 ;int err;if (a[OVS_DP_ATTR_USER_FEATURES ]) {
@@ -1801,9 +1815,7 @@ static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])return err; } - dp->user_features = user_features; - -if (dp->user_features &OVS_DP_F_DISPATCH_UPCALL_PER_CPU && +if (user_features &OVS_DP_F_DISPATCH_UPCALL_PER_CPU && a[OVS_DP_ATTR_PER_CPU_PIDS ]) {/* Upcall Netlink Port IDs have been updated */ err = ovs_dp_set_upcall_portids(dp,
@@ -1812,12 +1824,7 @@ static int ovs_dp_change(struct datapath *dp, struct nlattr *a[])return err; } -if ((dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) && - !(old_features &OVS_DP_F_TC_RECIRC_SHARING )) -tc_skb_ext_tc_enable (); -else if (!(dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) && - (old_features &OVS_DP_F_TC_RECIRC_SHARING )) -tc_skb_ext_tc_disable (); +ovs_dp_set_user_features (dp, user_features);return 0 ; }
@@ -1939,6 +1946,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) err_destroy_portids:kfree (rcu_dereference_raw (dp->upcall_portids)); err_unlock_and_destroy_meters: +/* The datapath is freed here and never reaches __dp_destroy(). */ +ovs_dp_set_user_features (dp,0 );ovs_unlock ();ovs_meters_exit (dp); err_destroy_ports:
@@ -1961,8 +1970,7 @@ static void __dp_destroy(struct datapath *dp)struct flow_table *table = &dp->table;int i; -if (dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) -tc_skb_ext_tc_disable (); +ovs_dp_set_user_features (dp,0 );for (i =0 ; i <DP_VPORT_HASH_BUCKETS ; i++) {struct vport *vport;
net/openvswitch/datapath.h +4 -1
@@ -76,7 +76,10 @@ struct dp_nlsk_pids {* ovs_mutex and RCU. * @stats_percpu: Per-CPU datapath statistics. * @net: Reference to net namespace. -* @user_features: Bitmap of enabled %OVS_DP_F_* features. +* @user_features: Bitmap of enabled %OVS_DP_F_* features. A datapath +* that has %OVS_DP_F_TC_RECIRC_SHARING set holds one reference to the tc +* skb extension, so this field is written last, through +* ovs_dp_set_user_features(), with ovs_mutex held. * @max_headroom: The maximum headroom of all vports in this datapath; it will * be used by all the internal vports in this dp. * @meter_tbl: Meter table.
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH net v4 1/2] net: openvswitch: do not record user features when the change fails
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] The patch changes __dp_destroy() (net/openvswitch/datapath.c:1973) so that its first statement is…
--
net: openvswitch: do not record user features when the change fails
This patch moves the write of dp->user_features in ovs_dp_change() so it happens after the per-cpu upcall portid update. It adds ovs_dp_set_user_features(), which keeps the tc skb extension reference in sync with the OVS_DP_F_TC_RECIRC_SHARING bit. The helper is then used from ovs_dp_reset_user_features(), the ovs_dp_cmd_new() error path and __dp_destroy().
Quoted 22 lines
net/openvswitch/datapath.c +14
-0@@ -1704,6 +1704,20 @@ static struct datapath *lookup_datapath(struct net *net,return dp ? dp :ERR_PTR (-ENODEV ); } +/* Called with ovs_mutex. */ +static void ovs_dp_set_user_features (struct datapath *dp,u32 features) +{ +bool was = dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ; +bool now = features &OVS_DP_F_TC_RECIRC_SHARING ; + +if (now && !was) +tc_skb_ext_tc_enable (); +else if (!now && was) +tc_skb_ext_tc_disable (); + + dp->user_features = features; +} +
[ ... ]
net/openvswitch/datapath.c static void __dp_destroy(struct datapath *dp) · line 1973
Quoted 7 lines
net/openvswitch/datapath.c +1
-2@@ -1961,8 +1970,7 @@ static void __dp_destroy(struct datapath *dp)struct flow_table *table = &dp->table;int i; -if (dp->user_features &OVS_DP_F_TC_RECIRC_SHARING ) -tc_skb_ext_tc_disable (); +ovs_dp_set_user_features (dp,0 );
[Severity: High]
Can this early clear of dp->user_features race with upcalls that are still in flight?
Before this patch, __dp_destroy() only dropped the tc reference. Now ovs_dp_set_user_features() does a plain store of 0 to the whole bitmap, so OVS_DP_F_UNALIGNED, OVS_DP_F_DISPATCH_UPCALL_PER_CPU and the other bits are cleared too, not only OVS_DP_F_TC_RECIRC_SHARING.
When this store runs, every vport is still attached, the datapath is still on ovs_net->dps, and call_rcu() has not run yet. Softirq readers on other CPUs can still be inside queue_userspace_packet() for this dp, and that function reads the field twice:
net/openvswitch/datapath.c:queue_userspace_packet() {
...
if (dp->user_features & OVS_DP_F_UNALIGNED)
hlen = min(skb_zerocopy_headlen(skb), cutlen);
...
skb_zerocopy() /* user_skb gets page frags, now nonlinear */
...
pad_packet(dp, user_skb);
}net/openvswitch/datapath.c:pad_packet() {
if (!(dp->user_features & OVS_DP_F_UNALIGNED)) {
size_t plen = NLA_ALIGN(skb->len) - skb->len;
if (plen > 0)
skb_put_zero(skb, plen);
...
}Say __dp_destroy() stores 0 between these two reads. Could pad_packet() then call skb_put_zero() on the nonlinear user_skb and hit SKB_LINEAR_ASSERT() in skb_put()?
plen is nonzero whenever the packet length is not a multiple of 4. ovs-vswitchd always sets OVS_DP_F_UNALIGNED. So it looks like deleting a datapath under traffic (OVS_DP_CMD_DEL, vswitchd teardown, or ovs_exit_net()) is enough to open this window. That needs only CAP_NET_ADMIN in the owning user namespace.
The same clear also changes in-flight upcalls in ovs_dp_process_packet() and output_userspace(). During teardown they fall back from per-CPU dispatch to per-vport portid selection.
The new kernel-doc in datapath.h says:
so this field is written last, through ovs_dp_set_user_features(), with ovs_mutex held.
Here, though, __dp_destroy() writes the field first, before any vport is detached.
The datapath is only freed after an RCU grace period. As far as I can tell, no fast-path code reads OVS_DP_F_TC_RECIRC_SHARING per dp; flow.c checks tc_skb_ext_tc_enabled(). Would it be enough for __dp_destroy() to keep the old conditional tc_skb_ext_tc_disable()? Or it could call something like:
ovs_dp_set_user_features(dp, dp->user_features &
~OVS_DP_F_TC_RECIRC_SHARING);The same bit could already be flipped racily through OVS_DP_CMD_SET and ovs_dp_reset_user_features() before this patch. Closing that older variant would also need queue_userspace_packet() to take one READ_ONCE() snapshot, pass it to pad_packet(), and use WRITE_ONCE() in the setter.
The only later patch in the series, "selftests/net/openvswitch: check that a failed set keeps the features", does not touch net/. So this is still present at the end of the series.
Quoted 3 lines
net/openvswitch/datapath.c +0
-0for (i =0 ; i <DP_VPORT_HASH_BUCKETS ; i++) {struct vport *vport;
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115163134.3202677-1-houminxi%40gmail.com
Re: [PATCH net v4 1/2] net: openvswitch: do not record user features when the change fails
Quoted 2 lines · On 16/11/2026 16:33, [email protected] wrote:
[Severity: High] Can this early clear of
dp->user_featuresrace with upcalls that are still in flight?
It can, and you are right about the two reads. __dp_destroy() runs before the ports are detached and before the datapath leaves the list, so queue_userspace_packet() can be between its two reads while it runs:OVS_DP_F_UNALIGNED decides whether the skb is copied as fragments, and pad_packet() reads the same field again to decide whether to pad. A store that clears the whole bitmap between them can make pad_packet() pad a skb whose message was sized for the smaller linear part, so the padding has nowhere to go.
Your second suggestion is what the respin does. __dp_destroy() now clears only the bit that path was already dropping:
ovs_dp_set_user_features(dp, dp->user_features & ~OVS_DP_F_TC_RECIRC_SHARING);
The ovs_dp_cmd_new() error path frees the datapath without going through __dp_destroy(), and it writes the field the same way now, so it does not open the same window from that side. ovs_dp_reset_user_features() still clears everything, which is the point of it: an outdated user space instance re-adding a datapath is supposed to lose the features.
I took the snapshot for the older variant as well, since a set can change OVS_DP_F_UNALIGNED just as easily as a destroy can. queue_userspace_packet() reads the field once and hands that value to pad_packet(), so the head room and the padding always agree and a set in the middle can no longer split them. The setter stores through WRITE_ONCE() for the same reason: the receive path reads the field without ovs_mutex.
Quoted 5 lines
Low priority / nit picks for your consideration:
- The patch addsexec 9>&1andovs_fail()so that a FAIL prints its reason on the real stdout.
- The patch runsexec 9>&1once at the top level ofopenvswitch.sh(line 52) and never closes it.
Both are gone, and the fd was worse than a style problem. The daemons the suite starts inherit the handle, and the kselftest runner reads the test output from a pipe, so the pipe never reached EOF: every subtest reported OK and the run then sat there until the harness timed out. Matthieu reported exactly that from the CI side. Those messages go to stderr now, which still reaches the runner from inside ovs_sbx and is not held open by anything that outlives the script.
Quoted 2 lines
- ovs_dp_features_check's comment says "A show that fails and a datapath that reports other features are different faults, so they..."
Rewritten in the respin, and it turned out to be a real bug: ovs-dpctl prints "No DP found" and exits 0, and it leaves the features line out when the kernel does not report them, so the check reported both of those as a feature mismatch. Both are
recognised in the output now, and the "could not run" status is left for the CLI failing.
You also asked in the earlier review of the series whether the return 2 path can be reached with the datapath missing. It cannot, and that is the same mistake as above. The recirc failure should have used ovs_fail rather than info(), and it does now, as do the sets that only did "|| return 1", so a FAIL carries its reason.
pw-bot: cr
PATCH v4 2/2 selftests/net/openvswitch: check that a failed set keeps the features
In reply to Minxi HouAdd a set-dp command to ovs-dpctl for the kernel's datapath SET command, and two tests that use it.
The first test clears the features of a fresh datapath, sets the dispatch bit with a valid pid list, and clears them again. It then sends a set that would set that bit with an empty per-cpu-pids. The request has to fail with EINVAL, and the datapath has to keep reporting the features it had, which a kernel that records them before the change reads as 0x8 instead of 0x0. A second request sends OVS_DP_CMD_NEW for that name from an outdated client, which makes the kernel drop the features, and a further set has to work.
The second test covers the recirc bit. It sets that bit on a fresh datapath and sends a set that would set the dispatch bit with an empty per-cpu-pids. The rejected request has to leave the recirc bit in place. A kernel that records the features first reads 0x8 there instead of 0x4. A datapath holds that bit only when the tc skb extension is compiled in, so the test prints the reason and skips when the kernel answers EOPNOTSUPP, and any other failure of that request fails the test. CONFIG_NET_TC_SKB_EXT depends on CONFIG_NET_CLS_ACT and both sit under CONFIG_NET_SCHED, so the selftest config fragment selects all three.
The reference count itself is not visible from user space, so the steps that use an outdated client only show that those paths run and that a datapath keeps working across them.
set-dp sends the features it is given. When --features is left out it sends the features the datapath reports, and it refuses to send the request when the datapath reports none. A pid list that is not a list of numbers is reported as such, and empty entries are dropped.
--- .../testing/selftests/net/openvswitch/config | 3 + .../selftests/net/openvswitch/openvswitch.sh | 173 ++++++++++++++++++ .../selftests/net/openvswitch/ovs-dpctl.py | 61 ++++++ 3 files changed, 237 insertions(+)
tools/testing/selftests/net/openvswitch/config +3 -0
@@ -2,10 +2,13 @@ CONFIG_GENEVE=m CONFIG_INET_DIAG=y CONFIG_IP_SCTP=y CONFIG_IPV6=y +CONFIG_NET_CLS_ACT=y CONFIG_NETFILTER=y CONFIG_NETFILTER_ADVANCED=y CONFIG_NET_IPGRE=m CONFIG_NET_IPGRE_DEMUX=m +CONFIG_NET_SCHED=y +CONFIG_NET_TC_SKB_EXT=y CONFIG_NF_CONNTRACK=m CONFIG_NF_CONNTRACK_OVS=y CONFIG_NF_CT_PROTO_SCTP=y
tools/testing/selftests/net/openvswitch/openvswitch.sh +173 -0
191 lines not on this page · raw message
tools/testing/selftests/net/openvswitch/ovs-dpctl.py +61 -0
79 lines not on this page · raw message
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH net v4 2/2] selftests/net/openvswitch: check that a failed set keeps the features
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The patch adds exec 9>&1 and ovs_fail() so that a FAIL prints its reason on the real stdout.
- [Low] ovs_dp_features_check's comment says "A show that fails and a datapath that reports other features are different faults, so they…
- [Low] The patch runs exec 9>&1 once at the top level of openvswitch.sh (line 52) and never closes it.
--
selftests/net/openvswitch: check that a failed set keeps the features
This adds a set-dp command to ovs-dpctl.py that sends OVS_DP_CMD_SET. It also adds two openvswitch.sh tests checking that a rejected set (dispatch bit with an empty per-cpu-pids) leaves the datapath features unchanged. The second test covers the recirc bit and skips when the kernel answers EOPNOTSUPP.
Quoted 4 lines
tools/testing/selftests/net/openvswitch/openvswitch.sh +0
-0
[ ... ]
tools/testing/selftests/net/openvswitch/openvswitch.sh info() { · line 52
Quoted 8 lines
tools/testing/selftests/net/openvswitch/openvswitch.sh +4
-0@@ -44,6 +46,11 @@ info() { [ $VERBOSE = 0 ] || echo $* } +# ovs_sbx sends everything a command prints to debug.log, and a failing run +# deletes that file. Keep a handle on the real stdout so a failure reason +# still reaches the CI log. +exec 9>&1
[Severity: Low]
fd 9 stays open for the whole life of the script, and bash does not mark it close-on-exec. That means every background daemon now inherits it. This includes the upcall listener started by ovs_add_if -u and the daemons started by ovs_netns_spawn_daemon():
$* >> $ovs_dir/stdout 2>> $ovs_dir/stderr &
These spawns redirect only fds 1 and 2.
Under the kselftest runner, fd 1, and so fd 9, is the write end of the pipe into tap_prefix in run_one() in kselftest/runner.sh. tap_prefix reads until EOF:
(((( tap_timeout "$cmd" 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) | (read xs; exit $xs)) 4>>"$logfile"
If a daemon outlives the script, could this pipeline block until that daemon exits?
One way a daemon could outlive the script is the retry branch in run_test(). It removes the sandbox without running ovs_exit_sig:
elif [ $ret -eq 2 ]; then
rm -rf test_${tname}
run_test "$1" "$2"I could not find a current test that returns 2 after spawning a daemon, so this needs such a leak to happen. Daemons may also already inherit the runner's fds 3 and 4, which limits how much fd 9 adds.
fd 9 is only needed for the new >&9 diagnostics. Would it be better to close it on the background spawns with 9>&-, or to open it only where it is used?
[ ... ]
tools/testing/selftests/net/openvswitch/openvswitch.sh test_netlink_checks () { · line 1435
Quoted 13 lines
tools/testing/selftests/net/openvswitch/openvswitch.sh +13
-0+ovs_dp_features_check() { + local out + + # A show that fails and a datapath that reports other features are + # different faults, so they return different statuses. ovs-dpctl prints + # the value with %X, so convert before comparing. + out=$(python3 $ovs_base/ovs-dpctl.py show "$1") || { + printf '# could not read the datapath %s\n' "$1" >&9 + return 2 + } + printf '%s\n' "$out" | + grep -q "features: 0x$(printf '%X' "$2")\$" +}
[Severity: Low]
Can the return 2 path be reached when the datapath is missing? The show branch of main() in ovs-dpctl.py only prints a message, and main() then returns 0:
if not found:
msg = "No DP found"
if args.showdp is not None:
msg += ":'%s'" % args.showdp
print(msg)
When OVS_DP_ATTR_USER_FEATURES is missing, print_ovsdp_full() leaves out the features line and the exit status is still 0:
if user_features is not None:
print(" features: 0x%X" % user_features)
In both cases show exits 0, grep fails and the helper returns 1. ovs_dp_features_expect() then prints the test-specific reason, for example "the outdated new request did not drop the features", and not "could not read the datapath". The "No DP found" text captured in $out is thrown away.
[ ... ]
Quoted 14 lines
tools/testing/selftests/net/openvswitch/openvswitch.sh +14
-0+test_dp_features_recirc() { + local t="test_dp_features_recirc" + local dp="dpfeat1" + + sbx_add "$t" || return $? + ovs_add_dp "$t" "$dp" || return 1 + + ovs_sbx "$t" ovs_dp_features_set "$dp" --features 0 || return 1 + + # 4 is OVS_DP_F_TC_RECIRC_SHARING. The kernel takes the bit only when + # the tc skb extension is compiled in. + ovs_sbx "$t" ovs_dp_features_set "$dp" --features 4 &> /dev/null + rc=$? + if [ $rc -ne 0 ]; then
tools/testing/selftests/net/openvswitch/openvswitch.sh test_netlink_checks () { · line 1557
Quoted 10 lines
tools/testing/selftests/net/openvswitch/openvswitch.sh +10
-0+ eopnotsupp=$(ovs_errno EOPNOTSUPP) || return 1 + if [ $rc -eq "$eopnotsupp" ]; then + # info() only writes debug.log, which CI does not keep. + printf "# tc skb extension is not compiled in," + printf " skipping recirc\n" + ovs_exit_sig + return $ksft_skip + fi + info "the recirc set failed with $rc" + return 1
[Severity: Low]
Should this be ovs_fail and not info()? With the default VERBOSE=0, info() only appends to debug.log, and run_test() deletes $ovs_dir after a FAIL:
ovs_exit_sig
[ "${PAUSE_ON_FAIL}" = "yes" ] || rm -rf "$ovs_dir"So if the recirc set fails with anything other than EOPNOTSUPP, CI gets a bare [FAIL] with no reason. The comment a few lines up says the same thing about info().
The set-dp steps that only do "|| return 1" have the same gap. One is the --features 0 step above. In test_dp_features() there are the --features 0 steps and the --features 8 set before the outdated add-dp:
ovs_sbx "$t" ovs_dp_features_set "$dp" --features 0 || return 1
ovs_sbx sends the "set failed: ..." or "DP ... not found." output from ovs-dpctl.py to debug.log, so these failures also reach CI with no reason.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115163134.3202677-1-houminxi%40gmail.com
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
The bug turned up while I was writing the YNL spec for this family and had to say what ovs_dp_change() does. The function records the new features before the per-cpu-pids check can fail the request. A failed request then leaves the features claiming a bit whose reference count was never taken. Nothing triggered it in the field.
The second patch shows it happening. A set with an empty per-cpu-pids fails with EINVAL, and on a kernel without the fix the datapath reports the features the rejected request asked for. I ran the openvswitch selftest suite both ways, failing on 7.2.13 and passing on 7.4.0-rc2 with the fix, in a virtual machine rather than on hardware.
Hi Minxi,
Quoted 6 lines · Minxi Hou
The datapath records the user features before it applies the change, so a request that fails leaves it claiming a bit whose reference count was never taken. The first patch records the features last. The second adds a selftest that drives the failing request and reads back what the datapath reports.
Quoted 12 lines
v4:
- Rebased onto current main.
- The skip message is one printf again. Splitting it made shellcheck report SC2182 and dropped a word and the newline from the output.
- The new tests say why they failed on stdout.info()writes debug.log and a failing run deletes that file, so CI showed a FAIL with no reason.
- A datapath that cannot be read is reported as that instead of as a feature mismatch.
- The outdated add-dp request is checked instead of discarded.
- The errno numbers come from python rather than from a literal, and a lookup that cannot answer says so rather than comparing against an empty string.
Thank you for the new version, but I suspect this series caused troubles on the CI side: it looks like openvswitch.sh hangs/times out after all subtests pass.
# TEST: psample [START]
# TEST: psample: Sampling packets with psample [ OK ]
=> then nothing for 10 minutes, instead of:
ok 1 selftests: net/openvswitch: openvswitch.sh
How did you validate this series? Note that the Netdev CI, for this specific case, combines 'config' files from net, net/af_unix net/openvswitch:
tools/testing/selftests/net/config
tools/testing/selftests/net/af_unix/config
tools/testing/selftests/net/openvswitch/config
Cheers,
Matt
Hi Matt,
You are right about the hang, and it is mine. I reproduced it here.
To get a failure reason into the CI log I duplicated stdout onto fd 9 in openvswitch.sh, because info() writes debug.log and a failing run deletes that file. The suite starts daemons that outlive the script: the per-vport upcall handlers from add-if -u, and the psample listener. They inherit the second handle. runner.sh reads the test output from a pipe, so as long as any process holds the write end, the pipe never reaches EOF and the run sits there after the last subtest has already passed.
Redirecting the output to a file hides this completely, which is how I ran it, and why I did not see it.
Writing those messages to stderr fixes it. stderr still reaches the runner from inside ovs_sbx, and the daemons send both stdout and stderr to files, so nothing is left holding the pipe.
Checked with the output piped the way runner.sh does it:
before: "TEST: psample ... [ OK ]", then nothing until the timeout
after: 21 tests [ OK ], and the run ends by itself
with a wrong expectation injected: the reason still reaches the log and the test fails, so the diagnostics still work
The configs merge here as well. The only message is the CONFIG_IP_SCTP m->y redefine, which is already in the fragment before this series.
I will send a v5 with this change.
Thanks,
Minxi