summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/path.go
diff options
context:
space:
mode:
authorMichael Lechner <lechner@netography.com>2019-06-08 20:33:48 -0400
committerMichael Lechner <lechner@netography.com>2019-06-08 20:33:48 -0400
commitc5c10006c01ea72b135487861f0618171e4bddfd (patch)
tree910b48a1265be9561cb30dd272281e06a3773a9a /internal/pkg/table/path.go
parent9d47a21f32fa0d59730e5da123ef318f494560ce (diff)
Support ipv4-flowspec for VRF enslaved neighbor
Diffstat (limited to 'internal/pkg/table/path.go')
-rw-r--r--internal/pkg/table/path.go34
1 files changed, 33 insertions, 1 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()