summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-05-09 16:09:58 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-05-12 09:48:09 +0900
commit0b9bc03e6c3a543ad9a4f644b15ace1d777deefb (patch)
tree70641aa0e59eb37fa228071732359b2135522ea2
parent12b809f5f7a19149f0ef6ced8ababf69e72ae0ad (diff)
BGPSpeaker/info_base: Add tables for L2VPN Flow Spec
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/services/protocols/bgp/info_base/l2vpnfs.py66
-rw-r--r--ryu/services/protocols/bgp/info_base/vrfl2vpnfs.py58
2 files changed, 124 insertions, 0 deletions
diff --git a/ryu/services/protocols/bgp/info_base/l2vpnfs.py b/ryu/services/protocols/bgp/info_base/l2vpnfs.py
new file mode 100644
index 00000000..d612cc74
--- /dev/null
+++ b/ryu/services/protocols/bgp/info_base/l2vpnfs.py
@@ -0,0 +1,66 @@
+# Copyright (C) 2017 Nippon Telegraph and Telephone Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+ Defines data types and models required specifically for
+ L2VPN Flow Specification support.
+"""
+
+import logging
+
+from ryu.lib.packet.bgp import FlowSpecL2VPNNLRI
+from ryu.lib.packet.bgp import RF_L2VPN_FLOWSPEC
+
+from ryu.services.protocols.bgp.info_base.vpn import VpnDest
+from ryu.services.protocols.bgp.info_base.vpn import VpnPath
+from ryu.services.protocols.bgp.info_base.vpn import VpnTable
+
+LOG = logging.getLogger('bgpspeaker.info_base.l2vpnfs')
+
+
+class L2VPNFlowSpecDest(VpnDest):
+ """L2VPN Flow Specification Destination
+
+ Store Flow Specification Paths.
+ """
+ ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
+
+
+class L2VPNFlowSpecTable(VpnTable):
+ """Global table to store L2VPN Flow Specification routing information.
+
+ Uses `L2VPNFlowSpecDest` to store destination information for each known
+ Flow Specification paths.
+ """
+ ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
+ VPN_DEST_CLASS = L2VPNFlowSpecDest
+
+
+class L2VPNFlowSpecPath(VpnPath):
+ """Represents a way of reaching an L2VPN Flow Specification destination."""
+ ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
+ VRF_PATH_CLASS = None # defined in init - anti cyclic import hack
+ NLRI_CLASS = FlowSpecL2VPNNLRI
+
+ def __init__(self, *args, **kwargs):
+ # Set dummy IP address.
+ kwargs['nexthop'] = '0.0.0.0'
+ super(L2VPNFlowSpecPath, self).__init__(*args, **kwargs)
+ from ryu.services.protocols.bgp.info_base.vrfl2vpnfs import(
+ L2vpnFlowSpecPath)
+ self.VRF_PATH_CLASS = L2vpnFlowSpecPath
+ # Because the L2VPN Flow Specification does not require nexthop,
+ # initialize with None.
+ self._nexthop = None
diff --git a/ryu/services/protocols/bgp/info_base/vrfl2vpnfs.py b/ryu/services/protocols/bgp/info_base/vrfl2vpnfs.py
new file mode 100644
index 00000000..8e2c545a
--- /dev/null
+++ b/ryu/services/protocols/bgp/info_base/vrfl2vpnfs.py
@@ -0,0 +1,58 @@
+# Copyright (C) 2017 Nippon Telegraph and Telephone Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+ Defines data types and models required specifically
+ for L2VPN support.
+ Represents data structures for VRF not VPN/global.
+ (Inside VRF you have L2VPN Flow Specification prefixes
+ and inside VPN you have L2VPN Flow Specification prefixes)
+"""
+
+import logging
+
+from ryu.lib.packet.bgp import RF_L2VPN_FLOWSPEC
+from ryu.lib.packet.bgp import FlowSpecL2VPNNLRI
+
+from ryu.services.protocols.bgp.info_base.l2vpnfs import L2VPNFlowSpecPath
+from ryu.services.protocols.bgp.info_base.vrffs import VRFFlowSpecDest
+from ryu.services.protocols.bgp.info_base.vrffs import VRFFlowSpecPath
+from ryu.services.protocols.bgp.info_base.vrffs import VRFFlowSpecTable
+
+LOG = logging.getLogger('bgpspeaker.info_base.vrfl2vpnfs')
+
+
+class L2vpnFlowSpecPath(VRFFlowSpecPath):
+ """Represents a way of reaching an IP destination with
+ a L2VPN Flow Specification.
+ """
+ ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
+ VPN_PATH_CLASS = L2VPNFlowSpecPath
+ VPN_NLRI_CLASS = FlowSpecL2VPNNLRI
+
+
+class L2vpnFlowSpecDest(VRFFlowSpecDest):
+ ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
+
+
+class L2vpnFlowSpecTable(VRFFlowSpecTable):
+ """Virtual Routing and Forwarding information base
+ for L2VPN Flow Specification.
+ """
+ ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
+ VPN_ROUTE_FAMILY = RF_L2VPN_FLOWSPEC
+ NLRI_CLASS = FlowSpecL2VPNNLRI
+ VRF_PATH_CLASS = L2vpnFlowSpecPath
+ VRF_DEST_CLASS = L2vpnFlowSpecDest