1 # Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 from collections import OrderedDict
20 import mock # Python 2
22 from unittest import mock # Python 3
24 from nose.tools import ok_, eq_, raises
26 from ryu.lib.packet.bgp import BGPPathAttributeOrigin
27 from ryu.lib.packet.bgp import BGPPathAttributeAsPath
28 from ryu.lib.packet.bgp import BGP_ATTR_ORIGIN_IGP
29 from ryu.lib.packet.bgp import BGP_ATTR_TYPE_ORIGIN
30 from ryu.lib.packet.bgp import BGP_ATTR_TYPE_AS_PATH
31 from ryu.lib.packet.bgp import BGP_ATTR_TYPE_EXTENDED_COMMUNITIES
32 from ryu.lib.packet.bgp import IPAddrPrefix
33 from ryu.lib.packet.bgp import IP6AddrPrefix
34 from ryu.lib.packet.bgp import EvpnArbitraryEsi
35 from ryu.lib.packet.bgp import EvpnLACPEsi
36 from ryu.lib.packet.bgp import EvpnEthernetAutoDiscoveryNLRI
37 from ryu.lib.packet.bgp import EvpnMacIPAdvertisementNLRI
38 from ryu.lib.packet.bgp import EvpnInclusiveMulticastEthernetTagNLRI
39 from ryu.lib.packet.bgp import FlowSpecIPv4NLRI
40 from ryu.lib.packet.bgp import BGPPathAttributeExtendedCommunities
41 from ryu.services.protocols.bgp.bgpspeaker import EVPN_MAX_ET
42 from ryu.services.protocols.bgp.bgpspeaker import ESI_TYPE_LACP
43 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_IPV4
44 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_FAMILY_VPNV4
45 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_TA_SAMPLE
46 from ryu.services.protocols.bgp.bgpspeaker import FLOWSPEC_TA_TERMINAL
47 from ryu.services.protocols.bgp.core import BgpCoreError
48 from ryu.services.protocols.bgp.core_managers import table_manager
49 from ryu.services.protocols.bgp.rtconf.vrfs import VRF_RF_IPV4
50 from ryu.services.protocols.bgp.rtconf.vrfs import VRF_RF_IPV6
51 from ryu.services.protocols.bgp.rtconf.vrfs import VRF_RF_L2_EVPN
52 from ryu.services.protocols.bgp.rtconf.vrfs import VRF_RF_IPV4_FLOWSPEC
53 from ryu.services.protocols.bgp.utils.bgp import create_v4flowspec_actions
56 LOG = logging.getLogger(__name__)
59 class Test_TableCoreManager(unittest.TestCase):
61 Test case for bgp.core_managers.table_manager.TableCoreManager
65 'ryu.services.protocols.bgp.core_managers.TableCoreManager.__init__',
66 mock.MagicMock(return_value=None))
67 def _test_update_vrf_table(self, prefix_inst, route_dist, prefix_str,
68 next_hop, route_family, route_type,
69 is_withdraw=False, **kwargs):
70 # Instantiate TableCoreManager
71 tbl_mng = table_manager.TableCoreManager(None, None)
72 vrf_table_mock = mock.MagicMock()
73 tbl_mng._tables = {(route_dist, route_family): vrf_table_mock}
76 tbl_mng.update_vrf_table(
77 route_dist=route_dist,
80 route_family=route_family,
81 route_type=route_type,
82 is_withdraw=is_withdraw,
86 call_args_list = vrf_table_mock.insert_vrf_path.call_args_list
87 ok_(len(call_args_list) == 1) # insert_vrf_path should be called once
88 args, kwargs = call_args_list[0]
89 ok_(len(args) == 0) # no positional argument
90 eq_(str(prefix_inst), str(kwargs['nlri']))
91 eq_(is_withdraw, kwargs['is_withdraw'])
93 eq_(None, kwargs['next_hop'])
94 eq_(False, kwargs['gen_lbl'])
96 eq_(next_hop, kwargs['next_hop'])
97 eq_(True, kwargs['gen_lbl'])
99 def test_update_vrf_table_ipv4(self):
101 route_dist = '65000:100'
102 ip_network = '192.168.0.0'
104 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
105 prefix_inst = IPAddrPrefix(ip_prefix_len, ip_network)
106 next_hop = '10.0.0.1'
107 route_family = VRF_RF_IPV4
108 route_type = None # should be ignored
109 kwargs = {} # should be ignored
111 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
112 next_hop, route_family, route_type,
115 def test_update_vrf_table_ipv6(self):
117 route_dist = '65000:100'
118 ip_network = 'fe80::'
120 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
121 prefix_inst = IP6AddrPrefix(ip_prefix_len, ip_network)
122 next_hop = 'fe80::0011:aabb:ccdd:eeff'
123 route_family = VRF_RF_IPV6
124 route_type = None # should be ignored
125 kwargs = {} # should be ignored
127 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
128 next_hop, route_family, route_type,
131 def test_update_vrf_table_l2_evpn_with_esi_int(self):
133 route_dist = '65000:100'
134 prefix_str = None # should be ignored
136 'ethernet_tag_id': 100,
137 'mac_addr': 'aa:bb:cc:dd:ee:ff',
138 'ip_addr': '192.168.0.1',
139 'mpls_labels': [], # not be used
141 esi = EvpnArbitraryEsi(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00')
142 prefix_inst = EvpnMacIPAdvertisementNLRI(
143 route_dist=route_dist,
146 next_hop = '10.0.0.1'
147 route_family = VRF_RF_L2_EVPN
148 route_type = EvpnMacIPAdvertisementNLRI.ROUTE_TYPE_NAME
151 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
152 next_hop, route_family, route_type,
155 def test_update_vrf_table_l2_evpn_with_esi_dict(self):
157 route_dist = '65000:100'
158 prefix_str = None # should be ignored
160 'ethernet_tag_id': EVPN_MAX_ET,
162 esi = EvpnLACPEsi(mac_addr='aa:bb:cc:dd:ee:ff', port_key=100)
163 prefix_inst = EvpnEthernetAutoDiscoveryNLRI(
164 route_dist=route_dist,
168 route_family = VRF_RF_L2_EVPN
169 route_type = EvpnEthernetAutoDiscoveryNLRI.ROUTE_TYPE_NAME
171 'type': ESI_TYPE_LACP,
172 'mac_addr': 'aa:bb:cc:dd:ee:ff',
176 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
177 next_hop, route_family, route_type,
180 def test_update_vrf_table_l2_evpn_without_esi(self):
182 route_dist = '65000:100'
183 prefix_str = None # should be ignored
185 'ethernet_tag_id': 100,
186 'ip_addr': '192.168.0.1',
188 prefix_inst = EvpnInclusiveMulticastEthernetTagNLRI(
189 route_dist=route_dist, **kwargs)
190 next_hop = '10.0.0.1'
191 route_family = VRF_RF_L2_EVPN
192 route_type = EvpnInclusiveMulticastEthernetTagNLRI.ROUTE_TYPE_NAME
194 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
195 next_hop, route_family, route_type,
199 'ryu.services.protocols.bgp.core_managers.TableCoreManager.__init__',
200 mock.MagicMock(return_value=None))
201 def test_update_vrf_table_l2_evpn_with_vni(self):
203 route_dist = '65000:100'
204 prefix_str = None # should be ignored
206 'ethernet_tag_id': 100,
207 'mac_addr': 'aa:bb:cc:dd:ee:ff',
208 'ip_addr': '192.168.0.1',
211 esi = EvpnArbitraryEsi(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00')
212 prefix_inst = EvpnMacIPAdvertisementNLRI(
213 route_dist=route_dist,
216 next_hop = '10.0.0.1'
217 route_family = VRF_RF_L2_EVPN
218 route_type = EvpnMacIPAdvertisementNLRI.ROUTE_TYPE_NAME
219 tunnel_type = 'vxlan'
222 # Instantiate TableCoreManager
223 tbl_mng = table_manager.TableCoreManager(None, None)
224 vrf_table_mock = mock.MagicMock()
225 tbl_mng._tables = {(route_dist, route_family): vrf_table_mock}
228 tbl_mng.update_vrf_table(
229 route_dist=route_dist,
232 route_family=route_family,
233 route_type=route_type,
234 tunnel_type=tunnel_type,
238 call_args_list = vrf_table_mock.insert_vrf_path.call_args_list
239 ok_(len(call_args_list) == 1) # insert_vrf_path should be called once
240 args, kwargs = call_args_list[0]
241 ok_(len(args) == 0) # no positional argument
242 eq_(str(prefix_inst), str(kwargs['nlri']))
243 eq_(next_hop, kwargs['next_hop'])
244 eq_(False, kwargs['gen_lbl']) # should not generate MPLS labels
245 eq_(tunnel_type, kwargs['tunnel_type'])
247 def test_update_vrf_table_ipv4_withdraw(self):
249 route_dist = '65000:100'
250 ip_network = '192.168.0.0'
252 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
253 prefix_inst = IPAddrPrefix(ip_prefix_len, ip_network)
254 next_hop = '10.0.0.1'
255 route_family = VRF_RF_IPV4
256 route_type = None # should be ignored
257 kwargs = {} # should be ignored
259 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
260 next_hop, route_family, route_type,
261 is_withdraw=True, **kwargs)
263 @raises(BgpCoreError)
265 'ryu.services.protocols.bgp.core_managers.TableCoreManager.__init__',
266 mock.MagicMock(return_value=None))
267 def test_update_vrf_table_no_vrf(self):
269 route_dist = '65000:100'
270 ip_network = '192.168.0.0'
272 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
273 next_hop = '10.0.0.1'
274 route_family = VRF_RF_IPV4
275 route_type = None # should be ignored
276 kwargs = {} # should be ignored
278 # Instantiate TableCoreManager
279 tbl_mng = table_manager.TableCoreManager(None, None)
280 tbl_mng._tables = {} # no table
283 tbl_mng.update_vrf_table(
284 route_dist=route_dist,
287 route_family=route_family,
288 route_type=route_type,
291 @raises(BgpCoreError)
292 def test_update_vrf_table_invalid_next_hop(self):
294 route_dist = '65000:100'
295 ip_network = '192.168.0.0'
297 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
298 prefix_inst = IPAddrPrefix(ip_prefix_len, ip_network)
299 next_hop = 'xxx.xxx.xxx.xxx' # invalid
300 route_family = VRF_RF_IPV4
301 route_type = None # should be ignored
302 kwargs = {} # should be ignored
304 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
305 next_hop, route_family, route_type,
308 @raises(BgpCoreError)
309 def test_update_vrf_table_invalid_ipv4_prefix(self):
311 route_dist = '65000:100'
312 ip_network = 'xxx.xxx.xxx.xxx' # invalid
314 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
315 prefix_inst = IPAddrPrefix(ip_prefix_len, ip_network)
316 next_hop = '10.0.0.1'
317 route_family = VRF_RF_IPV4
318 route_type = None # should be ignored
319 kwargs = {} # should be ignored
321 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
322 next_hop, route_family, route_type,
325 @raises(BgpCoreError)
326 def test_update_vrf_table_invalid_ipv6_prefix(self):
328 route_dist = '65000:100'
329 ip_network = 'xxxx::' # invalid
331 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
332 prefix_inst = IP6AddrPrefix(ip_prefix_len, ip_network)
333 next_hop = 'fe80::0011:aabb:ccdd:eeff'
334 route_family = VRF_RF_IPV6
335 route_type = None # should be ignored
336 kwargs = {} # should be ignored
338 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
339 next_hop, route_family, route_type,
342 @raises(BgpCoreError)
343 def test_update_vrf_table_invalid_route_family(self):
345 route_dist = '65000:100'
346 ip_network = '192.168.0.0'
348 prefix_str = '%s/%d' % (ip_network, ip_prefix_len)
349 prefix_inst = IPAddrPrefix(ip_prefix_len, ip_network)
350 next_hop = '10.0.0.1'
351 route_family = 'foobar' # invalid
352 route_type = None # should be ignored
353 kwargs = {} # should be ignored
355 self._test_update_vrf_table(prefix_inst, route_dist, prefix_str,
356 next_hop, route_family, route_type,
360 'ryu.services.protocols.bgp.core_managers.TableCoreManager.__init__',
361 mock.MagicMock(return_value=None))
363 'ryu.services.protocols.bgp.core_managers.TableCoreManager.learn_path')
364 def _test_update_global_table(self, learn_path_mock, prefix, next_hop,
365 is_withdraw, expected_next_hop):
367 origin = BGPPathAttributeOrigin(BGP_ATTR_ORIGIN_IGP)
368 aspath = BGPPathAttributeAsPath([[]])
369 pathattrs = OrderedDict()
370 pathattrs[BGP_ATTR_TYPE_ORIGIN] = origin
371 pathattrs[BGP_ATTR_TYPE_AS_PATH] = aspath
372 pathattrs = str(pathattrs)
374 # Instantiate TableCoreManager
375 tbl_mng = table_manager.TableCoreManager(None, None)
378 tbl_mng.update_global_table(
381 is_withdraw=is_withdraw,
385 call_args_list = learn_path_mock.call_args_list
386 ok_(len(call_args_list) == 1) # learn_path should be called once
387 args, kwargs = call_args_list[0]
388 ok_(len(kwargs) == 0) # no keyword argument
389 output_path = args[0]
390 eq_(None, output_path.source)
391 eq_(prefix, output_path.nlri.prefix)
392 eq_(pathattrs, str(output_path.pathattr_map))
393 eq_(expected_next_hop, output_path.nexthop)
394 eq_(is_withdraw, output_path.is_withdraw)
396 def test_update_global_table_ipv4(self):
397 self._test_update_global_table(
398 prefix='192.168.0.0/24',
401 expected_next_hop='10.0.0.1',
404 def test_update_global_table_ipv4_withdraw(self):
405 self._test_update_global_table(
406 prefix='192.168.0.0/24',
409 expected_next_hop='10.0.0.1',
412 def test_update_global_table_ipv4_no_next_hop(self):
413 self._test_update_global_table(
414 prefix='192.168.0.0/24',
417 expected_next_hop='0.0.0.0',
420 def test_update_global_table_ipv6(self):
421 self._test_update_global_table(
423 next_hop='fe80::0011:aabb:ccdd:eeff',
425 expected_next_hop='fe80::0011:aabb:ccdd:eeff',
428 def test_update_global_table_ipv6_withdraw(self):
429 self._test_update_global_table(
431 next_hop='fe80::0011:aabb:ccdd:eeff',
433 expected_next_hop='fe80::0011:aabb:ccdd:eeff',
436 def test_update_global_table_ipv6_no_next_hop(self):
437 self._test_update_global_table(
441 expected_next_hop='::',
445 'ryu.services.protocols.bgp.core_managers.TableCoreManager.__init__',
446 mock.MagicMock(return_value=None))
447 def _test_update_flowspec_vrf_table(self, flowspec_family, route_family,
448 route_dist, rules, prefix,
449 is_withdraw, actions=None):
450 # Instantiate TableCoreManager
451 tbl_mng = table_manager.TableCoreManager(None, None)
452 vrf_table_mock = mock.MagicMock()
453 tbl_mng._tables = {(route_dist, route_family): vrf_table_mock}
456 tbl_mng.update_flowspec_vrf_table(
457 flowspec_family=flowspec_family,
458 route_dist=route_dist,
461 is_withdraw=is_withdraw,
465 call_args_list = vrf_table_mock.insert_vrffs_path.call_args_list
467 call_args_list) == 1) # insert_vrffs_path should be called once
468 args, kwargs = call_args_list[0]
469 ok_(len(args) == 0) # no positional argument
470 eq_(prefix, kwargs['nlri'].prefix)
471 eq_(is_withdraw, kwargs['is_withdraw'])
473 def test_update_flowspec_vrf_table_vpnv4(self):
474 flowspec_family = 'vpnv4fs'
475 route_family = 'ipv4fs'
476 route_dist = '65001:100'
478 'dst_prefix': '10.70.1.0/24',
486 prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)'
488 self._test_update_flowspec_vrf_table(
489 flowspec_family=flowspec_family,
490 route_family=route_family,
491 route_dist=route_dist,
498 def test_update_flowspec_vrf_table_vpnv4_without_actions(self):
499 flowspec_family = 'vpnv4fs'
500 route_family = 'ipv4fs'
501 route_dist = '65001:100'
503 'dst_prefix': '10.70.1.0/24',
505 prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)'
507 self._test_update_flowspec_vrf_table(
508 flowspec_family=flowspec_family,
509 route_family=route_family,
510 route_dist=route_dist,
516 @raises(BgpCoreError)
517 def test_update_flowspec_vrf_table_vpnv4_invalid_actions(self):
518 flowspec_family = 'vpnv4fs'
519 route_family = 'ipv4fs'
520 route_dist = '65001:100'
522 'dst_prefix': '10.70.1.0/24',
529 prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)'
531 self._test_update_flowspec_vrf_table(
532 flowspec_family=flowspec_family,
533 route_family=route_family,
534 route_dist=route_dist,
541 @raises(BgpCoreError)
542 def test_update_flowspec_vrf_table_vpnv4_invalid_flowspec_family(self):
543 flowspec_family = 'invalid'
544 route_family = 'ipv4fs'
545 route_dist = '65001:100'
547 'dst_prefix': '10.70.1.0/24',
549 prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)'
551 self._test_update_flowspec_vrf_table(
552 flowspec_family=flowspec_family,
553 route_family=route_family,
554 route_dist=route_dist,
560 @raises(BgpCoreError)
561 def test_update_flowspec_vrf_table_vpnv4_invalid_route_family(self):
562 flowspec_family = 'vpnv4fs'
563 route_family = 'invalid'
564 route_dist = '65001:100'
566 'dst_prefix': '10.70.1.0/24',
568 prefix = 'ipv4fs(dst_prefix:10.70.1.0/24)'
570 self._test_update_flowspec_vrf_table(
571 flowspec_family=flowspec_family,
572 route_family=route_family,
573 route_dist=route_dist,
580 'ryu.services.protocols.bgp.core_managers.TableCoreManager.__init__',
581 mock.MagicMock(return_value=None))
583 'ryu.services.protocols.bgp.core_managers.TableCoreManager.learn_path')
584 def _test_update_flowspec_global_table(self, learn_path_mock,
585 flowspec_family, rules, prefix,
586 is_withdraw, actions=None):
587 # Instantiate TableCoreManager
588 tbl_mng = table_manager.TableCoreManager(None, None)
591 tbl_mng.update_flowspec_global_table(
592 flowspec_family=flowspec_family,
595 is_withdraw=is_withdraw,
599 call_args_list = learn_path_mock.call_args_list
600 ok_(len(call_args_list) == 1) # learn_path should be called once
601 args, kwargs = call_args_list[0]
602 ok_(len(kwargs) == 0) # no keyword argument
603 output_path = args[0]
604 eq_(None, output_path.source)
605 eq_(prefix, output_path.nlri.prefix)
606 eq_(None, output_path.nexthop)
607 eq_(is_withdraw, output_path.is_withdraw)
609 def test_update_flowspec_global_table_ipv4(self):
610 flowspec_family = 'ipv4fs'
612 'dst_prefix': '10.60.1.0/24',
620 prefix = 'ipv4fs(dst_prefix:10.60.1.0/24)'
622 self._test_update_flowspec_global_table(
623 flowspec_family=flowspec_family,
630 def test_update_flowspec_global_table_ipv4_without_actions(self):
631 flowspec_family = 'ipv4fs'
633 'dst_prefix': '10.60.1.0/24',
635 prefix = 'ipv4fs(dst_prefix:10.60.1.0/24)'
637 self._test_update_flowspec_global_table(
638 flowspec_family=flowspec_family,
644 @raises(BgpCoreError)
645 def test_update_flowspec_global_table_ipv4_invalid_actions(self):
646 flowspec_family = 'ipv4fs'
648 'dst_prefix': '10.60.1.0/24',
655 prefix = 'ipv4fs(dst_prefix:10.60.1.0/24)'
657 self._test_update_flowspec_global_table(
658 flowspec_family=flowspec_family,
665 @raises(BgpCoreError)
666 def test_update_flowspec_global_table_ipv4_invalid_flowspec_family(self):
667 flowspec_family = 'invalid'
669 'dst_prefix': '10.60.1.0/24',
677 prefix = 'ipv4fs(dst_prefix:10.60.1.0/24)'
679 self._test_update_flowspec_global_table(
680 flowspec_family=flowspec_family,
687 def test_update_flowspec_global_table_ipv6(self):
688 flowspec_family = 'ipv6fs'
690 'dst_prefix': '2001::3/128/32',
698 prefix = 'ipv6fs(dst_prefix:2001::3/128/32)'
700 self._test_update_flowspec_global_table(
701 flowspec_family=flowspec_family,
708 def test_update_flowspec_global_table_ipv6_without_actions(self):
709 flowspec_family = 'ipv6fs'
711 'dst_prefix': '2001::3/128/32',
713 prefix = 'ipv6fs(dst_prefix:2001::3/128/32)'
715 self._test_update_flowspec_global_table(
716 flowspec_family=flowspec_family,
722 @raises(BgpCoreError)
723 def test_update_flowspec_global_table_ipv6_invalid_actions(self):
724 flowspec_family = 'ipv6fs'
726 'dst_prefix': '2001::3/128/32',
733 prefix = 'ipv4fs(dst_prefix:2001::3/128/32)'
735 self._test_update_flowspec_global_table(
736 flowspec_family=flowspec_family,
743 @raises(BgpCoreError)
744 def test_update_flowspec_global_table_ipv6_invalid_flowspec_family(self):
745 flowspec_family = 'invalid'
747 'dst_prefix': '2001::3/128/32',
755 prefix = 'ipv4fs(dst_prefix:2001::3/128/32)'
757 self._test_update_flowspec_global_table(
758 flowspec_family=flowspec_family,
765 def test_update_flowspec_vrf_table_vpnv6(self):
766 flowspec_family = 'vpnv6fs'
767 route_family = 'ipv6fs'
768 route_dist = '65001:100'
770 'dst_prefix': '2001::3/128/32',
778 prefix = 'ipv6fs(dst_prefix:2001::3/128/32)'
780 self._test_update_flowspec_vrf_table(
781 flowspec_family=flowspec_family,
782 route_family=route_family,
783 route_dist=route_dist,
790 def test_update_flowspec_vrf_table_vpnv6_without_actions(self):
791 flowspec_family = 'vpnv6fs'
792 route_family = 'ipv6fs'
793 route_dist = '65001:100'
795 'dst_prefix': '2001::3/128/32',
797 prefix = 'ipv6fs(dst_prefix:2001::3/128/32)'
799 self._test_update_flowspec_vrf_table(
800 flowspec_family=flowspec_family,
801 route_family=route_family,
802 route_dist=route_dist,
808 @raises(BgpCoreError)
809 def test_update_flowspec_vrf_table_vpnv6_invalid_actions(self):
810 flowspec_family = 'vpnv6fs'
811 route_family = 'ipv6fs'
812 route_dist = '65001:100'
814 'dst_prefix': '2001::3/128/32',
821 prefix = 'ipv6fs(dst_prefix:2001::3/128/32)'
823 self._test_update_flowspec_vrf_table(
824 flowspec_family=flowspec_family,
825 route_family=route_family,
826 route_dist=route_dist,
833 @raises(BgpCoreError)
834 def test_update_flowspec_vrf_table_vpnv6_invalid_route_family(self):
835 flowspec_family = 'vpnv6fs'
836 route_family = 'invalid'
837 route_dist = '65001:100'
839 'dst_prefix': '2001::3/128/32',
841 prefix = 'ipv4fs(dst_prefix:2001::3/128/32)'
843 self._test_update_flowspec_vrf_table(
844 flowspec_family=flowspec_family,
845 route_family=route_family,
846 route_dist=route_dist,
852 def test_update_flowspec_vrf_table_l2vpn(self):
853 flowspec_family = 'l2vpnfs'
854 route_family = 'l2vpnfs'
855 route_dist = '65001:100'
857 'dst_mac': '12:34:56:78:9a:bc',
865 prefix = 'l2vpnfs(dst_mac:12:34:56:78:9a:bc)'
867 self._test_update_flowspec_vrf_table(
868 flowspec_family=flowspec_family,
869 route_family=route_family,
870 route_dist=route_dist,
877 def test_update_flowspec_vrf_table_l2vpn_without_actions(self):
878 flowspec_family = 'l2vpnfs'
879 route_family = 'l2vpnfs'
880 route_dist = '65001:100'
882 'dst_mac': '12:34:56:78:9a:bc',
884 prefix = 'l2vpnfs(dst_mac:12:34:56:78:9a:bc)'
886 self._test_update_flowspec_vrf_table(
887 flowspec_family=flowspec_family,
888 route_family=route_family,
889 route_dist=route_dist,
895 @raises(BgpCoreError)
896 def test_update_flowspec_vrf_table_l2vpn_invalid_actions(self):
897 flowspec_family = 'l2vpnfs'
898 route_family = 'l2vpnfs'
899 route_dist = '65001:100'
901 'dst_mac': '12:34:56:78:9a:bc',
908 prefix = 'l2vpnfs(dst_mac:12:34:56:78:9a:bc)'
910 self._test_update_flowspec_vrf_table(
911 flowspec_family=flowspec_family,
912 route_family=route_family,
913 route_dist=route_dist,
920 @raises(BgpCoreError)
921 def test_update_flowspec_vrf_table_l2vpn_invalid_route_family(self):
922 flowspec_family = 'l2vpnfs'
923 route_family = 'invalid'
924 route_dist = '65001:100'
926 'dst_mac': '12:34:56:78:9a:bc',
928 prefix = 'l2vpnfs(dst_mac:12:34:56:78:9a:bc)'
930 self._test_update_flowspec_vrf_table(
931 flowspec_family=flowspec_family,
932 route_family=route_family,
933 route_dist=route_dist,