summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2014-05-30 11:25:24 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-06-02 12:01:48 +0900
commit1f316cf1c1b01729d03a2377bc3384a89d1de265 (patch)
treef983485a75647a2458fbb1a4428f239fd5cd674c
parent49dcfa5c0deb5097c0e0cce2a4fc666abfe0e176 (diff)
bgp: fix bug of exchanging paths between vrf and global_table
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/application.py4
-rw-r--r--ryu/services/protocols/bgp/core_managers/peer_manager.py1
-rw-r--r--ryu/services/protocols/bgp/info_base/vrf.py34
-rw-r--r--ryu/services/protocols/bgp/rtconf/vrfs.py2
4 files changed, 31 insertions, 10 deletions
diff --git a/ryu/services/protocols/bgp/application.py b/ryu/services/protocols/bgp/application.py
index d9e3ebf9..163e75f4 100644
--- a/ryu/services/protocols/bgp/application.py
+++ b/ryu/services/protocols/bgp/application.py
@@ -44,6 +44,7 @@ from ryu.services.protocols.bgp.rtconf.common import REFRESH_MAX_EOR_TIME
from ryu.services.protocols.bgp.rtconf.common import REFRESH_STALEPATH_TIME
from ryu.services.protocols.bgp.rtconf.common import ROUTER_ID
from ryu.services.protocols.bgp.rtconf import neighbors
+from ryu.services.protocols.bgp.rtconf import vrfs
from ryu.services.protocols.bgp.utils.dictconfig import dictConfig
from ryu.services.protocols.bgp.utils.validation import is_valid_ipv4
@@ -203,8 +204,9 @@ class BGPSpeaker(RyuApp):
All valid VRFs are loaded.
"""
vpns_conf = routing_settings.setdefault('vpns', {})
- for vrf in vpns_conf:
+ for vrfname, vrf in vpns_conf.iteritems():
try:
+ vrf[vrfs.VRF_NAME] = vrfname
call('vrf.create', **vrf)
LOG.debug('Added vrf %s' % str(vrf))
except RuntimeConfigError as e:
diff --git a/ryu/services/protocols/bgp/core_managers/peer_manager.py b/ryu/services/protocols/bgp/core_managers/peer_manager.py
index 505ffc8d..8fba6b06 100644
--- a/ryu/services/protocols/bgp/core_managers/peer_manager.py
+++ b/ryu/services/protocols/bgp/core_managers/peer_manager.py
@@ -10,6 +10,7 @@ from ryu.lib.packet.bgp import RF_IPv6_UC
from ryu.lib.packet.bgp import RF_IPv4_VPN
from ryu.lib.packet.bgp import RF_IPv6_VPN
from ryu.lib.packet.bgp import RF_RTC_UC
+from ryu.lib.packet.bgp import RouteTargetMembershipNLRI
from ryu.services.protocols.bgp.utils.bgp \
import clone_path_and_update_med_for_target_neighbor
LOG = logging.getLogger('bgpspeaker.core_managers.peer_manager')
diff --git a/ryu/services/protocols/bgp/info_base/vrf.py b/ryu/services/protocols/bgp/info_base/vrf.py
index 30b53a27..ad16d9aa 100644
--- a/ryu/services/protocols/bgp/info_base/vrf.py
+++ b/ryu/services/protocols/bgp/info_base/vrf.py
@@ -27,6 +27,7 @@ from ryu.lib.packet.bgp import BGP_ATTR_TYPE_MULTI_EXIT_DISC
from ryu.lib.packet.bgp import BGPPathAttributeOrigin
from ryu.lib.packet.bgp import BGPPathAttributeAsPath
from ryu.lib.packet.bgp import BGPPathAttributeExtendedCommunities
+from ryu.lib.packet.bgp import BGPTwoOctetAsSpecificExtendedCommunity
from ryu.lib.packet.bgp import BGPPathAttributeMultiExitDisc
from ryu.services.protocols.bgp.base import OrderedDict
@@ -146,8 +147,8 @@ class VrfTable(Table):
source = vpn_path.source
if not source:
source = VRF_TABLE
-
- vrf_nlri = self.NLRI_CLASS(vpn_path.nlri.prefix)
+ ip, masklen = vpn_path.nlri.prefix.split('/')
+ vrf_nlri = self.NLRI_CLASS(length=int(masklen), addr=ip)
vpn_nlri = vpn_path.nlri
puid = self.VRF_PATH_CLASS.create_puid(vpn_nlri.route_disc,
@@ -212,9 +213,24 @@ class VrfTable(Table):
pattrs[BGP_ATTR_TYPE_ORIGIN] = BGPPathAttributeOrigin(
EXPECTED_ORIGIN)
pattrs[BGP_ATTR_TYPE_AS_PATH] = BGPPathAttributeAsPath([])
+ communities = []
+ for rt in vrf_conf.export_rts:
+ as_num, local_admin = rt.split(':')
+ subtype = 2
+ communities.append(BGPTwoOctetAsSpecificExtendedCommunity(
+ as_number=int(as_num),
+ local_administrator=int(local_admin),
+ subtype=subtype))
+ for soo in vrf_conf.soo_list:
+ as_num, local_admin = rt.split(':')
+ subtype = 3
+ communities.append(BGPTwoOctetAsSpecificExtendedCommunity(
+ as_number=int(as_num),
+ local_administrator=int(local_admin),
+ subtype=subtype))
+
pattrs[BGP_ATTR_TYPE_EXTENDED_COMMUNITIES] = \
- BGPPathAttributeExtendedCommunities(
- rt_list=vrf_conf.export_rts, soo_list=vrf_conf.soo_list)
+ BGPPathAttributeExtendedCommunities(communities=communities)
if vrf_conf.multi_exit_disc:
pattrs[BGP_ATTR_TYPE_MULTI_EXIT_DISC] = \
BGPPathAttributeMultiExitDisc(vrf_conf.multi_exit_disc)
@@ -471,10 +487,12 @@ class VrfPath(Path):
)
return clone
- def clone_to_vpn(self, route_disc, for_withdrawal=False):
- vpn_nlri = self.VPN_NLRI_CLASS(
- self.label_list, route_disc, self._nlri.prefix
- )
+ def clone_to_vpn(self, route_dist, for_withdrawal=False):
+ ip, masklen = self._nlri.prefix.split('/')
+ vpn_nlri = self.VPN_NLRI_CLASS(length=int(masklen),
+ addr=ip,
+ labels=self.label_list,
+ route_dist=route_dist)
pathattrs = None
if not for_withdrawal:
diff --git a/ryu/services/protocols/bgp/rtconf/vrfs.py b/ryu/services/protocols/bgp/rtconf/vrfs.py
index 48b4809f..51c7a16d 100644
--- a/ryu/services/protocols/bgp/rtconf/vrfs.py
+++ b/ryu/services/protocols/bgp/rtconf/vrfs.py
@@ -134,7 +134,7 @@ class VrfConf(ConfWithId, ConfWithStats):
EXPORT_RTS])
OPTIONAL_SETTINGS = frozenset(
- [MULTI_EXIT_DISC, SITE_OF_ORIGINS, VRF_RF, IMPORT_MAPS]
+ [VRF_NAME, MULTI_EXIT_DISC, SITE_OF_ORIGINS, VRF_RF, IMPORT_MAPS]
)
def __init__(self, **kwargs):