diff options
-rw-r--r-- | internal/pkg/table/path.go | 34 | ||||
-rw-r--r-- | pkg/server/peer.go | 4 | ||||
-rw-r--r-- | pkg/server/server.go | 12 |
3 files changed, 47 insertions, 3 deletions
diff --git a/internal/pkg/table/path.go b/internal/pkg/table/path.go index 94925a9f..da81fecc 100644 --- a/internal/pkg/table/path.go +++ b/internal/pkg/table/path.go @@ -1076,11 +1076,21 @@ func (v *Vrf) ToGlobalPath(path *Path) error { pathIdentifier := path.GetNlri().PathIdentifier() path.OriginInfo().nlri = bgp.NewLabeledVPNIPAddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(v.MplsLabel), v.Rd) path.GetNlri().SetPathIdentifier(pathIdentifier) + case bgp.RF_FS_IPv4_UC: + n := nlri.(*bgp.FlowSpecIPv4Unicast) + pathIdentifier := path.GetNlri().PathIdentifier() + path.OriginInfo().nlri = bgp.NewFlowSpecIPv4VPN(v.Rd, n.FlowSpecNLRI.Value) + path.GetNlri().SetPathIdentifier(pathIdentifier) case bgp.RF_IPv6_UC: n := nlri.(*bgp.IPv6AddrPrefix) pathIdentifier := path.GetNlri().PathIdentifier() path.OriginInfo().nlri = bgp.NewLabeledVPNIPv6AddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(v.MplsLabel), v.Rd) path.GetNlri().SetPathIdentifier(pathIdentifier) + case bgp.RF_FS_IPv6_UC: + n := nlri.(*bgp.FlowSpecIPv6Unicast) + pathIdentifier := path.GetNlri().PathIdentifier() + path.OriginInfo().nlri = bgp.NewFlowSpecIPv6VPN(v.Rd, n.FlowSpecNLRI.Value) + path.GetNlri().SetPathIdentifier(pathIdentifier) case bgp.RF_EVPN: n := nlri.(*bgp.EVPNNLRI) switch n.RouteType { @@ -1157,17 +1167,39 @@ func (p *Path) ToLocal() *Path { ones, _ := c.Mask.Size() nlri = bgp.NewIPAddrPrefix(uint8(ones), c.IP.String()) nlri.SetPathLocalIdentifier(pathId) + case bgp.RF_FS_IPv4_VPN: + n := nlri.(*bgp.FlowSpecIPv4VPN) + nlri = bgp.NewFlowSpecIPv4Unicast(n.FlowSpecNLRI.Value) + nlri.SetPathLocalIdentifier(pathId) case bgp.RF_IPv6_VPN: n := nlri.(*bgp.LabeledVPNIPv6AddrPrefix) _, c, _ := net.ParseCIDR(n.IPPrefix()) ones, _ := c.Mask.Size() nlri = bgp.NewIPv6AddrPrefix(uint8(ones), c.IP.String()) nlri.SetPathLocalIdentifier(pathId) + case bgp.RF_FS_IPv6_VPN: + n := nlri.(*bgp.FlowSpecIPv6VPN) + nlri = bgp.NewFlowSpecIPv6Unicast(n.FlowSpecNLRI.Value) + nlri.SetPathLocalIdentifier(pathId) default: return p } path := NewPath(p.OriginInfo().source, nlri, p.IsWithdraw, p.GetPathAttrs(), p.GetTimestamp(), false) - path.delPathAttr(bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES) + switch f { + case bgp.RF_IPv4_VPN, bgp.RF_IPv6_VPN: + path.delPathAttr(bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES) + case bgp.RF_FS_IPv4_VPN, bgp.RF_FS_IPv6_VPN: + extcomms := path.GetExtCommunities() + newExtComms := make([]bgp.ExtendedCommunityInterface, 0, len(extcomms)) + for _, extComm := range extcomms { + _, subType := extComm.GetTypes() + if subType == bgp.EC_SUBTYPE_ROUTE_TARGET { + continue + } + newExtComms = append(newExtComms, extComm) + } + path.SetExtCommunities(newExtComms, true) + } if f == bgp.RF_IPv4_VPN { nh := path.GetNexthop() diff --git a/pkg/server/peer.go b/pkg/server/peer.go index 910c7472..f7b89371 100644 --- a/pkg/server/peer.go +++ b/pkg/server/peer.go @@ -228,6 +228,10 @@ func (peer *peer) toGlobalFamilies(families []bgp.RouteFamily) []bgp.RouteFamily fs = append(fs, bgp.RF_IPv4_VPN) case bgp.RF_IPv6_UC: fs = append(fs, bgp.RF_IPv6_VPN) + case bgp.RF_FS_IPv4_UC: + fs = append(fs, bgp.RF_FS_IPv4_VPN) + case bgp.RF_FS_IPv6_UC: + fs = append(fs, bgp.RF_FS_IPv6_VPN) default: log.WithFields(log.Fields{ "Topic": "Peer", diff --git a/pkg/server/server.go b/pkg/server/server.go index 647843da..82efeb6a 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -610,7 +610,7 @@ func (s *BgpServer) prePolicyFilterpath(peer *peer, path, old *table.Path) (*tab peerVrf := peer.fsm.pConf.Config.Vrf peer.fsm.lock.RUnlock() if path != nil && peerVrf != "" { - if f := path.GetRouteFamily(); f != bgp.RF_IPv4_VPN && f != bgp.RF_IPv6_VPN { + if f := path.GetRouteFamily(); f != bgp.RF_IPv4_VPN && f != bgp.RF_IPv6_VPN && f != bgp.RF_FS_IPv4_VPN && f != bgp.RF_FS_IPv6_VPN { return nil, nil, true } vrf := peer.localRib.Vrfs[peerVrf] @@ -1242,6 +1242,10 @@ func (s *BgpServer) propagateUpdateToNeighbors(source *peer, newPath *table.Path return bgp.RF_IPv4_UC case bgp.RF_IPv6_VPN: return bgp.RF_IPv6_UC + case bgp.RF_FS_IPv4_VPN: + return bgp.RF_FS_IPv4_UC + case bgp.RF_FS_IPv6_VPN: + return bgp.RF_FS_IPv6_UC } } return family @@ -2426,6 +2430,10 @@ func (s *BgpServer) getVrfRib(name string, family bgp.RouteFamily, prefixes []*t af = bgp.RF_IPv4_VPN case bgp.RF_IPv6_UC: af = bgp.RF_IPv6_VPN + case bgp.RF_FS_IPv4_UC: + af = bgp.RF_FS_IPv4_VPN + case bgp.RF_FS_IPv6_UC: + af = bgp.RF_FS_IPv6_VPN case bgp.RF_EVPN: af = bgp.RF_EVPN } @@ -2763,7 +2771,7 @@ func (s *BgpServer) addNeighbor(c *config.Neighbor) error { } families, _ := config.AfiSafis(c.AfiSafis).ToRfList() for _, f := range families { - if f != bgp.RF_IPv4_UC && f != bgp.RF_IPv6_UC { + if f != bgp.RF_IPv4_UC && f != bgp.RF_IPv6_UC && f != bgp.RF_FS_IPv4_UC && f != bgp.RF_FS_IPv6_UC { return fmt.Errorf("%s is not supported for VRF enslaved neighbor", f) } } |