@@ -491,7 +491,7 @@ impl BackgroundTask for SwitchPortSettingsManager {
491
491
// build a list of desired settings for each switch
492
492
let mut desired_bgp_configs: HashMap <
493
493
SwitchLocation ,
494
- Vec < ApplyRequest > ,
494
+ ApplyRequest ,
495
495
> = HashMap :: new ( ) ;
496
496
497
497
// we currently only support one bgp config per switch
@@ -785,48 +785,47 @@ impl BackgroundTask for SwitchPortSettingsManager {
785
785
} ,
786
786
} ;
787
787
788
- let request = ApplyRequest {
789
- asn : * request_bgp_config. asn ,
790
- peers,
791
- originate : request_prefixes. clone ( ) ,
792
- checker : request_bgp_config. checker . as_ref ( ) . map ( |code| CheckerSource {
793
- asn : * request_bgp_config. asn ,
794
- code : code. clone ( ) ,
795
- } ) ,
796
- shaper : request_bgp_config. shaper . as_ref ( ) . map ( |code| ShaperSource {
797
- asn : * request_bgp_config. asn ,
798
- code : code. clone ( ) ,
799
- } ) ,
800
- } ;
801
-
802
788
match desired_bgp_configs. entry ( * location) {
803
789
Entry :: Occupied ( mut occupied_entry) => {
804
- occupied_entry. get_mut ( ) . push ( request) ;
790
+ let config = occupied_entry. get_mut ( ) ;
791
+ // peers are the only per-port part of the config.
792
+ config. peers . extend ( peers) ;
805
793
}
806
794
Entry :: Vacant ( vacant_entry) => {
807
- vacant_entry. insert ( vec ! [ request] ) ;
795
+ vacant_entry. insert (
796
+ ApplyRequest {
797
+ asn : * request_bgp_config. asn ,
798
+ peers,
799
+ originate : request_prefixes. clone ( ) ,
800
+ checker : request_bgp_config. checker . as_ref ( ) . map ( |code| CheckerSource {
801
+ asn : * request_bgp_config. asn ,
802
+ code : code. clone ( ) ,
803
+ } ) ,
804
+ shaper : request_bgp_config. shaper . as_ref ( ) . map ( |code| ShaperSource {
805
+ asn : * request_bgp_config. asn ,
806
+ code : code. clone ( ) ,
807
+ } ) ,
808
+ } ) ;
808
809
}
809
810
}
810
811
}
811
812
812
- for ( location, configs ) in & desired_bgp_configs {
813
+ for ( location, config ) in & desired_bgp_configs {
813
814
let client = match mgd_clients. get ( location) {
814
815
Some ( client) => client,
815
816
None => {
816
817
error ! ( log, "no mgd client found for switch" ; "switch_location" => ?location) ;
817
818
continue ;
818
819
} ,
819
820
} ;
820
- for config in configs {
821
- info ! (
822
- & log,
823
- "applying bgp config" ;
824
- "switch_location" => ?location,
825
- "config" => ?config,
826
- ) ;
827
- if let Err ( e) = client. bgp_apply ( config) . await {
828
- error ! ( log, "error while applying bgp configuration" ; "error" => ?e) ;
829
- }
821
+ info ! (
822
+ & log,
823
+ "applying bgp config" ;
824
+ "switch_location" => ?location,
825
+ "config" => ?config,
826
+ ) ;
827
+ if let Err ( e) = client. bgp_apply ( config) . await {
828
+ error ! ( log, "error while applying bgp configuration" ; "error" => ?e) ;
830
829
}
831
830
}
832
831
0 commit comments