summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-11-06 06:58:37 +0000
committerWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-11-06 07:44:04 +0000
commit4534be26098f7a90e8bc515d697c259762bdaeb7 (patch)
treeb6d51df1a53b946fa5c319c838c227ac105e2f1f /server
parente4cd6e08f66c80a17230b709ede67f40d62969ce (diff)
server: fix bug of disable/enable/softreset behavior for vrfed neighbor
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/peer.go25
-rw-r--r--server/server.go16
2 files changed, 34 insertions, 7 deletions
diff --git a/server/peer.go b/server/peer.go
index ffbce86b..4c76248c 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -100,6 +100,29 @@ func (peer *Peer) configuredRFlist() []bgp.RouteFamily {
return rfs
}
+func (peer *Peer) toGlobalFamilies(families []bgp.RouteFamily) []bgp.RouteFamily {
+ if peer.fsm.pConf.Config.Vrf != "" {
+ fs := make([]bgp.RouteFamily, 0, len(families))
+ for _, f := range families {
+ switch f {
+ case bgp.RF_IPv4_UC:
+ fs = append(fs, bgp.RF_IPv4_VPN)
+ case bgp.RF_IPv6_UC:
+ fs = append(fs, bgp.RF_IPv6_VPN)
+ default:
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": peer.ID(),
+ "Family": f,
+ "VRF": peer.fsm.pConf.Config.Vrf,
+ }).Warn("invalid family configured for vrfed neighbor")
+ }
+ }
+ families = fs
+ }
+ return families
+}
+
func classifyFamilies(all, part []bgp.RouteFamily) ([]bgp.RouteFamily, []bgp.RouteFamily) {
a := []bgp.RouteFamily{}
b := []bgp.RouteFamily{}
@@ -285,7 +308,7 @@ func (peer *Peer) filterpath(path *table.Path, withdrawals []*table.Path) *table
func (peer *Peer) getBestFromLocal(rfList []bgp.RouteFamily) ([]*table.Path, []*table.Path) {
pathList := []*table.Path{}
filtered := []*table.Path{}
- for _, path := range peer.localRib.GetBestPathList(peer.TableID(), rfList) {
+ for _, path := range peer.localRib.GetBestPathList(peer.TableID(), peer.toGlobalFamilies(rfList)) {
if p := peer.filterpath(path, nil); p != nil {
pathList = append(pathList, p)
} else {
diff --git a/server/server.go b/server/server.go
index c86b2af2..263bc00c 100644
--- a/server/server.go
+++ b/server/server.go
@@ -427,6 +427,9 @@ func (server *BgpServer) notifyBestWatcher(best map[string][]*table.Path, multip
}
func (server *BgpServer) dropPeerAllRoutes(peer *Peer, families []bgp.RouteFamily) {
+
+ families = peer.toGlobalFamilies(families)
+
ids := make([]string, 0, len(server.neighborMap))
if peer.isRouteServerClient() {
for _, targetPeer := range server.neighborMap {
@@ -512,6 +515,13 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []*
var alteredPathList, withdrawn []*table.Path
var best map[string][]*table.Path
+ if peer != nil && peer.fsm.pConf.Config.Vrf != "" {
+ vrf := server.globalRib.Vrfs[peer.fsm.pConf.Config.Vrf]
+ for idx, path := range pathList {
+ pathList[idx] = path.ToGlobal(vrf)
+ }
+ }
+
if peer != nil && peer.isRouteServerClient() {
for _, path := range pathList {
path.Filter(peer.ID(), table.POLICY_DIRECTION_IMPORT)
@@ -816,12 +826,6 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
}
if len(pathList) > 0 {
- if v := peer.fsm.pConf.Config.Vrf; v != "" {
- vrf := server.globalRib.Vrfs[v]
- for idx, path := range pathList {
- pathList[idx] = path.ToGlobal(vrf)
- }
- }
altered := server.propagateUpdate(peer, pathList)
if server.isWatched(WATCH_EVENT_TYPE_POST_UPDATE) {
_, y := peer.fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]