@@ -498,43 +498,46 @@ func (nrc *NetworkRoutingController) advertisePodRoute() error {
498498 }
499499
500500 // Advertise IPv4 CIDRs
501- nodePrimaryIPv4IP := nrc .krNode .FindBestIPv4NodeAddress ()
502- if nrc .krNode .IsIPv4Capable () && nodePrimaryIPv4IP == nil {
503- return fmt .Errorf ("previous logic marked this node as IPv4 capable, but we couldn't find any " +
504- "available IPv4 node IPs, this shouldn't happen" )
505- }
506- for _ , cidr := range nrc .podIPv4CIDRs {
507- ip , cidrNet , err := net .ParseCIDR (cidr )
508- cidrLen , _ := cidrNet .Mask .Size ()
509- if err != nil || cidrLen < 0 || cidrLen > 32 {
510- return fmt .Errorf ("the pod CIDR IP given is not a proper mask: %d" , cidrLen )
511- }
512- klog .V (2 ).Infof ("Advertising route: '%s/%d via %s' to peers" ,
513- ip , cidrLen , nrc .krNode .GetPrimaryNodeIP ().String ())
514- nlri , _ := anypb .New (& gobgpapi.IPAddressPrefix {
515- PrefixLen : uint32 (cidrLen ),
516- Prefix : ip .String (),
517- })
518-
519- a1 , _ := anypb .New (& gobgpapi.OriginAttribute {
520- Origin : 0 ,
521- })
522- a2 , _ := anypb .New (& gobgpapi.NextHopAttribute {
523- NextHop : nodePrimaryIPv4IP .String (),
524- })
525- attrs := []* anypb.Any {a1 , a2 }
526-
527- response , err := nrc .bgpServer .AddPath (context .Background (), & gobgpapi.AddPathRequest {
528- Path : & gobgpapi.Path {
529- Family : & gobgpapi.Family {Afi : gobgpapi .Family_AFI_IP , Safi : gobgpapi .Family_SAFI_UNICAST },
530- Nlri : nlri ,
531- Pattrs : attrs ,
532- },
533- })
534- if err != nil {
535- return err
501+ if nrc .krNode .IsIPv4Capable () {
502+ nodePrimaryIPv4IP := nrc .krNode .FindBestIPv4NodeAddress ()
503+ if nodePrimaryIPv4IP == nil {
504+ return fmt .Errorf ("previous logic marked this node as IPv4 capable, but we couldn't find any " +
505+ "available IPv4 node IPs, this shouldn't happen" )
506+ }
507+
508+ for _ , cidr := range nrc .podIPv4CIDRs {
509+ ip , cidrNet , err := net .ParseCIDR (cidr )
510+ cidrLen , _ := cidrNet .Mask .Size ()
511+ if err != nil || cidrLen < 0 || cidrLen > 32 {
512+ return fmt .Errorf ("the pod CIDR IP given is not a proper mask: %d" , cidrLen )
513+ }
514+ klog .V (2 ).Infof ("Advertising route: '%s/%d via %s' to peers" ,
515+ ip , cidrLen , nrc .krNode .GetPrimaryNodeIP ().String ())
516+ nlri , _ := anypb .New (& gobgpapi.IPAddressPrefix {
517+ PrefixLen : uint32 (cidrLen ),
518+ Prefix : ip .String (),
519+ })
520+
521+ a1 , _ := anypb .New (& gobgpapi.OriginAttribute {
522+ Origin : 0 ,
523+ })
524+ a2 , _ := anypb .New (& gobgpapi.NextHopAttribute {
525+ NextHop : nodePrimaryIPv4IP .String (),
526+ })
527+ attrs := []* anypb.Any {a1 , a2 }
528+
529+ response , err := nrc .bgpServer .AddPath (context .Background (), & gobgpapi.AddPathRequest {
530+ Path : & gobgpapi.Path {
531+ Family : & gobgpapi.Family {Afi : gobgpapi .Family_AFI_IP , Safi : gobgpapi .Family_SAFI_UNICAST },
532+ Nlri : nlri ,
533+ Pattrs : attrs ,
534+ },
535+ })
536+ if err != nil {
537+ return err
538+ }
539+ klog .V (1 ).Infof ("Response from adding path: %s" , response )
536540 }
537- klog .V (1 ).Infof ("Response from adding path: %s" , response )
538541 }
539542
540543 // Advertise IPv6 CIDRs
0 commit comments