@@ -524,7 +524,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
524524 IpNet :: V6 ( _) => None ,
525525 } )
526526 . collect ( ) ;
527- self . db . create_origin4 ( & prefix4) ?;
527+ self . db . create_origin4 ( self . config . asn , & prefix4) ?;
528528
529529 // Skip network propagation if router is shutdown
530530 if !self . shutdown . load ( Ordering :: Acquire ) {
@@ -534,7 +534,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
534534 }
535535
536536 pub fn set_origin4 ( & self , prefixes : Vec < IpNet > ) -> Result < ( ) , Error > {
537- let origin4 = self . db . get_origin4 ( ) ?;
537+ let origin4 = self . db . get_origin4 ( self . config . asn ) ?;
538538 let current: BTreeSet < & Ipv4Net > = origin4. iter ( ) . collect ( ) ;
539539
540540 let prefix4: Vec < Ipv4Net > = prefixes
@@ -554,7 +554,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
554554 let to_announce: Vec < Ipv4Net > =
555555 new. difference ( & current) . map ( |x| * * x) . collect ( ) ;
556556
557- self . db . set_origin4 ( & prefix4) ?;
557+ self . db . set_origin4 ( self . config . asn , & prefix4) ?;
558558
559559 // Skip network propagation if router is shutdown
560560 if !self . shutdown . load ( Ordering :: Acquire ) {
@@ -565,13 +565,13 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
565565 }
566566
567567 pub fn clear_origin4 ( & self ) -> Result < ( ) , Error > {
568- let current = self . db . get_origin4 ( ) ?;
568+ let current = self . db . get_origin4 ( self . config . asn ) ?;
569569
570570 // Skip network propagation if router is shutdown
571571 if !self . shutdown . load ( Ordering :: Acquire ) {
572572 self . withdraw_origin4 ( current) ;
573573 }
574- self . db . clear_origin4 ( ) ?;
574+ self . db . clear_origin4 ( self . config . asn ) ?;
575575 Ok ( ( ) )
576576 }
577577
@@ -628,7 +628,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
628628 IpNet :: V4 ( _) => None ,
629629 } )
630630 . collect ( ) ;
631- self . db . create_origin6 ( & prefix6) ?;
631+ self . db . create_origin6 ( self . config . asn , & prefix6) ?;
632632
633633 // Skip network propagation if router is shutdown
634634 if !self . shutdown . load ( Ordering :: Acquire ) {
@@ -638,7 +638,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
638638 }
639639
640640 pub fn set_origin6 ( & self , prefixes : Vec < IpNet > ) -> Result < ( ) , Error > {
641- let origin6 = self . db . get_origin6 ( ) ?;
641+ let origin6 = self . db . get_origin6 ( self . config . asn ) ?;
642642 let current: BTreeSet < & Ipv6Net > = origin6. iter ( ) . collect ( ) ;
643643
644644 let prefix6: Vec < Ipv6Net > = prefixes
@@ -658,7 +658,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
658658 let to_announce: Vec < Ipv6Net > =
659659 new. difference ( & current) . map ( |x| * * x) . collect ( ) ;
660660
661- self . db . set_origin6 ( & prefix6) ?;
661+ self . db . set_origin6 ( self . config . asn , & prefix6) ?;
662662
663663 // Skip network propagation if router is shutdown
664664 if !self . shutdown . load ( Ordering :: Acquire ) {
@@ -669,16 +669,26 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
669669 }
670670
671671 pub fn clear_origin6 ( & self ) -> Result < ( ) , Error > {
672- let current = self . db . get_origin6 ( ) ?;
672+ let current = self . db . get_origin6 ( self . config . asn ) ?;
673673
674674 // Skip network propagation if router is shutdown
675675 if !self . shutdown . load ( Ordering :: Acquire ) {
676676 self . withdraw_origin6 ( current) ;
677677 }
678- self . db . clear_origin6 ( ) ?;
678+ self . db . clear_origin6 ( self . config . asn ) ?;
679679 Ok ( ( ) )
680680 }
681681
682+ /// Prefixes this router is currently originating into IPv4 unicast.
683+ pub fn originated4 ( & self ) -> Result < Vec < Ipv4Net > , rdb:: error:: Error > {
684+ self . db . get_origin4 ( self . config . asn )
685+ }
686+
687+ /// Prefixes this router is currently originating into IPv6 unicast.
688+ pub fn originated6 ( & self ) -> Result < Vec < Ipv6Net > , rdb:: error:: Error > {
689+ self . db . get_origin6 ( self . config . asn )
690+ }
691+
682692 fn announce_origin6 ( & self , prefixes : Vec < Ipv6Net > ) {
683693 if prefixes. is_empty ( ) {
684694 return ;
@@ -788,7 +798,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
788798 }
789799
790800 fn announce_all ( & self ) -> Result < ( ) , Error > {
791- let originated4 = self . db . get_origin4 ( ) ?;
801+ let originated4 = self . db . get_origin4 ( self . config . asn ) ?;
792802
793803 if !originated4. is_empty ( ) {
794804 slog:: debug!(
@@ -802,7 +812,7 @@ impl<Cnx: BgpConnection + 'static> Router<Cnx> {
802812 }
803813
804814 // Also announce IPv6 originated routes
805- let originated6 = self . db . get_origin6 ( ) ?;
815+ let originated6 = self . db . get_origin6 ( self . config . asn ) ?;
806816
807817 if !originated6. is_empty ( ) {
808818 slog:: debug!(
0 commit comments