summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS5
-rw-r--r--src/vat/api_format.c37
-rw-r--r--src/vnet/geneve/geneve.api34
-rw-r--r--src/vnet/geneve/geneve_api.c29
-rw-r--r--src/vpp/api/custom_dump.c6
-rw-r--r--test/test_geneve.py30
6 files changed, 78 insertions, 63 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 011571691e6..4f5e24a3366 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -268,6 +268,11 @@ M: Dave Barach <dave@barachs.net>
M: Neale Ranns <nranns@cisco.com>
F: src/plugins/dhcp/
+VNET GENEVE
+I: geneve
+M: N/A
+F: src/vnet/geneve/
+
Plugin - Access Control List (ACL) Based Forwarding
I: abf
M: Neale Ranns <nranns@cisco.com>
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 1a2fca1622e..369dcc44641 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -12439,20 +12439,19 @@ api_geneve_add_del_tunnel (vat_main_t * vam)
if (ipv6_set)
{
- clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
- clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
+ clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
+ clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
}
else
{
- clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
- clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
+ clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
+ clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
}
mp->encap_vrf_id = ntohl (encap_vrf_id);
mp->decap_next_index = ntohl (decap_next_index);
mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
mp->vni = ntohl (vni);
mp->is_add = is_add;
- mp->is_ipv6 = ipv6_set;
S (mp);
W (ret);
@@ -12463,8 +12462,19 @@ static void vl_api_geneve_tunnel_details_t_handler
(vl_api_geneve_tunnel_details_t * mp)
{
vat_main_t *vam = &vat_main;
- ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
- ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
+ ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
+ ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
+
+ if (mp->src_address.af == ADDRESS_IP6)
+ {
+ clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
+ clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
+ }
+ else
+ {
+ clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
+ clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
+ }
print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
ntohl (mp->sw_if_index),
@@ -12480,6 +12490,7 @@ static void vl_api_geneve_tunnel_details_t_handler_json
{
vat_main_t *vam = &vat_main;
vat_json_node_t *node = NULL;
+ bool is_ipv6;
if (VAT_JSON_ARRAY != vam->json_tree.type)
{
@@ -12490,29 +12501,29 @@ static void vl_api_geneve_tunnel_details_t_handler_json
vat_json_init_object (node);
vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- if (mp->is_ipv6)
+ is_ipv6 = mp->src_address.af == ADDRESS_IP6;
+ if (is_ipv6)
{
struct in6_addr ip6;
- clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
+ clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
vat_json_object_add_ip6 (node, "src_address", ip6);
- clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
+ clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
vat_json_object_add_ip6 (node, "dst_address", ip6);
}
else
{
struct in_addr ip4;
- clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
+ clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (node, "src_address", ip4);
- clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
+ clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (node, "dst_address", ip4);
}
vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
vat_json_object_add_uint (node, "decap_next_index",
ntohl (mp->decap_next_index));
vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
- vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
vat_json_object_add_uint (node, "mcast_sw_if_index",
ntohl (mp->mcast_sw_if_index));
}
diff --git a/src/vnet/geneve/geneve.api b/src/vnet/geneve/geneve.api
index b48989c2687..5fad670b9db 100644
--- a/src/vnet/geneve/geneve.api
+++ b/src/vnet/geneve/geneve.api
@@ -13,17 +13,20 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ethernet/ethernet_types.api";
+import "vnet/ip/ip_types.api";
define geneve_add_del_tunnel
{
u32 client_index;
u32 context;
- u8 is_add;
- u8 is_ipv6;
- u8 local_address[16];
- u8 remote_address[16];
- u32 mcast_sw_if_index;
+ bool is_add;
+ vl_api_address_t local_address;
+ vl_api_address_t remote_address;
+ vl_api_interface_index_t mcast_sw_if_index;
u32 encap_vrf_id;
u32 decap_next_index;
u32 vni;
@@ -33,27 +36,26 @@ define geneve_add_del_tunnel_reply
{
u32 context;
i32 retval;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
define geneve_tunnel_dump
{
u32 client_index;
u32 context;
- u32 sw_if_index;
+ vl_api_interface_index_t sw_if_index;
};
define geneve_tunnel_details
{
u32 context;
- u32 sw_if_index;
- u8 src_address[16];
- u8 dst_address[16];
- u32 mcast_sw_if_index;
+ vl_api_interface_index_t sw_if_index;
+ vl_api_address_t src_address;
+ vl_api_address_t dst_address;
+ vl_api_interface_index_t mcast_sw_if_index;
u32 encap_vrf_id;
u32 decap_next_index;
u32 vni;
- u8 is_ipv6;
};
/** \brief Interface set geneve-bypass request
@@ -67,7 +69,7 @@ autoreply define sw_interface_set_geneve_bypass
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 is_ipv6;
- u8 enable;
+ vl_api_interface_index_t sw_if_index;
+ bool is_ipv6;
+ bool enable;
};
diff --git a/src/vnet/geneve/geneve_api.c b/src/vnet/geneve/geneve_api.c
index 0bada58710e..2a4f5aa8053 100644
--- a/src/vnet/geneve/geneve_api.c
+++ b/src/vnet/geneve/geneve_api.c
@@ -22,6 +22,7 @@
#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/vnet_msg_enum.h>
@@ -78,15 +79,16 @@ static void vl_api_geneve_add_del_tunnel_t_handler
vnet_geneve_add_del_tunnel_args_t a = {
.is_add = mp->is_add,
- .is_ip6 = mp->is_ipv6,
+ .is_ip6 = mp->remote_address.af,
.mcast_sw_if_index = ntohl (mp->mcast_sw_if_index),
.encap_fib_index = p[0],
.decap_next_index = ntohl (mp->decap_next_index),
.vni = ntohl (mp->vni),
- .remote = to_ip46 (mp->is_ipv6, mp->remote_address),
- .local = to_ip46 (mp->is_ipv6, mp->local_address),
};
+ ip_address_decode (&mp->remote_address, &a.remote);
+ ip_address_decode (&mp->local_address, &a.local);
+
/* Check src & dst are different */
if (ip46_address_cmp (&a.remote, &a.local) == 0)
{
@@ -123,23 +125,18 @@ 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);
- if (is_ipv6)
- {
- memcpy (rmp->src_address, t->local.ip6.as_u8, 16);
- memcpy (rmp->dst_address, t->remote.ip6.as_u8, 16);
- rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
- }
- else
- {
- memcpy (rmp->src_address, t->local.ip4.as_u8, 4);
- memcpy (rmp->dst_address, t->remote.ip4.as_u8, 4);
- rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
- }
+ 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,
+ &rmp->dst_address);
+ rmp->encap_vrf_id =
+ htonl (is_ipv6 ? im6->fibs[t->encap_fib_index].
+ ft_table_id : im4->fibs[t->encap_fib_index].ft_table_id);
+
rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index);
rmp->vni = htonl (t->vni);
rmp->decap_next_index = htonl (t->decap_next_index);
rmp->sw_if_index = htonl (t->sw_if_index);
- rmp->is_ipv6 = is_ipv6;
rmp->context = context;
vl_api_send_msg (reg, (u8 *) rmp);
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 3c6eada0a05..14da1242335 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -1708,8 +1708,10 @@ static void *vl_api_geneve_add_del_tunnel_t_print
u8 *s;
s = format (0, "SCRIPT: geneve_add_del_tunnel ");
- ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local_address);
- ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote_address);
+ ip46_address_t local;
+ ip46_address_t remote;
+ ip_address_decode (&mp->remote_address, &remote);
+ ip_address_decode (&mp->local_address, &local);
u8 is_grp = ip46_address_is_multicast (&remote);
char *remote_name = is_grp ? "group" : "dst";
diff --git a/test/test_geneve.py b/test/test_geneve.py
index 04271e31b69..ffa8fb8e8e5 100644
--- a/test/test_geneve.py
+++ b/test/test_geneve.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import socket
-from util import ip4n_range, ip4_range
+from util import ip4_range, ip4_range
import unittest
from framework import VppTestCase, VppTestRunner
from template_bd import BridgeDomain
@@ -90,15 +90,14 @@ class TestGeneve(BridgeDomain, VppTestCase):
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_ip4n will not be resolved
+ # 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()
- dest_ip4n = socket.inet_pton(socket.AF_INET, dest_ip4)
r = cls.vapi.geneve_add_del_tunnel(
- local_address=cls.pg0.local_ip4n, remote_address=dest_ip4n,
+ 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)
@@ -114,8 +113,8 @@ class TestGeneve(BridgeDomain, VppTestCase):
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_ip4n,
- remote_address=cls.mcast_ip4n, mcast_sw_if_index=1,
+ 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")
@@ -136,11 +135,11 @@ class TestGeneve(BridgeDomain, VppTestCase):
n_distinct_dst_tunnels = 10
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.geneve_add_del_tunnel(local_address=cls.pg0.local_ip4n,
- remote_address=dest_ip4n,
+ for dest_ip4 in ip4_range(cls.mcast_ip4, ip_range_start,
+ ip_range_end):
+ vni = bytearray(dest_ip4)[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)
@@ -177,7 +176,6 @@ class TestGeneve(BridgeDomain, VppTestCase):
# Our Multicast address
cls.mcast_ip4 = '239.1.1.1'
- cls.mcast_ip4n = socket.inet_pton(socket.AF_INET, cls.mcast_ip4)
iplong = atol(cls.mcast_ip4)
cls.mcast_mac = "01:00:5e:%02x:%02x:%02x" % (
(iplong >> 16) & 0x7F, (iplong >> 8) & 0xFF, iplong & 0xFF)
@@ -186,8 +184,8 @@ class TestGeneve(BridgeDomain, VppTestCase):
# into BD.
cls.single_tunnel_bd = 1
r = cls.vapi.geneve_add_del_tunnel(
- local_address=cls.pg0.local_ip4n,
- remote_address=cls.pg0.remote_ip4n, vni=cls.single_tunnel_bd)
+ local_address=cls.pg0.local_ip4,
+ remote_address=cls.pg0.remote_ip4, 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(
@@ -199,8 +197,8 @@ class TestGeneve(BridgeDomain, VppTestCase):
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_ip4n,
- remote_address=cls.mcast_ip4n, mcast_sw_if_index=1,
+ 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)