summaryrefslogtreecommitdiffstats
path: root/test/test_vxlan.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_vxlan.py')
-rw-r--r--test/test_vxlan.py118
1 files changed, 66 insertions, 52 deletions
diff --git a/test/test_vxlan.py b/test/test_vxlan.py
index 7613054882a..910611c63cc 100644
--- a/test/test_vxlan.py
+++ b/test/test_vxlan.py
@@ -12,6 +12,7 @@ from scapy.layers.inet import IP, UDP
from scapy.layers.vxlan import VXLAN
from scapy.utils import atol
from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_vxlan_tunnel import VppVxlanTunnel
from vpp_ip import INVALID_INDEX
@@ -98,8 +99,9 @@ class TestVxlan(BridgeDomain, VppTestCase):
rip.add_vpp_config()
dest_ip4n = socket.inet_pton(socket.AF_INET, dest_ip4)
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=dest_ip4n, vni=vni)
+ r = VppVxlanTunnel(cls, src=cls.pg0.local_ip4,
+ dst=dest_ip4, vni=vni)
+ r.add_vpp_config()
cls.vapi.sw_interface_set_l2_bridge(r.sw_if_index, bd_id=vni)
@classmethod
@@ -112,12 +114,14 @@ class TestVxlan(BridgeDomain, VppTestCase):
vni_start = 10000
vni_end = vni_start + n_shared_dst_tunnels
for vni in range(vni_start, vni_end):
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=cls.mcast_ip4n,
- mcast_sw_if_index=1,
- is_add=is_add, vni=vni)
- if r.sw_if_index == 0xffffffff:
- raise ValueError("bad sw_if_index: ~0")
+ r = VppVxlanTunnel(cls, src=cls.pg0.local_ip4,
+ dst=cls.mcast_ip4, mcast_sw_if_index=1, vni=vni)
+ if is_add:
+ r.add_vpp_config()
+ if r.sw_if_index == 0xffffffff:
+ raise ValueError("bad sw_if_index: ~0")
+ else:
+ r.remove_vpp_config()
@classmethod
def add_shared_mcast_dst_load(cls):
@@ -135,13 +139,15 @@ class TestVxlan(BridgeDomain, VppTestCase):
n_distinct_dst_tunnels = 200
ip_range_start = 10
ip_range_end = ip_range_start + n_distinct_dst_tunnels
- for dest_ip4n in ip4n_range(cls.mcast_ip4n, ip_range_start,
- ip_range_end):
- vni = bytearray(dest_ip4n)[3]
- cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=dest_ip4n,
- mcast_sw_if_index=1, is_add=is_add,
- vni=vni)
+ for dest_ip4 in ip4_range(cls.mcast_ip4, ip_range_start,
+ ip_range_end):
+ vni = bytearray(socket.inet_pton(socket.AF_INET, dest_ip4))[3]
+ r = VppVxlanTunnel(cls, src=cls.pg0.local_ip4,
+ dst=dest_ip4, mcast_sw_if_index=1, vni=vni)
+ if is_add:
+ r.add_vpp_config()
+ else:
+ r.remove_vpp_config()
@classmethod
def add_mcast_tunnels_load(cls):
@@ -182,43 +188,6 @@ class TestVxlan(BridgeDomain, VppTestCase):
cls.mcast_mac = "01:00:5e:%02x:%02x:%02x" % (
(iplong >> 16) & 0x7F, (iplong >> 8) & 0xFF, iplong & 0xFF)
- # Create VXLAN VTEP on VPP pg0, and put vxlan_tunnel0 and pg1
- # into BD.
- cls.single_tunnel_bd = 1
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=cls.pg0.remote_ip4n,
- vni=cls.single_tunnel_bd)
- cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
- bd_id=cls.single_tunnel_bd)
- cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg1.sw_if_index, bd_id=cls.single_tunnel_bd)
-
- # Setup vni 2 to test multicast flooding
- cls.n_ucast_tunnels = 10
- cls.mcast_flood_bd = 2
- cls.create_vxlan_flood_test_bd(cls.mcast_flood_bd,
- cls.n_ucast_tunnels)
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=cls.mcast_ip4n,
- mcast_sw_if_index=1,
- vni=cls.mcast_flood_bd)
- cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
- bd_id=cls.mcast_flood_bd)
- cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg2.sw_if_index, bd_id=cls.mcast_flood_bd)
-
- # Add and delete mcast tunnels to check stability
- cls.add_shared_mcast_dst_load()
- cls.add_mcast_tunnels_load()
- cls.del_shared_mcast_dst_load()
- cls.del_mcast_tunnels_load()
-
- # Setup vni 3 to test unicast flooding
- cls.ucast_flood_bd = 3
- cls.create_vxlan_flood_test_bd(cls.ucast_flood_bd,
- cls.n_ucast_tunnels)
- cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg3.sw_if_index, bd_id=cls.ucast_flood_bd)
except Exception:
super(TestVxlan, cls).tearDownClass()
raise
@@ -227,6 +196,51 @@ class TestVxlan(BridgeDomain, VppTestCase):
def tearDownClass(cls):
super(TestVxlan, cls).tearDownClass()
+ def setUp(self):
+ super(TestVxlan, self).setUp()
+ # Create VXLAN VTEP on VPP pg0, and put vxlan_tunnel0 and pg1
+ # into BD.
+ self.single_tunnel_bd = 1
+ r = VppVxlanTunnel(self, src=self.pg0.local_ip4,
+ dst=self.pg0.remote_ip4, vni=self.single_tunnel_bd)
+ r.add_vpp_config()
+ self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
+ bd_id=self.single_tunnel_bd)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg1.sw_if_index, bd_id=self.single_tunnel_bd)
+
+ # Setup vni 2 to test multicast flooding
+ self.n_ucast_tunnels = 10
+ self.mcast_flood_bd = 2
+ self.create_vxlan_flood_test_bd(self.mcast_flood_bd,
+ self.n_ucast_tunnels)
+ r = VppVxlanTunnel(self, src=self.pg0.local_ip4, dst=self.mcast_ip4,
+ mcast_sw_if_index=1, vni=self.mcast_flood_bd)
+ r.add_vpp_config()
+ self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
+ bd_id=self.mcast_flood_bd)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg2.sw_if_index, bd_id=self.mcast_flood_bd)
+
+ # Add and delete mcast tunnels to check stability
+ self.add_shared_mcast_dst_load()
+ self.add_mcast_tunnels_load()
+ self.del_shared_mcast_dst_load()
+ self.del_mcast_tunnels_load()
+
+ # Setup vni 3 to test unicast flooding
+ self.ucast_flood_bd = 3
+ self.create_vxlan_flood_test_bd(self.ucast_flood_bd,
+ self.n_ucast_tunnels)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg3.sw_if_index, bd_id=self.ucast_flood_bd)
+
+ def test_decap(self):
+ """ Decapsulation test
+ from BridgeDoman
+ """
+ super(TestVxlan, self).test_decap()
+
def test_encap_big_packet(self):
""" Encapsulation test send big frame from pg1
Verify receipt of encapsulated frames on pg0
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798