summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-01-19 10:04:01 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-03 22:47:34 -0800
commitada5cb1db61b481378ad78ba2d78bf36eff67e2e (patch)
treed9d8ff43802828190da1b8277a68a2be500d6883 /server/fsm.go
parent1063bcab1ee22cac4c7e375aaf37589747bad133 (diff)
server/fsm: Logging Administrative Shutdown Communication
This patch enable to log the body of the Cease NOTIFICATION message with "Administrative Shutdown" and "Administrative Reset" subcodes. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go54
1 files changed, 41 insertions, 13 deletions
diff --git a/server/fsm.go b/server/fsm.go
index c72f7f24..a8ca047a 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -696,13 +696,26 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) {
}
case bgp.BGP_MSG_NOTIFICATION:
body := m.Body.(*bgp.BGPNotification)
- log.WithFields(log.Fields{
- "Topic": "Peer",
- "Key": h.fsm.pConf.Config.NeighborAddress,
- "Code": body.ErrorCode,
- "Subcode": body.ErrorSubcode,
- "Data": body.Data,
- }).Warn("received notification")
+ if body.ErrorCode == bgp.BGP_ERROR_CEASE && (body.ErrorSubcode == bgp.BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN || body.ErrorSubcode == bgp.BGP_ERROR_SUB_ADMINISTRATIVE_RESET) {
+ communication, rest := decodeAdministrativeCommunication(body.Data)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": h.fsm.pConf.Config.NeighborAddress,
+ "Code": body.ErrorCode,
+ "Subcode": body.ErrorSubcode,
+ "Communicated-Reason": communication,
+ "Data": rest,
+ }).Warn("received notification")
+ } else {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": h.fsm.pConf.Config.NeighborAddress,
+ "Code": body.ErrorCode,
+ "Subcode": body.ErrorSubcode,
+ "Data": body.Data,
+ }).Warn("received notification")
+ }
+
if s := h.fsm.pConf.GracefulRestart.State; s.Enabled && s.NotificationEnabled && body.ErrorCode == bgp.BGP_ERROR_CEASE && body.ErrorSubcode == bgp.BGP_ERROR_SUB_HARD_RESET {
sendToErrorCh(FSM_HARD_RESET)
} else {
@@ -1097,13 +1110,28 @@ func (h *FSMHandler) sendMessageloop() error {
switch m.Header.Type {
case bgp.BGP_MSG_NOTIFICATION:
- log.WithFields(log.Fields{
- "Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
- "State": fsm.state.String(),
- "Data": m,
- }).Warn("sent notification")
body := m.Body.(*bgp.BGPNotification)
+ if body.ErrorCode == bgp.BGP_ERROR_CEASE && (body.ErrorSubcode == bgp.BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN || body.ErrorSubcode == bgp.BGP_ERROR_SUB_ADMINISTRATIVE_RESET) {
+ communication, rest := decodeAdministrativeCommunication(body.Data)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": fsm.pConf.Config.NeighborAddress,
+ "State": fsm.state.String(),
+ "Code": body.ErrorCode,
+ "Subcode": body.ErrorSubcode,
+ "Communicated-Reason": communication,
+ "Data": rest,
+ }).Warn("sent notification")
+ } else {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": fsm.pConf.Config.NeighborAddress,
+ "State": fsm.state.String(),
+ "Code": body.ErrorCode,
+ "Subcode": body.ErrorSubcode,
+ "Data": body.Data,
+ }).Warn("sent notification")
+ }
h.errorCh <- FsmStateReason(fmt.Sprintf("%s %s", FSM_NOTIFICATION_SENT, bgp.NewNotificationErrorCode(body.ErrorCode, body.ErrorSubcode).String()))
conn.Close()
return fmt.Errorf("closed")