For the interoperability with other MP BGP EVPN VXLAN implementations
(e.g., Cisco NX-OS), this patch enables to advertise the VNI with the
PMSI Tunnel attribute on the Inclusive Multicast Ethernet Tag Route
messages.

Suggested-by: Albert Siersema <[email protected]>
Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/services/protocols/bgp/bgpspeaker.py                 | 16 +++++++++++++---
 .../protocols/bgp/core_managers/table_manager.py         |  5 +++++
 ryu/services/protocols/bgp/info_base/vrf.py              |  3 ++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/ryu/services/protocols/bgp/bgpspeaker.py 
b/ryu/services/protocols/bgp/bgpspeaker.py
index 6a0025c..d82be62 100644
--- a/ryu/services/protocols/bgp/bgpspeaker.py
+++ b/ryu/services/protocols/bgp/bgpspeaker.py
@@ -581,18 +581,25 @@ class BGPSpeaker(object):
 
         ``vni`` specifies an Virtual Network Identifier for VXLAN
         or Virtual Subnet Identifier for NVGRE.
-        If tunnel_type is not 'vxlan' or 'nvgre', this field is ignored.
+        If tunnel_type is not TUNNEL_TYPE_VXLAN or TUNNEL_TYPE_NVGRE,
+        this field is ignored.
 
         ``next_hop`` specifies the next hop address for this prefix.
 
         ``tunnel_type`` specifies the data plane encapsulation type
-        to advertise. By the default, this encapsulation attribute is
-        not advertised.
+        to advertise.
+        By the default, this attribute is not advertised.
+        The supported encapsulation types are TUNNEL_TYPE_VXLAN and
+        TUNNEL_TYPE_NVGRE.
 
         ``pmsi_tunnel_type`` specifies the type of the PMSI tunnel attribute
         used to encode the multicast tunnel identifier.
         This field is advertised only if route_type is
         EVPN_MULTICAST_ETAG_ROUTE.
+        By the default, this attribute is not advertised.
+        The supported PMSI tunnel types are PMSI_TYPE_NO_TUNNEL_INFO and
+        PMSI_TYPE_INGRESS_REP.
+        This attribute can also carry vni if tunnel_type is specified.
 
         ``redundancy_mode`` specifies a redundancy mode type.
         The supported redundancy mode types are REDUNDANCY_MODE_ALL_ACTIVE
@@ -638,6 +645,9 @@ class BGPSpeaker(object):
                 EVPN_ETHERNET_TAG_ID: ethernet_tag_id,
                 IP_ADDR: ip_addr,
             })
+            # Set tunnel type specific arguments
+            if tunnel_type in [TUNNEL_TYPE_VXLAN, TUNNEL_TYPE_NVGRE]:
+                kwargs[EVPN_VNI] = vni
             # Set PMSI Tunnel Attribute arguments
             if pmsi_tunnel_type in [
                     PMSI_TYPE_NO_TUNNEL_INFO,
diff --git a/ryu/services/protocols/bgp/core_managers/table_manager.py 
b/ryu/services/protocols/bgp/core_managers/table_manager.py
index 0e084b8..5aa9454 100644
--- a/ryu/services/protocols/bgp/core_managers/table_manager.py
+++ b/ryu/services/protocols/bgp/core_managers/table_manager.py
@@ -36,6 +36,7 @@ from ryu.lib.packet.bgp import EvpnEsi
 from ryu.lib.packet.bgp import EvpnArbitraryEsi
 from ryu.lib.packet.bgp import EvpnNLRI
 from ryu.lib.packet.bgp import EvpnMacIPAdvertisementNLRI
+from ryu.lib.packet.bgp import EvpnInclusiveMulticastEthernetTagNLRI
 from ryu.lib.packet.bgp import IPAddrPrefix
 from ryu.lib.packet.bgp import IP6AddrPrefix
 
@@ -543,6 +544,10 @@ class TableCoreManager(object):
             if route_type == EvpnMacIPAdvertisementNLRI.ROUTE_TYPE_NAME:
                 # MPLS labels will be assigned automatically
                 kwargs['mpls_labels'] = []
+            if route_type == 
EvpnInclusiveMulticastEthernetTagNLRI.ROUTE_TYPE_NAME:
+                # Inclusive Multicast Ethernet Tag Route does not have "vni",
+                # omit "vni" from "kwargs" here.
+                vni = kwargs.pop('vni', None)
             subclass = EvpnNLRI._lookup_type_name(route_type)
             kwargs['route_dist'] = route_dist
             esi = kwargs.get('esi', None)
diff --git a/ryu/services/protocols/bgp/info_base/vrf.py 
b/ryu/services/protocols/bgp/info_base/vrf.py
index 4900e12..dec6b19 100644
--- a/ryu/services/protocols/bgp/info_base/vrf.py
+++ b/ryu/services/protocols/bgp/info_base/vrf.py
@@ -319,7 +319,8 @@ class VrfTable(Table):
                 pattrs[BGP_ATTR_TYEP_PMSI_TUNNEL_ATTRIBUTE] = \
                     BGPPathAttributePmsiTunnel(pmsi_flags=0,
                                                tunnel_type=pmsi_tunnel_type,
-                                               tunnel_id=tunnel_id)
+                                               tunnel_id=tunnel_id,
+                                               vni=kwargs.get('vni', None))
 
         puid = self.VRF_PATH_CLASS.create_puid(
             vrf_conf.route_dist, nlri.prefix)
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to