hold a raw update_msg in ReceivedRoute to deliver unmodified update msg to bmp server.
Signed-off-by: ISHIDA Wataru <ishida.wat...@lab.ntt.co.jp> --- ryu/services/protocols/bgp/bmp.py | 3 +-- ryu/services/protocols/bgp/model.py | 3 ++- ryu/services/protocols/bgp/peer.py | 21 +++++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ryu/services/protocols/bgp/bmp.py b/ryu/services/protocols/bgp/bmp.py index 4fbbecb..f01b509 100644 --- a/ryu/services/protocols/bgp/bmp.py +++ b/ryu/services/protocols/bgp/bmp.py @@ -171,11 +171,10 @@ class BMPClient(Activity): peer_bgp_id = peer.protocol.recv_open_msg.bgp_identifier peer_address, _ = peer.protocol._remotename - bgp_update = peer._construct_update(path) is_post_policy = not path.filtered timestamp = timegm(path.timestamp) - msg = bmp.BMPRouteMonitoring(bgp_update=bgp_update, + msg = bmp.BMPRouteMonitoring(bgp_update=path.bgp_update, peer_type=peer_type, is_post_policy=is_post_policy, peer_distinguisher=peer_distinguisher, diff --git a/ryu/services/protocols/bgp/model.py b/ryu/services/protocols/bgp/model.py index 0781ee1..5905ae4 100644 --- a/ryu/services/protocols/bgp/model.py +++ b/ryu/services/protocols/bgp/model.py @@ -161,10 +161,11 @@ class ReceivedRoute(object): about a particular BGP destination. """ - def __init__(self, path, peer, filtered=None, timestamp=None): + def __init__(self, path, peer, bgp_update, filtered=None, timestamp=None): assert(path and hasattr(peer, 'version_num')) self.path = path + self.bgp_update = bgp_update # Peer to which this path was received. self._received_peer = peer diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py index 4dafb10..2a345ba 100644 --- a/ryu/services/protocols/bgp/peer.py +++ b/ryu/services/protocols/bgp/peer.py @@ -1345,13 +1345,13 @@ class Peer(Source, Sink, NeighborConfListener, Activity): if mp_unreach_attr: # Extract withdraws from given message. - self._extract_and_handle_mpbgp_withdraws(mp_unreach_attr) + self._extract_and_handle_mpbgp_withdraws(update_msg) if nlri_list: self._extract_and_handle_bgp4_new_paths(update_msg) if withdraw_list: - self._extract_and_handle_bgp4_withdraws(withdraw_list) + self._extract_and_handle_bgp4_withdraws(update_msg) def _extract_and_handle_bgp4_new_paths(self, update_msg): """Extracts new paths advertised in the given update message's @@ -1404,7 +1404,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): block, blocked_cause = self._apply_in_filter(new_path) nlri_str = new_path.nlri.formatted_nlri_str - received_route = ReceivedRoute(new_path, self, block) + received_route = ReceivedRoute(new_path, self, update_msg, block) self._adj_rib_in[nlri_str] = received_route self._signal_bus.adj_rib_in_changed(self, received_route) @@ -1427,7 +1427,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): LOG.error('Max. prefix allowed for this neighbor ' 'exceeded.') - def _extract_and_handle_bgp4_withdraws(self, withdraw_list): + def _extract_and_handle_bgp4_withdraws(self, update_msg): """Extracts withdraws advertised in the given update message's *MpUnReachNlri* attribute. @@ -1439,6 +1439,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): Extracted withdraws are added to appropriate *Destination* for further processing. """ + withdraw_list = update_msg.withdrawn_routes msg_rf = RF_IPv4_UC # Check if this route family is among supported route families. if msg_rf not in SUPPORTED_GLOBAL_RF: @@ -1464,7 +1465,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): block, blocked_cause = self._apply_in_filter(w_path) - received_route = ReceivedRoute(w_path, self, block) + received_route = ReceivedRoute(w_path, self, update_msg, block) nlri_str = w_nlri.formatted_nlri_str self._adj_rib_in[nlri_str] = received_route self._signal_bus.adj_rib_in_changed(self, received_route) @@ -1556,7 +1557,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): block, blocked_cause = self._apply_in_filter(new_path) - received_route = ReceivedRoute(new_path, self, block) + received_route = ReceivedRoute(new_path, self, update_msg, block) nlri_str = msg_nlri.formatted_nlri_str self._adj_rib_in[nlri_str] = received_route self._signal_bus.adj_rib_in_changed(self, received_route) @@ -1584,7 +1585,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): LOG.error('Max. prefix allowed for this neighbor ' 'exceeded.') - def _extract_and_handle_mpbgp_withdraws(self, mp_unreach_attr): + def _extract_and_handle_mpbgp_withdraws(self, update_msg): """Extracts withdraws advertised in the given update message's *MpUnReachNlri* attribute. @@ -1596,6 +1597,10 @@ class Peer(Source, Sink, NeighborConfListener, Activity): Extracted withdraws are added to appropriate *Destination* for further processing. """ + mp_unreach_attr = update_msg.get_path_attr( + BGP_ATTR_TYPE_MP_UNREACH_NLRI + ) + msg_rf = mp_unreach_attr.route_family # Check if this route family is among supported route families. if msg_rf not in SUPPORTED_GLOBAL_RF: @@ -1620,7 +1625,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity): ) block, blocked_cause = self._apply_in_filter(w_path) - received_route = ReceivedRoute(w_path, self, block) + received_route = ReceivedRoute(w_path, self, update_msg, block) nlri_str = w_nlri.formatted_nlri_str self._adj_rib_in[nlri_str] = received_route self._signal_bus.adj_rib_in_changed(self, received_route) -- 1.9.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel