@@ -7,10 +7,14 @@ use netlink_packet_utils::{
7
7
DecodeError , Emitable , Parseable ,
8
8
} ;
9
9
10
- use super :: super :: { InfoBondPort , InfoBridgePort } ;
10
+ use super :: {
11
+ super :: { InfoBondPort , InfoBridgePort } ,
12
+ InfoVrf ,
13
+ } ;
11
14
12
15
const BOND : & str = "bond" ;
13
16
const BRIDGE : & str = "bridge" ;
17
+ const VRF : & str = "vrf" ;
14
18
15
19
const IFLA_INFO_PORT_KIND : u16 = 4 ;
16
20
const IFLA_INFO_PORT_DATA : u16 = 5 ;
@@ -20,6 +24,7 @@ const IFLA_INFO_PORT_DATA: u16 = 5;
20
24
pub enum InfoPortKind {
21
25
Bond ,
22
26
Bridge ,
27
+ Vrf ,
23
28
Other ( String ) ,
24
29
}
25
30
@@ -31,6 +36,7 @@ impl std::fmt::Display for InfoPortKind {
31
36
match self {
32
37
Self :: Bond => BOND ,
33
38
Self :: Bridge => BRIDGE ,
39
+ Self :: Vrf => VRF ,
34
40
Self :: Other ( s) => s. as_str( ) ,
35
41
}
36
42
)
@@ -42,6 +48,7 @@ impl Nla for InfoPortKind {
42
48
let len = match self {
43
49
Self :: Bond => BOND . len ( ) ,
44
50
Self :: Bridge => BRIDGE . len ( ) ,
51
+ Self :: Vrf => VRF . len ( ) ,
45
52
Self :: Other ( s) => s. len ( ) ,
46
53
} ;
47
54
len + 1
@@ -51,6 +58,7 @@ impl Nla for InfoPortKind {
51
58
let s = match self {
52
59
Self :: Bond => BOND ,
53
60
Self :: Bridge => BRIDGE ,
61
+ Self :: Vrf => VRF ,
54
62
Self :: Other ( s) => s. as_str ( ) ,
55
63
} ;
56
64
buffer[ ..s. len ( ) ] . copy_from_slice ( s. as_bytes ( ) ) ;
@@ -76,16 +84,20 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoPortKind {
76
84
Ok ( match s. as_str ( ) {
77
85
BOND => Self :: Bond ,
78
86
BRIDGE => Self :: Bridge ,
87
+ VRF => Self :: Vrf ,
79
88
_ => Self :: Other ( s) ,
80
89
} )
81
90
}
82
91
}
83
92
93
+ pub type InfoVrfPort = InfoVrf ;
94
+
84
95
#[ derive( Debug , PartialEq , Eq , Clone ) ]
85
96
#[ non_exhaustive]
86
97
pub enum InfoPortData {
87
98
BondPort ( Vec < InfoBondPort > ) ,
88
99
BridgePort ( Vec < InfoBridgePort > ) ,
100
+ VrfPort ( Vec < InfoVrfPort > ) ,
89
101
Other ( Vec < u8 > ) ,
90
102
}
91
103
@@ -94,6 +106,7 @@ impl Nla for InfoPortData {
94
106
match self {
95
107
Self :: BondPort ( nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
96
108
Self :: BridgePort ( nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
109
+ Self :: VrfPort ( nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
97
110
Self :: Other ( bytes) => bytes. len ( ) ,
98
111
}
99
112
}
@@ -102,6 +115,7 @@ impl Nla for InfoPortData {
102
115
match self {
103
116
Self :: BondPort ( nlas) => nlas. as_slice ( ) . emit ( buffer) ,
104
117
Self :: BridgePort ( nlas) => nlas. as_slice ( ) . emit ( buffer) ,
118
+ Self :: VrfPort ( nlas) => nlas. as_slice ( ) . emit ( buffer) ,
105
119
Self :: Other ( bytes) => buffer. copy_from_slice ( bytes) ,
106
120
}
107
121
}
@@ -125,6 +139,10 @@ impl InfoPortData {
125
139
. map ( |nla| nla. and_then ( |nla| InfoBridgePort :: parse ( & nla) ) )
126
140
. collect :: < Result < Vec < _ > , _ > > ( )
127
141
. map ( InfoPortData :: BridgePort ) ,
142
+ InfoPortKind :: Vrf => NlasIterator :: new ( payload)
143
+ . map ( |nla| nla. and_then ( |nla| InfoVrfPort :: parse ( & nla) ) )
144
+ . collect :: < Result < Vec < _ > , _ > > ( )
145
+ . map ( InfoPortData :: VrfPort ) ,
128
146
InfoPortKind :: Other ( _) => Ok ( InfoPortData :: Other ( payload. to_vec ( ) ) ) ,
129
147
} ;
130
148
0 commit comments