🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Minxi Hou Tue, 10 Nov 2026 17:47
[PATCH net-next v7 2/2] netlink: specs: add ovs datapath and vport set operations
#14099
Author: Minxi Hou
Date: Tue, 10 Nov 2026 17:47
196 lines
17283 bytes
Both families register a SET command that the spec never described, so a
YNL client could not change an existing datapath or vport. The datapath
NEW command also gains the masks cache size, the per-cpu upcall pids and
the ifindex, which its handler reads. new, del and set take
CAP_NET_ADMIN, which is GENL_UNS_ADMIN_PERM in the kernel.

The datapath SET command changes the user features, the masks cache size
and the per-cpu upcall pids. A request that leaves out user-features is
read as zero, which clears the features set earlier. per-cpu-pids takes
effect only when the same request sets OVS_DP_F_DISPATCH_UPCALL_PER_CPU
in user-features; without that bit the pids are dropped and the request
still succeeds. The masks cache size has an upper bound of 4096, which
the attribute records.

The vport SET command changes the upcall pid. It finds the vport by name,
or by port number when the request carries no name. An ifindex or options
are rejected with -EOPNOTSUPP, and a type that differs from the vport's
type with -EINVAL. The type only has to match. The vport NEW request list
gains the port number, which its handler reads.

The ifindex attribute is signed in both policies, which read it with
nla_get_s32_default() and reject anything below zero, so declare it as
s32 to match them rather than leaving it u32. The field in the generated
reply struct becomes __s32 with it. The reply itself does not change:
ovs_vport_cmd_fill_info() still puts the value as u32, and the two types
have the same width.

The ops in both families skip strict and dump validation in the kernel,
so the spec says so for get, new, del and set.

Signed-off-by: Minxi Hou <houminxi@gmail.com>
---
 Documentation/netlink/specs/ovs_datapath.yaml | 36 +++++++++++++++++--
 Documentation/netlink/specs/ovs_vport.yaml    | 29 ++++++++++++++-
 2 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/Documentation/netlink/specs/ovs_datapath.yaml b/Documentation/netlink/specs/ovs_datapath.yaml
index f7b3671991e6..b24dc1e03f46 100644
--- a/Documentation/netlink/specs/ovs_datapath.yaml
+++ b/Documentation/netlink/specs/ovs_datapath.yaml
@@ -102,13 +102,17 @@ attribute-sets:
       -
         name: masks-cache-size
         type: u32
+        checks:
+          max: 4096
       -
         name: per-cpu-pids
         type: binary
         sub-type: u32
       -
         name: ifindex
-        type: u32
+        type: s32
+        checks:
+          min: 0
 
 operations:
   fixed-header: ovs-header
@@ -119,6 +123,7 @@ operations:
       doc: Get / dump OVS data path configuration and state
       value: 3
       attribute-set: datapath
+      dont-validate: [strict, dump]
       do: &dp-get-op
         request:
           attributes:
@@ -135,24 +140,51 @@ operations:
       dump: *dp-get-op
     -
       name: new
-      doc: Create new OVS data path
+      doc: |
+        Create new OVS data path. per-cpu-pids takes effect only when the
+        same request sets OVS_DP_F_DISPATCH_UPCALL_PER_CPU in user-features.
       value: 1
       attribute-set: datapath
+      dont-validate: [strict, dump]
+      flags: [uns-admin-perm]
       do:
         request:
           attributes:
             - name
             - upcall-pid
             - user-features
+            - masks-cache-size
+            - per-cpu-pids
+            - ifindex
     -
       name: del
       doc: Delete existing OVS data path
       value: 2
       attribute-set: datapath
+      dont-validate: [strict, dump]
+      flags: [uns-admin-perm]
+      do:
+        request:
+          attributes:
+            - name
+    -
+      name: set
+      doc: |
+        Modify an existing OVS data path. The kernel treats a missing
+        user-features attribute as zero and clears the previously set
+        features. per-cpu-pids takes effect only when the same request
+        sets OVS_DP_F_DISPATCH_UPCALL_PER_CPU in user-features.
+      value: 4
+      attribute-set: datapath
+      dont-validate: [strict, dump]
+      flags: [uns-admin-perm]
       do:
         request:
           attributes:
             - name
+            - user-features
+            - masks-cache-size
+            - per-cpu-pids
 
 mcast-groups:
   list:
diff --git a/Documentation/netlink/specs/ovs_vport.yaml b/Documentation/netlink/specs/ovs_vport.yaml
index fa975f8821b6..5a3ac4b03033 100644
--- a/Documentation/netlink/specs/ovs_vport.yaml
+++ b/Documentation/netlink/specs/ovs_vport.yaml
@@ -111,7 +111,9 @@ attribute-sets:
         type: unused
       -
         name: ifindex
-        type: u32
+        type: s32
+        checks:
+          min: 0
       -
         name: netnsid
         type: u32
