summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-08 15:13:21 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-08 15:29:04 +0900
commit5ae3e111f7d16cdd8c07d2d30fbf21fd50b820bd (patch)
treed45997c34a5e9be644d1b17e9177359a3104fd7f /server/server.go
parent54c8d7e19c8c3ce2198a79b10dc04255e4d5e285 (diff)
server: add mrt bgp4mp support
You can enable the feature like: [Global] [Global.GlobalConfig] As = 64512 RouterId = "10.0.255.254" [Global.Mrt] FileName = "update.dump" Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index 2cb0d29e..c1ba5206 100644
--- a/server/server.go
+++ b/server/server.go
@@ -69,6 +69,20 @@ func (m *broadcastGrpcMsg) send() {
}
}
+type broadcastBGPMsg struct {
+ message *bgp.BGPMessage
+ peerAS uint32
+ localAS uint32
+ peerAddress net.IP
+ localAddress net.IP
+ fourBytesAs bool
+ ch chan *broadcastBGPMsg
+}
+
+func (m *broadcastBGPMsg) send() {
+ m.ch <- m
+}
+
type BgpServer struct {
bgpConfig config.Bgp
globalTypeCh chan config.Global
@@ -76,6 +90,7 @@ type BgpServer struct {
deletedPeerCh chan config.Neighbor
updatedPeerCh chan config.Neighbor
rpkiConfigCh chan config.RpkiServers
+ dumper *dumper
GrpcReqCh chan *GrpcRequest
listenPort int
@@ -138,6 +153,15 @@ func (server *BgpServer) Serve() {
g := <-server.globalTypeCh
server.bgpConfig.Global = g
+ if g.Mrt.FileName != "" {
+ d, err := newDumper(g.Mrt.FileName)
+ if err != nil {
+ log.Warn(err)
+ } else {
+ server.dumper = d
+ }
+ }
+
senderCh := make(chan *SenderMsg, 1<<16)
go func(ch chan *SenderMsg) {
for {
@@ -772,6 +796,19 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan *
server.roaClient.validate(pathList)
}
}
+ if m.Header.Type == bgp.BGP_MSG_UPDATE && server.dumper != nil {
+ _, y := peer.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]
+ bm := &broadcastBGPMsg{
+ message: m,
+ peerAS: peer.peerInfo.AS,
+ localAS: peer.peerInfo.LocalAS,
+ peerAddress: peer.peerInfo.Address,
+ localAddress: peer.fsm.LocalAddr(),
+ fourBytesAs: y,
+ ch: server.dumper.sendCh(),
+ }
+ server.broadcastMsgs = append(server.broadcastMsgs, bm)
+ }
msgs = append(msgs, server.propagateUpdate(peer, pathList)...)
default:
log.WithFields(log.Fields{