summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorEiichiro Watanabe <a16tochjp@gmail.com>2019-01-12 00:51:23 +0900
committerEiichiro Watanabe <a16tochjp@gmail.com>2019-01-12 00:51:23 +0900
commit61d7a5e90bae220a45accf9914604ea568ae8c4a (patch)
treee1f8fcc5944043ea2310512c975ec2049f748fad /pkg
parent98d8925b82766f21f49378172a3c0763054a619a (diff)
server: Fix peer down reason code in BMP
Diffstat (limited to 'pkg')
-rw-r--r--pkg/server/bmp.go14
-rw-r--r--pkg/server/fsm.go23
2 files changed, 13 insertions, 24 deletions
diff --git a/pkg/server/bmp.go b/pkg/server/bmp.go
index 063574c0..6742a813 100644
--- a/pkg/server/bmp.go
+++ b/pkg/server/bmp.go
@@ -277,7 +277,19 @@ func bmpPeerDown(ev *watchEventPeerState, t uint8, policy bool, pd uint64) *bmp.
flags |= bmp.BMP_PEER_FLAG_POST_POLICY
}
ph := bmp.NewBMPPeerHeader(t, flags, pd, ev.PeerAddress.String(), ev.PeerAS, ev.PeerID.String(), float64(ev.Timestamp.Unix()))
- return bmp.NewBMPPeerDownNotification(*ph, uint8(ev.StateReason.peerDownReason), ev.StateReason.BGPNotification, ev.StateReason.Data)
+
+ reasonCode := bmp.BMP_peerDownByUnknownReason
+ switch ev.StateReason.Type {
+ case fsmDying, fsmInvalidMsg, fsmNotificationSent, fsmHoldTimerExpired, fsmIdleTimerExpired, fsmRestartTimerExpired:
+ reasonCode = bmp.BMP_PEER_DOWN_REASON_LOCAL_BGP_NOTIFICATION
+ case fsmAdminDown:
+ reasonCode = bmp.BMP_PEER_DOWN_REASON_LOCAL_NO_NOTIFICATION
+ case fsmNotificationRecv, fsmGracefulRestart, fsmHardReset:
+ reasonCode = bmp.BMP_PEER_DOWN_REASON_REMOTE_BGP_NOTIFICATION
+ case fsmReadFailed, fsmWriteFailed:
+ reasonCode = bmp.BMP_PEER_DOWN_REASON_REMOTE_NO_NOTIFICATION
+ }
+ return bmp.NewBMPPeerDownNotification(*ph, uint8(reasonCode), ev.StateReason.BGPNotification, ev.StateReason.Data)
}
func bmpPeerRoute(t uint8, policy bool, pd uint64, fourBytesAs bool, peeri *table.PeerInfo, timestamp int64, payload []byte) *bmp.BMPMessage {
diff --git a/pkg/server/fsm.go b/pkg/server/fsm.go
index 319f1eb6..56b2c35e 100644
--- a/pkg/server/fsm.go
+++ b/pkg/server/fsm.go
@@ -39,15 +39,6 @@ const (
minConnectRetryInterval = 10
)
-type peerDownReason int
-
-const (
- peerDownByLocal peerDownReason = iota
- peerDownByLocalWithoutNotification
- peerDownByRemote
- peerDownByRemoteWithoutNotification
-)
-
type fsmStateReasonType uint8
const (
@@ -70,26 +61,13 @@ const (
type fsmStateReason struct {
Type fsmStateReasonType
- peerDownReason peerDownReason
BGPNotification *bgp.BGPMessage
Data []byte
}
func newfsmStateReason(typ fsmStateReasonType, notif *bgp.BGPMessage, data []byte) *fsmStateReason {
- var reasonCode peerDownReason
- switch typ {
- case fsmDying, fsmInvalidMsg, fsmNotificationSent, fsmHoldTimerExpired, fsmIdleTimerExpired, fsmRestartTimerExpired:
- reasonCode = peerDownByLocal
- case fsmAdminDown:
- reasonCode = peerDownByLocalWithoutNotification
- case fsmNotificationRecv, fsmGracefulRestart, fsmHardReset:
- reasonCode = peerDownByRemote
- case fsmReadFailed, fsmWriteFailed:
- reasonCode = peerDownByRemoteWithoutNotification
- }
return &fsmStateReason{
Type: typ,
- peerDownReason: reasonCode,
BGPNotification: notif,
Data: data,
}
@@ -1892,7 +1870,6 @@ func (h *fsmHandler) loop(ctx context.Context, wg *sync.WaitGroup) error {
reason := fsm.reason
if fsm.h.sentNotification != nil {
reason.Type = fsmNotificationSent
- reason.peerDownReason = peerDownByLocal
reason.BGPNotification = fsm.h.sentNotification
}
log.WithFields(log.Fields{