bgp: supporting loopback interface as neighbour_source_address for iBGP

In generally, iBGP session is established between loopback interfaces.
Therefore, we need to specify loopback interface as neighbour_source_address.
This parameter is just like update-source command in cisco router.

Signed-off-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Toshiki Tsuboi 2014-10-10 23:18:36 +09:00 committed by FUJITA Tomonori
parent 5aa14c61a1
commit 5fc3113d73
2 changed files with 21 additions and 2 deletions

View File

@ -58,6 +58,8 @@ from ryu.services.protocols.bgp.rtconf.neighbors import IN_FILTER
from ryu.services.protocols.bgp.rtconf.neighbors import OUT_FILTER
from ryu.services.protocols.bgp.rtconf.neighbors import IS_ROUTE_SERVER_CLIENT
from ryu.services.protocols.bgp.rtconf.neighbors import IS_NEXT_HOP_SELF
from ryu.services.protocols.bgp.rtconf.neighbors import LOCAL_ADDRESS
from ryu.services.protocols.bgp.rtconf.neighbors import LOCAL_PORT
from ryu.services.protocols.bgp.info_base.base import Filter
@ -181,7 +183,8 @@ class BGPSpeaker(object):
enable_vpnv6=DEFAULT_CAP_MBGP_VPNV6,
next_hop=None, password=None, multi_exit_disc=None,
site_of_origins=None, is_route_server_client=False,
is_next_hop_self=False):
is_next_hop_self=False, local_address=None,
local_port=None):
""" This method registers a new neighbor. The BGP speaker tries to
establish a bgp session with the peer (accepts a connection
from the peer and also tries to connect to it).
@ -220,6 +223,11 @@ class BGPSpeaker(object):
``is_next_hop_self`` specifies whether the BGP speaker announces
its own ip address to iBGP neighbor or not as path's next_hop address.
``local_address`` specifies Loopback interface address for iBGP peering.
``local_port`` specifies source TCP port for iBGP peering.
"""
bgp_neighbor = {}
bgp_neighbor[neighbors.IP_ADDRESS] = address
@ -249,6 +257,12 @@ class BGPSpeaker(object):
if site_of_origins:
bgp_neighbor[SITE_OF_ORIGINS] = site_of_origins
if local_address:
bgp_neighbor[LOCAL_ADDRESS] = local_address
if local_port:
bgp_neighbor[LOCAL_PORT] = local_port
call('neighbor.create', **bgp_neighbor)
def neighbor_del(self, address):

View File

@ -1037,7 +1037,12 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
peer_address = (self._neigh_conf.ip_address,
const.STD_BGP_SERVER_PORT_NUM)
LOG.debug('%s trying to connect to %s' % (self, peer_address))
if bind_addr:
LOG.debug('%s trying to connect from %s to %s'
% (self, bind_addr, peer_address))
else:
LOG.debug('%s trying to connect to %s'
% (self, peer_address))
tcp_conn_timeout = self._common_conf.tcp_conn_timeout
try:
password = self._neigh_conf.password