backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / services / protocols / bgp / bgp_sample_conf.py
1
2 from __future__ import absolute_import
3
4 import os
5
6 from ryu.services.protocols.bgp.bgpspeaker import RF_VPN_V4
7 from ryu.services.protocols.bgp.bgpspeaker import RF_VPN_V6
8 from ryu.services.protocols.bgp.bgpspeaker import RF_L2_EVPN
9 from ryu.services.protocols.bgp.bgpspeaker import RF_VPNV4_FLOWSPEC
10 from ryu.services.protocols.bgp.bgpspeaker import RF_VPNV6_FLOWSPEC
11 from ryu.services.protocols.bgp.bgpspeaker import RF_L2VPN_FLOWSPEC
12 from ryu.services.protocols.bgp.bgpspeaker import EVPN_MAX_ET
13 from ryu.services.protocols.bgp.bgpspeaker import ESI_TYPE_LACP
14 from ryu.services.protocols.bgp.bgpspeaker import ESI_TYPE_MAC_BASED
15 from ryu.services.protocols.bgp.bgpspeaker import EVPN_ETH_AUTO_DISCOVERY
16 from ryu.services.protocols.bgp.bgpspeaker import EVPN_MAC_IP_ADV_ROUTE
17 from ryu.services.protocols.bgp.bgpspeaker import TUNNEL_TYPE_VXLAN
18 from ryu.services.protocols.bgp.bgpspeaker import EVPN_MULTICAST_ETAG_ROUTE
19 from ryu.services.protocols.bgp.bgpspeaker import EVPN_ETH_SEGMENT
20 from ryu.services.protocols.bgp.bgpspeaker import EVPN_IP_PREFIX_ROUTE
21 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_IPV4
22 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_IPV6
23 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_VPNV4
24 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_VPNV6
25 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_L2VPN
26 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_TA_SAMPLE
27 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_TA_TERMINAL
28 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_VLAN_POP
29 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_VLAN_PUSH
30 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_VLAN_SWAP
31 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_VLAN_RW_INNER
32 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_VLAN_RW_OUTER
33 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_TPID_TI
34 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_TPID_TO
35 from ryu.services.protocols.bgp.bgpspeaker import REDUNDANCY_MODE_SINGLE_ACTIVE
36
37 # =============================================================================
38 # BGP configuration.
39 # =============================================================================
40 BGP = {
41
42     # AS number for this BGP instance.
43     'local_as': 65001,
44
45     # BGP Router ID.
46     'router_id': '172.17.0.1',
47
48     # Default local preference
49     'local_pref': 100,
50
51     # List of TCP listen host addresses.
52     'bgp_server_hosts': ['0.0.0.0', '::'],
53
54     # List of BGP neighbors.
55     # The parameters for each neighbor are the same as the arguments of
56     # BGPSpeaker.neighbor_add() method.
57     'neighbors': [
58         {
59             'address': '172.17.0.2',
60             'remote_as': 65002,
61             'enable_ipv4': True,
62             'enable_ipv6': True,
63             'enable_vpnv4': True,
64             'enable_vpnv6': True,
65         },
66         {
67             'address': '172.17.0.3',
68             'remote_as': 65001,
69             'enable_evpn': True,
70         },
71         {
72             'address': '172.17.0.4',
73             'remote_as': 65001,
74             'enable_ipv4fs': True,
75             'enable_ipv6fs': True,
76             'enable_vpnv4fs': True,
77             'enable_vpnv6fs': True,
78             'enable_l2vpnfs': True,
79         },
80     ],
81
82     # List of BGP VRF tables.
83     # The parameters for each VRF table are the same as the arguments of
84     # BGPSpeaker.vrf_add() method.
85     'vrfs': [
86         # Example of VRF for IPv4
87         {
88             'route_dist': '65001:100',
89             'import_rts': ['65001:100'],
90             'export_rts': ['65001:100'],
91             'route_family': RF_VPN_V4,
92         },
93         # Example of VRF for IPv6
94         {
95             'route_dist': '65001:150',
96             'import_rts': ['65001:150'],
97             'export_rts': ['65001:150'],
98             'route_family': RF_VPN_V6,
99         },
100         # Example of VRF for EVPN
101         {
102             'route_dist': '65001:200',
103             'import_rts': ['65001:200'],
104             'export_rts': ['65001:200'],
105             'route_family': RF_L2_EVPN,
106         },
107         # Example of VRF for IPv4 FlowSpec
108         {
109             'route_dist': '65001:250',
110             'import_rts': ['65001:250'],
111             'export_rts': ['65001:250'],
112             'route_family': RF_VPNV4_FLOWSPEC,
113         },
114         # Example of VRF for IPv6 FlowSpec
115         {
116             'route_dist': '65001:300',
117             'import_rts': ['65001:300'],
118             'export_rts': ['65001:300'],
119             'route_family': RF_VPNV6_FLOWSPEC,
120         },
121         # Example of VRF for L2VPN FlowSpec
122         {
123             'route_dist': '65001:350',
124             'import_rts': ['65001:350'],
125             'export_rts': ['65001:350'],
126             'route_family': RF_L2VPN_FLOWSPEC,
127         },
128     ],
129
130     # List of BGP routes.
131     # The parameters for each route are the same as the arguments of
132     # the following methods:
133     # - BGPSpeaker.prefix_add()
134     # - BGPSpeaker.evpn_prefix_add()
135     # - BGPSpeaker.flowspec_prefix_add()
136     'routes': [
137         # Example of IPv4 prefix
138         {
139             'prefix': '10.10.1.0/24',
140         },
141         # Example of VPNv4 prefix
142         {
143             'prefix': '10.20.1.0/24',
144             'next_hop': '172.17.0.1',
145             'route_dist': '65001:100',
146         },
147         # Example of IPv6 prefix
148         {
149             'prefix': '2001:db8:1::/64',
150         },
151         # Example of VPNv6 prefix
152         {
153             'prefix': '2001:db8:2::/64',
154             'next_hop': '172.17.0.1',
155             'route_dist': '65001:150',
156         },
157         # Example of EVPN prefix
158         {
159             'route_type': EVPN_ETH_AUTO_DISCOVERY,
160             'route_dist': '65001:200',
161             'esi': {
162                 'type': ESI_TYPE_LACP,
163                 'mac_addr': 'aa:bb:cc:dd:ee:ff',
164                 'port_key': 100,
165             },
166             'ethernet_tag_id': EVPN_MAX_ET,
167             'redundancy_mode': REDUNDANCY_MODE_SINGLE_ACTIVE,
168         },
169         {
170             'route_type': EVPN_MAC_IP_ADV_ROUTE,
171             'route_dist': '65001:200',
172             'esi': 0,
173             'ethernet_tag_id': 0,
174             'tunnel_type': TUNNEL_TYPE_VXLAN,
175             'vni': 200,
176             'mac_addr': 'aa:bb:cc:dd:ee:ff',
177             'ip_addr': '10.30.1.1',
178             'next_hop': '172.17.0.1',
179         },
180         {
181             'route_type': EVPN_MULTICAST_ETAG_ROUTE,
182             'route_dist': '65001:200',
183             'esi': 0,
184             'ethernet_tag_id': 0,
185             'ip_addr': '10.40.1.1',
186         },
187         {
188             'route_type': EVPN_ETH_SEGMENT,
189             'route_dist': '65001:200',
190             'esi': {
191                 'type': ESI_TYPE_MAC_BASED,
192                 'mac_addr': 'aa:bb:cc:dd:ee:ff',
193                 'local_disc': 100,
194             },
195             'ip_addr': '172.17.0.1',
196         },
197         {
198             'route_type': EVPN_IP_PREFIX_ROUTE,
199             'route_dist': '65001:200',
200             'esi': 0,
201             'ethernet_tag_id': 0,
202             'ip_prefix': '10.50.1.0/24',
203             'gw_ip_addr': '172.16.0.1',
204         },
205         # Example of Flow Specification IPv4 prefix
206         {
207             'flowspec_family': FLOWSPEC_FAMILY_IPV4,
208             'rules': {
209                 'dst_prefix': '10.60.1.0/24',
210                 'src_prefix': '172.17.0.0/24',
211                 'ip_proto': 6,
212                 'port': '80 | 8000',
213                 'dst_port': '>9000 & <9050',
214                 'src_port': '>=8500 & <=9000',
215                 'icmp_type': 0,
216                 'icmp_code': 6,
217                 'tcp_flags': 'SYN+ACK & !=URGENT',
218                 'packet_len': 1000,
219                 'dscp': '22 | 24',
220                 'fragment': 'LF | ==FF',
221             },
222             'actions': {
223                 'traffic_rate': {
224                     'as_number': 0,
225                     'rate_info': 100.0,
226                 },
227                 'traffic_action': {
228                     'action': FLOWSPEC_TA_SAMPLE | FLOWSPEC_TA_TERMINAL,
229                 },
230                 'redirect': {
231                     'as_number': 10,
232                     'local_administrator': 100,
233                 },
234                 'traffic_marking': {
235                     'dscp': 24,
236                 }
237             },
238         },
239         # Example of Flow Specification VPNv4 prefix
240         {
241             'flowspec_family': FLOWSPEC_FAMILY_VPNV4,
242             'route_dist': '65001:250',
243             'rules': {
244                 'dst_prefix': '10.70.1.0/24',
245                 'src_prefix': '172.18.0.0/24',
246                 'ip_proto': 6,
247                 'port': '80 | 8000',
248                 'dst_port': '>9000 & <9050',
249                 'src_port': '>=8500 & <=9000',
250                 'icmp_type': 0,
251                 'icmp_code': 6,
252                 'tcp_flags': 'SYN+ACK & !=URGENT',
253                 'packet_len': 1000,
254                 'dscp': '22 | 24',
255                 'fragment': 'LF | ==FF',
256             },
257             'actions': {
258                 'traffic_rate': {
259                     'as_number': 0,
260                     'rate_info': 100.0,
261                 },
262                 'traffic_action': {
263                     'action': FLOWSPEC_TA_SAMPLE | FLOWSPEC_TA_TERMINAL,
264                 },
265                 'redirect': {
266                     'as_number': 10,
267                     'local_administrator': 100,
268                 },
269                 'traffic_marking': {
270                     'dscp': 24,
271                 }
272             },
273         },
274         # Example of Flow Specification IPv6 prefix
275         {
276             'flowspec_family': FLOWSPEC_FAMILY_IPV6,
277             'rules': {
278                 'dst_prefix': '2001::1/128/32',
279                 'src_prefix': '3001::2/128',
280                 'next_header': 6,
281                 'port': '80 | 8000',
282                 'dst_port': '>9000 & <9050',
283                 'src_port': '>=8500 & <=9000',
284                 'icmp_type': 0,
285                 'icmp_code': 6,
286                 'tcp_flags': 'SYN+ACK & !=URGENT',
287                 'packet_len': 1000,
288                 'dscp': '22 | 24',
289                 'fragment': 'LF | ==FF',
290                 'flow_label': 100,
291             },
292             'actions': {
293                 'traffic_rate': {
294                     'as_number': 0,
295                     'rate_info': 100.0,
296                 },
297                 'traffic_action': {
298                     'action': FLOWSPEC_TA_SAMPLE | FLOWSPEC_TA_TERMINAL,
299                 },
300                 'redirect': {
301                     'as_number': 10,
302                     'local_administrator': 100,
303                 },
304                 'traffic_marking': {
305                     'dscp': 24,
306                 }
307             },
308         },
309         # Example of Flow Specification VPNv6 prefix
310         {
311             'flowspec_family': FLOWSPEC_FAMILY_VPNV6,
312             'route_dist': '65001:300',
313             'rules': {
314                 'dst_prefix': '2001::1/128/32',
315                 'src_prefix': '3001::2/128',
316                 'next_header': 6,
317                 'port': '80 | 8000',
318                 'dst_port': '>9000 & <9050',
319                 'src_port': '>=8500 & <=9000',
320                 'icmp_type': 0,
321                 'icmp_code': 6,
322                 'tcp_flags': 'SYN+ACK & !=URGENT',
323                 'packet_len': 1000,
324                 'dscp': '22 | 24',
325                 'fragment': 'LF | ==FF',
326                 'flow_label': 100,
327             },
328             'actions': {
329                 'traffic_rate': {
330                     'as_number': 0,
331                     'rate_info': 100.0,
332                 },
333                 'traffic_action': {
334                     'action': FLOWSPEC_TA_SAMPLE | FLOWSPEC_TA_TERMINAL,
335                 },
336                 'redirect': {
337                     'as_number': 10,
338                     'local_administrator': 100,
339                 },
340                 'traffic_marking': {
341                     'dscp': 24,
342                 }
343             },
344         },
345         # Example of Flow Specification L2VPN prefix
346         {
347             'flowspec_family': FLOWSPEC_FAMILY_L2VPN,
348             'route_dist': '65001:350',
349             'rules': {
350                 'ether_type': 0x0800,
351                 'src_mac': '12:34:56:78:90:AB',
352                 'dst_mac': 'BE:EF:C0:FF:EE:DD',
353                 'llc_dsap': 0x42,
354                 'llc_ssap': 0x42,
355                 'llc_control': 100,
356                 'snap': 0x12345,
357                 'vlan_id': '>4000',
358                 'vlan_cos': '>=3',
359                 'inner_vlan_id': '<3000',
360                 'inner_vlan_cos': '<=5',
361             },
362             'actions': {
363                 'traffic_rate': {
364                     'as_number': 0,
365                     'rate_info': 100.0,
366                 },
367                 'traffic_action': {
368                     'action': FLOWSPEC_TA_SAMPLE | FLOWSPEC_TA_TERMINAL,
369                 },
370                 'redirect': {
371                     'as_number': 10,
372                     'local_administrator': 100,
373                 },
374                 'traffic_marking': {
375                     'dscp': 24,
376                 },
377                 'vlan_action': {
378                     'actions_1': FLOWSPEC_VLAN_POP | FLOWSPEC_VLAN_PUSH,
379                     'vlan_1': 3000,
380                     'cos_1': 3,
381                     'actions_2': FLOWSPEC_VLAN_SWAP,
382                     'vlan_2': 4000,
383                     'cos_2': 2,
384                 },
385                 'tpid_action': {
386                     'actions': FLOWSPEC_TPID_TI | FLOWSPEC_TPID_TO,
387                     'tpid_1': 200,
388                     'tpid_2': 300,
389                 }
390             },
391         }
392     ],
393 }
394
395
396 # =============================================================================
397 # SSH server configuration.
398 # =============================================================================
399 SSH = {
400     'ssh_port': 4990,
401     'ssh_host': 'localhost',
402     # 'ssh_host_key': '/etc/ssh_host_rsa_key',
403     # 'ssh_username': 'ryu',
404     # 'ssh_password': 'ryu',
405 }
406
407
408 # =============================================================================
409 # Logging configuration.
410 # =============================================================================
411 LOGGING = {
412
413     # We use python logging package for logging.
414     'version': 1,
415     'disable_existing_loggers': False,
416
417     'formatters': {
418         'verbose': {
419             'format': '%(levelname)s %(asctime)s %(module)s ' +
420                       '[%(process)d %(thread)d] %(message)s'
421         },
422         'simple': {
423             'format': '%(levelname)s %(asctime)s %(module)s %(lineno)s ' +
424                       '%(message)s'
425         },
426         'stats': {
427             'format': '%(message)s'
428         },
429     },
430
431     'handlers': {
432         # Outputs log to console.
433         'console': {
434             'level': 'DEBUG',
435             'class': 'logging.StreamHandler',
436             'formatter': 'simple'
437         },
438         'console_stats': {
439             'level': 'DEBUG',
440             'class': 'logging.StreamHandler',
441             'formatter': 'stats'
442         },
443         # Rotates log file when its size reaches 10MB.
444         'log_file': {
445             'level': 'ERROR',
446             'class': 'logging.handlers.RotatingFileHandler',
447             'filename': os.path.join('.', 'bgpspeaker.log'),
448             'maxBytes': '10000000',
449             'formatter': 'verbose'
450         },
451         'stats_file': {
452             'level': 'DEBUG',
453             'class': 'logging.handlers.RotatingFileHandler',
454             'filename': os.path.join('.', 'statistics_bgps.log'),
455             'maxBytes': '10000000',
456             'formatter': 'stats'
457         },
458     },
459
460     # Fine-grained control of logging per instance.
461     'loggers': {
462         'bgpspeaker': {
463             'handlers': ['console', 'log_file'],
464             'level': 'DEBUG',
465             'propagate': False,
466         },
467         'stats': {
468             'handlers': ['stats_file', 'console_stats'],
469             'level': 'INFO',
470             'propagate': False,
471             'formatter': 'stats',
472         },
473     },
474
475     # Root loggers.
476     'root': {
477         'handlers': ['console', 'log_file'],
478         'level': 'DEBUG',
479         'propagate': True,
480     },
481 }