summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--api/grpc_server.go2
-rw-r--r--server/server.go33
-rw-r--r--table/vrf.go25
3 files changed, 32 insertions, 28 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go
index 43960620..4f74a334 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -273,7 +273,7 @@ func (s *Server) GetRib(ctx context.Context, arg *GetRibRequest) (*GetRibRespons
return &GetRibResponse{Table: &Table{
Type: arg.Table.Type,
- Family: arg.Table.Family,
+ Family: uint32(tbl.GetRoutefamily()),
Destinations: dsts},
}, err
}
diff --git a/server/server.go b/server/server.go
index 1a42a447..befe1e53 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1037,37 +1037,19 @@ func (server *BgpServer) fixupApiPath(vrfId string, pathList []*table.Path) erro
path.SetSource(pi)
}
- extcomms := make([]bgp.ExtendedCommunityInterface, 0)
- nlri := path.GetNlri()
- rf := bgp.AfiSafiToRouteFamily(nlri.AFI(), nlri.SAFI())
-
if vrfId != "" {
label, err := server.globalRib.GetNextLabel(vrfId, path.GetNexthop().String(), path.IsWithdraw)
if err != nil {
return err
}
vrf := server.globalRib.Vrfs[vrfId]
- switch rf {
- case bgp.RF_IPv4_UC:
- n := nlri.(*bgp.IPAddrPrefix)
- nlri = bgp.NewLabeledVPNIPAddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(label), vrf.Rd)
- case bgp.RF_IPv6_UC:
- n := nlri.(*bgp.IPv6AddrPrefix)
- nlri = bgp.NewLabeledVPNIPv6AddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(label), vrf.Rd)
- case bgp.RF_EVPN:
- n := nlri.(*bgp.EVPNNLRI)
- switch n.RouteType {
- case bgp.EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT:
- n.RouteTypeData.(*bgp.EVPNMacIPAdvertisementRoute).RD = vrf.Rd
- case bgp.EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG:
- n.RouteTypeData.(*bgp.EVPNMulticastEthernetTagRoute).RD = vrf.Rd
- }
- default:
- return fmt.Errorf("unsupported route family for vrf: %s", rf)
+ if err := vrf.ToGlobalPath(path, label); err != nil {
+ return err
}
- extcomms = append(extcomms, vrf.ExportRt...)
}
- if rf == bgp.RF_EVPN {
+
+ if path.GetRouteFamily() == bgp.RF_EVPN {
+ nlri := path.GetNlri()
evpnNlri := nlri.(*bgp.EVPNNLRI)
if evpnNlri.RouteType == bgp.EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT {
macIpAdv := evpnNlri.RouteTypeData.(*bgp.EVPNMacIPAdvertisementRoute)
@@ -1075,14 +1057,11 @@ func (server *BgpServer) fixupApiPath(vrfId string, pathList []*table.Path) erro
mac := macIpAdv.MacAddress
paths := server.globalRib.GetBestPathList(table.GLOBAL_RIB_NAME, []bgp.RouteFamily{bgp.RF_EVPN})
if m := getMacMobilityExtendedCommunity(etag, mac, paths); m != nil {
- extcomms = append(extcomms, m)
+ path.SetExtCommunities([]bgp.ExtendedCommunityInterface{m}, false)
}
}
}
- if len(extcomms) > 0 {
- path.SetExtCommunities(extcomms, false)
- }
}
return nil
}
diff --git a/table/vrf.go b/table/vrf.go
index c8fc2a16..18a5af87 100644
--- a/table/vrf.go
+++ b/table/vrf.go
@@ -16,6 +16,7 @@
package table
import (
+ "fmt"
"github.com/osrg/gobgp/packet/bgp"
)
@@ -27,6 +28,30 @@ type Vrf struct {
LabelMap map[string]uint32
}
+func (v *Vrf) ToGlobalPath(path *Path, label uint32) error {
+ nlri := path.GetNlri()
+ switch rf := path.GetRouteFamily(); rf {
+ case bgp.RF_IPv4_UC:
+ n := nlri.(*bgp.IPAddrPrefix)
+ path.OriginInfo().nlri = bgp.NewLabeledVPNIPAddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(label), v.Rd)
+ case bgp.RF_IPv6_UC:
+ n := nlri.(*bgp.IPv6AddrPrefix)
+ path.OriginInfo().nlri = bgp.NewLabeledVPNIPv6AddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(label), v.Rd)
+ case bgp.RF_EVPN:
+ n := nlri.(*bgp.EVPNNLRI)
+ switch n.RouteType {
+ case bgp.EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT:
+ n.RouteTypeData.(*bgp.EVPNMacIPAdvertisementRoute).RD = v.Rd
+ case bgp.EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG:
+ n.RouteTypeData.(*bgp.EVPNMulticastEthernetTagRoute).RD = v.Rd
+ }
+ default:
+ return fmt.Errorf("unsupported route family for vrf: %s", rf)
+ }
+ path.SetExtCommunities(v.ExportRt, false)
+ return nil
+}
+
func (v *Vrf) Clone() *Vrf {
f := func(rt []bgp.ExtendedCommunityInterface) []bgp.ExtendedCommunityInterface {
l := make([]bgp.ExtendedCommunityInterface, 0, len(rt))