summaryrefslogtreecommitdiffhomepage
path: root/server/mrt.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-05-11 12:48:42 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2018-05-11 12:48:42 +0900
commit04f36f09a17c45f09f103dc167caf0fbdb721578 (patch)
treed58829e3ad733f4f16cb5427351adc2a6737e8b7 /server/mrt.go
parent2b0f16dcc6a47bd8d6518746038b3d65ff55e8c4 (diff)
mrt: Enable to dump locally generated routes
For reloading locally generated routes by using MRT dump file, this patch enables to include locally generated routes into TABLE_DUMPv2 records. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/mrt.go')
-rw-r--r--server/mrt.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/server/mrt.go b/server/mrt.go
index 613f0b07..a6becd08 100644
--- a/server/mrt.go
+++ b/server/mrt.go
@@ -21,11 +21,12 @@ import (
"os"
"time"
+ log "github.com/sirupsen/logrus"
+
"github.com/osrg/gobgp/config"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/packet/mrt"
"github.com/osrg/gobgp/table"
- log "github.com/sirupsen/logrus"
)
const (
@@ -114,12 +115,16 @@ func (m *mrtWriter) loop() error {
}
case *WatchEventTable:
t := uint32(time.Now().Unix())
- peers := make([]*mrt.Peer, 0, len(e.Neighbor))
+
+ peers := make([]*mrt.Peer, 1, len(e.Neighbor)+1)
+ // Adding dummy Peer record for locally generated routes
+ peers[0] = mrt.NewPeer("0.0.0.0", "0.0.0.0", 0, true)
neighborMap := make(map[string]*config.Neighbor)
for _, pconf := range e.Neighbor {
peers = append(peers, mrt.NewPeer(pconf.State.RemoteRouterId, pconf.State.NeighborAddress, pconf.Config.PeerAs, true))
neighborMap[pconf.State.NeighborAddress] = pconf
}
+
if bm, err := mrt.NewMRTMessage(t, mrt.TABLE_DUMPv2, mrt.PEER_INDEX_TABLE, mrt.NewPeerIndexTable(e.RouterId, "", peers)); err != nil {
log.WithFields(log.Fields{
"Topic": "mrt",
@@ -177,11 +182,10 @@ func (m *mrtWriter) loop() error {
entries := make([]*mrt.RibEntry, 0, len(pathList))
entriesAddPath := make([]*mrt.RibEntry, 0, len(pathList))
for _, path := range pathList {
- if path.IsLocal() {
- continue
- }
isAddPath := false
- if neighbor, ok := neighborMap[path.GetSource().Address.String()]; ok {
+ if path.IsLocal() {
+ isAddPath = true
+ } else if neighbor, ok := neighborMap[path.GetSource().Address.String()]; ok {
isAddPath = neighbor.IsAddPathReceiveEnabled(path.GetRouteFamily())
}
if !isAddPath {