@@ -16,10 +16,10 @@ use oxide::{
1616 types:: {
1717 Address , AddressConfig , BgpAnnounceSetCreate , BgpAnnouncementCreate , BgpPeer ,
1818 BgpPeerConfig , BgpPeerStatus , ImportExportPolicy , IpNet , LinkConfigCreate , LinkFec ,
19- LinkSpeed , LldpLinkConfigCreate , Name , NameOrId , Route , RouteConfig ,
20- SwitchInterfaceConfigCreate , SwitchInterfaceKind , SwitchInterfaceKind2 , SwitchPort ,
21- SwitchPortConfigCreate , SwitchPortGeometry , SwitchPortGeometry2 , SwitchPortRouteConfig ,
22- SwitchPortSettingsCreate , SwitchSlot ,
19+ LinkSpeed , LldpLinkConfigCreate , Name , NameOrId , Route , RouteConfig , RouterPeerIpAddr ,
20+ RouterPeerType , SwitchInterfaceConfigCreate , SwitchInterfaceKind , SwitchInterfaceKind2 ,
21+ SwitchPort , SwitchPortConfigCreate , SwitchPortGeometry , SwitchPortGeometry2 ,
22+ SwitchPortRouteConfig , SwitchPortSettingsCreate , SwitchSlot ,
2323 } ,
2424 Client , ClientSystemHardwareExt , ClientSystemNetworkingExt ,
2525} ;
@@ -423,7 +423,10 @@ impl AuthenticatedCmd for CmdBgpFilter {
423423 let peer = config
424424 . peers
425425 . iter_mut ( )
426- . find ( |x| x. addr == Some ( self . peer ) )
426+ . find ( |x| match & x. addr {
427+ RouterPeerType :: Numbered { ip } if * * ip == self . peer => true ,
428+ _ => false ,
429+ } )
427430 . ok_or ( anyhow:: anyhow!( "specified peer does not exist" ) ) ?;
428431
429432 let list: Vec < IpNet > = self
@@ -504,7 +507,10 @@ impl AuthenticatedCmd for CmdBgpAuth {
504507 let peer = config
505508 . peers
506509 . iter_mut ( )
507- . find ( |x| x. addr == Some ( self . peer ) )
510+ . find ( |x| match & x. addr {
511+ RouterPeerType :: Numbered { ip } if * * ip == self . peer => true ,
512+ _ => false ,
513+ } )
508514 . ok_or ( anyhow:: anyhow!( "specified peer does not exist" ) ) ?;
509515
510516 peer. md5_auth_key = self . authstring . clone ( ) ;
@@ -566,7 +572,10 @@ impl AuthenticatedCmd for CmdBgpLocalPref {
566572 let peer = config
567573 . peers
568574 . iter_mut ( )
569- . find ( |x| x. addr == Some ( self . peer ) )
575+ . find ( |x| match & x. addr {
576+ RouterPeerType :: Numbered { ip } if * * ip == self . peer => true ,
577+ _ => false ,
578+ } )
570579 . ok_or ( anyhow:: anyhow!( "specified peer does not exist" ) ) ?;
571580
572581 peer. local_pref = self . local_pref
@@ -1091,7 +1100,9 @@ impl AuthenticatedCmd for CmdBgpPeerSet {
10911100 let mut settings =
10921101 current_port_settings ( client, & self . rack , self . switch . into ( ) , & self . port ) . await ?;
10931102 let peer = BgpPeer {
1094- addr : Some ( self . addr ) ,
1103+ addr : RouterPeerType :: Numbered {
1104+ ip : RouterPeerIpAddr ( self . addr ) ,
1105+ } ,
10951106 allowed_import : if self . allowed_imports . is_empty ( ) {
10961107 ImportExportPolicy :: NoFiltering
10971108 } else {
@@ -1121,22 +1132,33 @@ impl AuthenticatedCmd for CmdBgpPeerSet {
11211132 enforce_first_as : self . enforce_first_as ,
11221133 hold_time : self . hold_time ,
11231134 idle_hold_time : self . idle_hold_time ,
1124- interface_name : PHY0 . try_into ( ) . unwrap ( ) ,
1135+ // interface_name: PHY0.try_into().unwrap(),
11251136 keepalive : self . keepalive ,
11261137 local_pref : self . local_pref ,
11271138 md5_auth_key : self . authstring . clone ( ) ,
11281139 min_ttl : self . min_ttl ,
11291140 multi_exit_discriminator : self . multi_exit_discriminator ,
11301141 remote_asn : self . remote_asn ,
11311142 vlan_id : self . vlan_id ,
1132- router_lifetime : self . router_lifetime . unwrap_or ( 0 ) ,
1143+ // router_lifetime: self.router_lifetime.unwrap_or(0),
11331144 } ;
11341145 match settings
11351146 . bgp_peers
11361147 . iter_mut ( )
11371148 . find ( |link| * link. link_name == PHY0 )
11381149 {
1139- Some ( conf) => match conf. peers . iter_mut ( ) . find ( |x| x. addr == peer. addr ) {
1150+ Some ( conf) => match conf. peers . iter_mut ( ) . find ( |x| match ( & x. addr , & peer. addr ) {
1151+ (
1152+ RouterPeerType :: Unnumbered { router_lifetime : a } ,
1153+ RouterPeerType :: Unnumbered { router_lifetime : b } ,
1154+ ) if * * a == * * b => true ,
1155+ ( RouterPeerType :: Numbered { ip : a } , RouterPeerType :: Numbered { ip : b } )
1156+ if * * a == * * b =>
1157+ {
1158+ true
1159+ }
1160+ _ => false ,
1161+ } ) {
11401162 Some ( p) => * p = peer,
11411163 None => conf. peers . push ( peer) ,
11421164 } ,
@@ -1192,7 +1214,11 @@ impl AuthenticatedCmd for CmdBgpPeerDel {
11921214 . find ( |link| * link. link_name == PHY0 )
11931215 {
11941216 let before = config. peers . len ( ) ;
1195- config. peers . retain ( |x| x. addr != Some ( self . addr ) ) ;
1217+ config. peers . retain ( |x| match & x. addr {
1218+ RouterPeerType :: Numbered { ip } if * * ip == self . addr => true ,
1219+ _ => false ,
1220+ } ) ;
1221+ // != Some(self.addr));
11961222 let after = config. peers . len ( ) ;
11971223 if before == after {
11981224 eprintln_nopipe ! ( "no peers match the provided address" ) ;
@@ -1352,7 +1378,11 @@ impl AuthenticatedCmd for CmdPortConfig {
13521378 writeln ! (
13531379 & mut tw,
13541380 "{}\t {}\t [{}]\t [{}]\t {:?}\t {}\t {}\t {}\t {}\t {}\t {}\t {}\t {}\t {}\t {}\t {}\t {}" ,
1355- p. addr. map_or( "-" . to_string( ) , |a| a. to_string( ) ) ,
1381+ match & p. addr {
1382+ RouterPeerType :: Unnumbered { router_lifetime } =>
1383+ format!( "({router_lifetime})" ) ,
1384+ RouterPeerType :: Numbered { ip } => ip. to_string( ) ,
1385+ } ,
13561386 match & p. bgp_config {
13571387 NameOrId :: Id ( id) => bgp_configs[ id] . to_string( ) ,
13581388 NameOrId :: Name ( name) => name. to_string( ) ,
0 commit comments