@@ -359,18 +359,43 @@ func (nrc *NetworkRoutingController) advertisePodRoute() error {
359359 cidrStr := strings .Split (cidr , "/" )
360360 subnet := cidrStr [0 ]
361361 cidrLen , _ := strconv .Atoi (cidrStr [1 ])
362- attrs := []bgp.PathAttributeInterface {
363- bgp .NewPathAttributeOrigin (0 ),
364- bgp .NewPathAttributeNextHop (nrc .nodeIP .String ()),
365- }
362+ if nrc .isIpv6 {
363+ prefixes := []bgp.AddrPrefixInterface {bgp .NewIPv6AddrPrefix (uint8 (cidrLen ), subnet )}
364+ attrs := []bgp.PathAttributeInterface {
365+ bgp .NewPathAttributeOrigin (bgp .BGP_ORIGIN_ATTR_TYPE_IGP ),
366+ // This requires some research.
367+ // For ipv6 what should be next-hop value? According to this https://www.noction.com/blog/bgp-next-hop
368+ // using the link-local address may be more appropriate.
369+ bgp .NewPathAttributeMpReachNLRI (nrc .nodeIP .String (), prefixes ),
370+ & bgp.PathAttributeNextHop {
371+ PathAttribute : bgp.PathAttribute {
372+ Flags : bgp .PathAttrFlags [bgp .BGP_ATTR_TYPE_NEXT_HOP ],
373+ Type : bgp .BGP_ATTR_TYPE_NEXT_HOP ,
374+ Length : 16 ,
375+ },
376+ Value : nrc .nodeIP ,
377+ },
378+ }
379+
380+ glog .V (2 ).Infof ("Advertising route: '%s/%s via %s' to peers using attribute: %+q" , subnet , strconv .Itoa (cidrLen ), nrc .nodeIP .String (), attrs )
381+
382+ if _ , err := nrc .bgpServer .AddPath ("" , []* table.Path {table .NewPath (nil , bgp .NewIPv6AddrPrefix (uint8 (cidrLen ),
383+ subnet ), false , attrs , time .Now (), false )}); err != nil {
384+ return fmt .Errorf (err .Error ())
385+ }
386+ } else {
387+ attrs := []bgp.PathAttributeInterface {
388+ bgp .NewPathAttributeOrigin (0 ),
389+ bgp .NewPathAttributeNextHop (nrc .nodeIP .String ()),
390+ }
366391
367- glog .V (2 ).Infof ("Advertising route: '%s/%s via %s' to peers" , subnet , strconv .Itoa (cidrLen ), nrc .nodeIP .String ())
392+ glog .V (2 ).Infof ("Advertising route: '%s/%s via %s' to peers" , subnet , strconv .Itoa (cidrLen ), nrc .nodeIP .String ())
368393
369- if _ , err := nrc .bgpServer .AddPath ("" , []* table.Path {table .NewPath (nil , bgp .NewIPAddrPrefix (uint8 (cidrLen ),
370- subnet ), false , attrs , time .Now (), false )}); err != nil {
371- return fmt .Errorf (err .Error ())
394+ if _ , err := nrc .bgpServer .AddPath ("" , []* table.Path {table .NewPath (nil , bgp .NewIPAddrPrefix (uint8 (cidrLen ),
395+ subnet ), false , attrs , time .Now (), false )}); err != nil {
396+ return fmt .Errorf (err .Error ())
397+ }
372398 }
373-
374399 return nil
375400}
376401
0 commit comments