@@ -68,9 +68,9 @@ pub enum InfoVxlan {
68
68
UDPZeroCsumRX ( bool ) ,
69
69
RemCsumTX ( bool ) ,
70
70
RemCsumRX ( bool ) ,
71
- Gbp ( u8 ) ,
72
- Gpe ( u8 ) ,
73
- RemCsumNoPartial ( u8 ) ,
71
+ Gbp ( bool ) ,
72
+ Gpe ( bool ) ,
73
+ RemCsumNoPartial ( bool ) ,
74
74
TtlInherit ( bool ) ,
75
75
Df ( u8 ) ,
76
76
Vnifilter ( bool ) ,
@@ -80,151 +80,168 @@ pub enum InfoVxlan {
80
80
81
81
impl Nla for InfoVxlan {
82
82
fn value_len ( & self ) -> usize {
83
- use self :: InfoVxlan :: * ;
84
- match * self {
85
- Tos ( _) | Ttl ( _) | Learning ( _) | Proxy ( _) | Rsc ( _) | L2Miss ( _)
86
- | L3Miss ( _) | CollectMetadata ( _) | UDPCsum ( _)
87
- | UDPZeroCsumTX ( _) | UDPZeroCsumRX ( _) | RemCsumTX ( _)
88
- | RemCsumRX ( _) | Gbp ( _) | Gpe ( _) | RemCsumNoPartial ( _)
89
- | TtlInherit ( _) | Df ( _) | Vnifilter ( _) | Localbypass ( _) => 1 ,
90
- Port ( _) => 2 ,
91
- Id ( _) | Label ( _) | Link ( _) | Ageing ( _) | Limit ( _)
92
- | PortRange ( _) => 4 ,
93
- Local ( ref bytes) | Local6 ( ref bytes) | Group ( ref bytes)
94
- | Group6 ( ref bytes) => bytes. len ( ) ,
95
- Other ( ref nla) => nla. value_len ( ) ,
83
+ match self {
84
+ Self :: Tos ( _)
85
+ | Self :: Ttl ( _)
86
+ | Self :: Learning ( _)
87
+ | Self :: Proxy ( _)
88
+ | Self :: Rsc ( _)
89
+ | Self :: L2Miss ( _)
90
+ | Self :: L3Miss ( _)
91
+ | Self :: CollectMetadata ( _)
92
+ | Self :: UDPCsum ( _)
93
+ | Self :: UDPZeroCsumTX ( _)
94
+ | Self :: UDPZeroCsumRX ( _)
95
+ | Self :: RemCsumTX ( _)
96
+ | Self :: RemCsumRX ( _)
97
+ | Self :: TtlInherit ( _)
98
+ | Self :: Df ( _)
99
+ | Self :: Vnifilter ( _)
100
+ | Self :: Localbypass ( _) => 1 ,
101
+ Self :: Gbp ( _) | Self :: Gpe ( _) | Self :: RemCsumNoPartial ( _) => 0 ,
102
+ Self :: Port ( _) => 2 ,
103
+ Self :: Id ( _)
104
+ | Self :: Label ( _)
105
+ | Self :: Link ( _)
106
+ | Self :: Ageing ( _)
107
+ | Self :: Limit ( _)
108
+ | Self :: PortRange ( _) => 4 ,
109
+ Self :: Local ( bytes)
110
+ | Self :: Local6 ( bytes)
111
+ | Self :: Group ( bytes)
112
+ | Self :: Group6 ( bytes) => bytes. len ( ) ,
113
+ Self :: Other ( nla) => nla. value_len ( ) ,
96
114
}
97
115
}
98
116
99
117
fn emit_value ( & self , buffer : & mut [ u8 ] ) {
100
- use self :: InfoVxlan :: * ;
101
118
match self {
102
- Id ( ref value) | Label ( ref value) | Link ( ref value)
103
- | Ageing ( ref value) | Limit ( ref value) => {
104
- NativeEndian :: write_u32 ( buffer, * value)
119
+ Self :: Id ( value)
120
+ | Self :: Label ( value)
121
+ | Self :: Link ( value)
122
+ | Self :: Ageing ( value)
123
+ | Self :: Limit ( value) => NativeEndian :: write_u32 ( buffer, * value) ,
124
+ Self :: Gbp ( _value)
125
+ | Self :: Gpe ( _value)
126
+ | Self :: RemCsumNoPartial ( _value) => ( ) ,
127
+ Self :: Tos ( value) | Self :: Ttl ( value) | Self :: Df ( value) => {
128
+ buffer[ 0 ] = * value
105
129
}
106
- Tos ( ref value)
107
- | Gbp ( ref value)
108
- | Gpe ( ref value)
109
- | RemCsumNoPartial ( ref value)
110
- | Ttl ( ref value)
111
- | Df ( ref value) => buffer[ 0 ] = * value,
112
- Vnifilter ( ref value)
113
- | Localbypass ( ref value)
114
- | Learning ( ref value)
115
- | Proxy ( ref value)
116
- | Rsc ( ref value)
117
- | L2Miss ( ref value)
118
- | L3Miss ( ref value)
119
- | CollectMetadata ( ref value)
120
- | UDPCsum ( ref value)
121
- | UDPZeroCsumTX ( ref value)
122
- | UDPZeroCsumRX ( ref value)
123
- | RemCsumTX ( ref value)
124
- | RemCsumRX ( ref value)
125
- | TtlInherit ( ref value) => buffer[ 0 ] = * value as u8 ,
126
- Local ( ref value) | Group ( ref value) | Group6 ( ref value)
127
- | Local6 ( ref value) => buffer. copy_from_slice ( value. as_slice ( ) ) ,
128
- Port ( ref value) => BigEndian :: write_u16 ( buffer, * value) ,
129
- PortRange ( ref range) => {
130
+ Self :: Vnifilter ( value)
131
+ | Self :: Localbypass ( value)
132
+ | Self :: Learning ( value)
133
+ | Self :: Proxy ( value)
134
+ | Self :: Rsc ( value)
135
+ | Self :: L2Miss ( value)
136
+ | Self :: L3Miss ( value)
137
+ | Self :: CollectMetadata ( value)
138
+ | Self :: UDPCsum ( value)
139
+ | Self :: UDPZeroCsumTX ( value)
140
+ | Self :: UDPZeroCsumRX ( value)
141
+ | Self :: RemCsumTX ( value)
142
+ | Self :: RemCsumRX ( value)
143
+ | Self :: TtlInherit ( value) => buffer[ 0 ] = * value as u8 ,
144
+ Self :: Local ( value)
145
+ | Self :: Group ( value)
146
+ | Self :: Group6 ( value)
147
+ | Self :: Local6 ( value) => buffer. copy_from_slice ( value. as_slice ( ) ) ,
148
+ Self :: Port ( value) => BigEndian :: write_u16 ( buffer, * value) ,
149
+ Self :: PortRange ( range) => {
130
150
BigEndian :: write_u16 ( buffer, range. 0 ) ;
131
151
BigEndian :: write_u16 ( & mut buffer[ 2 ..] , range. 1 )
132
152
}
133
- Other ( ref nla) => nla. emit_value ( buffer) ,
153
+ Self :: Other ( nla) => nla. emit_value ( buffer) ,
134
154
}
135
155
}
136
156
137
157
fn kind ( & self ) -> u16 {
138
- use self :: InfoVxlan :: * ;
139
-
140
158
match self {
141
- Id ( _) => IFLA_VXLAN_ID ,
142
- Group ( _) => IFLA_VXLAN_GROUP ,
143
- Group6 ( _) => IFLA_VXLAN_GROUP6 ,
144
- Link ( _) => IFLA_VXLAN_LINK ,
145
- Local ( _) => IFLA_VXLAN_LOCAL ,
146
- Local6 ( _) => IFLA_VXLAN_LOCAL6 ,
147
- Tos ( _) => IFLA_VXLAN_TOS ,
148
- Ttl ( _) => IFLA_VXLAN_TTL ,
149
- Label ( _) => IFLA_VXLAN_LABEL ,
150
- Learning ( _) => IFLA_VXLAN_LEARNING ,
151
- Ageing ( _) => IFLA_VXLAN_AGEING ,
152
- Limit ( _) => IFLA_VXLAN_LIMIT ,
153
- PortRange ( _) => IFLA_VXLAN_PORT_RANGE ,
154
- Proxy ( _) => IFLA_VXLAN_PROXY ,
155
- Rsc ( _) => IFLA_VXLAN_RSC ,
156
- L2Miss ( _) => IFLA_VXLAN_L2MISS ,
157
- L3Miss ( _) => IFLA_VXLAN_L3MISS ,
158
- CollectMetadata ( _) => IFLA_VXLAN_COLLECT_METADATA ,
159
- Port ( _) => IFLA_VXLAN_PORT ,
160
- UDPCsum ( _) => IFLA_VXLAN_UDP_CSUM ,
161
- UDPZeroCsumTX ( _) => IFLA_VXLAN_UDP_ZERO_CSUM6_TX ,
162
- UDPZeroCsumRX ( _) => IFLA_VXLAN_UDP_ZERO_CSUM6_RX ,
163
- RemCsumTX ( _) => IFLA_VXLAN_REMCSUM_TX ,
164
- RemCsumRX ( _) => IFLA_VXLAN_REMCSUM_RX ,
165
- Gbp ( _) => IFLA_VXLAN_GBP ,
166
- Gpe ( _) => IFLA_VXLAN_GPE ,
167
- RemCsumNoPartial ( _) => IFLA_VXLAN_REMCSUM_NOPARTIAL ,
168
- TtlInherit ( _) => IFLA_VXLAN_TTL_INHERIT ,
169
- Df ( _) => IFLA_VXLAN_DF ,
170
- Vnifilter ( _) => IFLA_VXLAN_VNIFILTER ,
171
- Localbypass ( _) => IFLA_VXLAN_LOCALBYPASS ,
172
- Other ( nla) => nla. kind ( ) ,
159
+ Self :: Id ( _) => IFLA_VXLAN_ID ,
160
+ Self :: Group ( _) => IFLA_VXLAN_GROUP ,
161
+ Self :: Group6 ( _) => IFLA_VXLAN_GROUP6 ,
162
+ Self :: Link ( _) => IFLA_VXLAN_LINK ,
163
+ Self :: Local ( _) => IFLA_VXLAN_LOCAL ,
164
+ Self :: Local6 ( _) => IFLA_VXLAN_LOCAL6 ,
165
+ Self :: Tos ( _) => IFLA_VXLAN_TOS ,
166
+ Self :: Ttl ( _) => IFLA_VXLAN_TTL ,
167
+ Self :: Label ( _) => IFLA_VXLAN_LABEL ,
168
+ Self :: Learning ( _) => IFLA_VXLAN_LEARNING ,
169
+ Self :: Ageing ( _) => IFLA_VXLAN_AGEING ,
170
+ Self :: Limit ( _) => IFLA_VXLAN_LIMIT ,
171
+ Self :: PortRange ( _) => IFLA_VXLAN_PORT_RANGE ,
172
+ Self :: Proxy ( _) => IFLA_VXLAN_PROXY ,
173
+ Self :: Rsc ( _) => IFLA_VXLAN_RSC ,
174
+ Self :: L2Miss ( _) => IFLA_VXLAN_L2MISS ,
175
+ Self :: L3Miss ( _) => IFLA_VXLAN_L3MISS ,
176
+ Self :: CollectMetadata ( _) => IFLA_VXLAN_COLLECT_METADATA ,
177
+ Self :: Port ( _) => IFLA_VXLAN_PORT ,
178
+ Self :: UDPCsum ( _) => IFLA_VXLAN_UDP_CSUM ,
179
+ Self :: UDPZeroCsumTX ( _) => IFLA_VXLAN_UDP_ZERO_CSUM6_TX ,
180
+ Self :: UDPZeroCsumRX ( _) => IFLA_VXLAN_UDP_ZERO_CSUM6_RX ,
181
+ Self :: RemCsumTX ( _) => IFLA_VXLAN_REMCSUM_TX ,
182
+ Self :: RemCsumRX ( _) => IFLA_VXLAN_REMCSUM_RX ,
183
+ Self :: Gbp ( _) => IFLA_VXLAN_GBP ,
184
+ Self :: Gpe ( _) => IFLA_VXLAN_GPE ,
185
+ Self :: RemCsumNoPartial ( _) => IFLA_VXLAN_REMCSUM_NOPARTIAL ,
186
+ Self :: TtlInherit ( _) => IFLA_VXLAN_TTL_INHERIT ,
187
+ Self :: Df ( _) => IFLA_VXLAN_DF ,
188
+ Self :: Vnifilter ( _) => IFLA_VXLAN_VNIFILTER ,
189
+ Self :: Localbypass ( _) => IFLA_VXLAN_LOCALBYPASS ,
190
+ Self :: Other ( nla) => nla. kind ( ) ,
173
191
}
174
192
}
175
193
}
176
194
177
195
impl < ' a , T : AsRef < [ u8 ] > + ?Sized > Parseable < NlaBuffer < & ' a T > > for InfoVxlan {
178
196
fn parse ( buf : & NlaBuffer < & ' a T > ) -> Result < Self , DecodeError > {
179
- use self :: InfoVxlan :: * ;
180
197
let payload = buf. value ( ) ;
181
198
Ok ( match buf. kind ( ) {
182
199
IFLA_VXLAN_ID => {
183
- Id ( parse_u32 ( payload) . context ( "invalid IFLA_VXLAN_ID value" ) ?)
200
+ Self :: Id ( parse_u32 ( payload) . context ( "invalid IFLA_VXLAN_ID value" ) ?)
184
201
}
185
- IFLA_VXLAN_GROUP => Group ( payload. to_vec ( ) ) ,
186
- IFLA_VXLAN_GROUP6 => Group6 ( payload. to_vec ( ) ) ,
187
- IFLA_VXLAN_LINK => Link (
202
+ IFLA_VXLAN_GROUP => Self :: Group ( payload. to_vec ( ) ) ,
203
+ IFLA_VXLAN_GROUP6 => Self :: Group6 ( payload. to_vec ( ) ) ,
204
+ IFLA_VXLAN_LINK => Self :: Link (
188
205
parse_u32 ( payload) . context ( "invalid IFLA_VXLAN_LINK value" ) ?,
189
206
) ,
190
- IFLA_VXLAN_LOCAL => Local ( payload. to_vec ( ) ) ,
191
- IFLA_VXLAN_LOCAL6 => Local6 ( payload. to_vec ( ) ) ,
207
+ IFLA_VXLAN_LOCAL => Self :: Local ( payload. to_vec ( ) ) ,
208
+ IFLA_VXLAN_LOCAL6 => Self :: Local6 ( payload. to_vec ( ) ) ,
192
209
IFLA_VXLAN_TOS => {
193
- Tos ( parse_u8 ( payload)
210
+ Self :: Tos ( parse_u8 ( payload)
194
211
. context ( "invalid IFLA_VXLAN_TOS value" ) ?)
195
212
}
196
213
IFLA_VXLAN_TTL => {
197
- Ttl ( parse_u8 ( payload)
214
+ Self :: Ttl ( parse_u8 ( payload)
198
215
. context ( "invalid IFLA_VXLAN_TTL value" ) ?)
199
216
}
200
- IFLA_VXLAN_LABEL => Label (
217
+ IFLA_VXLAN_LABEL => Self :: Label (
201
218
parse_u32 ( payload) . context ( "invalid IFLA_VXLAN_LABEL value" ) ?,
202
219
) ,
203
- IFLA_VXLAN_LEARNING => Learning (
220
+ IFLA_VXLAN_LEARNING => Self :: Learning (
204
221
parse_u8 ( payload)
205
222
. context ( "invalid IFLA_VXLAN_LEARNING value" ) ? > 0 ,
206
223
) ,
207
- IFLA_VXLAN_AGEING => Ageing (
224
+ IFLA_VXLAN_AGEING => Self :: Ageing (
208
225
parse_u32 ( payload)
209
226
. context ( "invalid IFLA_VXLAN_AGEING value" ) ?,
210
227
) ,
211
- IFLA_VXLAN_LIMIT => Limit (
228
+ IFLA_VXLAN_LIMIT => Self :: Limit (
212
229
parse_u32 ( payload) . context ( "invalid IFLA_VXLAN_LIMIT value" ) ?,
213
230
) ,
214
- IFLA_VXLAN_PROXY => Proxy (
231
+ IFLA_VXLAN_PROXY => Self :: Proxy (
215
232
parse_u8 ( payload) . context ( "invalid IFLA_VXLAN_PROXY value" ) ? > 0 ,
216
233
) ,
217
234
IFLA_VXLAN_RSC => {
218
- Rsc ( parse_u8 ( payload)
235
+ Self :: Rsc ( parse_u8 ( payload)
219
236
. context ( "invalid IFLA_VXLAN_RSC value" ) ?> 0 )
220
237
}
221
- IFLA_VXLAN_L2MISS => L2Miss (
238
+ IFLA_VXLAN_L2MISS => Self :: L2Miss (
222
239
parse_u8 ( payload) . context ( "invalid IFLA_VXLAN_L2MISS value" ) ? > 0 ,
223
240
) ,
224
- IFLA_VXLAN_L3MISS => L3Miss (
241
+ IFLA_VXLAN_L3MISS => Self :: L3Miss (
225
242
parse_u8 ( payload) . context ( "invalid IFLA_VXLAN_L3MISS value" ) ? > 0 ,
226
243
) ,
227
- IFLA_VXLAN_COLLECT_METADATA => CollectMetadata (
244
+ IFLA_VXLAN_COLLECT_METADATA => Self :: CollectMetadata (
228
245
parse_u8 ( payload)
229
246
. context ( "invalid IFLA_VXLAN_COLLECT_METADATA value" ) ? >0 ,
230
247
) ,
@@ -235,60 +252,55 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoVxlan {
235
252
}
236
253
let low = parse_u16_be ( & payload[ 0 ..2 ] ) . context ( err) ?;
237
254
let high = parse_u16_be ( & payload[ 2 ..] ) . context ( err) ?;
238
- PortRange ( ( low, high) )
255
+ Self :: PortRange ( ( low, high) )
239
256
}
240
- IFLA_VXLAN_PORT => Port (
257
+ IFLA_VXLAN_PORT => Self :: Port (
241
258
parse_u16_be ( payload)
242
259
. context ( "invalid IFLA_VXLAN_PORT value" ) ?,
243
260
) ,
244
- IFLA_VXLAN_UDP_CSUM => UDPCsum (
261
+ IFLA_VXLAN_UDP_CSUM => Self :: UDPCsum (
245
262
parse_u8 ( payload)
246
263
. context ( "invalid IFLA_VXLAN_UDP_CSUM value" ) ? > 0 ,
247
264
) ,
248
- IFLA_VXLAN_UDP_ZERO_CSUM6_TX => UDPZeroCsumTX (
265
+ IFLA_VXLAN_UDP_ZERO_CSUM6_TX => Self :: UDPZeroCsumTX (
249
266
parse_u8 ( payload)
250
267
. context ( "invalid IFLA_VXLAN_UDP_ZERO_CSUM6_TX value" ) ? > 0 ,
251
268
) ,
252
- IFLA_VXLAN_UDP_ZERO_CSUM6_RX => UDPZeroCsumRX (
269
+ IFLA_VXLAN_UDP_ZERO_CSUM6_RX => Self :: UDPZeroCsumRX (
253
270
parse_u8 ( payload)
254
271
. context ( "invalid IFLA_VXLAN_UDP_ZERO_CSUM6_RX value" ) ? > 0 ,
255
272
) ,
256
- IFLA_VXLAN_REMCSUM_TX => RemCsumTX (
273
+ IFLA_VXLAN_REMCSUM_TX => Self :: RemCsumTX (
257
274
parse_u8 ( payload)
258
275
. context ( "invalid IFLA_VXLAN_REMCSUM_TX value" ) ? > 0 ,
259
276
) ,
260
- IFLA_VXLAN_REMCSUM_RX => RemCsumRX (
277
+ IFLA_VXLAN_REMCSUM_RX => Self :: RemCsumRX (
261
278
parse_u8 ( payload)
262
279
. context ( "invalid IFLA_VXLAN_REMCSUM_RX value" ) ? > 0 ,
263
280
) ,
264
281
IFLA_VXLAN_DF => {
265
- Df ( parse_u8 ( payload) . context ( "invalid IFLA_VXLAN_DF value" ) ?)
282
+ Self :: Df ( parse_u8 ( payload) . context ( "invalid IFLA_VXLAN_DF value" ) ?)
266
283
}
267
284
IFLA_VXLAN_GBP => {
268
- Gbp ( parse_u8 ( payload)
269
- . context ( "invalid IFLA_VXLAN_GBP value" ) ?)
285
+ Self :: Gbp ( true )
270
286
}
271
287
IFLA_VXLAN_GPE => {
272
- Gpe ( parse_u8 ( payload)
273
- . context ( "invalid IFLA_VXLAN_GPE value" ) ?)
288
+ Self :: Gpe ( true )
274
289
}
275
- IFLA_VXLAN_REMCSUM_NOPARTIAL => RemCsumNoPartial (
276
- parse_u8 ( payload)
277
- . context ( "invalid IFLA_VXLAN_REMCSUM_NO_PARTIAL" ) ?,
278
- ) ,
279
- IFLA_VXLAN_TTL_INHERIT => TtlInherit (
290
+ IFLA_VXLAN_REMCSUM_NOPARTIAL => Self :: RemCsumNoPartial ( true ) ,
291
+ IFLA_VXLAN_TTL_INHERIT => Self :: TtlInherit (
280
292
parse_u8 ( payload)
281
293
. context ( "invalid IFLA_VXLAN_TTL_INHERIT value" ) ? > 0 ,
282
294
) ,
283
- IFLA_VXLAN_VNIFILTER => Vnifilter (
295
+ IFLA_VXLAN_VNIFILTER => Self :: Vnifilter (
284
296
parse_u8 ( payload)
285
297
. context ( "invalid IFLA_VXLAN_VNIFILTER value" ) ? > 0 ,
286
298
) ,
287
- IFLA_VXLAN_LOCALBYPASS => Localbypass (
299
+ IFLA_VXLAN_LOCALBYPASS => Self :: Localbypass (
288
300
parse_u8 ( payload)
289
301
. context ( "invalid IFLA_VXLAN_LOCALBYPASS value" ) ? > 0 ,
290
302
) ,
291
- unknown_kind => Other ( DefaultNla :: parse ( buf) . context ( format ! (
303
+ unknown_kind => Self :: Other ( DefaultNla :: parse ( buf) . context ( format ! (
292
304
"Failed to parse IFLA_INFO_DATA(vxlan) NLA type: {unknown_kind} as DefaultNla"
293
305
) ) ?) ,
294
306
} )
0 commit comments