X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_gre.py;h=7936334ba77b3503e197663aaab26ad1adffcd07;hb=d67a428b3b2183cd78d7fca82e8afe2f26387810;hp=6b3c23f273ac41097bb99a3c3df584725aaa90c3;hpb=7f9b7f9f492d1748d8ba025b3a713058fdb1943d;p=vpp.git diff --git a/test/test_gre.py b/test/test_gre.py index 6b3c23f273a..7936334ba77 100644 --- a/test/test_gre.py +++ b/test/test_gre.py @@ -11,16 +11,57 @@ from scapy.volatile import RandMAC, RandIP from framework import VppTestCase, VppTestRunner from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint -from vpp_gre_interface import VppGreInterface, VppGre6Interface +from vpp_gre_interface import VppGreInterface from vpp_ip import DpoProto from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable from util import ppp, ppc +from vpp_papi import VppEnum -class GreTunnelTypes: - TT_L3 = 0 - TT_TEB = 1 - TT_ERSPAN = 2 +class TestGREInputNodes(VppTestCase): + """ GRE Input Nodes Test Case """ + + def setUp(self): + super(TestGREInputNodes, self).setUp() + + # create 3 pg interfaces - set one in a non-default table. + self.create_pg_interfaces(range(1)) + + for i in self.pg_interfaces: + i.admin_up() + i.config_ip4() + + def tearDown(self): + for i in self.pg_interfaces: + i.unconfig_ip4() + i.admin_down() + super(TestGREInputNodes, self).tearDown() + + def test_gre_input_node(self): + """ GRE gre input nodes not registerd unless configured """ + pkt = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / + IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) / + GRE()) + + self.pg0.add_stream(pkt) + self.pg_start() + # no tunnel created, gre-input not registered + err = self.statistics.get_counter( + '/err/ip4-input/unknown ip protocol')[0] + self.assertEqual(err, 1) + err_count = err + + # create gre tunnel + gre_if = VppGreInterface(self, self.pg0.local_ip4, "1.1.1.2") + gre_if.add_vpp_config() + + self.pg0.add_stream(pkt) + self.pg_start() + # tunnel created, gre-input registered + err = self.statistics.get_counter( + '/err/ip4-input/unknown ip protocol')[0] + # expect no new errors + self.assertEqual(err, err_count) class TestGRE(VppTestCase): @@ -567,9 +608,9 @@ class TestGRE(VppTestCase): # - assign an IP Address # - Add a route via the tunnel # - gre_if = VppGre6Interface(self, - self.pg2.local_ip6, - "1002::1") + gre_if = VppGreInterface(self, + self.pg2.local_ip6, + "1002::1") gre_if.add_vpp_config() gre_if.admin_up() gre_if.config_ip6() @@ -762,10 +803,12 @@ class TestGRE(VppTestCase): # gre_if1 = VppGreInterface(self, self.pg0.local_ip4, "2.2.2.2", - type=GreTunnelTypes.TT_TEB) + type=(VppEnum.vl_api_gre_tunnel_type_t. + GRE_API_TUNNEL_TYPE_TEB)) gre_if2 = VppGreInterface(self, self.pg0.local_ip4, "2.2.2.3", - type=GreTunnelTypes.TT_TEB) + type=(VppEnum.vl_api_gre_tunnel_type_t. + GRE_API_TUNNEL_TYPE_TEB)) gre_if1.add_vpp_config() gre_if2.add_vpp_config()