summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/gre/interface.c4
-rw-r--r--src/vnet/gre/node.c3
-rw-r--r--test/test_gre.py46
3 files changed, 50 insertions, 3 deletions
diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c
index 2025838d9ad..ea93536fb27 100644
--- a/src/vnet/gre/interface.c
+++ b/src/vnet/gre/interface.c
@@ -306,6 +306,10 @@ vnet_gre_tunnel_add (vnet_gre_tunnel_add_del_args_t * a,
if (sw_if_indexp)
*sw_if_indexp = sw_if_index;
+ /* register gre46-input nodes */
+ ip4_register_protocol (IP_PROTOCOL_GRE, gre4_input_node.index);
+ ip6_register_protocol (IP_PROTOCOL_GRE, gre6_input_node.index);
+
return 0;
}
diff --git a/src/vnet/gre/node.c b/src/vnet/gre/node.c
index ff74d1b4e79..891fc9c08d4 100644
--- a/src/vnet/gre/node.c
+++ b/src/vnet/gre/node.c
@@ -577,9 +577,6 @@ gre_input_init (vlib_main_t * vm)
gre_register_input_protocol (vm, GRE_PROTOCOL_mpls_unicast,
mpls_unicast_input->index, GRE_TUNNEL_TYPE_L3);
- ip4_register_protocol (IP_PROTOCOL_GRE, gre4_input_node.index);
- ip6_register_protocol (IP_PROTOCOL_GRE, gre6_input_node.index);
-
return 0;
}
diff --git a/test/test_gre.py b/test/test_gre.py
index 71117ad738c..7936334ba77 100644
--- a/test/test_gre.py
+++ b/test/test_gre.py
@@ -18,6 +18,52 @@ from util import ppp, ppc
from vpp_papi import VppEnum
+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):
""" GRE Test Case """