osrg / gobgp

BGP implemented in the Go Programming Language
https://osrg.github.io/gobgp/
Apache License 2.0
3.64k stars 694 forks source link

GetGwAddress() returns an empty string #1796

Closed greenpau closed 6 years ago

greenpau commented 6 years ago

Added 2 routes, BGP EVPN Type 2 and 5:

gobgp global rib -a evpn add macadv 02:34:aa:bb:cc:dd 10.10.10.20 \
        etag 0 label 6500120 rd 10.10.10.1:1020 rt 65001:1020 encap vxlan \
        nexthop 172.16.10.20 origin igp router-mac 04:56:aa:bb:cc:dd
gobgp global rib -a evpn add prefix 10.10.10.20/32 \
        nexthop 172.16.10.20 origin igp esi 0 etag 0 rd rd 10.10.10.1:1020 \
        rt 65001:1020 gw 172.16.10.20 label 6500120 encap vxlan \
        router-mac 04:56:aa:bb:cc:dd

The routes get installed and "Next Hop" is set:

$ gobgp global rib -a evpn
   Network                                                                          Labels     Next Hop             AS_PATH              Age        Attrs
*> [type:macadv][rd:10.10.10.1:1020][etag:0][mac:02:34:aa:bb:cc:dd][ip:10.10.10.20] [6500120]  172.16.10.20                              00:02:08   [{Origin: i} {Extcomms: [65001:1020], [VXLAN], [router's mac: 04:56:aa:bb:cc:dd]} [ESI: single-homed]]
*> [type:Prefix][rd:10.10.10.1:1020][etag:0][prefix:10.10.10.20/32]                 [6500120]  172.16.10.20                              00:02:07   [{Origin: i} {Extcomms: [65001:1020], [VXLAN], [router's mac: 04:56:aa:bb:cc:dd]} [ESI: single-homed]]
$

However, when reading the path, GetGwAddress() returns an empty string, instead of "172.16.10.20".

(*gobgpapi.EVPNIPPrefixRoute)(0xc42016fea0)(rd:<type_url:"type.googleapis.com/gobgpapi.RouteDistinguisherIPAddress" value:"\n\n10.10.10.1\020\374\007" > esi:<value:"\000\000\000\000\000\000\000\000\000" > ip_prefix:"10.10.10.20" ip_prefix_len:32 label:6500120 )
(*any.Any)(0xc420171fb0)(type_url:"type.googleapis.com/gobgpapi.RouteDistinguisherIPAddress" value:"\n\n10.10.10.1\020\374\007" )
(*gobgpapi.EthernetSegmentIdentifier)(0xc420172ea0)(value:"\000\000\000\000\000\000\000\000\000" )
(uint32) 0
(string) (len=11) "10.10.10.20"
(string) ""
(uint32) 6500120

The above gets generated by the folloing:

                case *gobgpapi.EVPNIPPrefixRoute:
                    spew.Dump(nlri)
                    spew.Dump(nlri.GetRd())
                    spew.Dump(nlri.GetEsi())
                    spew.Dump(nlri.GetEthernetTag())
                    spew.Dump(nlri.GetIpPrefix())
                    spew.Dump(nlri.GetGwAddress())
                    spew.Dump(nlri.GetLabel())

The above functions are from here:

https://github.com/osrg/gobgp/blob/master/api/attribute.pb.go#L567-L633

greenpau commented 6 years ago

No issue here, closing. Gateway is not being set (it is /32) in the above command, hence it is empty. The "NEXT_HOP" is being carried in the extended community attribute.