summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorToshiki Tsuboi <t.tsubo2000@gmail.com>2014-10-10 23:18:36 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-10-11 10:30:31 +0900
commit5fc3113d7384cec14f070d781e2cc8b0605402a6 (patch)
tree74e770e15c3318771e566df9565e11fb8c3262bc
parent5aa14c61a1f31ca277cdc7e978cd45c7f4b9cbe4 (diff)
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>
-rw-r--r--ryu/services/protocols/bgp/bgpspeaker.py16
-rw-r--r--ryu/services/protocols/bgp/peer.py7
2 files changed, 21 insertions, 2 deletions
diff --git a/ryu/services/protocols/bgp/bgpspeaker.py b/ryu/services/protocols/bgp/bgpspeaker.py
index c969b08e..70a5bc40 100644
--- a/ryu/services/protocols/bgp/bgpspeaker.py
+++ b/ryu/services/protocols/bgp/bgpspeaker.py
@@ -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):
diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py
index 2baf4a88..8c17a58b 100644
--- a/ryu/services/protocols/bgp/peer.py
+++ b/ryu/services/protocols/bgp/peer.py
@@ -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