Hey Iwase,
BTW, we are using Git for indexing versions.
Would you send patches in the git format?
Sure, I prefer git anyway :) I diff-ed it because I consulted:
https://github.com/osrg/ryu/blob/master/CONTRIBUTING.rst
and the linked:
https://kernel.org/doc/html/latest/process/submitting-patches.html
(btw your link to kernel.org in CONTRIBUTING.rst is out of date)
Granted I did forget the pep8 step :( Ran "./run_tests.sh -p" this
time. Which btw doesn't complain about lines being too long ?! Fixed
these by hand tho.
Anyway, maybe CONTRIBUTING.rst should be updated with the excellent
howto you sent me ?
e.g.)
$ git clone https://github.com/osrg/ryu.git
$ cd ryu
Create a branch, if needed.
$ git checkout -b <your branch>
<... some modifications ...>
$ git add <modified files>
$ git commit -s
Format patches. ("N" means the number of commits to be included)
$ git format-patch HEAD~N
Then, you can use *.patch for submitting!
By Mailer or "git send-email" command like:
$ git send-email --to="[email protected]" *.patch
I attached the patch created like the above.
Could you review and test my patch?
FYI, if you can use Git, applying patches is easy:
e.g.)
Save *.patch files and
$ git am *.patch
I'll check your patch.
In the meantime, here is a run-test-ed and git version of my patch.
What are your thoughts on checking a maximum number of local ASN
occurances in the path instead of this boolean toggle ?
Any preferences there ?
Cheers,
Albert
>From 55db3d4b9d7a352b3ce6c33c6dfbd54ccfb9204d Mon Sep 17 00:00:00 2001
From: Albert Siersema <[email protected]>
Date: Thu, 2 Feb 2017 11:30:46 +0100
Subject: [PATCH] BGP: allow local ASN in path
The use case for this patch is auto RD/RT and
simplified leaf/spine architectures, see below.
Cisco/Juniper/Cumulus and undoubtedly more vendors offer a
simplification/generalization of the EVPN configuration by
not having to specify RD/RT's, e.g. in Cisco NX-OS syntax:
evpn
vni 10311 l2
rd auto
route-target import auto
route-target export auto
To further simplify configuration (and facilitate auto RD).
All physical leaf switches share the same ASN (e.g. 65511).
All spine switches in turn share an ASN as well (e.g. 65510).
This means an AS path has to be accepted with the local ASN in it.
To this end, Cisco includes an 'allowas-in' configuration statement.
See: http://www.cisco.com/c/en/us/products/collateral/switches/nexus-9000-series-switches/guide-c07-734107.html
search for "MP-eBGP Design with VTEP Leaf Nodes in the Same BGP Autonomous System"
Signed-off-by: Albert Siersema <[email protected]>
---
ryu/services/protocols/bgp/bgpspeaker.py | 5 ++++-
ryu/services/protocols/bgp/peer.py | 20 ++++++++++++++------
ryu/services/protocols/bgp/rtconf/common.py | 15 ++++++++++++++-
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/ryu/services/protocols/bgp/bgpspeaker.py b/ryu/services/protocols/bgp/bgpspeaker.py
index 6a0025c..74361dd 100644
--- a/ryu/services/protocols/bgp/bgpspeaker.py
+++ b/ryu/services/protocols/bgp/bgpspeaker.py
@@ -60,6 +60,7 @@ from ryu.services.protocols.bgp.rtconf.common import DEFAULT_BGP_SERVER_PORT
from ryu.services.protocols.bgp.rtconf.common import (
DEFAULT_REFRESH_MAX_EOR_TIME, DEFAULT_REFRESH_STALEPATH_TIME)
from ryu.services.protocols.bgp.rtconf.common import DEFAULT_LABEL_RANGE
+from ryu.services.protocols.bgp.rtconf.common import ALLOW_LOCAL_AS_IN
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 LABEL_RANGE
@@ -174,7 +175,8 @@ class BGPSpeaker(object):
peer_up_handler=None,
ssh_console=False,
ssh_port=None, ssh_host=None, ssh_host_key=None,
- label_range=DEFAULT_LABEL_RANGE):
+ label_range=DEFAULT_LABEL_RANGE.
+ allow_local_as_in=False):
"""Create a new BGPSpeaker object with as_number and router_id to
listen on bgp_server_port.
@@ -232,6 +234,7 @@ class BGPSpeaker(object):
REFRESH_STALEPATH_TIME: refresh_stalepath_time,
REFRESH_MAX_EOR_TIME: refresh_max_eor_time,
LABEL_RANGE: label_range,
+ ALLOW_LOCAL_AS_IN: allow_local_as_in,
}
self._core_start(settings)
self._init_signal_listeners()
diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py
index 8bf96d6..95b6c37 100644
--- a/ryu/services/protocols/bgp/peer.py
+++ b/ryu/services/protocols/bgp/peer.py
@@ -1623,9 +1623,13 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
aspath = umsg_pattrs.get(BGP_ATTR_TYPE_AS_PATH)
# Check if AS_PATH has loops.
if aspath.has_local_as(self.local_as):
- LOG.error('Update message AS_PATH has loops. Ignoring this'
- ' UPDATE. %s', update_msg)
- return
+ if self._common_conf.allow_local_as_in:
+ LOG.info('Allowing update message AS_PATH with own AS {}'.
+ format(update_msg))
+ else:
+ LOG.error('Update message AS_PATH has loops. Ignoring this'
+ ' UPDATE. %s', update_msg)
+ return
next_hop = update_msg.get_path_attr(BGP_ATTR_TYPE_NEXT_HOP).value
# Nothing to do if we do not have any new NLRIs in this message.
@@ -1751,9 +1755,13 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
aspath = umsg_pattrs.get(BGP_ATTR_TYPE_AS_PATH)
# Check if AS_PATH has loops.
if aspath.has_local_as(self.local_as):
- LOG.error('Update message AS_PATH has loops. Ignoring this'
- ' UPDATE. %s', update_msg)
- return
+ if self._common_conf.allow_local_as_in:
+ LOG.info('Allowing update message AS_PATH with own AS {}'.
+ format(update_msg))
+ else:
+ LOG.error('Update message AS_PATH has loops. Ignoring this'
+ ' UPDATE. %s', update_msg)
+ return
if msg_rf in (RF_IPv4_VPN, RF_IPv6_VPN):
# Check if we have Extended Communities Attribute.
diff --git a/ryu/services/protocols/bgp/rtconf/common.py b/ryu/services/protocols/bgp/rtconf/common.py
index acf4634..0373c15 100644
--- a/ryu/services/protocols/bgp/rtconf/common.py
+++ b/ryu/services/protocols/bgp/rtconf/common.py
@@ -40,6 +40,7 @@ ROUTER_ID = 'router_id'
LABEL_RANGE = 'label_range'
LABEL_RANGE_MAX = 'max'
LABEL_RANGE_MIN = 'min'
+ALLOW_LOCAL_AS_IN = 'allow_local_as_in'
# Configuration that can be set at global level as well as per context
# (session/vrf) level
@@ -80,6 +81,11 @@ DEFAULT_MED = 0
DEFAULT_MAX_PATH_EXT_RTFILTER_ALL = True
+@validate(name=ALLOW_LOCAL_AS_IN)
+def validate_allow_local_as_in(allowit):
+ return allowit
+
+
@validate(name=LOCAL_AS)
def validate_local_as(asn):
if asn is None:
@@ -208,13 +214,16 @@ class CommonConf(BaseConf):
LABEL_RANGE, BGP_SERVER_PORT,
TCP_CONN_TIMEOUT,
BGP_CONN_RETRY_TIME,
- MAX_PATH_EXT_RTFILTER_ALL])
+ MAX_PATH_EXT_RTFILTER_ALL,
+ ALLOW_LOCAL_AS_IN])
def __init__(self, **kwargs):
super(CommonConf, self).__init__(**kwargs)
def _init_opt_settings(self, **kwargs):
super(CommonConf, self)._init_opt_settings(**kwargs)
+ self._settings[ALLOW_LOCAL_AS_IN] = compute_optional_conf(
+ ALLOW_LOCAL_AS_IN, False, **kwargs)
self._settings[LABEL_RANGE] = compute_optional_conf(
LABEL_RANGE, DEFAULT_LABEL_RANGE, **kwargs)
self._settings[REFRESH_STALEPATH_TIME] = compute_optional_conf(
@@ -236,6 +245,10 @@ class CommonConf(BaseConf):
# =========================================================================
@property
+ def allow_local_as_in(self):
+ return self._settings[ALLOW_LOCAL_AS_IN]
+
+ @property
def local_as(self):
return self._settings[LOCAL_AS]
--
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