mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-11 15:26:11 +02:00
BGPSpeaker: Enable to set capability for IPv6
This patch enables BGPSpeaker to set the capability for IPv6 unicast address family. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
4ed018df09
commit
e760300e93
@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
from ryu.services.protocols.bgp.bgpspeaker import RF_VPN_V4
|
||||
from ryu.services.protocols.bgp.bgpspeaker import RF_VPN_V6
|
||||
from ryu.services.protocols.bgp.bgpspeaker import RF_L2_EVPN
|
||||
from ryu.services.protocols.bgp.bgpspeaker import EVPN_MAC_IP_ADV_ROUTE
|
||||
from ryu.services.protocols.bgp.bgpspeaker import TUNNEL_TYPE_VXLAN
|
||||
@ -25,11 +26,13 @@ BGP = {
|
||||
'address': '172.17.0.2',
|
||||
'remote_as': 65002,
|
||||
'enable_ipv4': True,
|
||||
'enable_ipv6': True,
|
||||
'enable_vpnv4': True,
|
||||
'enable_vpnv6': True,
|
||||
},
|
||||
{
|
||||
'address': '172.17.0.3',
|
||||
'remote_as': 65000,
|
||||
'remote_as': 65001,
|
||||
'enable_evpn': True,
|
||||
},
|
||||
],
|
||||
@ -38,16 +41,25 @@ BGP = {
|
||||
# The parameters for each VRF table are the same as the arguments of
|
||||
# BGPSpeaker.vrf_add() method.
|
||||
'vrfs': [
|
||||
# Example of VRF for IPv4
|
||||
{
|
||||
'route_dist': '65001:100',
|
||||
'import_rts': ['65001:100'],
|
||||
'export_rts': ['65001:100'],
|
||||
'route_family': RF_VPN_V4,
|
||||
},
|
||||
# Example of VRF for IPv6
|
||||
{
|
||||
'route_dist': '65000:200',
|
||||
'import_rts': ['65000:200'],
|
||||
'export_rts': ['65000:200'],
|
||||
'route_dist': '65001:150',
|
||||
'import_rts': ['65001:150'],
|
||||
'export_rts': ['65001:150'],
|
||||
'route_family': RF_VPN_V6,
|
||||
},
|
||||
# Example of VRF for EVPN
|
||||
{
|
||||
'route_dist': '65001:200',
|
||||
'import_rts': ['65001:200'],
|
||||
'export_rts': ['65001:200'],
|
||||
'route_family': RF_L2_EVPN,
|
||||
},
|
||||
],
|
||||
@ -66,10 +78,20 @@ BGP = {
|
||||
'next_hop': '172.17.0.1',
|
||||
'route_dist': '65001:100',
|
||||
},
|
||||
# Example of IPv6 prefix
|
||||
{
|
||||
'prefix': '2001:db8:1::/64',
|
||||
},
|
||||
# Example of VPNv6 prefix
|
||||
{
|
||||
'prefix': '2001:db8:2::/64',
|
||||
'next_hop': '172.17.0.1',
|
||||
'route_dist': '65001:150',
|
||||
},
|
||||
# Example of EVPN prefix
|
||||
{
|
||||
'route_type': EVPN_MAC_IP_ADV_ROUTE,
|
||||
'route_dist': '65000:200',
|
||||
'route_dist': '65001:200',
|
||||
'esi': 0,
|
||||
'ethernet_tag_id': 0,
|
||||
'tunnel_type': TUNNEL_TYPE_VXLAN,
|
||||
|
||||
@ -64,6 +64,7 @@ from ryu.services.protocols.bgp.rtconf.base import CAP_FOUR_OCTET_AS_NUMBER
|
||||
from ryu.services.protocols.bgp.rtconf.base import MULTI_EXIT_DISC
|
||||
from ryu.services.protocols.bgp.rtconf.base import SITE_OF_ORIGINS
|
||||
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_IPV4
|
||||
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_IPV6
|
||||
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_VPNV4
|
||||
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_VPNV6
|
||||
from ryu.services.protocols.bgp.rtconf.neighbors import DEFAULT_CAP_MBGP_EVPN
|
||||
@ -289,6 +290,7 @@ class BGPSpeaker(object):
|
||||
|
||||
def neighbor_add(self, address, remote_as,
|
||||
enable_ipv4=DEFAULT_CAP_MBGP_IPV4,
|
||||
enable_ipv6=DEFAULT_CAP_MBGP_IPV6,
|
||||
enable_vpnv4=DEFAULT_CAP_MBGP_VPNV4,
|
||||
enable_vpnv6=DEFAULT_CAP_MBGP_VPNV6,
|
||||
enable_evpn=DEFAULT_CAP_MBGP_EVPN,
|
||||
@ -313,6 +315,9 @@ class BGPSpeaker(object):
|
||||
``enable_ipv4`` enables IPv4 address family for this
|
||||
neighbor. The default is True.
|
||||
|
||||
``enable_ipv6`` enables IPv6 address family for this
|
||||
neighbor. The default is False.
|
||||
|
||||
``enable_vpnv4`` enables VPNv4 address family for this
|
||||
neighbor. The default is False.
|
||||
|
||||
@ -371,23 +376,12 @@ class BGPSpeaker(object):
|
||||
CONNECT_MODE: connect_mode,
|
||||
CAP_ENHANCED_REFRESH: enable_enhanced_refresh,
|
||||
CAP_FOUR_OCTET_AS_NUMBER: enable_four_octet_as_number,
|
||||
CAP_MBGP_IPV4: enable_ipv4,
|
||||
CAP_MBGP_IPV6: enable_ipv6,
|
||||
CAP_MBGP_VPNV4: enable_vpnv4,
|
||||
CAP_MBGP_VPNV6: enable_vpnv6,
|
||||
CAP_MBGP_EVPN: enable_evpn,
|
||||
}
|
||||
# v6 advertisement is available with only v6 peering
|
||||
if netaddr.valid_ipv4(address):
|
||||
bgp_neighbor[CAP_MBGP_IPV4] = enable_ipv4
|
||||
bgp_neighbor[CAP_MBGP_IPV6] = False
|
||||
bgp_neighbor[CAP_MBGP_VPNV4] = enable_vpnv4
|
||||
bgp_neighbor[CAP_MBGP_VPNV6] = enable_vpnv6
|
||||
bgp_neighbor[CAP_MBGP_EVPN] = enable_evpn
|
||||
elif netaddr.valid_ipv6(address):
|
||||
bgp_neighbor[CAP_MBGP_IPV4] = False
|
||||
bgp_neighbor[CAP_MBGP_IPV6] = True
|
||||
bgp_neighbor[CAP_MBGP_VPNV4] = False
|
||||
bgp_neighbor[CAP_MBGP_VPNV6] = False
|
||||
bgp_neighbor[CAP_MBGP_EVPN] = enable_evpn
|
||||
else:
|
||||
# FIXME: should raise an exception
|
||||
pass
|
||||
|
||||
if multi_exit_disc:
|
||||
bgp_neighbor[MULTI_EXIT_DISC] = multi_exit_disc
|
||||
|
||||
@ -18,8 +18,6 @@ from __future__ import absolute_import
|
||||
import logging
|
||||
import time
|
||||
|
||||
import netaddr
|
||||
|
||||
from . import docker_base as base
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -61,9 +59,10 @@ class RyuBGPContainer(base.BGPContainer):
|
||||
n_addr = info['neigh_addr'].split('/')[0]
|
||||
c << " 'address': '%s'," % n_addr
|
||||
c << " 'remote_as': %s," % str(peer.asn)
|
||||
if netaddr.IPNetwork(n_addr).version == 4:
|
||||
c << " 'enable_ipv4': True,"
|
||||
c << " 'enable_vpnv4': True,"
|
||||
c << " 'enable_ipv4': True,"
|
||||
c << " 'enable_ipv6': True,"
|
||||
c << " 'enable_vpnv4': True,"
|
||||
c << " 'enable_vpnv6': True,"
|
||||
c << ' },'
|
||||
c << ' ],'
|
||||
c << " 'routes': ["
|
||||
@ -201,7 +200,7 @@ class RyuBGPContainer(base.BGPContainer):
|
||||
time.sleep(1)
|
||||
return result
|
||||
|
||||
def run(self, wait=False):
|
||||
def run(self, wait=False, w_time=WAIT_FOR_BOOT):
|
||||
w_time = super(RyuBGPContainer,
|
||||
self).run(wait=wait, w_time=self.WAIT_FOR_BOOT)
|
||||
return w_time
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user