summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-09 07:43:43 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-09 07:43:43 +0000
commit3ced192e5c5bda81290e4a13d17bedd66b36b439 (patch)
treeaa0ac5f307d72658d0297ff344186fce77455ba0 /server/server.go
parentdb59fed44d8a1df5b5feffbfb1fc7f3c9b61a8c1 (diff)
server: fix to send more appropriate notification code/subcode
admin-down : 6/2 peer-as/neighbor-address : 6/3 other : 6/6 Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/server/server.go b/server/server.go
index d8e1d7c8..41e142fd 100644
--- a/server/server.go
+++ b/server/server.go
@@ -2167,7 +2167,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
}
close(grpcReq.ResponseCh)
case REQ_DEL_NEIGHBOR:
- m, err := server.handleDelNeighbor(grpcReq.Data.(*config.Neighbor))
+ m, err := server.handleDelNeighbor(grpcReq.Data.(*config.Neighbor), bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED)
grpcReq.ResponseCh <- &GrpcResponse{
ResponseErr: err,
}
@@ -2343,7 +2343,7 @@ func (server *BgpServer) handleAddNeighbor(c *config.Neighbor) ([]*SenderMsg, er
return nil, nil
}
-func (server *BgpServer) handleDelNeighbor(c *config.Neighbor) ([]*SenderMsg, error) {
+func (server *BgpServer) handleDelNeighbor(c *config.Neighbor, code, subcode uint8) ([]*SenderMsg, error) {
addr := c.Config.NeighborAddress
n, y := server.neighborMap[addr]
if !y {
@@ -2366,8 +2366,7 @@ func (server *BgpServer) handleDelNeighbor(c *config.Neighbor) ([]*SenderMsg, er
delete(server.neighborMap, addr)
m := server.dropPeerAllRoutes(n, n.configuredRFlist())
- notification := bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED, nil)
- m = append(m, newSenderMsg(n, nil, notification, false))
+ n.fsm.sendNotification(code, subcode, nil, "")
return m, nil
}
@@ -2385,7 +2384,13 @@ func (server *BgpServer) handleUpdateNeighbor(c *config.Neighbor) ([]*SenderMsg,
original := peer.fsm.pConf
if !original.Config.Equal(&c.Config) || !original.Transport.Config.Equal(&c.Transport.Config) {
- msgs, err := server.handleDelNeighbor(peer.fsm.pConf)
+ sub := uint8(bgp.BGP_ERROR_SUB_OTHER_CONFIGURATION_CHANGE)
+ if original.Config.AdminDown != c.Config.AdminDown {
+ sub = bgp.BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN
+ } else if original.Config.PeerAs != c.Config.PeerAs {
+ sub = bgp.BGP_ERROR_SUB_PEER_DECONFIGURED
+ }
+ msgs, err := server.handleDelNeighbor(peer.fsm.pConf, bgp.BGP_ERROR_CEASE, sub)
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
@@ -2535,7 +2540,7 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) ([]*SenderM
Config: config.NeighborConfig{
NeighborAddress: arg.Peer.Conf.NeighborAddress,
},
- })
+ }, bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED)
default:
return nil, fmt.Errorf("unsupported operation %s", arg.Operation)
}