diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-08-22 17:21:33 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-08-25 13:33:30 +0900 |
commit | 83324ef9d7f3a0e45fccbabba3aa4f246bd2819c (patch) | |
tree | 5a6d6f80aac356c527a466f421e11228058eaa40 | |
parent | 8ea4e674a99065f73706b8b2e3849a5a9d42952d (diff) |
table_manager: Rename internal API for consistency
This patch remames the internal (not for users) API for the consistency,
and add missing docstring.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/bgp/api/rtconf.py | 4 | ||||
-rw-r--r-- | ryu/services/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 75a26ec9..45c6420b 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 261f4178..edb476c5 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 |