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 new operation reads per-cpu-pids the same way, so its doc says so too. The vport SET command changes the upcall pid. It finds the vport by name or by port number, and rejects an ifindex with -EOPNOTSUPP before it looks at the type or the options. A type that differs from the vport's type is rejected with -EINVAL, and options with -EOPNOTSUPP. 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 with a minimum of 0 rather than u32. A generated client would otherwise offer a setter for values the kernel rejects with -ERANGE. 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 <[email protected]> --- Documentation/netlink/specs/ovs_datapath.yaml | 35 +++++++++++++++++-- Documentation/netlink/specs/ovs_vport.yaml | 30 +++++++++++++++- 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..4a64985633c4 100644 --- a/Documentation/netlink/specs/ovs_datapath.yaml +++ b/Documentation/netlink/specs/ovs_datapath.yaml @@ -108,7 +108,9 @@ attribute-sets: sub-type: u32 - name: ifindex - type: u32 + type: s32 + checks: + min: 0 operations: fixed-header: ovs-header @@ -119,6 +121,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 +138,52 @@ 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 + user-features in the same request sets + OVS_DP_F_DISPATCH_UPCALL_PER_CPU. 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..16b21c42cac8 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,6 +130,8 @@ operations: name: new doc: Create a new OVS vport attribute-set: vport + dont-validate: [strict, dump] + flags: [uns-admin-perm] do: request: attributes: @@ -140,6 +144,8 @@ operations: 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 +156,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 +172,27 @@ 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. The kernel rejects an ifindex with -EOPNOTSUPP, before + it looks at the type or the options. It rejects a type that differs + from the vport's type with -EINVAL, and rejects options with + -EOPNOTSUPP. The only 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 + - options + - upcall-pid + - port-no + - ifindex mcast-groups: list: -- 2.56.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
