Skip to content

Commit 9186c43

Browse files
committed
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/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 7b515f3 + af852f1 commit 9186c43

File tree

14 files changed

+74
-62
lines changed

14 files changed

+74
-62
lines changed

Documentation/netlink/genetlink-legacy.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ $schema: https://json-schema.org/draft-07/schema
66

77
# Common defines
88
$defs:
9+
name:
10+
type: string
11+
pattern: ^[0-9a-z-]+$
912
uint:
1013
type: integer
1114
minimum: 0
@@ -76,7 +79,7 @@ properties:
7679
additionalProperties: False
7780
properties:
7881
name:
79-
type: string
82+
$ref: '#/$defs/name'
8083
header:
8184
description: For C-compatible languages, header which already defines this value.
8285
type: string
@@ -103,7 +106,7 @@ properties:
103106
additionalProperties: False
104107
properties:
105108
name:
106-
type: string
109+
$ref: '#/$defs/name'
107110
value:
108111
type: integer
109112
doc:
@@ -132,7 +135,7 @@ properties:
132135
additionalProperties: False
133136
properties:
134137
name:
135-
type: string
138+
$ref: '#/$defs/name'
136139
type:
137140
description: The netlink attribute type
138141
enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary ]
@@ -169,7 +172,7 @@ properties:
169172
name:
170173
description: |
171174
Name used when referring to this space in other definitions, not used outside of the spec.
172-
type: string
175+
$ref: '#/$defs/name'
173176
name-prefix:
174177
description: |
175178
Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
@@ -206,7 +209,7 @@ properties:
206209
additionalProperties: False
207210
properties:
208211
name:
209-
type: string
212+
$ref: '#/$defs/name'
210213
type: &attr-type
211214
description: The netlink attribute type
212215
enum: [ unused, pad, flag, binary, bitfield32,
@@ -348,7 +351,7 @@ properties:
348351
properties:
349352
name:
350353
description: Name of the operation, also defining its C enum value in uAPI.
351-
type: string
354+
$ref: '#/$defs/name'
352355
doc:
353356
description: Documentation for the command.
354357
type: string

Documentation/netlink/genetlink.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ $schema: https://json-schema.org/draft-07/schema
66

77
# Common defines
88
$defs:
9+
name:
10+
type: string
11+
pattern: ^[0-9a-z-]+$
912
uint:
1013
type: integer
1114
minimum: 0
@@ -29,7 +32,7 @@ additionalProperties: False
2932
properties:
3033
name:
3134
description: Name of the genetlink family.
32-
type: string
35+
$ref: '#/$defs/name'
3336
doc:
3437
type: string
3538
protocol:
@@ -48,7 +51,7 @@ properties:
4851
additionalProperties: False
4952
properties:
5053
name:
51-
type: string
54+
$ref: '#/$defs/name'
5255
header:
5356
description: For C-compatible languages, header which already defines this value.
5457
type: string
@@ -75,7 +78,7 @@ properties:
7578
additionalProperties: False
7679
properties:
7780
name:
78-
type: string
81+
$ref: '#/$defs/name'
7982
value:
8083
type: integer
8184
doc:
@@ -96,7 +99,7 @@ properties:
9699
name:
97100
description: |
98101
Name used when referring to this space in other definitions, not used outside of the spec.
99-
type: string
102+
$ref: '#/$defs/name'
100103
name-prefix:
101104
description: |
102105
Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
@@ -121,7 +124,7 @@ properties:
121124
additionalProperties: False
122125
properties:
123126
name:
124-
type: string
127+
$ref: '#/$defs/name'
125128
type: &attr-type
126129
enum: [ unused, pad, flag, binary,
127130
uint, sint, u8, u16, u32, u64, s8, s16, s32, s64,
@@ -243,7 +246,7 @@ properties:
243246
properties:
244247
name:
245248
description: Name of the operation, also defining its C enum value in uAPI.
246-
type: string
249+
$ref: '#/$defs/name'
247250
doc:
248251
description: Documentation for the command.
249252
type: string
@@ -327,7 +330,7 @@ properties:
327330
name:
328331
description: |
329332
The name for the group, used to form the define and the value of the define.
330-
type: string
333+
$ref: '#/$defs/name'
331334
flags: *cmd_flags
332335

333336
kernel-family:

Documentation/netlink/netlink-raw.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ $schema: https://json-schema.org/draft-07/schema
66

77
# Common defines
88
$defs:
9+
name:
10+
type: string
11+
pattern: ^[0-9a-z-]+$
12+
name-cap:
13+
type: string
14+
pattern: ^[0-9a-zA-Z-]+$
915
uint:
1016
type: integer
1117
minimum: 0
@@ -71,7 +77,7 @@ properties:
7177
additionalProperties: False
7278
properties:
7379
name:
74-
type: string
80+
$ref: '#/$defs/name'
7581
header:
7682
description: For C-compatible languages, header which already defines this value.
7783
type: string
@@ -98,7 +104,7 @@ properties:
98104
additionalProperties: False
99105
properties:
100106
name:
101-
type: string
107+
$ref: '#/$defs/name'
102108
value:
103109
type: integer
104110
doc:
@@ -124,7 +130,7 @@ properties:
124130
additionalProperties: False
125131
properties:
126132
name:
127-
type: string
133+
$ref: '#/$defs/name-cap'
128134
type:
129135
description: |
130136
The netlink attribute type. Members of type 'binary' or 'pad'
@@ -183,7 +189,7 @@ properties:
183189
name:
184190
description: |
185191
Name used when referring to this space in other definitions, not used outside of the spec.
186-
type: string
192+
$ref: '#/$defs/name'
187193
name-prefix:
188194
description: |
189195
Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
@@ -220,7 +226,7 @@ properties:
220226
additionalProperties: False
221227
properties:
222228
name:
223-
type: string
229+
$ref: '#/$defs/name'
224230
type: &attr-type
225231
description: The netlink attribute type
226232
enum: [ unused, pad, flag, binary, bitfield32,
@@ -408,7 +414,7 @@ properties:
408414
properties:
409415
name:
410416
description: Name of the operation, also defining its C enum value in uAPI.
411-
type: string
417+
$ref: '#/$defs/name'
412418
doc:
413419
description: Documentation for the command.
414420
type: string

Documentation/netlink/specs/devlink.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ definitions:
3838
-
3939
name: dsa
4040
-
41-
name: pci_pf
41+
name: pci-pf
4242
-
43-
name: pci_vf
43+
name: pci-vf
4444
-
4545
name: virtual
4646
-
4747
name: unused
4848
-
49-
name: pci_sf
49+
name: pci-sf
5050
-
5151
type: enum
5252
name: port-fn-state
@@ -220,7 +220,7 @@ definitions:
220220
-
221221
name: flag
222222
-
223-
name: nul_string
223+
name: nul-string
224224
value: 10
225225
-
226226
name: binary

Documentation/netlink/specs/dpll.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ definitions:
188188
value: 10000
189189
-
190190
type: const
191-
name: pin-frequency-77_5-khz
191+
name: pin-frequency-77-5-khz
192192
value: 77500
193193
-
194194
type: const

Documentation/netlink/specs/ethtool.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ definitions:
4848
name: started
4949
doc: The firmware flashing process has started.
5050
-
51-
name: in_progress
51+
name: in-progress
5252
doc: The firmware flashing process is in progress.
5353
-
5454
name: completed
@@ -1422,7 +1422,7 @@ attribute-sets:
14221422
name: hkey
14231423
type: binary
14241424
-
1425-
name: input_xfrm
1425+
name: input-xfrm
14261426
type: u32
14271427
-
14281428
name: start-context
@@ -2238,7 +2238,7 @@ operations:
22382238
- hfunc
22392239
- indir
22402240
- hkey
2241-
- input_xfrm
2241+
- input-xfrm
22422242
dump:
22432243
request:
22442244
attributes:

Documentation/netlink/specs/fou.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ kernel-policy: global
1515
definitions:
1616
-
1717
type: enum
18-
name: encap_type
18+
name: encap-type
1919
name-prefix: fou-encap-
2020
enum-name:
2121
entries: [ unspec, direct, gue ]
@@ -43,26 +43,26 @@ attribute-sets:
4343
name: type
4444
type: u8
4545
-
46-
name: remcsum_nopartial
46+
name: remcsum-nopartial
4747
type: flag
4848
-
49-
name: local_v4
49+
name: local-v4
5050
type: u32
5151
-
52-
name: local_v6
52+
name: local-v6
5353
type: binary
5454
checks:
5555
min-len: 16
5656
-
57-
name: peer_v4
57+
name: peer-v4
5858
type: u32
5959
-
60-
name: peer_v6
60+
name: peer-v6
6161
type: binary
6262
checks:
6363
min-len: 16
6464
-
65-
name: peer_port
65+
name: peer-port
6666
type: u16
6767
byte-order: big-endian
6868
-
@@ -90,12 +90,12 @@ operations:
9090
- port
9191
- ipproto
9292
- type
93-
- remcsum_nopartial
94-
- local_v4
95-
- peer_v4
96-
- local_v6
97-
- peer_v6
98-
- peer_port
93+
- remcsum-nopartial
94+
- local-v4
95+
- peer-v4
96+
- local-v6
97+
- peer-v6
98+
- peer-port
9999
- ifindex
100100

101101
-
@@ -112,11 +112,11 @@ operations:
112112
- af
113113
- ifindex
114114
- port
115-
- peer_port
116-
- local_v4
117-
- peer_v4
118-
- local_v6
119-
- peer_v6
115+
- peer-port
116+
- local-v4
117+
- peer-v4
118+
- local-v6
119+
- peer-v6
120120

121121
-
122122
name: get

Documentation/netlink/specs/mptcp_pm.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ definitions:
5757
doc: >-
5858
A new subflow has been established. 'error' should not be set.
5959
Attributes: token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 |
60-
daddr6, sport, dport, backup, if_idx [, error].
60+
daddr6, sport, dport, backup, if-idx [, error].
6161
-
6262
name: sub-closed
6363
doc: >-
6464
A subflow has been closed. An error (copy of sk_err) could be set if an
6565
error has been detected for this subflow.
6666
Attributes: token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 |
67-
daddr6, sport, dport, backup, if_idx [, error].
67+
daddr6, sport, dport, backup, if-idx [, error].
6868
-
6969
name: sub-priority
7070
value: 13
7171
doc: >-
7272
The priority of a subflow has changed. 'error' should not be set.
7373
Attributes: token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 |
74-
daddr6, sport, dport, backup, if_idx [, error].
74+
daddr6, sport, dport, backup, if-idx [, error].
7575
-
7676
name: listener-created
7777
value: 15
@@ -255,7 +255,7 @@ attribute-sets:
255255
name: timeout
256256
type: u32
257257
-
258-
name: if_idx
258+
name: if-idx
259259
type: u32
260260
-
261261
name: reset-reason

Documentation/netlink/specs/nfsd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ attribute-sets:
2727
name: proc
2828
type: u32
2929
-
30-
name: service_time
30+
name: service-time
3131
type: s64
3232
-
3333
name: pad
@@ -139,7 +139,7 @@ operations:
139139
- prog
140140
- version
141141
- proc
142-
- service_time
142+
- service-time
143143
- saddr4
144144
- daddr4
145145
- saddr6

0 commit comments

Comments
 (0)