aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/vxlan-gbp/vxlan_gbp.api60
-rw-r--r--src/vnet/vxlan-gbp/vxlan_gbp.c14
-rw-r--r--src/vnet/vxlan-gbp/vxlan_gbp.h7
-rw-r--r--src/vnet/vxlan-gbp/vxlan_gbp_api.c73
4 files changed, 73 insertions, 81 deletions
diff --git a/src/vnet/vxlan-gbp/vxlan_gbp.api b/src/vnet/vxlan-gbp/vxlan_gbp.api
index ecb5ba27f18..6e41ec8b2b9 100644
--- a/src/vnet/vxlan-gbp/vxlan_gbp.api
+++ b/src/vnet/vxlan-gbp/vxlan_gbp.api
@@ -1,3 +1,4 @@
+/* Hey Emacs use -*- mode: C -*- */
/*
* Copyright (c) 2018 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,39 +14,45 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "1.1.0";
+import "vnet/ip/ip_types.api";
-/** \brief Create or delete a VXLAN-GBP tunnel
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - Use 1 to create the tunnel, 0 to remove it
- @param is_ipv6 - Use 0 for IPv4, 1 for IPv6
+/** \brief Definition of a VXLAN GBP tunnel
@param instance - optional unique custom device instance, else ~0.
- @param src_address - Source IP address
- @param dst_address - Destination IP address, can be multicast
+ @param src - Source IP address
+ @param dst - Destination IP address, can be multicast
@param mcast_sw_if_index - Interface for multicast destination
- @param encap_vrf_id - Encap route table FIB index
+ @param encap_table_id - Encap route table
@param decap_next_index - Name of decap next graph node
@param vni - The VXLAN Network Identifier, uint24
- @param sclass - The policy group id
+ @param sw_ifindex - Ignored in add message, set in details
*/
-define vxlan_gbp_add_del_tunnel
+typedef vxlan_gbp_tunnel
{
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 is_ipv6;
- u32 instance; /* If non-~0, specifies a custom dev instance */
- u8 src_address[16];
- u8 dst_address[16];
+ u32 instance;
+ vl_api_address_t src;
+ vl_api_address_t dst;
u32 mcast_sw_if_index;
- u32 encap_vrf_id;
+ u32 encap_table_id;
u32 decap_next_index;
u32 vni;
- u16 sclass;
+ u32 sw_if_index;
};
-define vxlan_gbp_add_del_tunnel_reply
+/** \brief Create or delete a VXLAN-GBP tunnel
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_add - Use 1 to create the tunnel, 0 to remove it
+*/
+define vxlan_gbp_tunnel_add_del
+{
+ u32 client_index;
+ u32 context;
+ u8 is_add;
+ vl_api_vxlan_gbp_tunnel_t tunnel;
+};
+
+define vxlan_gbp_tunnel_add_del_reply
{
u32 context;
i32 retval;
@@ -62,16 +69,7 @@ define vxlan_gbp_tunnel_dump
define vxlan_gbp_tunnel_details
{
u32 context;
- u32 sw_if_index;
- u32 instance;
- u8 src_address[16];
- u8 dst_address[16];
- u32 mcast_sw_if_index;
- u32 encap_vrf_id;
- u32 decap_next_index;
- u32 vni;
- u16 sclass;
- u8 is_ipv6;
+ vl_api_vxlan_gbp_tunnel_t tunnel;
};
/** \brief Interface set vxlan-bypass request
diff --git a/src/vnet/vxlan-gbp/vxlan_gbp.c b/src/vnet/vxlan-gbp/vxlan_gbp.c
index 14b3e667dbf..253261dc9e5 100644
--- a/src/vnet/vxlan-gbp/vxlan_gbp.c
+++ b/src/vnet/vxlan-gbp/vxlan_gbp.c
@@ -352,8 +352,8 @@ mcast_shared_remove (ip46_address_t * dst)
hash_unset_mem_free (&vxlan_gbp_main.mcast_shared, dst);
}
-int vnet_vxlan_gbp_add_del_tunnel
- (vnet_vxlan_gbp_add_del_tunnel_args_t * a, u32 * sw_if_indexp)
+int vnet_vxlan_gbp_tunnel_add_del
+ (vnet_vxlan_gbp_tunnel_add_del_args_t * a, u32 * sw_if_indexp)
{
vxlan_gbp_main_t *vxm = &vxlan_gbp_main;
vxlan_gbp_tunnel_t *t = 0;
@@ -654,7 +654,7 @@ unformat_decap_next (unformat_input_t * input, va_list * args)
}
static clib_error_t *
-vxlan_gbp_add_del_tunnel_command_fn (vlib_main_t * vm,
+vxlan_gbp_tunnel_add_del_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
@@ -763,7 +763,7 @@ vxlan_gbp_add_del_tunnel_command_fn (vlib_main_t * vm,
if (vni >> 24)
return clib_error_return (0, "vni %d out of range", vni);
- vnet_vxlan_gbp_add_del_tunnel_args_t a = {
+ vnet_vxlan_gbp_tunnel_add_del_args_t a = {
.is_add = is_add,
.is_ip6 = ipv6_set,
.instance = instance,
@@ -773,7 +773,7 @@ vxlan_gbp_add_del_tunnel_command_fn (vlib_main_t * vm,
};
u32 tunnel_sw_if_index;
- int rv = vnet_vxlan_gbp_add_del_tunnel (&a, &tunnel_sw_if_index);
+ int rv = vnet_vxlan_gbp_tunnel_add_del (&a, &tunnel_sw_if_index);
switch (rv)
{
@@ -794,7 +794,7 @@ vxlan_gbp_add_del_tunnel_command_fn (vlib_main_t * vm,
default:
return clib_error_return
- (0, "vnet_vxlan_gbp_add_del_tunnel returned %d", rv);
+ (0, "vnet_vxlan_gbp_tunnel_add_del returned %d", rv);
}
return 0;
@@ -832,7 +832,7 @@ VLIB_CLI_COMMAND (create_vxlan_gbp_tunnel_command, static) = {
" {dst <remote-vtep-addr>|group <mcast-vtep-addr> <intf-name>} vni <nn>"
" [instance <id>]"
" [encap-vrf-id <nn>] [decap-next [l2|node <name>]] [del]",
- .function = vxlan_gbp_add_del_tunnel_command_fn,
+ .function = vxlan_gbp_tunnel_add_del_command_fn,
};
/* *INDENT-ON* */
diff --git a/src/vnet/vxlan-gbp/vxlan_gbp.h b/src/vnet/vxlan-gbp/vxlan_gbp.h
index bc0ccf308b6..472866ecd6d 100644
--- a/src/vnet/vxlan-gbp/vxlan_gbp.h
+++ b/src/vnet/vxlan-gbp/vxlan_gbp.h
@@ -185,15 +185,14 @@ typedef struct
u8 is_ip6;
u32 instance;
ip46_address_t src, dst;
- u16 sclass;
u32 mcast_sw_if_index;
u32 encap_fib_index;
u32 decap_next_index;
u32 vni;
-} vnet_vxlan_gbp_add_del_tunnel_args_t;
+} vnet_vxlan_gbp_tunnel_add_del_args_t;
-int vnet_vxlan_gbp_add_del_tunnel
- (vnet_vxlan_gbp_add_del_tunnel_args_t * a, u32 * sw_if_indexp);
+int vnet_vxlan_gbp_tunnel_add_del
+ (vnet_vxlan_gbp_tunnel_add_del_args_t * a, u32 * sw_if_indexp);
void vnet_int_vxlan_gbp_bypass_mode (u32 sw_if_index, u8 is_ip6,
u8 is_enable);
diff --git a/src/vnet/vxlan-gbp/vxlan_gbp_api.c b/src/vnet/vxlan-gbp/vxlan_gbp_api.c
index b064a1f4392..1bba74d6370 100644
--- a/src/vnet/vxlan-gbp/vxlan_gbp_api.c
+++ b/src/vnet/vxlan-gbp/vxlan_gbp_api.c
@@ -25,6 +25,7 @@
#include <vnet/feature/feature.h>
#include <vnet/vxlan-gbp/vxlan_gbp.h>
#include <vnet/fib/fib_table.h>
+#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
@@ -46,7 +47,7 @@
#define foreach_vpe_api_msg \
_(SW_INTERFACE_SET_VXLAN_GBP_BYPASS, sw_interface_set_vxlan_gbp_bypass) \
-_(VXLAN_GBP_ADD_DEL_TUNNEL, vxlan_gbp_add_del_tunnel) \
+_(VXLAN_GBP_TUNNEL_ADD_DEL, vxlan_gbp_tunnel_add_del) \
_(VXLAN_GBP_TUNNEL_DUMP, vxlan_gbp_tunnel_dump)
static void
@@ -65,32 +66,36 @@ static void
REPLY_MACRO (VL_API_SW_INTERFACE_SET_VXLAN_GBP_BYPASS_REPLY);
}
-static void vl_api_vxlan_gbp_add_del_tunnel_t_handler
- (vl_api_vxlan_gbp_add_del_tunnel_t * mp)
+static void vl_api_vxlan_gbp_tunnel_add_del_t_handler
+ (vl_api_vxlan_gbp_tunnel_add_del_t * mp)
{
- vl_api_vxlan_gbp_add_del_tunnel_reply_t *rmp;
+ vl_api_vxlan_gbp_tunnel_add_del_reply_t *rmp;
+ ip46_address_t src, dst;
+ ip46_type_t itype;
int rv = 0;
u32 fib_index;
- fib_index = fib_table_find (fib_ip_proto (mp->is_ipv6),
- ntohl (mp->encap_vrf_id));
+ itype = ip_address_decode (&mp->tunnel.src, &src);
+ itype = ip_address_decode (&mp->tunnel.dst, &dst);
+
+ fib_index = fib_table_find (fib_proto_from_ip46 (itype),
+ ntohl (mp->tunnel.encap_table_id));
if (fib_index == ~0)
{
rv = VNET_API_ERROR_NO_SUCH_FIB;
goto out;
}
- vnet_vxlan_gbp_add_del_tunnel_args_t a = {
+ vnet_vxlan_gbp_tunnel_add_del_args_t a = {
.is_add = mp->is_add,
- .is_ip6 = mp->is_ipv6,
- .instance = ntohl (mp->instance),
- .mcast_sw_if_index = ntohl (mp->mcast_sw_if_index),
+ .is_ip6 = (itype == IP46_TYPE_IP6),
+ .instance = ntohl (mp->tunnel.instance),
+ .mcast_sw_if_index = ntohl (mp->tunnel.mcast_sw_if_index),
.encap_fib_index = fib_index,
- .decap_next_index = ntohl (mp->decap_next_index),
- .vni = ntohl (mp->vni),
- .sclass = ntohs (mp->sclass),
- .dst = to_ip46 (mp->is_ipv6, mp->dst_address),
- .src = to_ip46 (mp->is_ipv6, mp->src_address),
+ .decap_next_index = ntohl (mp->tunnel.decap_next_index),
+ .vni = ntohl (mp->tunnel.vni),
+ .dst = dst,
+ .src = src,
};
/* Check src & dst are different */
@@ -107,11 +112,11 @@ static void vl_api_vxlan_gbp_add_del_tunnel_t_handler
}
u32 sw_if_index = ~0;
- rv = vnet_vxlan_gbp_add_del_tunnel (&a, &sw_if_index);
+ rv = vnet_vxlan_gbp_tunnel_add_del (&a, &sw_if_index);
out:
/* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_VXLAN_GBP_ADD_DEL_TUNNEL_REPLY,
+ REPLY_MACRO2(VL_API_VXLAN_GBP_TUNNEL_ADD_DEL_REPLY,
({
rmp->sw_if_index = ntohl (sw_if_index);
}));
@@ -122,33 +127,23 @@ static void send_vxlan_gbp_tunnel_details
(vxlan_gbp_tunnel_t * t, vl_api_registration_t * reg, u32 context)
{
vl_api_vxlan_gbp_tunnel_details_t *rmp;
- ip4_main_t *im4 = &ip4_main;
- ip6_main_t *im6 = &ip6_main;
- u8 is_ipv6 = !ip46_address_is_ip4 (&t->dst);
+ ip46_type_t itype = (ip46_address_is_ip4 (&t->dst) ?
+ IP46_TYPE_IP4 : IP46_TYPE_IP6);
rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_VXLAN_GBP_TUNNEL_DETAILS);
- if (is_ipv6)
- {
- memcpy (rmp->src_address, t->src.ip6.as_u8, 16);
- memcpy (rmp->dst_address, t->dst.ip6.as_u8, 16);
- rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
- }
- else
- {
- memcpy (rmp->src_address, t->src.ip4.as_u8, 4);
- memcpy (rmp->dst_address, t->dst.ip4.as_u8, 4);
- rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
- }
- rmp->instance = htonl (t->user_instance);
- rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index);
- rmp->vni = htonl (t->vni);
- rmp->sclass = htons (t->sclass);
- rmp->decap_next_index = htonl (t->decap_next_index);
- rmp->sw_if_index = htonl (t->sw_if_index);
- rmp->is_ipv6 = is_ipv6;
+ ip_address_encode (&t->src, itype, &rmp->tunnel.src);
+ ip_address_encode (&t->dst, itype, &rmp->tunnel.dst);
+ rmp->tunnel.encap_table_id =
+ fib_table_get_table_id (t->encap_fib_index, fib_proto_from_ip46 (itype));
+
+ rmp->tunnel.instance = htonl (t->user_instance);
+ rmp->tunnel.mcast_sw_if_index = htonl (t->mcast_sw_if_index);
+ rmp->tunnel.vni = htonl (t->vni);
+ rmp->tunnel.decap_next_index = htonl (t->decap_next_index);
+ rmp->tunnel.sw_if_index = htonl (t->sw_if_index);
rmp->context = context;
vl_api_send_msg (reg, (u8 *) rmp);