diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-05-24 13:20:35 +0900 |
---|---|---|
committer | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-06-09 11:23:06 +0900 |
commit | 7854b9a6c376aecb45f1c6837a1555808ec052a3 (patch) | |
tree | b1b9e5579ef8a24fa8b1fbf4fd5165af7fd24cf3 | |
parent | 4bce52c3f37d2e69b5184c6be472565cd6bea483 (diff) |
bmp: Support number of withdraw updates and prefixes
This patch enables to send BMP statistics reports for the following types;
- Stat Type = 11: (32-bit Counter) Number of updates subjected to
treat-as-withdraw treatment.
- Stat Type = 12: (32-bit Counter) Number of prefixes subjected to
treat-as-withdraw treatment.
Note: Currently, this implementation considers only updates or prefixes
received from neighbors, but not enough to follow the handling process
described in RFC7606.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r-- | server/bmp.go | 2 | ||||
-rw-r--r-- | server/fsm.go | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/server/bmp.go b/server/bmp.go index 16db2c55..4d76822b 100644 --- a/server/bmp.go +++ b/server/bmp.go @@ -295,6 +295,8 @@ func bmpPeerStats(peerType uint8, peerDist uint64, timestamp int64, neighConf *c []bmp.BMPStatsTLVInterface{ bmp.NewBMPStatsTLV64(bmp.BMP_STAT_TYPE_ADJ_RIB_IN, uint64(neighConf.State.AdjTable.Accepted)), bmp.NewBMPStatsTLV64(bmp.BMP_STAT_TYPE_LOC_RIB, uint64(neighConf.State.AdjTable.Advertised+neighConf.State.AdjTable.Filtered)), + bmp.NewBMPStatsTLV32(bmp.BMP_STAT_TYPE_WITHDRAW_UPDATE, neighConf.State.Messages.Received.WithdrawUpdate), + bmp.NewBMPStatsTLV32(bmp.BMP_STAT_TYPE_WITHDRAW_PREFIX, neighConf.State.Messages.Received.WithdrawPrefix), }, ) } diff --git a/server/fsm.go b/server/fsm.go index 6107f749..3817bd23 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -20,6 +20,7 @@ import ( "github.com/eapache/channels" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet/bgp" + "github.com/osrg/gobgp/packet/bmp" "github.com/osrg/gobgp/table" log "github.com/sirupsen/logrus" "gopkg.in/tomb.v2" @@ -182,6 +183,18 @@ func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) { } } +func (fsm *FSM) bmpStatsUpdate(statType uint16, increment int) { + stats := &fsm.pConf.State.Messages.Received + switch statType { + // TODO + // Support other stat types. + case bmp.BMP_STAT_TYPE_WITHDRAW_UPDATE: + stats.WithdrawUpdate += uint32(increment) + case bmp.BMP_STAT_TYPE_WITHDRAW_PREFIX: + stats.WithdrawPrefix += uint32(increment) + } +} + func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingPolicy) *FSM { adminState := ADMIN_STATE_UP if pConf.Config.AdminDown { @@ -712,6 +725,17 @@ func (h *FSMHandler) recvMessageWithError() (*FsmMsg, error) { return fmsg, err } + if routes := len(body.WithdrawnRoutes); routes > 0 { + h.fsm.bmpStatsUpdate(bmp.BMP_STAT_TYPE_WITHDRAW_UPDATE, 1) + h.fsm.bmpStatsUpdate(bmp.BMP_STAT_TYPE_WITHDRAW_PREFIX, routes) + } else if attr := getPathAttrFromBGPUpdate(body, bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI); attr != nil { + mpUnreach := attr.(*bgp.PathAttributeMpUnreachNLRI) + if routes = len(mpUnreach.Value); routes > 0 { + h.fsm.bmpStatsUpdate(bmp.BMP_STAT_TYPE_WITHDRAW_UPDATE, 1) + h.fsm.bmpStatsUpdate(bmp.BMP_STAT_TYPE_WITHDRAW_PREFIX, routes) + } + } + table.UpdatePathAttrs4ByteAs(body) if err = table.UpdatePathAggregator4ByteAs(body); err != nil { fmsg.MsgData = err |