@@ -128,18 +130,23 @@ operations:
       name: new
       doc: Create a new OVS vport
       attribute-set: vport
+      dont-validate: [strict, dump]
+      flags: [uns-admin-perm]
       do:
         request:
           attributes:
             - name
             - type
             - upcall-pid
+            - port-no
             - ifindex
             - options
     -
       name: del
       doc: Delete existing OVS vport from a data path
       attribute-set: vport
+      dont-validate: [strict, dump]
+      flags: [uns-admin-perm]
       do:
         request:
           attributes:
@@ -150,6 +157,7 @@ operations:
       name: get
       doc: Get / dump OVS vport configuration and state
       attribute-set: vport
+      dont-validate: [strict, dump]
       do: &vport-get-op
         request:
           attributes:
@@ -165,6 +173,25 @@ operations:
             - netnsid
             - upcall-stats
       dump: *vport-get-op
+    -
+      name: set
+      doc: |
+        Modify an existing OVS vport. The vport is picked by name, or by
+        port number when the request carries no name. An ifindex or options
+        are rejected with -EOPNOTSUPP, and a type that differs from the
+        vport's type with -EINVAL. The type only has to match; the one
+        attribute that changes state is upcall-pid.
+      value: 4
+      attribute-set: vport
+      dont-validate: [strict, dump]
+      flags: [uns-admin-perm]
+      do:
+        request:
+          attributes:
+            - name
+            - type
+            - upcall-pid
+            - port-no
 
 mcast-groups:
   list:
-- 
2.56.0
Re: [PATCH net-next v7 2/2] netlink: specs: add ovs datapath and vport set operations
#14837
Author: netdev-bot+sashiko
Date: Thu, 12 Nov 2026 02:02
184 lines
14597 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0 (3)

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).

- [Medium] The patch adds `checks: max: 4096` to `masks-cache-size` in
  Documentation/netlink/specs/ovs_datapath.yaml.

Pre-existing issues:
- [Low] This problem wasn't introduced by this patch, but
  Documentation/netlink/specs/ovs_vport.yaml still declares the vport…
- [Low] This problem wasn't introduced by this patch, but the vport `get`
  do request in Documentation/netlink/specs/ovs_vport.yaml lists only…
- [Low] The new vport and datapath `set` ops in the specs declare no
  reply and no notification.

--

netlink: specs: add ovs datapath and vport set operations

This commit adds SET operations to the ovs_datapath and ovs_vport netlink
specs and adds more attributes to the NEW request lists. It also marks
new, del and set as uns-admin-perm and changes ifindex to s32 with a
minimum of 0. Finally it puts a maximum of 4096 on masks-cache-size and
marks all ops as dont-validate strict and dump.

> diff --git a/Documentation/netlink/specs/ovs_datapath.yaml b/Documentation/netlink/specs/ovs_datapath.yaml
> index f7b3671991e6c..b24dc1e03f46a 100644
> --- a/Documentation/netlink/specs/ovs_datapath.yaml
> +++ b/Documentation/netlink/specs/ovs_datapath.yaml
> @@ -102,13 +102,17 @@ attribute-sets:
>        -
>          name: masks-cache-size
>          type: u32
> +        checks:
> +          max: 4096

[Severity: Medium]
Is 4096 the right bound on every configuration? The commit message says:

  The masks cache size has an upper bound of 4096, which the attribute
  records.

However, datapath_policy in net/openvswitch/datapath.c computes the limit
from the percpu unit size:

	[OVS_DP_ATTR_MASKS_CACHE_SIZE] =  NLA_POLICY_RANGE(NLA_U32, 0,
		PCPU_MIN_UNIT_SIZE / sizeof(struct mask_cache_entry)),

and include/linux/percpu.h has:

#define PCPU_MIN_UNIT_SIZE		PFN_ALIGN(32 << 10)

struct mask_cache_entry is 8 bytes. That gives a limit of 4096 on 4K and
16K page kernels, 8192 with 64K pages (ppc64, arm64 with
CONFIG_ARM64_64K_PAGES) and 32768 with 256K pages. On those
configurations the spec would mark values that the kernel accepts as out
of range.

The spec also leaves out a second rule.
ovs_flow_tbl_masks_cache_resize() in net/openvswitch/flow_table.c rejects
any non-zero size that is not a power of two:

	if ((!is_power_of_2(size) && size != 0) ||
	    (size * sizeof(struct mask_cache_entry)) > PCPU_MIN_UNIT_SIZE)
		return -EINVAL;

Could the max check be dropped? Another option is to document the bound
as PCPU_MIN_UNIT_SIZE / 8, along with the zero-or-power-of-two rule.

[ ... ]

