summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2020-09-18 07:35:06 +0000
committerOle Tr�an <otroan@employees.org>2020-09-21 17:04:13 +0000
commit3a6adc52fe4cad83883c00ad47aefdfb995fb441 (patch)
treeedea9964987a211545d538c8641696a02e4aa3ad /src
parent6810a77da36c6750938800314c15e840ee2a8c93 (diff)
geneve: Move to plugin
Type: refactor Change-Id: I613bf4d6517591351b212bfe6c8d93abf235f5dc Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/geneve/CMakeLists.txt35
-rw-r--r--src/plugins/geneve/decap.c (renamed from src/vnet/geneve/decap.c)6
-rw-r--r--src/plugins/geneve/encap.c (renamed from src/vnet/geneve/encap.c)2
-rw-r--r--src/plugins/geneve/geneve.api (renamed from src/vnet/geneve/geneve.api)0
-rw-r--r--src/plugins/geneve/geneve.c (renamed from src/vnet/geneve/geneve.c)2
-rw-r--r--src/plugins/geneve/geneve.h (renamed from src/vnet/geneve/geneve.h)6
-rw-r--r--src/plugins/geneve/geneve_api.c (renamed from src/vnet/geneve/geneve_api.c)41
-rw-r--r--src/plugins/geneve/geneve_error.def (renamed from src/vnet/geneve/geneve_error.def)0
-rw-r--r--src/plugins/geneve/geneve_packet.h (renamed from src/vnet/geneve/geneve_packet.h)0
-rw-r--r--src/plugins/geneve/geneve_test.c (renamed from src/vnet/geneve/geneve_test.c)98
-rw-r--r--src/plugins/geneve/test/test_geneve.py307
-rw-r--r--src/vat/CMakeLists.txt1
-rw-r--r--src/vnet/CMakeLists.txt23
-rw-r--r--src/vpp/CMakeLists.txt1
14 files changed, 448 insertions, 74 deletions
diff --git a/src/plugins/geneve/CMakeLists.txt b/src/plugins/geneve/CMakeLists.txt
new file mode 100644
index 00000000000..43eb0172097
--- /dev/null
+++ b/src/plugins/geneve/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright (c) 2020 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_vpp_plugin(geneve
+ SOURCES
+ geneve.c
+ encap.c
+ decap.c
+ geneve_api.c
+
+ MULTIARCH_SOURCES
+ encap.c
+ decap.c
+
+ API_FILES
+ geneve.api
+
+ INSTALL_HEADERS
+ geneve.h
+ geneve_packet.h
+ geneve_error.def
+
+ API_TEST_SOURCES
+ geneve_test.c
+)
diff --git a/src/vnet/geneve/decap.c b/src/plugins/geneve/decap.c
index b570e3512c4..f42c0a88a5a 100644
--- a/src/vnet/geneve/decap.c
+++ b/src/plugins/geneve/decap.c
@@ -14,8 +14,8 @@
*/
#include <vlib/vlib.h>
-#include <vnet/pg/pg.h>
-#include <vnet/geneve/geneve.h>
+
+#include <geneve/geneve.h>
typedef struct
{
@@ -807,7 +807,7 @@ VLIB_NODE_FN (geneve6_input_node) (vlib_main_t * vm,
static char *geneve_error_strings[] = {
#define geneve_error(n,s) s,
-#include <vnet/geneve/geneve_error.def>
+#include <geneve/geneve_error.def>
#undef geneve_error
#undef _
};
diff --git a/src/vnet/geneve/encap.c b/src/plugins/geneve/encap.c
index 2859a9ae652..6a84d0c5490 100644
--- a/src/vnet/geneve/encap.c
+++ b/src/plugins/geneve/encap.c
@@ -17,7 +17,7 @@
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/geneve/geneve.h>
+#include <geneve/geneve.h>
/* Statistics (not all errors) */
#define foreach_geneve_encap_error \
diff --git a/src/vnet/geneve/geneve.api b/src/plugins/geneve/geneve.api
index fd871733fb9..fd871733fb9 100644
--- a/src/vnet/geneve/geneve.api
+++ b/src/plugins/geneve/geneve.api
diff --git a/src/vnet/geneve/geneve.c b/src/plugins/geneve/geneve.c
index e16616b69ea..f991af97571 100644
--- a/src/vnet/geneve/geneve.c
+++ b/src/plugins/geneve/geneve.c
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <vnet/geneve/geneve.h>
+#include <geneve/geneve.h>
#include <vnet/ip/format.h>
#include <vnet/fib/fib_entry.h>
#include <vnet/fib/fib_table.h>
diff --git a/src/vnet/geneve/geneve.h b/src/plugins/geneve/geneve.h
index 46b048ada3f..029f7534497 100644
--- a/src/vnet/geneve/geneve.h
+++ b/src/plugins/geneve/geneve.h
@@ -18,13 +18,15 @@
#include <vppinfra/error.h>
#include <vppinfra/hash.h>
#include <vnet/vnet.h>
+
+#include <geneve/geneve_packet.h>
+
#include <vnet/ip/ip.h>
#include <vnet/ip/vtep.h>
#include <vnet/l2/l2_input.h>
#include <vnet/l2/l2_output.h>
#include <vnet/l2/l2_bd.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/geneve/geneve_packet.h>
#include <vnet/ip/ip4_packet.h>
#include <vnet/ip/ip6_packet.h>
#include <vnet/udp/udp.h>
@@ -154,7 +156,7 @@ typedef enum
typedef enum
{
#define geneve_error(n,s) GENEVE_ERROR_##n,
-#include <vnet/geneve/geneve_error.def>
+#include <geneve/geneve_error.def>
#undef geneve_error
GENEVE_N_ERROR,
} geneve_input_error_t;
diff --git a/src/vnet/geneve/geneve_api.c b/src/plugins/geneve/geneve_api.c
index 8c4a4cadc28..f6b9afda7d5 100644
--- a/src/vnet/geneve/geneve_api.c
+++ b/src/plugins/geneve/geneve_api.c
@@ -20,21 +20,28 @@
#include <vnet/interface.h>
#include <vnet/api_errno.h>
#include <vnet/feature/feature.h>
-#include <vnet/geneve/geneve.h>
#include <vnet/fib/fib_table.h>
#include <vnet/ip/ip_types_api.h>
-#include <vnet/geneve/geneve.api_enum.h>
-#include <vnet/geneve/geneve.api_types.h>
+#include <geneve/geneve.h>
+
+/* define message IDs */
+#include <vnet/format_fns.h>
+#include <geneve/geneve.api_enum.h>
+#include <geneve/geneve.api_types.h>
+
+/**
+ * Base message ID fot the plugin
+ */
+static u32 geneve_base_msg_id;
+#define REPLY_MSG_ID_BASE geneve_base_msg_id
-#define REPLY_MSG_ID_BASE gm->msg_id_base
#include <vlibapi/api_helper_macros.h>
static void
vl_api_sw_interface_set_geneve_bypass_t_handler
(vl_api_sw_interface_set_geneve_bypass_t * mp)
{
- geneve_main_t *gm = &geneve_main;
vl_api_sw_interface_set_geneve_bypass_reply_t *rmp;
int rv = 0;
u32 sw_if_index = ntohl (mp->sw_if_index);
@@ -50,7 +57,6 @@ static void
static void vl_api_geneve_add_del_tunnel_t_handler
(vl_api_geneve_add_del_tunnel_t * mp)
{
- geneve_main_t *gm = &geneve_main;
vl_api_geneve_add_del_tunnel_reply_t *rmp;
int rv = 0;
ip4_main_t *im = &ip4_main;
@@ -102,7 +108,6 @@ out:
static void vl_api_geneve_add_del_tunnel2_t_handler
(vl_api_geneve_add_del_tunnel2_t * mp)
{
- geneve_main_t *gm = &geneve_main;
vl_api_geneve_add_del_tunnel2_reply_t *rmp;
int rv = 0;
ip4_main_t *im = &ip4_main;
@@ -155,7 +160,6 @@ out:
static void send_geneve_tunnel_details
(geneve_tunnel_t * t, vl_api_registration_t * reg, u32 context)
{
- geneve_main_t *gm = &geneve_main;
vl_api_geneve_tunnel_details_t *rmp;
ip4_main_t *im4 = &ip4_main;
ip6_main_t *im6 = &ip6_main;
@@ -163,7 +167,7 @@ static void send_geneve_tunnel_details
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_GENEVE_TUNNEL_DETAILS + gm->msg_id_base);
+ rmp->_vl_msg_id = ntohs (VL_API_GENEVE_TUNNEL_DETAILS + REPLY_MSG_ID_BASE);
ip_address_encode (&t->local, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
&rmp->src_address);
ip_address_encode (&t->remote, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
@@ -222,23 +226,36 @@ static void vl_api_geneve_tunnel_dump_t_handler
*/
/* API definitions */
#include <vnet/format_fns.h>
-#include <vnet/geneve/geneve.api.c>
+#include <geneve/geneve.api.c>
static clib_error_t *
geneve_api_hookup (vlib_main_t * vm)
{
- geneve_main_t *gm = &geneve_main;
+ api_main_t *am = vlibapi_get_main ();
/*
* Set up the (msg_name, crc, message-id) table
*/
- gm->msg_id_base = setup_message_id_table ();
+ geneve_base_msg_id = setup_message_id_table ();
+
+ am->api_trace_cfg[VL_API_GENEVE_ADD_DEL_TUNNEL + REPLY_MSG_ID_BASE].size +=
+ 16 * sizeof (u32);
return 0;
}
VLIB_API_INIT_FUNCTION (geneve_api_hookup);
+#include <vlib/unix/plugin.h>
+#include <vpp/app/version.h>
+
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () = {
+ .version = VPP_BUILD_VER,
+ .description = "GENEVE Tunnels",
+};
+/* *INDENT-ON* */
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/geneve/geneve_error.def b/src/plugins/geneve/geneve_error.def
index 73abc8ddbf1..73abc8ddbf1 100644
--- a/src/vnet/geneve/geneve_error.def
+++ b/src/plugins/geneve/geneve_error.def
diff --git a/src/vnet/geneve/geneve_packet.h b/src/plugins/geneve/geneve_packet.h
index a0d0687434c..a0d0687434c 100644
--- a/src/vnet/geneve/geneve_packet.h
+++ b/src/plugins/geneve/geneve_packet.h
diff --git a/src/vnet/geneve/geneve_test.c b/src/plugins/geneve/geneve_test.c
index 183ce5311de..ad6d3296ef6 100644
--- a/src/vnet/geneve/geneve_test.c
+++ b/src/plugins/geneve/geneve_test.c
@@ -1,7 +1,4 @@
/*
- *------------------------------------------------------------------
- * geneve_test.c
- *
* Copyright (c) 2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,16 +11,22 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *------------------------------------------------------------------
*/
-
+
#include <vat/vat.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
-#include <vnet/format_fns.h>
+#include <vppinfra/error.h>
+
#include <vnet/ip/ip.h>
-#include <vpp/api/types.h>
-#include <vnet/geneve/geneve.h>
+#include <vnet/ip/ip_types_api.h>
+#include <geneve/geneve.h>
+
+/* define message IDs */
+#include <vnet/format_fns.h>
+#include <geneve/geneve.api_enum.h>
+#include <geneve/geneve.api_types.h>
+#include <vpp/api/vpe.api_types.h>
typedef struct
{
@@ -35,19 +38,17 @@ typedef struct
geneve_test_main_t geneve_test_main;
-/* Declare message IDs */
-#include <vnet/geneve/geneve.api_enum.h>
-#include <vnet/geneve/geneve.api_types.h>
-#include <vpp/api/vpe.api_types.h>
-
#define __plugin_msg_base geneve_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>
-uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
-static void vl_api_geneve_add_del_tunnel2_reply_t_handler
- (vl_api_geneve_add_del_tunnel2_reply_t * mp)
-{
-}
+/* Macro to finish up custom dump fns */
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+#define FINISH \
+ vec_add1 (s, 0); \
+ vl_print (handle, (char *)s); \
+ vec_free (s); \
+ return handle;
+
static void vl_api_geneve_add_del_tunnel_reply_t_handler
(vl_api_geneve_add_del_tunnel_reply_t * mp)
{
@@ -65,6 +66,23 @@ static void vl_api_geneve_add_del_tunnel_reply_t_handler
}
}
+static void vl_api_geneve_add_del_tunnel2_reply_t_handler
+ (vl_api_geneve_add_del_tunnel2_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ i32 retval = ntohl (mp->retval);
+ if (vam->async_mode)
+ {
+ vam->async_errors += (retval < 0);
+ }
+ else
+ {
+ vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->result_ready = 1;
+ }
+}
+
static int
api_sw_interface_set_geneve_bypass (vat_main_t * vam)
{
@@ -115,6 +133,7 @@ api_sw_interface_set_geneve_bypass (vat_main_t * vam)
W (ret);
return ret;
}
+
static uword unformat_geneve_decap_next
(unformat_input_t * input, va_list * args)
{
@@ -131,12 +150,6 @@ static uword unformat_geneve_decap_next
}
static int
-api_geneve_add_del_tunnel2 (vat_main_t * vam)
-{
- return 0; // NOT YET IMPLEMENTED
-}
-
-static int
api_geneve_add_del_tunnel (vat_main_t * vam)
{
unformat_input_t *line_input = vam->input;
@@ -291,6 +304,12 @@ api_geneve_add_del_tunnel (vat_main_t * vam)
return ret;
}
+static int
+api_geneve_add_del_tunnel2 (vat_main_t * vam)
+{
+ return api_geneve_add_del_tunnel (vam);
+}
+
static void vl_api_geneve_tunnel_details_t_handler
(vl_api_geneve_tunnel_details_t * mp)
{
@@ -327,7 +346,6 @@ api_geneve_tunnel_dump (vat_main_t * vam)
u32 sw_if_index;
u8 sw_if_index_set = 0;
int ret;
- geneve_test_main_t *gm = &geneve_test_main;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
@@ -358,17 +376,37 @@ api_geneve_tunnel_dump (vat_main_t * vam)
S (mp);
/* Use a control ping for synchronization */
- if (!gm->ping_id)
- gm->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
+ if (!geneve_test_main.ping_id)
+ geneve_test_main.ping_id =
+ vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
- mp_ping->_vl_msg_id = htons (gm->ping_id);
+ mp_ping->_vl_msg_id = htons (geneve_test_main.ping_id);
mp_ping->client_index = vam->my_client_index;
+
+ fformat (vam->ofp, "Sending ping id=%d\n", geneve_test_main.ping_id);
+
+ vam->result_ready = 0;
S (mp_ping);
W (ret);
return ret;
}
-#include <vnet/geneve/geneve.api_test.c>
-VAT_REGISTER_FEATURE_FUNCTION(vat_geneve_plugin_register);
+/* _(sw_interface_set_geneve_bypass, */
+/* "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") */
+/* _(geneve_add_del_tunnel, */
+/* "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" */
+/* "{ <intfc> | mcast_sw_if_index <nn> } }\n" */
+/* "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") */
+/* _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") */
+
+
+#include <geneve/geneve.api_test.c>
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/geneve/test/test_geneve.py b/src/plugins/geneve/test/test_geneve.py
new file mode 100644
index 00000000000..9ce1f8ff643
--- /dev/null
+++ b/src/plugins/geneve/test/test_geneve.py
@@ -0,0 +1,307 @@
+#!/usr/bin/env python3
+
+import socket
+from util import ip4_range
+import unittest
+from framework import VppTestCase, VppTestRunner
+from template_bd import BridgeDomain
+
+from scapy.layers.l2 import Ether, ARP
+from scapy.layers.inet import IP, UDP, ICMP
+from scapy.contrib.geneve import GENEVE
+
+import util
+from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip import INVALID_INDEX
+
+
+class TestGeneve(BridgeDomain, VppTestCase):
+ """ GENEVE Test Case """
+
+ def __init__(self, *args):
+ BridgeDomain.__init__(self)
+ VppTestCase.__init__(self, *args)
+
+ def encapsulate(self, pkt, vni):
+
+ """
+ Encapsulate the original payload frame by adding GENEVE header with its
+ UDP, IP and Ethernet fields
+ """
+ return (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
+ IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
+ UDP(sport=self.dport, dport=self.dport, chksum=0) /
+ GENEVE(vni=vni) /
+ pkt)
+
+ def ip_range(self, start, end):
+ """ range of remote ip's """
+ return ip4_range(self.pg0.remote_ip4, start, end)
+
+ def encap_mcast(self, pkt, src_ip, src_mac, vni):
+ """
+ Encapsulate the original payload frame by adding GENEVE header with its
+ UDP, IP and Ethernet fields
+ """
+ return (Ether(src=src_mac, dst=self.mcast_mac) /
+ IP(src=src_ip, dst=self.mcast_ip4) /
+ UDP(sport=self.dport, dport=self.dport, chksum=0) /
+ GENEVE(vni=vni) /
+ pkt)
+
+ def decapsulate(self, pkt):
+ """
+ Decapsulate the original payload frame by removing GENEVE header
+ """
+ # check if is set I flag
+ # self.assertEqual(pkt[GENEVE].flags, int('0x8', 16))
+ return pkt[GENEVE].payload
+
+ # Method for checking GENEVE encapsulation.
+ #
+ def check_encapsulation(self, pkt, vni, local_only=False, mcast_pkt=False):
+ # TODO: add error messages
+ # Verify source MAC is VPP_MAC and destination MAC is MY_MAC resolved
+ # by VPP using ARP.
+ self.assertEqual(pkt[Ether].src, self.pg0.local_mac)
+ if not local_only:
+ if not mcast_pkt:
+ self.assertEqual(pkt[Ether].dst, self.pg0.remote_mac)
+ else:
+ self.assertEqual(pkt[Ether].dst, type(self).mcast_mac)
+ # Verify GENEVE tunnel source IP is VPP_IP and destination IP is MY_IP.
+ self.assertEqual(pkt[IP].src, self.pg0.local_ip4)
+ if not local_only:
+ if not mcast_pkt:
+ self.assertEqual(pkt[IP].dst, self.pg0.remote_ip4)
+ else:
+ self.assertEqual(pkt[IP].dst, type(self).mcast_ip4)
+ # Verify UDP destination port is GENEVE 4789, source UDP port could be
+ # arbitrary.
+ self.assertEqual(pkt[UDP].dport, type(self).dport)
+ # TODO: checksum check
+ # Verify VNI
+ self.assertEqual(pkt[GENEVE].vni, vni)
+
+ @classmethod
+ def create_geneve_flood_test_bd(cls, vni, n_ucast_tunnels):
+ # Create 10 ucast geneve tunnels under bd
+ ip_range_start = 10
+ ip_range_end = ip_range_start + n_ucast_tunnels
+ next_hop_address = cls.pg0.remote_ip4
+ for dest_ip4 in ip4_range(next_hop_address, ip_range_start,
+ ip_range_end):
+ # add host route so dest_ip4 will not be resolved
+ rip = VppIpRoute(cls, dest_ip4, 32,
+ [VppRoutePath(next_hop_address,
+ INVALID_INDEX)],
+ register=False)
+ rip.add_vpp_config()
+ r = cls.vapi.geneve_add_del_tunnel(
+ local_address=cls.pg0.local_ip4, remote_address=dest_ip4,
+ vni=vni)
+ cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
+ bd_id=vni)
+
+ @classmethod
+ def add_del_shared_mcast_dst_load(cls, is_add):
+ """
+ add or del tunnels sharing the same mcast dst
+ to test geneve ref_count mechanism
+ """
+ n_shared_dst_tunnels = 10
+ vni_start = 10000
+ vni_end = vni_start + n_shared_dst_tunnels
+ for vni in range(vni_start, vni_end):
+ r = cls.vapi.geneve_add_del_tunnel(
+ local_address=cls.pg0.local_ip4,
+ remote_address=cls.mcast_ip4, mcast_sw_if_index=1,
+ is_add=is_add, vni=vni)
+ if r.sw_if_index == 0xffffffff:
+ raise ValueError("bad sw_if_index: ~0")
+
+ @classmethod
+ def add_shared_mcast_dst_load(cls):
+ cls.add_del_shared_mcast_dst_load(is_add=1)
+
+ @classmethod
+ def del_shared_mcast_dst_load(cls):
+ cls.add_del_shared_mcast_dst_load(is_add=0)
+
+ @classmethod
+ def add_del_mcast_tunnels_load(cls, is_add):
+ """
+ add or del tunnels to test geneve stability
+ """
+ n_distinct_dst_tunnels = 10
+ ip_range_start = 10
+ ip_range_end = ip_range_start + n_distinct_dst_tunnels
+ for dest_ip4 in ip4_range(cls.mcast_ip4, ip_range_start,
+ ip_range_end):
+ vni = int(dest_ip4.split('.')[3])
+ cls.vapi.geneve_add_del_tunnel(local_address=cls.pg0.local_ip4,
+ remote_address=dest_ip4,
+ mcast_sw_if_index=1, is_add=is_add,
+ vni=vni)
+
+ @classmethod
+ def add_mcast_tunnels_load(cls):
+ cls.add_del_mcast_tunnels_load(is_add=1)
+
+ @classmethod
+ def del_mcast_tunnels_load(cls):
+ cls.add_del_mcast_tunnels_load(is_add=0)
+
+ # Class method to start the GENEVE test case.
+ # Overrides setUpClass method in VppTestCase class.
+ # Python try..except statement is used to ensure that the tear down of
+ # the class will be executed even if exception is raised.
+ # @param cls The class pointer.
+ @classmethod
+ def setUpClass(cls):
+ super(TestGeneve, cls).setUpClass()
+
+ try:
+ cls.dport = 6081
+
+ # Create 2 pg interfaces.
+ cls.create_pg_interfaces(range(4))
+ for pg in cls.pg_interfaces:
+ pg.admin_up()
+
+ # Configure IPv4 addresses on VPP pg0.
+ cls.pg0.config_ip4()
+
+ # Resolve MAC address for VPP's IP address on pg0.
+ cls.pg0.resolve_arp()
+
+ # Our Multicast address
+ cls.mcast_ip4 = '239.1.1.1'
+ cls.mcast_mac = util.mcast_ip_to_mac(cls.mcast_ip4)
+
+ # Create GENEVE VTEP on VPP pg0, and put geneve_tunnel0 and pg1
+ # into BD.
+ cls.single_tunnel_vni = 0xabcde
+ cls.single_tunnel_bd = 1
+ r = cls.vapi.geneve_add_del_tunnel(
+ local_address=cls.pg0.local_ip4,
+ remote_address=cls.pg0.remote_ip4, vni=cls.single_tunnel_vni)
+ 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_geneve_flood_test_bd(cls.mcast_flood_bd,
+ cls.n_ucast_tunnels)
+ r = cls.vapi.geneve_add_del_tunnel(
+ local_address=cls.pg0.local_ip4,
+ remote_address=cls.mcast_ip4, 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_geneve_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(TestGeneve, cls).tearDownClass()
+ raise
+
+ # Method to define VPP actions before tear down of the test case.
+ # Overrides tearDown method in VppTestCase class.
+ # @param self The object pointer.
+ def tearDown(self):
+ super(TestGeneve, self).tearDown()
+
+ def show_commands_at_teardown(self):
+ self.logger.info(self.vapi.cli("show bridge-domain 1 detail"))
+ self.logger.info(self.vapi.cli("show bridge-domain 2 detail"))
+ self.logger.info(self.vapi.cli("show bridge-domain 3 detail"))
+ self.logger.info(self.vapi.cli("show geneve tunnel"))
+
+
+class TestGeneveL3(VppTestCase):
+ """ GENEVE L3 Test Case """
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestGeneveL3, cls).setUpClass()
+ try:
+ cls.create_pg_interfaces(range(2))
+ cls.interfaces = list(cls.pg_interfaces)
+
+ for i in cls.interfaces:
+ i.admin_up()
+ i.config_ip4()
+ i.resolve_arp()
+ except Exception:
+ super(TestGeneveL3, cls).tearDownClass()
+ raise
+
+ @classmethod
+ def tearDownClass(cls):
+ super(TestGeneveL3, cls).tearDownClass()
+
+ def tearDown(self):
+ super(TestGeneveL3, self).tearDown()
+
+ def show_commands_at_teardown(self):
+ self.logger.info(self.vapi.cli("show geneve tunnel"))
+ self.logger.info(self.vapi.cli("show ip neighbor"))
+
+ def test_l3_packet(self):
+ vni = 1234
+ r = self.vapi.add_node_next(node_name="geneve4-input",
+ next_name="ethernet-input")
+ r = self.vapi.geneve_add_del_tunnel2(
+ is_add=1,
+ local_address=self.pg0.local_ip4,
+ remote_address=self.pg0.remote_ip4,
+ vni=vni,
+ l3_mode=1,
+ decap_next_index=r.next_index)
+
+ self.vapi.sw_interface_add_del_address(
+ sw_if_index=r.sw_if_index, prefix="10.0.0.1/24")
+
+ pkt = (Ether(src=self.pg0.remote_mac, dst="d0:0b:ee:d0:00:00") /
+ IP(src='10.0.0.2', dst='10.0.0.1') /
+ ICMP())
+
+ encap = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
+ IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
+ UDP(sport=6081, dport=6081, chksum=0) /
+ GENEVE(vni=vni))
+
+ arp = (Ether(src=self.pg0.remote_mac, dst="d0:0b:ee:d0:00:00") /
+ ARP(op="is-at", hwsrc=self.pg0.remote_mac,
+ hwdst="d0:0b:ee:d0:00:00", psrc="10.0.0.2",
+ pdst="10.0.0.1"))
+
+ rx = self.send_and_expect(self.pg0, encap/pkt*1, self.pg0)
+ rx = self.send_and_assert_no_replies(self.pg0, encap/arp*1, self.pg0)
+ rx = self.send_and_expect(self.pg0, encap/pkt*1, self.pg0)
+ self.assertEqual(rx[0][ICMP].type, 0) # echo reply
+
+ r = self.vapi.geneve_add_del_tunnel2(
+ is_add=0,
+ local_address=self.pg0.local_ip4,
+ remote_address=self.pg0.remote_ip4,
+ vni=vni)
+
+if __name__ == '__main__':
+ unittest.main(testRunner=VppTestRunner)
diff --git a/src/vat/CMakeLists.txt b/src/vat/CMakeLists.txt
index ed14e846625..ee53386f114 100644
--- a/src/vat/CMakeLists.txt
+++ b/src/vat/CMakeLists.txt
@@ -33,7 +33,6 @@ add_vpp_executable(vpp_api_test ENABLE_EXPORTS
ip_types.c
protocols.def
../vnet/arp/arp_test.c
- ../vnet/geneve/geneve_test.c
DEPENDS api_headers
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index 579302c4687..124af13f202 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -322,29 +322,6 @@ list(APPEND VNET_MULTIARCH_SOURCES vxlan/decap.c)
list(APPEND VNET_API_FILES vxlan/vxlan.api)
##############################################################################
-# Layer 2 / Geneve
-##############################################################################
-list(APPEND VNET_SOURCES
- geneve/geneve.c
- geneve/encap.c
- geneve/decap.c
- geneve/geneve_api.c
-)
-
-list(APPEND VNET_MULTIARCH_SOURCES
- geneve/encap.c
- geneve/decap.c
-)
-
-list(APPEND VNET_HEADERS
- geneve/geneve.h
- geneve/geneve_packet.h
- geneve/geneve_error.def
-)
-
-list(APPEND VNET_API_FILES geneve/geneve.api)
-
-##############################################################################
# Layer 2 / Bonding
##############################################################################
list(APPEND VNET_SOURCES
diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt
index 64a8eb86bc6..ae1e4d76c02 100644
--- a/src/vpp/CMakeLists.txt
+++ b/src/vpp/CMakeLists.txt
@@ -74,7 +74,6 @@ if(VPP_API_TEST_BUILTIN)
api/plugin.c
api/types.c
../vnet/arp/arp_test.c
- ../vnet/geneve/geneve_test.c
)
add_definitions(-DVPP_API_TEST_BUILTIN=1)
endif()