diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-01-31 09:13:27 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-02-03 22:47:34 -0800 |
commit | 64360afd459436a49a1f1254cca21fffbe6945b5 (patch) | |
tree | 9b61d1357d73f8be7e8501e78c606eb41cda94d6 /server/server.go | |
parent | ada5cb1db61b481378ad78ba2d78bf36eff67e2e (diff) |
cli: Administrative Shutdown Communication on disable neighbor
This patch adds "--reason" option support into the disable neighbor command
which can specify "Administrative Shutdown Communication" on the BGP Cease
NOTIFICATION message.
Usage:
$ gobgp neighbor <neighbor address> disable --reason "some messages"
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/server/server.go b/server/server.go index 38b65422..435c9f72 100644 --- a/server/server.go +++ b/server/server.go @@ -1001,8 +1001,9 @@ func (s *BgpServer) DeleteBmp(c *config.BmpServerConfig) error { func (s *BgpServer) Shutdown() { s.mgmtOperation(func() error { s.shutdown = true + stateOp := AdminStateOperation{ADMIN_STATE_DOWN, nil} for _, p := range s.neighborMap { - p.fsm.adminStateCh <- ADMIN_STATE_DOWN + p.fsm.adminStateCh <- stateOp } // TODO: call fsmincomingCh.Close() return nil @@ -1801,15 +1802,15 @@ func (s *BgpServer) ResetNeighbor(addr, communication string) error { }, true) } -func (s *BgpServer) setAdminState(addr string, enable bool) error { +func (s *BgpServer) setAdminState(addr, communication string, enable bool) error { peers, err := s.addrToPeers(addr) if err != nil { return err } for _, peer := range peers { - f := func(state AdminState, message string) { + f := func(stateOp *AdminStateOperation, message string) { select { - case peer.fsm.adminStateCh <- state: + case peer.fsm.adminStateCh <- *stateOp: log.WithFields(log.Fields{ "Topic": "Peer", "Key": peer.fsm.pConf.Config.NeighborAddress, @@ -1819,9 +1820,9 @@ func (s *BgpServer) setAdminState(addr string, enable bool) error { } } if enable { - f(ADMIN_STATE_UP, "ADMIN_STATE_UP requested") + f(&AdminStateOperation{ADMIN_STATE_UP, nil}, "ADMIN_STATE_UP requested") } else { - f(ADMIN_STATE_DOWN, "ADMIN_STATE_DOWN requested") + f(&AdminStateOperation{ADMIN_STATE_DOWN, newAdministrativeCommunication(communication)}, "ADMIN_STATE_DOWN requested") } } return nil @@ -1829,13 +1830,13 @@ func (s *BgpServer) setAdminState(addr string, enable bool) error { func (s *BgpServer) EnableNeighbor(addr string) error { return s.mgmtOperation(func() error { - return s.setAdminState(addr, true) + return s.setAdminState(addr, "", true) }, true) } -func (s *BgpServer) DisableNeighbor(addr string) error { +func (s *BgpServer) DisableNeighbor(addr, communication string) error { return s.mgmtOperation(func() error { - return s.setAdminState(addr, false) + return s.setAdminState(addr, communication, false) }, true) } |