> diff --git a/Documentation/netlink/specs/ovs_vport.yaml b/Documentation/netlink/specs/ovs_vport.yaml
> index fa975f8821b6c..5a3ac4b03033a 100644
> --- a/Documentation/netlink/specs/ovs_vport.yaml
> +++ b/Documentation/netlink/specs/ovs_vport.yaml
> @@ -111,7 +111,9 @@ attribute-sets:
>          type: unused
>        -
>          name: ifindex
> -        type: u32
> +        type: s32
> +        checks:
> +          min: 0
>        -
>          name: netnsid
>          type: u32

[Severity: Low]
This isn't a bug introduced by this patch. Since ifindex is being matched
to the kernel policy here, should netnsid be fixed the same way? The spec
still declares netnsid as u32, but vport_policy in
net/openvswitch/datapath.c has:

	[OVS_VPORT_ATTR_NETNSID] = { .type = NLA_S32 },

and ovs_vport_cmd_fill_info() sends it with nla_put_s32():

		int id = peernet2id_alloc(net, net_vport, GFP_ATOMIC);

		if (nla_put_s32(skb, OVS_VPORT_ATTR_NETNSID, id))

peernet2id_alloc() can return NETNSA_NSID_NOT_ASSIGNED (-1). A YNL client
that follows the spec would read that as 4294967295.

[ ... ]

> @@ -150,6 +157,7 @@ operations:
>        name: get
>        doc: Get / dump OVS vport configuration and state
>        attribute-set: vport
> +      dont-validate: [strict, dump]
>        do: &vport-get-op
>          request:
>            attributes:

[Severity: Low]
This is a pre-existing issue and was not introduced by this patch. The get
do request still lists only name. ovs_vport_cmd_get() uses the same
lookup_vport() helper as set and del, and that helper falls back to the
port number when the request has no name:

	} else if (a[OVS_VPORT_ATTR_PORT_NO]) {
		u32 port_no = nla_get_u32(a[OVS_VPORT_ATTR_PORT_NO]);

del and the new set op both list port-no. Should get list it too, so that
clients generated from the spec can look up a vport by port number?

> @@ -165,6 +173,25 @@ operations:
>              - netnsid
>              - upcall-stats
>        dump: *vport-get-op
> +    -
> +      name: set
> +      doc: |
> +        Modify an existing OVS vport. The vport is picked by name, or by
> +        port number when the request carries no name. An ifindex or options
> +        are rejected with -EOPNOTSUPP, and a type that differs from the
> +        vport's type with -EINVAL. The type only has to match; the one
> +        attribute that changes state is upcall-pid.
> +      value: 4
> +      attribute-set: vport
> +      dont-validate: [strict, dump]
> +      flags: [uns-admin-perm]
> +      do:
> +        request:
> +          attributes:
> +            - name
> +            - type
> +            - upcall-pid
> +            - port-no

[Severity: Low]
This is a pre-existing gap, and the existing new and del ops have it too.
The new set op here declares no reply or notification, and neither does
the datapath set op in ovs_datapath.yaml.

ovs_vport_cmd_set() builds a full vport message and sends it with
ovs_notify(), which calls genl_notify():

	err = ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info),
				      info->snd_portid, info->snd_seq, 0,
				      OVS_VPORT_CMD_SET, GFP_KERNEL);
	BUG_ON(err < 0);

	ovs_unlock();
	ovs_notify(&dp_vport_genl_family, reply, info);

ovs_dp_cmd_set() does the same with OVS_DP_CMD_SET. These messages go to
the family's multicast group. They also go to the requester when
NLM_F_ECHO is set.

Should the set ops describe these messages, for example with a notify
entry that reuses the get reply, so generated clients can decode them?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110174751.973464-1-houminxi%40gmail.com
Re: [PATCH net-next v7 2/2] netlink: specs: add ovs datapath and vport set operations
#14838
Author: Jakub Kicinski
Date: Thu, 12 Nov 2026 02:03
14 lines
8201 bytes
On Thu, 12 Nov 2026 02:02:26 +0000 netdev-bot+sashiko@kernel.org wrote:
> > @@ -102,13 +102,17 @@ attribute-sets:
> >        -
> >          name: masks-cache-size
> >          type: u32
> > +        checks:
> > +          max: 4096  
> 
> [Severity: Medium]
> Is 4096 the right bound on every configuration? 

Just don't add the bound if it can't be easily expressed.
We are not planning to code gen the policy anyway, AFAIU
Re: [PATCH net-next v7 2/2] netlink: specs: add ovs datapath and vport set operations
#16560
Author: Minxi Hou
Date: Sun, 15 Nov 2026 07:26
11 lines
10929 bytes
The bound is the one point here I agree with, and v8 drops the declaration
rather than narrowing it. These families are classic, so the generator does
not turn a check into a policy, and the kernel limit is an expression rather
than a constant.

On the other point: v8 also takes out the sentences that described what a
dump does with an attribute. Each dump now has a request list of its own,
which says what it takes, so the prose that repeated it is gone.

pw-bot: cr
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads