@@ -10,6 +10,9 @@ pub use self::af_spec_inet::*;
10
10
mod link_infos;
11
11
pub use self :: link_infos:: * ;
12
12
13
+ mod prop_list;
14
+ pub use self :: prop_list:: * ;
15
+
13
16
mod map;
14
17
pub use self :: map:: * ;
15
18
@@ -32,7 +35,7 @@ use byteorder::{ByteOrder, NativeEndian};
32
35
33
36
use crate :: {
34
37
constants:: * ,
35
- nlas:: { self , DefaultNla , NlaBuffer , NlasIterator } ,
38
+ nlas:: { self , DefaultNla , NlaBuffer , NlasIterator , NLA_F_NESTED } ,
36
39
parsers:: { parse_i32, parse_string, parse_u32, parse_u8} ,
37
40
traits:: { Emitable , Parseable , ParseableParametrized } ,
38
41
DecodeError ,
@@ -68,7 +71,7 @@ pub enum Nla {
68
71
/// [1]: https://lwn.net/ml/netdev/[email protected] /
69
72
/// [2]: https://lwn.net/ml/netdev/[email protected] /
70
73
/// [defining message]: https://lwn.net/ml/netdev/[email protected] /
71
- PropList ( Vec < u8 > ) ,
74
+ PropList ( Vec < Prop > ) ,
72
75
/// `protodown` is a mechanism that allows protocols to hold an interface down.
73
76
/// This field is used to specify the reason why it is held down.
74
77
/// For additional context see the related linux kernel threads<sup>[1][1],[2][2]</sup>.
@@ -174,7 +177,6 @@ impl nlas::Nla for Nla {
174
177
| AfSpecUnknown ( ref bytes)
175
178
| AfSpecBridge ( ref bytes)
176
179
| Map ( ref bytes)
177
- | PropList ( ref bytes)
178
180
| ProtoDownReason ( ref bytes)
179
181
=> bytes. len ( ) ,
180
182
@@ -217,6 +219,7 @@ impl nlas::Nla for Nla {
217
219
Stats ( _) => LINK_STATS_LEN ,
218
220
Stats64 ( _) => LINK_STATS64_LEN ,
219
221
Info ( ref nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
222
+ PropList ( ref nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
220
223
AfSpecInet ( ref nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
221
224
// AfSpecBridge(ref nlas) => nlas.as_slice().buffer_len(),
222
225
Other ( ref attr) => attr. value_len ( ) ,
@@ -257,7 +260,6 @@ impl nlas::Nla for Nla {
257
260
| Stats ( ref bytes)
258
261
| Stats64 ( ref bytes)
259
262
| Map ( ref bytes)
260
- | PropList ( ref bytes)
261
263
| ProtoDownReason ( ref bytes)
262
264
=> buffer. copy_from_slice ( bytes. as_slice ( ) ) ,
263
265
@@ -303,6 +305,7 @@ impl nlas::Nla for Nla {
303
305
304
306
OperState ( state) => buffer[ 0 ] = state. into ( ) ,
305
307
Info ( ref nlas) => nlas. as_slice ( ) . emit ( buffer) ,
308
+ PropList ( ref nlas) => nlas. as_slice ( ) . emit ( buffer) ,
306
309
AfSpecInet ( ref nlas) => nlas. as_slice ( ) . emit ( buffer) ,
307
310
// AfSpecBridge(ref nlas) => nlas.as_slice().emit(buffer),
308
311
// default nlas
@@ -334,7 +337,7 @@ impl nlas::Nla for Nla {
334
337
CarrierUpCount ( _) => IFLA_CARRIER_UP_COUNT ,
335
338
CarrierDownCount ( _) => IFLA_CARRIER_DOWN_COUNT ,
336
339
NewIfIndex ( _) => IFLA_NEW_IFINDEX ,
337
- PropList ( _) => IFLA_PROP_LIST ,
340
+ PropList ( _) => IFLA_PROP_LIST | NLA_F_NESTED ,
338
341
ProtoDownReason ( _) => IFLA_PROTO_DOWN_REASON ,
339
342
// Mac address
340
343
Address ( _) => IFLA_ADDRESS ,
@@ -409,7 +412,16 @@ impl<'a, T: AsRef<[u8]> + ?Sized> ParseableParametrized<NlaBuffer<&'a T>, u16> f
409
412
IFLA_CARRIER_UP_COUNT => CarrierUpCount ( payload. to_vec ( ) ) ,
410
413
IFLA_CARRIER_DOWN_COUNT => CarrierDownCount ( payload. to_vec ( ) ) ,
411
414
IFLA_NEW_IFINDEX => NewIfIndex ( payload. to_vec ( ) ) ,
412
- IFLA_PROP_LIST => PropList ( payload. to_vec ( ) ) ,
415
+ IFLA_PROP_LIST => {
416
+ let error_msg = "invalid IFLA_PROP_LIST value" ;
417
+ let mut nlas = vec ! [ ] ;
418
+ for nla in NlasIterator :: new ( payload) {
419
+ let nla = & nla. context ( error_msg) ?;
420
+ let parsed = Prop :: parse ( nla) . context ( error_msg) ?;
421
+ nlas. push ( parsed) ;
422
+ }
423
+ PropList ( nlas)
424
+ }
413
425
IFLA_PROTO_DOWN_REASON => ProtoDownReason ( payload. to_vec ( ) ) ,
414
426
// HW address (we parse them as Vec for now, because for IP over GRE, the HW address is
415
427
// an IP instead of a MAC for example
0 commit comments