diff options
-rw-r--r-- | packet/bgp/bgp.go | 11 | ||||
-rw-r--r-- | server/fsm.go | 15 |
2 files changed, 24 insertions, 2 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go index 9ea753c4..de5545d0 100644 --- a/packet/bgp/bgp.go +++ b/packet/bgp/bgp.go @@ -4660,6 +4660,10 @@ func (p *PathAttributeMpReachNLRI) MarshalJSON() ([]byte, error) { }) } +func (p *PathAttributeMpReachNLRI) String() string { + return fmt.Sprintf("{MpReach(%s): {Nexthop: %s, NLRIs: %s}}", AfiSafiToRouteFamily(p.AFI, p.SAFI), p.Nexthop, p.Value) +} + func NewPathAttributeMpReachNLRI(nexthop string, nlri []AddrPrefixInterface) *PathAttributeMpReachNLRI { t := BGP_ATTR_TYPE_MP_REACH_NLRI ip := net.ParseIP(nexthop) @@ -4742,6 +4746,13 @@ func (p *PathAttributeMpUnreachNLRI) Serialize() ([]byte, error) { return p.PathAttribute.Serialize() } +func (p *PathAttributeMpUnreachNLRI) String() string { + if len(p.Value) > 0 { + return fmt.Sprintf("{MpUnreach(%s): {NLRIs: %s}}", AfiSafiToRouteFamily(p.AFI, p.SAFI), p.Value) + } + return fmt.Sprintf("{MpUnreach(%s): End-of-Rib}", AfiSafiToRouteFamily(p.AFI, p.SAFI)) +} + func NewPathAttributeMpUnreachNLRI(nlri []AddrPrefixInterface) *PathAttributeMpUnreachNLRI { t := BGP_ATTR_TYPE_MP_UNREACH_NLRI p := &PathAttributeMpUnreachNLRI{ diff --git a/server/fsm.go b/server/fsm.go index 34c8b187..f3d365f2 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -1049,7 +1049,8 @@ func (h *FSMHandler) sendMessageloop() error { } fsm.bgpMessageStateUpdate(m.Header.Type, false) - if m.Header.Type == bgp.BGP_MSG_NOTIFICATION { + switch m.Header.Type { + case bgp.BGP_MSG_NOTIFICATION: log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.Config.NeighborAddress, @@ -1059,7 +1060,17 @@ func (h *FSMHandler) sendMessageloop() error { h.errorCh <- FSM_NOTIFICATION_SENT conn.Close() return fmt.Errorf("closed") - } else { + case bgp.BGP_MSG_UPDATE: + update := m.Body.(*bgp.BGPUpdate) + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": fsm.pConf.Config.NeighborAddress, + "State": fsm.state, + "nlri": update.NLRI, + "withdrawals": update.WithdrawnRoutes, + "attributes": update.PathAttributes, + }).Debug("sent update") + default: log.WithFields(log.Fields{ "Topic": "Peer", "Key": fsm.pConf.Config.NeighborAddress, |