summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-29 13:17:46 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-29 13:17:46 +0900
commit4f3f0468a1d32e3dc1a18d18601c4c9867e4f377 (patch)
tree733ef3e3f636c0f2415795bb94c8988a8a922491 /server/server.go
parent56bfc93a38d9646b488bbc105a0c14f8166cfc19 (diff)
mrt: inject properly uses AS number and RouterID
Currently, mrt inject wrongly use gobgpd's AS number and RouterID. Instead use these in the dump file. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/server/server.go b/server/server.go
index 64db3420..af85883b 100644
--- a/server/server.go
+++ b/server/server.go
@@ -858,7 +858,7 @@ func getMacMobilityExtendedCommunity(etag uint32, mac net.HardwareAddr, evpnPath
return nil
}
-func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *table.PeerInfo) []*table.Path {
+func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest) []*table.Path {
var nlri bgp.AddrPrefixInterface
result := &GrpcResponse{}
@@ -868,12 +868,24 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *ta
var rf bgp.RouteFamily
var path *api.Path
seen := make(map[bgp.BGPAttrType]bool)
+ var pi *table.PeerInfo
arg, ok := grpcReq.Data.(*api.ModPathArguments)
if !ok {
result.ResponseErr = fmt.Errorf("type assertion failed")
goto ERR
}
+ if arg.Asn != 0 {
+ pi = &table.PeerInfo{
+ AS: arg.Asn,
+ LocalID: net.ParseIP(arg.Id),
+ }
+ } else {
+ pi = &table.PeerInfo{
+ AS: server.bgpConfig.Global.GlobalConfig.As,
+ LocalID: server.bgpConfig.Global.GlobalConfig.RouterId,
+ }
+ }
path = arg.Path
if len(path.Nlri) > 0 {
@@ -985,7 +997,7 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *ta
pattr = append(pattr, bgp.NewPathAttributeExtendedCommunities(extcomms))
}
- return []*table.Path{table.NewPath(peerInfo, nlri, path.IsWithdraw, pattr, false, time.Now(), path.NoImplicitWithdraw)}
+ return []*table.Path{table.NewPath(pi, nlri, path.IsWithdraw, pattr, false, time.Now(), path.NoImplicitWithdraw)}
ERR:
grpcReq.ResponseCh <- result
close(grpcReq.ResponseCh)
@@ -1151,11 +1163,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
}
case REQ_MOD_PATH:
- pi := &table.PeerInfo{
- AS: server.bgpConfig.Global.GlobalConfig.As,
- LocalID: server.bgpConfig.Global.GlobalConfig.RouterId,
- }
- pathList := server.handleModPathRequest(grpcReq, pi)
+ pathList := server.handleModPathRequest(grpcReq)
if len(pathList) > 0 {
msgs = server.propagateUpdate("", false, pathList)
grpcReq.ResponseCh <- &GrpcResponse{}