diff options
-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 |