@@ -30,9 +30,10 @@ use futures::future::BoxFuture;
3030use mg_admin_client:: types:: {
3131 AddStaticRoute4Request , AddStaticRoute6Request , ApplyRequest ,
3232 BgpPeerConfig , CheckerSource , DeleteStaticRoute4Request ,
33- DeleteStaticRoute6Request , ImportExportPolicy as MgImportExportPolicy ,
34- ShaperSource , StaticRoute4 , StaticRoute4List , StaticRoute6 ,
35- StaticRoute6List ,
33+ DeleteStaticRoute6Request , ImportExportPolicy4 as MgImportExportPolicy4 ,
34+ ImportExportPolicy6 as MgImportExportPolicy6 , Ipv4UnicastConfig ,
35+ Ipv6UnicastConfig , JitterRange , ShaperSource , StaticRoute4 ,
36+ StaticRoute4List , StaticRoute6 , StaticRoute6List ,
3637} ;
3738use nexus_db_queries:: {
3839 context:: OpContext ,
@@ -48,7 +49,7 @@ use omicron_common::{
4849 internal:: shared:: ParseSwitchLocationError ,
4950 } ,
5051} ;
51- use rdb_types:: { Prefix as MgPrefix , Prefix4 , Prefix6 } ;
52+ use rdb_types:: { Prefix4 , Prefix6 } ;
5253use serde_json:: json;
5354use sled_agent_client:: types:: {
5455 BgpConfig as SledBgpConfig , BgpPeerConfig as SledBgpPeerConfig ,
@@ -703,30 +704,48 @@ impl BackgroundTask for SwitchPortSettingsManager {
703704 }
704705 } ;
705706
706- let import_policy = match allow_import {
707+ let import_policy4 = match & allow_import {
707708 Some ( list) => {
708- MgImportExportPolicy :: Allow ( list
709+ MgImportExportPolicy4 :: Allow ( list
710+ . clone ( )
709711 . into_iter ( )
710- . map ( |x|
712+ . filter_map ( |x|
711713 match x. prefix {
712- IpNetwork :: V4 ( p) => MgPrefix :: V4 (
714+ IpNetwork :: V4 ( p) => Some (
713715 Prefix4 {
714716 length : p. prefix ( ) ,
715717 value : p. ip ( ) ,
716718 }
717719 ) ,
718- IpNetwork :: V6 ( p) => MgPrefix :: V6 (
720+ IpNetwork :: V6 ( _) => None ,
721+ }
722+ )
723+ . collect ( )
724+ )
725+ }
726+ None => MgImportExportPolicy4 :: NoFiltering ,
727+ } ;
728+
729+ let import_policy6 = match & allow_import {
730+ Some ( list) => {
731+ MgImportExportPolicy6 :: Allow ( list
732+ . clone ( )
733+ . into_iter ( )
734+ . filter_map ( |x|
735+ match x. prefix {
736+ IpNetwork :: V6 ( p) => Some (
719737 Prefix6 {
720738 length : p. prefix ( ) ,
721739 value : p. ip ( ) ,
722740 }
723- )
741+ ) ,
742+ IpNetwork :: V4 ( _) => None ,
724743 }
725744 )
726745 . collect ( )
727746 )
728747 }
729- None => MgImportExportPolicy :: NoFiltering ,
748+ None => MgImportExportPolicy6 :: NoFiltering ,
730749 } ;
731750
732751 let allow_export = match self . datastore . allow_export_for_peer (
@@ -753,30 +772,48 @@ impl BackgroundTask for SwitchPortSettingsManager {
753772 }
754773 } ;
755774
756- let export_policy = match allow_export {
775+ let export_policy4 = match & allow_export {
757776 Some ( list) => {
758- MgImportExportPolicy :: Allow ( list
777+ MgImportExportPolicy4 :: Allow ( list
778+ . clone ( )
759779 . into_iter ( )
760- . map ( |x|
780+ . filter_map ( |x|
761781 match x. prefix {
762- IpNetwork :: V4 ( p) => MgPrefix :: V4 (
782+ IpNetwork :: V4 ( p) => Some (
763783 Prefix4 {
764784 length : p. prefix ( ) ,
765785 value : p. ip ( ) ,
766786 }
767787 ) ,
768- IpNetwork :: V6 ( p) => MgPrefix :: V6 (
788+ IpNetwork :: V6 ( _) => None ,
789+ }
790+ )
791+ . collect ( )
792+ )
793+ }
794+ None => MgImportExportPolicy4 :: NoFiltering ,
795+ } ;
796+
797+ let export_policy6 = match & allow_export {
798+ Some ( list) => {
799+ MgImportExportPolicy6 :: Allow ( list
800+ . clone ( )
801+ . into_iter ( )
802+ . filter_map ( |x|
803+ match x. prefix {
804+ IpNetwork :: V6 ( p) => Some (
769805 Prefix6 {
770806 length : p. prefix ( ) ,
771807 value : p. ip ( ) ,
772808 }
773- )
809+ ) ,
810+ IpNetwork :: V4 ( _) => None ,
774811 }
775812 )
776813 . collect ( )
777814 )
778815 }
779- None => MgImportExportPolicy :: NoFiltering ,
816+ None => MgImportExportPolicy6 :: NoFiltering ,
780817 } ;
781818
782819 // now that the peer passes the above validations, add it to the list for configuration
@@ -797,9 +834,24 @@ impl BackgroundTask for SwitchPortSettingsManager {
797834 local_pref : peer. local_pref . as_ref ( ) . map ( |x| x. 0 ) ,
798835 enforce_first_as : peer. enforce_first_as ,
799836 communities : communities. into_iter ( ) . map ( |c| c. community . 0 ) . collect ( ) ,
800- allow_export : export_policy,
801- allow_import : import_policy,
837+ ipv4_unicast : Some ( Ipv4UnicastConfig {
838+ nexthop : None ,
839+ import_policy : import_policy4,
840+ export_policy : export_policy4,
841+ } ) ,
842+ ipv6_unicast : Some ( Ipv6UnicastConfig {
843+ nexthop : None ,
844+ import_policy : import_policy6,
845+ export_policy : export_policy6,
846+ } ) ,
802847 vlan_id : peer. vlan_id . map ( |x| x. 0 ) ,
848+ //TODO plumb these out to the external API
849+ connect_retry_jitter : Some ( JitterRange {
850+ max : 1.0 ,
851+ min : 0.75 ,
852+ } ) ,
853+ deterministic_collision_resolution : false ,
854+ idle_hold_jitter : None ,
803855 } ;
804856
805857 // update the stored vec if it exists, create a new on if it doesn't exist
@@ -874,7 +926,7 @@ impl BackgroundTask for SwitchPortSettingsManager {
874926 "switch_location" => ?location,
875927 "config" => ?config,
876928 ) ;
877- if let Err ( e) = client. bgp_apply ( config) . await {
929+ if let Err ( e) = client. bgp_apply_v2 ( config) . await {
878930 error ! ( log, "error while applying bgp configuration" ; "error" => ?e) ;
879931 }
880932 }
0 commit comments