summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-09-14 16:33:03 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2017-11-02 13:49:09 +0900
commit3a0c52c808772baaa2942afe3882c648ac77e318 (patch)
tree77ba560ec1688356dc1fc65a00132ee999f2cc73 /server
parentd2a34c964aa0a43afc488f1d4497e4cd51a8c15a (diff)
server: function notifyPrePolicyUpdateWatcher
The function for notifying WATCH_EVENT_TYPE_PRE_UPDATE event hasn't been defined yet, this patch defines a function for it. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server')
-rw-r--r--server/server.go47
1 files changed, 29 insertions, 18 deletions
diff --git a/server/server.go b/server/server.go
index 28749f2c..ff7fcaf0 100644
--- a/server/server.go
+++ b/server/server.go
@@ -496,6 +496,33 @@ func (server *BgpServer) notifyBestWatcher(best []*table.Path, multipath [][]*ta
server.notifyWatcher(WATCH_EVENT_TYPE_BEST_PATH, &WatchEventBestPath{PathList: clonedB, MultiPathList: clonedM})
}
+func (server *BgpServer) notifyPrePolicyUpdateWatcher(peer *Peer, pathList []*table.Path, msg *bgp.BGPMessage, timestamp time.Time, payload []byte) {
+ if !server.isWatched(WATCH_EVENT_TYPE_PRE_UPDATE) || peer == nil {
+ return
+ }
+ cloned := clonePathList(pathList)
+ if len(cloned) == 0 {
+ return
+ }
+ _, y := peer.fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]
+ l, _ := peer.fsm.LocalHostPort()
+ ev := &WatchEventUpdate{
+ Message: msg,
+ PeerAS: peer.fsm.peerInfo.AS,
+ LocalAS: peer.fsm.peerInfo.LocalAS,
+ PeerAddress: peer.fsm.peerInfo.Address,
+ LocalAddress: net.ParseIP(l),
+ PeerID: peer.fsm.peerInfo.ID,
+ FourBytesAs: y,
+ Timestamp: timestamp,
+ Payload: payload,
+ PostPolicy: false,
+ PathList: cloned,
+ Neighbor: peer.ToConfig(false),
+ }
+ server.notifyWatcher(WATCH_EVENT_TYPE_PRE_UPDATE, ev)
+}
+
func (server *BgpServer) notifyPostPolicyUpdateWatcher(peer *Peer, pathList []*table.Path) {
if !server.isWatched(WATCH_EVENT_TYPE_POST_UPDATE) || peer == nil {
return
@@ -986,24 +1013,8 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
sendFsmOutgoingMsg(peer, nil, notification, true)
return
}
- if m.Header.Type == bgp.BGP_MSG_UPDATE && server.isWatched(WATCH_EVENT_TYPE_PRE_UPDATE) {
- _, y := peer.fsm.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER]
- l, _ := peer.fsm.LocalHostPort()
- ev := &WatchEventUpdate{
- Message: m,
- PeerAS: peer.fsm.peerInfo.AS,
- LocalAS: peer.fsm.peerInfo.LocalAS,
- PeerAddress: peer.fsm.peerInfo.Address,
- LocalAddress: net.ParseIP(l),
- PeerID: peer.fsm.peerInfo.ID,
- FourBytesAs: y,
- Timestamp: e.timestamp,
- Payload: e.payload,
- PostPolicy: false,
- PathList: clonePathList(pathList),
- Neighbor: peer.ToConfig(false),
- }
- server.notifyWatcher(WATCH_EVENT_TYPE_PRE_UPDATE, ev)
+ if m.Header.Type == bgp.BGP_MSG_UPDATE {
+ server.notifyPrePolicyUpdateWatcher(peer, pathList, m, e.timestamp, e.payload)
}
if len(pathList) > 0 {