diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-08-21 12:25:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-24 14:37:27 +0900 |
commit | 2a4423fda3efb78368a9c8fdd5d8a48caf359c96 (patch) | |
tree | 4d2e371ec49d6abd093b38c75aeb6892f88964a8 | |
parent | 1a9008b73ec1f9af6212d113a40253c22227e770 (diff) |
bgp: Added support to indicate the next hop IP address for the BGP module
If the path has a next hop value set, it should be used in the BGP
Update message first. This changes to logic to use the check for the
next hop in the order prefix/path->peer config->speaker config. This
will allow for sending the nexthop as part of the add_prefix message and
allow for overiding the nexthop of the peer if one is set.
Based-on: Alan Quillin <alanquillin@gmail.com>
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/bgp/info_base/base.py | 7 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/peer.py | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/ryu/services/protocols/bgp/info_base/base.py b/ryu/services/protocols/bgp/info_base/base.py index 3546c92b..7eb9c48d 100644 --- a/ryu/services/protocols/bgp/info_base/base.py +++ b/ryu/services/protocols/bgp/info_base/base.py @@ -809,6 +809,13 @@ class Path(object): return not interested_rts.isdisjoint(curr_rts) + def is_local(self): + return self._source == None + + def has_nexthop(self): + return not (not self._nexthop or self._nexthop == '0.0.0.0' or + self._nexthop == '::') + def __str__(self): return ( 'Path(source: %s, nlri: %s, source ver#: %s, ' diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py index f08ac1e8..67ba85c0 100644 --- a/ryu/services/protocols/bgp/peer.py +++ b/ryu/services/protocols/bgp/peer.py @@ -851,11 +851,12 @@ class Peer(Source, Sink, NeighborConfListener, Activity): nlri_list = [path.nlri] # By default we use BGPS's interface IP with this peer as next_hop. - # TODO(PH): change to use protocol's local address. - # next_hop = self.host_bind_ip next_hop = self._session_next_hop(path) + if path.is_local() and path.has_nexthop(): + next_hop = path.nexthop + # If this is a iBGP peer. - if not self.is_ebgp_peer() and path.source is not None: + if not self.is_ebgp_peer() and not path.is_local(): # If the path came from a bgp peer and not from NC, according # to RFC 4271 we should not modify next_hop. # However RFC 4271 allows us to change next_hop |