Skip to content

Commit af852f1

Browse files
committed
netlink: specs: enforce strict naming of properties
Add a regexp to make sure all names which may end up being visible to the user consist of lower case characters, numbers and dashes. Underscores keep sneaking into the specs, which is not visible in the C code but makes the Python and alike inconsistent. Note that starting with a number is okay, as in C the full name will include the family name. For legacy families we can't enforce the naming in the family name or the multicast group names, as these are part of the binary uAPI of the kernel. For classic netlink we need to allow capital letters in names of struct members. TC has some structs with capitalized members. Reviewed-by: Donald Hunter <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent eef0eae commit af852f1

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
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

0 commit comments

Comments
 (0)