summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-05-24 13:20:35 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2017-06-09 11:23:06 +0900
commit7854b9a6c376aecb45f1c6837a1555808ec052a3 (patch)
treeb1b9e5579ef8a24fa8b1fbf4fd5165af7fd24cf3 /server/fsm.go
parent4bce52c3f37d2e69b5184c6be472565cd6bea483 (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>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go24
1 files changed, 24 insertions, 0 deletions
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