This patch remames the internal (not for users) API for the consistency, and add missing docstring.
Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com> --- ryu/services/protocols/bgp/api/rtconf.py | 4 ++-- .../protocols/bgp/core_managers/table_manager.py | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ryu/services/protocols/bgp/api/rtconf.py b/ryu/services/protocols/bgp/api/rtconf.py index 75a26ec..45c6420 100644 --- a/ryu/services/protocols/bgp/api/rtconf.py +++ b/ryu/services/protocols/bgp/api/rtconf.py @@ -272,14 +272,14 @@ def get_vrfs_conf(): @register(name='network.add') def add_network(prefix, next_hop=None): tm = CORE_MANAGER.get_core_service().table_manager - tm.add_to_global_table(prefix, next_hop) + tm.update_global_table(prefix, next_hop) return True @register(name='network.del') def del_network(prefix): tm = CORE_MANAGER.get_core_service().table_manager - tm.add_to_global_table(prefix, is_withdraw=True) + tm.update_global_table(prefix, is_withdraw=True) return True # ============================================================================= diff --git a/ryu/services/protocols/bgp/core_managers/table_manager.py b/ryu/services/protocols/bgp/core_managers/table_manager.py index 261f417..edb476c 100644 --- a/ryu/services/protocols/bgp/core_managers/table_manager.py +++ b/ryu/services/protocols/bgp/core_managers/table_manager.py @@ -552,8 +552,14 @@ class TableCoreManager(object): nlri=prefix, next_hop=next_hop, gen_lbl=gen_lbl, is_withdraw=is_withdraw) - def add_to_global_table(self, prefix, nexthop=None, - is_withdraw=False): + def update_global_table(self, prefix, next_hop=None, is_withdraw=False): + """Update a BGP route in the Global table for the given `prefix` + with the given `next_hop`. + + If `is_withdraw` is False, which is the default, add a BGP route + to the Global table. + If `is_withdraw` is True, remove a BGP route from the Global table. + """ src_ver_num = 1 peer = None # set mandatory path attributes @@ -569,17 +575,17 @@ class TableCoreManager(object): masklen = net.prefixlen if netaddr.valid_ipv4(ip): _nlri = IPAddrPrefix(masklen, ip) - if nexthop is None: - nexthop = '0.0.0.0' + if next_hop is None: + next_hop = '0.0.0.0' p = Ipv4Path else: _nlri = IP6AddrPrefix(masklen, ip) - if nexthop is None: - nexthop = '::' + if next_hop is None: + next_hop = '::' p = Ipv6Path new_path = p(peer, _nlri, src_ver_num, - pattrs=pathattrs, nexthop=nexthop, + pattrs=pathattrs, nexthop=next_hop, is_withdraw=is_withdraw) # add to global ipv4 table and propagates to neighbors -- 2.7.4 ------------------------------------------------------------------------------ _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel