Signed-off-by: ISHIDA Wataru <[email protected]>
---
 ryu/services/protocols/bgp/application.py          |    4 ++-
 .../protocols/bgp/core_managers/peer_manager.py    |    1 +
 ryu/services/protocols/bgp/info_base/vrf.py        |   34 +++++++++++++++-----
 ryu/services/protocols/bgp/rtconf/vrfs.py          |    2 +-
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/ryu/services/protocols/bgp/application.py 
b/ryu/services/protocols/bgp/application.py
index d9e3ebf..163e75f 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 505ffc8..8fba6b0 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 30b53a2..ad16d9a 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 48b4809..51c7a16 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):
-- 
1.7.10.4




------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to