Hello,

some comments like "# [AJS]" breaks pep8 check...
I don't recommend you to add name into source comment...

My apologies, I meant to remove them before submitting the patch, but kinda forgot about it :(
Removed an unnecessary 'self.vni = vni' line as well.
Fixed it all, now run_tests.sh runs flawlessly.
See attachment for an updated patch.
I did leave in some comments with regard to why the vni parameter is accepted, but these can be removed of course.

According RFC7432, "7.3.  Inclusive Multicast Ethernet Tag Route" has not vni
field. We should not add vni attribute.
I guess Cisco NX-OS send vni value as ethernet_tag_id, because Cisco NX-OS
provides "6.1.  VLAN-Based Service Interface", I guess.

That's what I thought at first, but the "Ethernet Tag ID" field of the EvpnInclusiveMulticastEthernetTagNLRI packet remains 0. The 'short' answer, see:
  https://tools.ietf.org/html/rfc7432#section-11.2
  https://tools.ietf.org/html/rfc7432#section-12.2
I read through the RFC's and the Ryu code plus I experimented a lot, including sniffing the traffic. The sniff also shows a Path Attribute PMSI_TUNNEL_ATTRIBUTE with a bogus MPLS Label Stack (644), the VNI is incoded in the MPLS LABEL (e.g. 10310644). i.e. the VNI gets passed as an RFC 6514 MPLS Label in the PathAttribute BGP_ATTR_TYEP_PMSI_TUNNEL_ATTRIBUTE.
See class BGPPathAttributePmsiTunnel in ryu/lib/packet/bgp.py
Most of the code was already there, I justed made it possible to pass it through to the path attribute :-)

We already add ip_addr_len check for the case with empty ip_addr at the following.
Is this not enough?
  https://github.com/osrg/ryu/blob/master/ryu/lib/packet/bgp.py#L1684

Without my changes, passing ip_addr=None fails, e.g. :

speaker.evpn_prefix_add(
    route_type=EVPN_MAC_IP_ADV_ROUTE,
    tunnel_type=TUNNEL_TYPE_VXLAN,
    route_dist=evpn_route_dist,
    ethernet_tag_id=0,
    mac_addr=evpn_mac,
    ip_addr=None,
    next_hop=loopback_IPv4,
    vni=0,
)

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/api/base.py", line 205, in call
    return call(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/api/base.py", line 169, in wrapped_fun
    validator(opt_value)
File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/api/prefix.py", line 196, in is_valid_ip_addr
    conf_value=addr)
ConfigValueError: 200.4 - Incorrect Value for configuration: ip_addr

Traceback (most recent call last):
  File "./bgp-ryu.py", line 198, in <module>
    bgp_speaker = myBGP()
  File "./bgp-ryu.py", line 51, in __init__
    self.start_BGP()
  File "./bgp-ryu.py", line 191, in start_BGP
    vni=0,
File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/bgpspeaker.py", line 671, in evpn_prefix_add
    call(func_name, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/api/base.py", line 208, in call
    raise r
ryu.services.protocols.bgp.rtconf.base.ConfigValueError: 200.4 - Incorrect Value for configuration: ip_addr


Regards,
Albert
diff -uprN ryu-git_20170126_1030CET/ryu/lib/packet/bgp.py ryu-AJS/ryu/lib/packet/bgp.py
--- ryu-git_20170126_1030CET/ryu/lib/packet/bgp.py	2017-01-26 10:31:23.308450201 +0100
+++ ryu-AJS/ryu/lib/packet/bgp.py	2017-01-27 11:23:09.553398529 +0100
@@ -1748,7 +1748,8 @@ class EvpnInclusiveMulticastEthernetTagN
     }
 
     def __init__(self, route_dist, ethernet_tag_id, ip_addr,
-                 ip_addr_len=None, type_=None, length=None):
+                 ip_addr_len=None, type_=None, length=None,
+                 vni=None):  # vni needed in BGPPathAttributePmsiTunnel (RFC 6514 MPLS Label) for interoperability
         super(EvpnInclusiveMulticastEthernetTagNLRI,
               self).__init__(type_, length)
         self.route_dist = route_dist
diff -uprN ryu-git_20170126_1030CET/ryu/services/protocols/bgp/api/prefix.py ryu-AJS/ryu/services/protocols/bgp/api/prefix.py
--- ryu-git_20170126_1030CET/ryu/services/protocols/bgp/api/prefix.py	2017-01-26 10:31:23.328450310 +0100
+++ ryu-AJS/ryu/services/protocols/bgp/api/prefix.py	2017-01-27 10:12:09.802147721 +0100
@@ -188,7 +188,8 @@ def is_valid_mac_addr(addr):
 
 @validate(name=IP_ADDR)
 def is_valid_ip_addr(addr):
-    if not (validation.is_valid_ipv4(addr)
+    if not (addr is None  # allow empty ip_addr (len 0), e.g. L2VPN MAC advertisement Cisco NX-OS
+            or validation.is_valid_ipv4(addr)
             or validation.is_valid_ipv6(addr)):
         raise ConfigValueError(conf_name=IP_ADDR,
                                conf_value=addr)
diff -uprN ryu-git_20170126_1030CET/ryu/services/protocols/bgp/bgpspeaker.py ryu-AJS/ryu/services/protocols/bgp/bgpspeaker.py
--- ryu-git_20170126_1030CET/ryu/services/protocols/bgp/bgpspeaker.py	2017-01-26 10:31:23.328450310 +0100
+++ ryu-AJS/ryu/services/protocols/bgp/bgpspeaker.py	2017-01-27 10:11:47.070023675 +0100
@@ -643,6 +643,8 @@ class BGPSpeaker(object):
                     PMSI_TYPE_NO_TUNNEL_INFO,
                     PMSI_TYPE_INGRESS_REP]:
                 kwargs[PMSI_TUNNEL_TYPE] = pmsi_tunnel_type
+                if vni is not None:
+                    kwargs[EVPN_VNI] = vni
             elif pmsi_tunnel_type is not None:
                 raise ValueError('Unsupported PMSI tunnel type: %s' %
                                  pmsi_tunnel_type)
diff -uprN ryu-git_20170126_1030CET/ryu/services/protocols/bgp/info_base/vrf.py ryu-AJS/ryu/services/protocols/bgp/info_base/vrf.py
--- ryu-git_20170126_1030CET/ryu/services/protocols/bgp/info_base/vrf.py	2017-01-26 10:31:23.332450332 +0100
+++ ryu-AJS/ryu/services/protocols/bgp/info_base/vrf.py	2017-01-27 10:11:33.153947695 +0100
@@ -52,6 +52,8 @@ from ryu.services.protocols.bgp.utils.st
 from ryu.services.protocols.bgp.utils.stats import RESOURCE_ID
 from ryu.services.protocols.bgp.utils.stats import RESOURCE_NAME
 
+from ryu.services.protocols.bgp.api.base import EVPN_VNI
+
 LOG = logging.getLogger('bgpspeaker.info_base.vrf')
 
 
@@ -326,10 +328,12 @@ class VrfTable(Table):
                         tunnel_endpoint_ip=self._core_service.router_id)
                 else:  # pmsi_tunnel_type == PMSI_TYPE_NO_TUNNEL_INFO
                     tunnel_id = None
+                vni = kwargs.get(EVPN_VNI, None)
                 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=vni)
 
         puid = self.VRF_PATH_CLASS.create_puid(
             vrf_conf.route_dist, nlri.prefix)
------------------------------------------------------------------------------
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