summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-04-13 14:52:18 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2018-04-18 09:18:13 +0900
commitb2e07101e9d579e7ccb98e68108c9752e70a4125 (patch)
tree7a17195db66d21d5054ff67445f2a07d7ec95300
parent34728dece3b9983ef9441b902c91fec5cb617f88 (diff)
server: Fix outgoing rtfilter
Currently, the result of Route Target Constraint filter is unexpectedly ignored when Route Reflector reflecting the VPN routes because "ignore" flag can be overwritten without evaluated. This patch fixes to return "nil" before "ignore" flag overwritten and enable to filter outgoing VPN routes based on RTC. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--server/server.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/server/server.go b/server/server.go
index cd739594..abd32dfa 100644
--- a/server/server.go
+++ b/server/server.go
@@ -363,11 +363,10 @@ func filterpath(peer *Peer, path, old *table.Path) *table.Path {
if _, y := peer.fsm.rfMap[bgp.RF_RTC_UC]; y && path.GetRouteFamily() != bgp.RF_RTC_UC {
ignore = true
for _, ext := range path.GetExtCommunities() {
- for _, path := range peer.adjRibIn.PathList([]bgp.RouteFamily{bgp.RF_RTC_UC}, true) {
- rt := path.GetNlri().(*bgp.RouteTargetMembershipNLRI).RouteTarget
- if rt == nil {
- ignore = false
- } else if ext.String() == rt.String() {
+ for _, p := range peer.adjRibIn.PathList([]bgp.RouteFamily{bgp.RF_RTC_UC}, true) {
+ rt := p.GetNlri().(*bgp.RouteTargetMembershipNLRI).RouteTarget
+ // Note: nil RT means the default route target
+ if rt == nil || ext.String() == rt.String() {
ignore = false
break
}
@@ -376,6 +375,14 @@ func filterpath(peer *Peer, path, old *table.Path) *table.Path {
break
}
}
+ if ignore {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": peer.ID(),
+ "Data": path,
+ }).Debug("Filtered by Route Target Constraint, ignore")
+ return nil
+ }
}
if !path.IsLocal() {
@@ -404,12 +411,12 @@ func filterpath(peer *Peer, path, old *table.Path) *table.Path {
// RFC4456 8. Avoiding Routing Information Loops
// If the local CLUSTER_ID is found in the CLUSTER_LIST,
// the advertisement received SHOULD be ignored.
- for _, clusterId := range path.GetClusterList() {
- if clusterId.Equal(peer.fsm.peerInfo.RouteReflectorClusterID) {
+ for _, clusterID := range path.GetClusterList() {
+ if clusterID.Equal(peer.fsm.peerInfo.RouteReflectorClusterID) {
log.WithFields(log.Fields{
"Topic": "Peer",
"Key": peer.ID(),
- "ClusterID": clusterId,
+ "ClusterID": clusterID,
"Data": path,
}).Debug("cluster list path attribute has local cluster id, ignore")
return nil