@@ -7,10 +7,14 @@ use netlink_packet_utils::{
77 DecodeError , Emitable , Parseable ,
88} ;
99
10- use super :: super :: { InfoBondPort , InfoBridgePort } ;
10+ use super :: {
11+ super :: { InfoBondPort , InfoBridgePort } ,
12+ InfoVrf ,
13+ } ;
1114
1215const BOND : & str = "bond" ;
1316const BRIDGE : & str = "bridge" ;
17+ const VRF : & str = "vrf" ;
1418
1519const IFLA_INFO_PORT_KIND : u16 = 4 ;
1620const IFLA_INFO_PORT_DATA : u16 = 5 ;
@@ -20,6 +24,7 @@ const IFLA_INFO_PORT_DATA: u16 = 5;
2024pub enum InfoPortKind {
2125 Bond ,
2226 Bridge ,
27+ Vrf ,
2328 Other ( String ) ,
2429}
2530
@@ -31,6 +36,7 @@ impl std::fmt::Display for InfoPortKind {
3136 match self {
3237 Self :: Bond => BOND ,
3338 Self :: Bridge => BRIDGE ,
39+ Self :: Vrf => VRF ,
3440 Self :: Other ( s) => s. as_str( ) ,
3541 }
3642 )
@@ -42,6 +48,7 @@ impl Nla for InfoPortKind {
4248 let len = match self {
4349 Self :: Bond => BOND . len ( ) ,
4450 Self :: Bridge => BRIDGE . len ( ) ,
51+ Self :: Vrf => VRF . len ( ) ,
4552 Self :: Other ( s) => s. len ( ) ,
4653 } ;
4754 len + 1
@@ -51,6 +58,7 @@ impl Nla for InfoPortKind {
5158 let s = match self {
5259 Self :: Bond => BOND ,
5360 Self :: Bridge => BRIDGE ,
61+ Self :: Vrf => VRF ,
5462 Self :: Other ( s) => s. as_str ( ) ,
5563 } ;
5664 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 {
7684 Ok ( match s. as_str ( ) {
7785 BOND => Self :: Bond ,
7886 BRIDGE => Self :: Bridge ,
87+ VRF => Self :: Vrf ,
7988 _ => Self :: Other ( s) ,
8089 } )
8190 }
8291}
8392
93+ pub type InfoVrfPort = InfoVrf ;
94+
8495#[ derive( Debug , PartialEq , Eq , Clone ) ]
8596#[ non_exhaustive]
8697pub enum InfoPortData {
8798 BondPort ( Vec < InfoBondPort > ) ,
8899 BridgePort ( Vec < InfoBridgePort > ) ,
100+ VrfPort ( Vec < InfoVrfPort > ) ,
89101 Other ( Vec < u8 > ) ,
90102}
91103
@@ -94,6 +106,7 @@ impl Nla for InfoPortData {
94106 match self {
95107 Self :: BondPort ( nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
96108 Self :: BridgePort ( nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
109+ Self :: VrfPort ( nlas) => nlas. as_slice ( ) . buffer_len ( ) ,
97110 Self :: Other ( bytes) => bytes. len ( ) ,
98111 }
99112 }
@@ -102,6 +115,7 @@ impl Nla for InfoPortData {
102115 match self {
103116 Self :: BondPort ( nlas) => nlas. as_slice ( ) . emit ( buffer) ,
104117 Self :: BridgePort ( nlas) => nlas. as_slice ( ) . emit ( buffer) ,
118+ Self :: VrfPort ( nlas) => nlas. as_slice ( ) . emit ( buffer) ,
105119 Self :: Other ( bytes) => buffer. copy_from_slice ( bytes) ,
106120 }
107121 }
@@ -125,6 +139,10 @@ impl InfoPortData {
125139 . map ( |nla| nla. and_then ( |nla| InfoBridgePort :: parse ( & nla) ) )
126140 . collect :: < Result < Vec < _ > , _ > > ( )
127141 . 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 ) ,
128146 InfoPortKind :: Other ( _) => Ok ( InfoPortData :: Other ( payload. to_vec ( ) ) ) ,
129147 } ;
130148
0 commit comments