Commit 9186c43c authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'netlink-specs-enforce-strict-naming-of-properties'

Jakub Kicinski says:

====================
netlink: specs: enforce strict naming of properties

I got annoyed once again by the name properties in the ethtool spec
which use underscore instead of dash. I previously assumed that there
is a lot of such properties in the specs so fixing them now would
be near impossible. On a closer look, however, I only found 22
(rough grep suggests we have ~4.8k names in the specs, so bad ones
are just 0.46%).

Add a regex to the JSON schema to enforce the naming, fix the few
bad names. I was hoping we could start enforcing this from newer
families, but there's no correlation between the protocol and the
number of errors. If anything classic netlink has more recently
added specs so it has fewer errors.

The regex is just for name properties which will end up visible
to the user (in Python or YNL CLI). I left the c-name properties
alone, those don't matter as much. C codegen rewrites them, anyway.

I'm not updating the spec for genetlink-c. Looks like it has no
users, new families use genetlink, all old ones need genetlink-legacy.
If these patches are merged I will remove genetlink-c completely
in net-next.
====================

Link: https://patch.msgid.link/20250624211002.3475021-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7b515f35 af852f1f
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ $schema: https://json-schema.org/draft-07/schema

# Common defines
$defs:
  name:
    type: string
    pattern: ^[0-9a-z-]+$
  uint:
    type: integer
    minimum: 0
@@ -76,7 +79,7 @@ properties:
      additionalProperties: False
      properties:
        name:
          type: string
          $ref: '#/$defs/name'
        header:
          description: For C-compatible languages, header which already defines this value.
          type: string
@@ -103,7 +106,7 @@ properties:
                additionalProperties: False
                properties:
                  name:
                    type: string
                    $ref: '#/$defs/name'
                  value:
                    type: integer
                  doc:
@@ -132,7 +135,7 @@ properties:
            additionalProperties: False
            properties:
              name:
                type: string
                $ref: '#/$defs/name'
              type:
                description: The netlink attribute type
                enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary ]
@@ -169,7 +172,7 @@ properties:
        name:
          description: |
            Name used when referring to this space in other definitions, not used outside of the spec.
          type: string
          $ref: '#/$defs/name'
        name-prefix:
          description: |
            Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
@@ -206,7 +209,7 @@ properties:
            additionalProperties: False
            properties:
              name:
                type: string
                $ref: '#/$defs/name'
              type: &attr-type
                description: The netlink attribute type
                enum: [ unused, pad, flag, binary, bitfield32,
@@ -348,7 +351,7 @@ properties:
          properties:
            name:
              description: Name of the operation, also defining its C enum value in uAPI.
              type: string
              $ref: '#/$defs/name'
            doc:
              description: Documentation for the command.
              type: string
+10 −7
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ $schema: https://json-schema.org/draft-07/schema

# Common defines
$defs:
  name:
    type: string
    pattern: ^[0-9a-z-]+$
  uint:
    type: integer
    minimum: 0
@@ -29,7 +32,7 @@ additionalProperties: False
properties:
  name:
    description: Name of the genetlink family.
    type: string
    $ref: '#/$defs/name'
  doc:
    type: string
  protocol:
@@ -48,7 +51,7 @@ properties:
      additionalProperties: False
      properties:
        name:
          type: string
          $ref: '#/$defs/name'
        header:
          description: For C-compatible languages, header which already defines this value.
          type: string
@@ -75,7 +78,7 @@ properties:
                additionalProperties: False
                properties:
                  name:
                    type: string
                    $ref: '#/$defs/name'
                  value:
                    type: integer
                  doc:
@@ -96,7 +99,7 @@ properties:
        name:
          description: |
            Name used when referring to this space in other definitions, not used outside of the spec.
          type: string
          $ref: '#/$defs/name'
        name-prefix:
          description: |
            Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
@@ -121,7 +124,7 @@ properties:
            additionalProperties: False
            properties:
              name:
                type: string
                $ref: '#/$defs/name'
              type: &attr-type
                enum: [ unused, pad, flag, binary,
                        uint, sint, u8, u16, u32, u64, s8, s16, s32, s64,
@@ -243,7 +246,7 @@ properties:
          properties:
            name:
              description: Name of the operation, also defining its C enum value in uAPI.
              type: string
              $ref: '#/$defs/name'
            doc:
              description: Documentation for the command.
              type: string
@@ -327,7 +330,7 @@ properties:
            name:
              description: |
                The name for the group, used to form the define and the value of the define.
              type: string
              $ref: '#/$defs/name'
            flags: *cmd_flags

  kernel-family:
+12 −6
Original line number Diff line number Diff line
@@ -6,6 +6,12 @@ $schema: https://json-schema.org/draft-07/schema

# Common defines
$defs:
  name:
    type: string
    pattern: ^[0-9a-z-]+$
  name-cap:
    type: string
    pattern: ^[0-9a-zA-Z-]+$
  uint:
    type: integer
    minimum: 0
@@ -71,7 +77,7 @@ properties:
      additionalProperties: False
      properties:
        name:
          type: string
          $ref: '#/$defs/name'
        header:
          description: For C-compatible languages, header which already defines this value.
          type: string
@@ -98,7 +104,7 @@ properties:
                additionalProperties: False
                properties:
                  name:
                    type: string
                    $ref: '#/$defs/name'
                  value:
                    type: integer
                  doc:
@@ -124,7 +130,7 @@ properties:
            additionalProperties: False
            properties:
              name:
                type: string
                $ref: '#/$defs/name-cap'
              type:
                description: |
                  The netlink attribute type. Members of type 'binary' or 'pad'
@@ -183,7 +189,7 @@ properties:
        name:
          description: |
            Name used when referring to this space in other definitions, not used outside of the spec.
          type: string
          $ref: '#/$defs/name'
        name-prefix:
          description: |
            Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
@@ -220,7 +226,7 @@ properties:
            additionalProperties: False
            properties:
              name:
                type: string
                $ref: '#/$defs/name'
              type: &attr-type
                description: The netlink attribute type
                enum: [ unused, pad, flag, binary, bitfield32,
@@ -408,7 +414,7 @@ properties:
          properties:
            name:
              description: Name of the operation, also defining its C enum value in uAPI.
              type: string
              $ref: '#/$defs/name'
            doc:
              description: Documentation for the command.
              type: string
+4 −4
Original line number Diff line number Diff line
@@ -38,15 +38,15 @@ definitions:
      -
        name: dsa
      -
        name: pci_pf
        name: pci-pf
      -
        name: pci_vf
        name: pci-vf
      -
        name: virtual
      -
        name: unused
      -
        name: pci_sf
        name: pci-sf
  -
    type: enum
    name: port-fn-state
@@ -220,7 +220,7 @@ definitions:
      -
        name: flag
      -
        name: nul_string
        name: nul-string
        value: 10
      -
        name: binary
+1 −1
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ definitions:
    value: 10000
  -
    type: const
    name: pin-frequency-77_5-khz
    name: pin-frequency-77-5-khz
    value: 77500
  -
    type: const
Loading