vxlan-gpe: add udp-port configuration support
similar behavior as here: 839dcc0fb7
Type: improvement
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Change-Id: I1b0a8f8f3dab48839e27df7065cf5f786cf0b5e9
This commit is contained in:

committed by
Damjan Marion

parent
3f59c63960
commit
ea96292985
@ -27,6 +27,7 @@
|
||||
#include <vlibmemory/api.h>
|
||||
#include <vnet/format_fns.h>
|
||||
#include <vnet/ip/ip_types_api.h>
|
||||
#include <vnet/udp/udp_local.h>
|
||||
|
||||
/* define message IDs */
|
||||
#include <ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api_enum.h>
|
||||
@ -92,7 +93,7 @@ static void vl_api_vxlan_gpe_ioam_vni_enable_t_handler
|
||||
clib_memcpy (&key4.remote, &mp->remote.un.ip4, sizeof (key4.remote));
|
||||
vni = clib_net_to_host_u32 (mp->vni);
|
||||
key4.vni = clib_host_to_net_u32 (vni << 8);
|
||||
key4.pad = 0;
|
||||
key4.port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
|
||||
|
||||
p = hash_get_mem (gm->vxlan4_gpe_tunnel_by_key, &key4);
|
||||
}
|
||||
@ -141,7 +142,7 @@ static void vl_api_vxlan_gpe_ioam_vni_disable_t_handler
|
||||
clib_memcpy (&key4.remote, &mp->remote, sizeof (key4.remote));
|
||||
vni = clib_net_to_host_u32 (mp->vni);
|
||||
key4.vni = clib_host_to_net_u32 (vni << 8);
|
||||
key4.pad = 0;
|
||||
key4.port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
|
||||
|
||||
p = hash_get_mem (gm->vxlan4_gpe_tunnel_by_key, &key4);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <vnet/dpo/load_balance.h>
|
||||
#include <vnet/fib/ip4_fib.h>
|
||||
#include <vnet/fib/fib_entry.h>
|
||||
#include <vnet/udp/udp_local.h>
|
||||
|
||||
vxlan_gpe_ioam_main_t vxlan_gpe_ioam_main;
|
||||
|
||||
@ -478,7 +479,7 @@ vxlan_gpe_set_ioam_rewrite_command_fn (vlib_main_t *
|
||||
key4.local = local.ip4.as_u32;
|
||||
key4.remote = remote.ip4.as_u32;
|
||||
key4.vni = clib_host_to_net_u32 (vni << 8);
|
||||
key4.pad = 0;
|
||||
key4.port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
|
||||
p = hash_get_mem (gm->vxlan4_gpe_tunnel_by_key, &key4);
|
||||
}
|
||||
else
|
||||
@ -488,6 +489,7 @@ vxlan_gpe_set_ioam_rewrite_command_fn (vlib_main_t *
|
||||
key6.remote.as_u64[0] = remote.ip6.as_u64[0];
|
||||
key6.remote.as_u64[1] = remote.ip6.as_u64[1];
|
||||
key6.vni = clib_host_to_net_u32 (vni << 8);
|
||||
key6.port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN6_GPE);
|
||||
p = hash_get_mem (gm->vxlan6_gpe_tunnel_by_key, &key6);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
option version = "2.0.0";
|
||||
option version = "2.1.0";
|
||||
|
||||
import "vnet/interface_types.api";
|
||||
import "vnet/ip/ip_types.api";
|
||||
@ -32,12 +32,48 @@ define vxlan_gpe_add_del_tunnel
|
||||
bool is_add [default=true];
|
||||
};
|
||||
|
||||
/** \brief Create or delete a VXLAN-GPE tunnel
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param local - Source IP address
|
||||
@param remote - Destination IP address, can be multicast
|
||||
@param local_port - Source UDP port. It is not included in sent packets. Used only for port registration
|
||||
@param remote_port - Destination UDP port
|
||||
@param mcast_sw_if_index - Interface for multicast destination
|
||||
@param encap_vrf_id - Encap route table FIB index
|
||||
@param decap_vrf_id - Decap route table FIB index
|
||||
@param protocol - Encapsulated protocol
|
||||
@param vni - The VXLAN Network Identifier, uint24
|
||||
@param is_add - Use 1 to create the tunnel, 0 to remove it
|
||||
*/
|
||||
define vxlan_gpe_add_del_tunnel_v2
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
vl_api_address_t local;
|
||||
vl_api_address_t remote;
|
||||
u16 local_port;
|
||||
u16 remote_port;
|
||||
vl_api_interface_index_t mcast_sw_if_index;
|
||||
u32 encap_vrf_id;
|
||||
u32 decap_vrf_id;
|
||||
vl_api_ip_proto_t protocol;
|
||||
u32 vni;
|
||||
bool is_add [default=true];
|
||||
};
|
||||
|
||||
define vxlan_gpe_add_del_tunnel_reply
|
||||
{
|
||||
u32 context;
|
||||
i32 retval;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
};
|
||||
define vxlan_gpe_add_del_tunnel_v2_reply
|
||||
{
|
||||
u32 context;
|
||||
i32 retval;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
};
|
||||
|
||||
define vxlan_gpe_tunnel_dump
|
||||
{
|
||||
@ -45,6 +81,12 @@ define vxlan_gpe_tunnel_dump
|
||||
u32 context;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
};
|
||||
define vxlan_gpe_tunnel_v2_dump
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
};
|
||||
|
||||
define vxlan_gpe_tunnel_details
|
||||
{
|
||||
@ -59,6 +101,21 @@ define vxlan_gpe_tunnel_details
|
||||
u32 decap_vrf_id;
|
||||
bool is_ipv6;
|
||||
};
|
||||
define vxlan_gpe_tunnel_v2_details
|
||||
{
|
||||
u32 context;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
vl_api_address_t local;
|
||||
vl_api_address_t remote;
|
||||
u16 local_port;
|
||||
u16 remote_port;
|
||||
u32 vni;
|
||||
vl_api_ip_proto_t protocol;
|
||||
vl_api_interface_index_t mcast_sw_if_index;
|
||||
u32 encap_vrf_id;
|
||||
u32 decap_vrf_id;
|
||||
bool is_ipv6;
|
||||
};
|
||||
|
||||
/** \brief Interface set vxlan-gpe-bypass request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
|
@ -87,11 +87,12 @@ format_vxlan_gpe_tunnel (u8 * s, va_list * args)
|
||||
vxlan_gpe_tunnel_t *t = va_arg (*args, vxlan_gpe_tunnel_t *);
|
||||
vxlan_gpe_main_t *ngm = &vxlan_gpe_main;
|
||||
|
||||
s = format (s, "[%d] lcl %U rmt %U vni %d fib-idx %d sw-if-idx %d ",
|
||||
t - ngm->tunnels,
|
||||
format_ip46_address, &t->local, IP46_TYPE_ANY,
|
||||
format_ip46_address, &t->remote, IP46_TYPE_ANY,
|
||||
t->vni, t->encap_fib_index, t->sw_if_index);
|
||||
s = format (s,
|
||||
"[%d] lcl %U rmt %U lcl_port %d rmt_port %d vni %d "
|
||||
"fib-idx %d sw-if-idx %d ",
|
||||
t - ngm->tunnels, format_ip46_address, &t->local, IP46_TYPE_ANY,
|
||||
format_ip46_address, &t->remote, IP46_TYPE_ANY, t->local_port,
|
||||
t->remote_port, t->vni, t->encap_fib_index, t->sw_if_index);
|
||||
|
||||
#if 0
|
||||
/* next_dpo not yet used by vxlan-gpe-encap node */
|
||||
@ -248,12 +249,14 @@ const static fib_node_vft_t vxlan_gpe_vft = {
|
||||
.fnv_back_walk = vxlan_gpe_tunnel_back_walk,
|
||||
};
|
||||
|
||||
#define foreach_gpe_copy_field \
|
||||
_(vni) \
|
||||
_(protocol) \
|
||||
_(mcast_sw_if_index) \
|
||||
_(encap_fib_index) \
|
||||
_(decap_fib_index)
|
||||
#define foreach_gpe_copy_field \
|
||||
_ (vni) \
|
||||
_ (protocol) \
|
||||
_ (mcast_sw_if_index) \
|
||||
_ (encap_fib_index) \
|
||||
_ (decap_fib_index) \
|
||||
_ (local_port) \
|
||||
_ (remote_port)
|
||||
|
||||
#define foreach_copy_ipv4 { \
|
||||
_(local.ip4.as_u32) \
|
||||
@ -304,8 +307,8 @@ vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
|
||||
ip0->checksum = ip4_header_checksum (ip0);
|
||||
|
||||
/* UDP header, randomize src port on something, maybe? */
|
||||
h0->udp.src_port = clib_host_to_net_u16 (4790);
|
||||
h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
|
||||
h0->udp.src_port = clib_host_to_net_u16 (t->local_port);
|
||||
h0->udp.dst_port = clib_host_to_net_u16 (t->remote_port);
|
||||
|
||||
/* VXLAN header. Are we having fun yet? */
|
||||
h0->vxlan.flags = VXLAN_GPE_FLAGS_I | VXLAN_GPE_FLAGS_P;
|
||||
@ -363,8 +366,8 @@ vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
|
||||
ip0->dst_address.as_u64[1] = t->remote.ip6.as_u64[1];
|
||||
|
||||
/* UDP header, randomize src port on something, maybe? */
|
||||
h0->udp.src_port = clib_host_to_net_u16 (4790);
|
||||
h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_VXLAN_GPE);
|
||||
h0->udp.src_port = clib_host_to_net_u16 (t->local_port);
|
||||
h0->udp.dst_port = clib_host_to_net_u16 (t->remote_port);
|
||||
|
||||
/* VXLAN header. Are we having fun yet? */
|
||||
h0->vxlan.flags = VXLAN_GPE_FLAGS_I | VXLAN_GPE_FLAGS_P;
|
||||
@ -453,12 +456,19 @@ int vnet_vxlan_gpe_add_del_tunnel
|
||||
vxlan6_gpe_tunnel_key_t key6, *key6_copy;
|
||||
u32 is_ip6 = a->is_ip6;
|
||||
|
||||
/* Set udp-ports */
|
||||
if (a->local_port == 0)
|
||||
a->local_port = is_ip6 ? UDP_DST_PORT_VXLAN6_GPE : UDP_DST_PORT_VXLAN_GPE;
|
||||
|
||||
if (a->remote_port == 0)
|
||||
a->remote_port = is_ip6 ? UDP_DST_PORT_VXLAN6_GPE : UDP_DST_PORT_VXLAN_GPE;
|
||||
|
||||
if (!is_ip6)
|
||||
{
|
||||
key4.local = a->local.ip4.as_u32;
|
||||
key4.remote = a->remote.ip4.as_u32;
|
||||
key4.vni = clib_host_to_net_u32 (a->vni << 8);
|
||||
key4.pad = 0;
|
||||
key4.port = (u32) clib_host_to_net_u16 (a->local_port);
|
||||
|
||||
p = hash_get_mem (ngm->vxlan4_gpe_tunnel_by_key, &key4);
|
||||
}
|
||||
@ -469,6 +479,7 @@ int vnet_vxlan_gpe_add_del_tunnel
|
||||
key6.remote.as_u64[0] = a->remote.ip6.as_u64[0];
|
||||
key6.remote.as_u64[1] = a->remote.ip6.as_u64[1];
|
||||
key6.vni = clib_host_to_net_u32 (a->vni << 8);
|
||||
key6.port = (u32) clib_host_to_net_u16 (a->local_port);
|
||||
|
||||
p = hash_get_mem (ngm->vxlan6_gpe_tunnel_by_key, &key6);
|
||||
}
|
||||
@ -719,12 +730,12 @@ int vnet_vxlan_gpe_add_del_tunnel
|
||||
if (a->is_add)
|
||||
{
|
||||
/* register udp ports */
|
||||
if (!is_ip6 && !udp_is_valid_dst_port (UDP_DST_PORT_VXLAN_GPE, 1))
|
||||
udp_register_dst_port (ngm->vlib_main, UDP_DST_PORT_VXLAN_GPE,
|
||||
vxlan4_gpe_input_node.index, 1 /* is_ip4 */ );
|
||||
if (is_ip6 && !udp_is_valid_dst_port (UDP_DST_PORT_VXLAN6_GPE, 0))
|
||||
udp_register_dst_port (ngm->vlib_main, UDP_DST_PORT_VXLAN6_GPE,
|
||||
vxlan6_gpe_input_node.index, 0 /* is_ip4 */ );
|
||||
if (!is_ip6 && !udp_is_valid_dst_port (a->local_port, 1))
|
||||
udp_register_dst_port (ngm->vlib_main, a->local_port,
|
||||
vxlan4_gpe_input_node.index, 1 /* is_ip4 */);
|
||||
if (is_ip6 && !udp_is_valid_dst_port (a->remote_port, 0))
|
||||
udp_register_dst_port (ngm->vlib_main, a->remote_port,
|
||||
vxlan6_gpe_input_node.index, 0 /* is_ip4 */);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -749,6 +760,8 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
|
||||
u8 protocol = VXLAN_GPE_PROTOCOL_IP4;
|
||||
u32 vni;
|
||||
u8 vni_set = 0;
|
||||
u32 local_port = 0;
|
||||
u32 remote_port = 0;
|
||||
int rv;
|
||||
u32 tmp;
|
||||
vnet_vxlan_gpe_add_del_tunnel_args_t _a, *a = &_a;
|
||||
@ -833,6 +846,10 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
|
||||
}
|
||||
else if (unformat (line_input, "vni %d", &vni))
|
||||
vni_set = 1;
|
||||
else if (unformat (line_input, "local_port %d", &local_port))
|
||||
;
|
||||
else if (unformat (line_input, "remote_port %d", &remote_port))
|
||||
;
|
||||
else if (unformat (line_input, "next-ip4"))
|
||||
protocol = VXLAN_GPE_PROTOCOL_IP4;
|
||||
else if (unformat (line_input, "next-ip6"))
|
||||
|
@ -64,7 +64,7 @@ typedef CLIB_PACKED (struct {
|
||||
|
||||
/**
|
||||
* @brief Key struct for IPv4 VXLAN GPE tunnel.
|
||||
* Key fields: local remote, vni
|
||||
* Key fields: local remote, vni, udp-port
|
||||
* all fields in NET byte order
|
||||
* VNI shifted 8 bits
|
||||
*/
|
||||
@ -76,7 +76,7 @@ typedef CLIB_PACKED(struct {
|
||||
u32 remote;
|
||||
|
||||
u32 vni;
|
||||
u32 pad;
|
||||
u32 port;
|
||||
};
|
||||
u64 as_u64[2];
|
||||
};
|
||||
@ -85,7 +85,7 @@ typedef CLIB_PACKED(struct {
|
||||
|
||||
/**
|
||||
* @brief Key struct for IPv6 VXLAN GPE tunnel.
|
||||
* Key fields: local remote, vni
|
||||
* Key fields: local remote, vni, udp-port
|
||||
* all fields in NET byte order
|
||||
* VNI shifted 8 bits
|
||||
*/
|
||||
@ -94,9 +94,21 @@ typedef CLIB_PACKED(struct {
|
||||
ip6_address_t local;
|
||||
ip6_address_t remote;
|
||||
u32 vni;
|
||||
u32 port;
|
||||
}) vxlan6_gpe_tunnel_key_t;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 tunnel_index;
|
||||
u16 next_index;
|
||||
u8 error;
|
||||
};
|
||||
u64 as_u64;
|
||||
} vxlan_gpe_decap_info_t;
|
||||
|
||||
/**
|
||||
* @brief Struct for VXLAN GPE tunnel
|
||||
*/
|
||||
@ -117,6 +129,10 @@ typedef struct
|
||||
ip46_address_t local;
|
||||
/** tunnel remote address */
|
||||
ip46_address_t remote;
|
||||
/** local udp-port **/
|
||||
u16 local_port;
|
||||
/** remote udp-port **/
|
||||
u16 remote_port;
|
||||
|
||||
/* mcast packet output intfc index (used only if dst is mcast) */
|
||||
u32 mcast_sw_if_index;
|
||||
@ -248,6 +264,8 @@ typedef struct
|
||||
u32 encap_fib_index;
|
||||
u32 decap_fib_index;
|
||||
u32 vni;
|
||||
u16 local_port;
|
||||
u16 remote_port;
|
||||
} vnet_vxlan_gpe_add_del_tunnel_args_t;
|
||||
|
||||
|
||||
|
@ -122,6 +122,73 @@ out:
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
static void
|
||||
vl_api_vxlan_gpe_add_del_tunnel_v2_t_handler (
|
||||
vl_api_vxlan_gpe_add_del_tunnel_v2_t *mp)
|
||||
{
|
||||
vl_api_vxlan_gpe_add_del_tunnel_v2_reply_t *rmp;
|
||||
int rv = 0;
|
||||
vnet_vxlan_gpe_add_del_tunnel_args_t _a, *a = &_a;
|
||||
u32 encap_fib_index, decap_fib_index;
|
||||
u8 protocol;
|
||||
uword *p;
|
||||
ip4_main_t *im = &ip4_main;
|
||||
u32 sw_if_index = ~0;
|
||||
|
||||
p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
|
||||
if (!p)
|
||||
{
|
||||
rv = VNET_API_ERROR_NO_SUCH_FIB;
|
||||
goto out;
|
||||
}
|
||||
encap_fib_index = p[0];
|
||||
|
||||
protocol = mp->protocol;
|
||||
|
||||
/* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
|
||||
if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT)
|
||||
{
|
||||
p = hash_get (im->fib_index_by_table_id, ntohl (mp->decap_vrf_id));
|
||||
if (!p)
|
||||
{
|
||||
rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
|
||||
goto out;
|
||||
}
|
||||
decap_fib_index = p[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
decap_fib_index = ntohl (mp->decap_vrf_id);
|
||||
}
|
||||
|
||||
clib_memset (a, 0, sizeof (*a));
|
||||
|
||||
a->is_add = mp->is_add;
|
||||
ip_address_decode (&mp->local, &a->local);
|
||||
ip_address_decode (&mp->remote, &a->remote);
|
||||
|
||||
/* Check src & dst are different */
|
||||
if (ip46_address_is_equal (&a->local, &a->remote))
|
||||
{
|
||||
rv = VNET_API_ERROR_SAME_SRC_DST;
|
||||
goto out;
|
||||
}
|
||||
|
||||
a->local_port = ntohs (mp->local_port);
|
||||
a->remote_port = ntohs (mp->remote_port);
|
||||
a->is_ip6 = !ip46_address_is_ip4 (&a->local);
|
||||
a->mcast_sw_if_index = ntohl (mp->mcast_sw_if_index);
|
||||
a->encap_fib_index = encap_fib_index;
|
||||
a->decap_fib_index = decap_fib_index;
|
||||
a->protocol = protocol;
|
||||
a->vni = ntohl (mp->vni);
|
||||
rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
|
||||
|
||||
out:
|
||||
REPLY_MACRO2 (VL_API_VXLAN_GPE_ADD_DEL_TUNNEL_V2_REPLY,
|
||||
({ rmp->sw_if_index = ntohl (sw_if_index); }));
|
||||
}
|
||||
|
||||
static void send_vxlan_gpe_tunnel_details
|
||||
(vxlan_gpe_tunnel_t * t, vl_api_registration_t * reg, u32 context)
|
||||
{
|
||||
@ -177,9 +244,9 @@ static void vl_api_vxlan_gpe_tunnel_dump_t_handler
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
pool_foreach (t, vgm->tunnels)
|
||||
{
|
||||
send_vxlan_gpe_tunnel_details(t, reg, mp->context);
|
||||
}
|
||||
{
|
||||
send_vxlan_gpe_tunnel_details (t, reg, mp->context);
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
else
|
||||
@ -194,6 +261,80 @@ static void vl_api_vxlan_gpe_tunnel_dump_t_handler
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
send_vxlan_gpe_tunnel_v2_details (vxlan_gpe_tunnel_t *t,
|
||||
vl_api_registration_t *reg, u32 context)
|
||||
{
|
||||
vl_api_vxlan_gpe_tunnel_v2_details_t *rmp;
|
||||
ip4_main_t *im4 = &ip4_main;
|
||||
ip6_main_t *im6 = &ip6_main;
|
||||
u8 is_ipv6 = !(t->flags & VXLAN_GPE_TUNNEL_IS_IPV4);
|
||||
|
||||
rmp = vl_msg_api_alloc (sizeof (*rmp));
|
||||
clib_memset (rmp, 0, sizeof (*rmp));
|
||||
rmp->_vl_msg_id =
|
||||
ntohs (REPLY_MSG_ID_BASE + VL_API_VXLAN_GPE_TUNNEL_V2_DETAILS);
|
||||
|
||||
ip_address_encode (&t->local, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
|
||||
&rmp->local);
|
||||
ip_address_encode (&t->remote, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
|
||||
&rmp->remote);
|
||||
rmp->local_port = htons (t->local_port);
|
||||
rmp->remote_port = htons (t->remote_port);
|
||||
|
||||
if (ip46_address_is_ip4 (&t->local))
|
||||
{
|
||||
rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
|
||||
rmp->decap_vrf_id = htonl (im4->fibs[t->decap_fib_index].ft_table_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
|
||||
rmp->decap_vrf_id = htonl (im6->fibs[t->decap_fib_index].ft_table_id);
|
||||
}
|
||||
rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index);
|
||||
rmp->vni = htonl (t->vni);
|
||||
rmp->protocol = t->protocol;
|
||||
rmp->sw_if_index = htonl (t->sw_if_index);
|
||||
rmp->context = context;
|
||||
|
||||
vl_api_send_msg (reg, (u8 *) rmp);
|
||||
}
|
||||
|
||||
static void
|
||||
vl_api_vxlan_gpe_tunnel_v2_dump_t_handler (
|
||||
vl_api_vxlan_gpe_tunnel_v2_dump_t *mp)
|
||||
{
|
||||
vl_api_registration_t *reg;
|
||||
vxlan_gpe_main_t *vgm = &vxlan_gpe_main;
|
||||
vxlan_gpe_tunnel_t *t;
|
||||
u32 sw_if_index;
|
||||
|
||||
reg = vl_api_client_index_to_registration (mp->client_index);
|
||||
if (!reg)
|
||||
return;
|
||||
|
||||
sw_if_index = ntohl (mp->sw_if_index);
|
||||
|
||||
if (~0 == sw_if_index)
|
||||
{
|
||||
pool_foreach (t, vgm->tunnels)
|
||||
{
|
||||
send_vxlan_gpe_tunnel_v2_details (t, reg, mp->context);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sw_if_index >= vec_len (vgm->tunnel_index_by_sw_if_index)) ||
|
||||
(~0 == vgm->tunnel_index_by_sw_if_index[sw_if_index]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
t = &vgm->tunnels[vgm->tunnel_index_by_sw_if_index[sw_if_index]];
|
||||
send_vxlan_gpe_tunnel_v2_details (t, reg, mp->context);
|
||||
}
|
||||
}
|
||||
|
||||
#include <vxlan-gpe/vxlan_gpe.api.c>
|
||||
|
||||
static clib_error_t *
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -93,8 +93,6 @@ defaultmapping = {
|
||||
'vxlan_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
|
||||
'decap_next_index': 4294967295,
|
||||
'instance': 4294967295, },
|
||||
'vxlan_gpe_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
|
||||
'protocol': 3, },
|
||||
'want_bfd_events': {'enable_disable': 1, },
|
||||
'want_igmp_events': {'enable': 1, },
|
||||
'want_interface_events': {'enable_disable': 1, },
|
||||
@ -654,41 +652,6 @@ class VppPapiProvider(object):
|
||||
'is_ip6': is_ip6
|
||||
}})
|
||||
|
||||
def vxlan_gpe_add_del_tunnel(
|
||||
self,
|
||||
src_addr,
|
||||
dst_addr,
|
||||
mcast_sw_if_index=0xFFFFFFFF,
|
||||
is_add=1,
|
||||
is_ipv6=0,
|
||||
encap_vrf_id=0,
|
||||
decap_vrf_id=0,
|
||||
protocol=3,
|
||||
vni=0):
|
||||
"""
|
||||
|
||||
:param local:
|
||||
:param remote:
|
||||
:param is_add: (Default value = 1)
|
||||
:param is_ipv6: (Default value = 0)
|
||||
:param encap_vrf_id: (Default value = 0)
|
||||
:param decap_vrf_id: (Default value = 0)
|
||||
:param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
|
||||
:param protocol: (Default value = 3)
|
||||
:param vni: (Default value = 0)
|
||||
|
||||
"""
|
||||
return self.api(self.papi.vxlan_gpe_add_del_tunnel,
|
||||
{'is_add': is_add,
|
||||
'is_ipv6': is_ipv6,
|
||||
'local': src_addr,
|
||||
'remote': dst_addr,
|
||||
'mcast_sw_if_index': mcast_sw_if_index,
|
||||
'encap_vrf_id': encap_vrf_id,
|
||||
'decap_vrf_id': decap_vrf_id,
|
||||
'protocol': protocol,
|
||||
'vni': vni})
|
||||
|
||||
def vxlan_gbp_tunnel_dump(self, sw_if_index=0xffffffff):
|
||||
return self.api(self.papi.vxlan_gbp_tunnel_dump,
|
||||
{'sw_if_index': sw_if_index})
|
||||
|
83
test/vpp_vxlan_gpe_tunnel.py
Normal file
83
test/vpp_vxlan_gpe_tunnel.py
Normal file
@ -0,0 +1,83 @@
|
||||
from vpp_interface import VppInterface
|
||||
from vpp_papi import VppEnum
|
||||
|
||||
|
||||
INDEX_INVALID = 0xffffffff
|
||||
DEFAULT_PORT = 4790
|
||||
UNDEFINED_PORT = 0
|
||||
|
||||
|
||||
def find_vxlan_gpe_tunnel(test, src, dst, s_port, d_port, vni):
|
||||
ts = test.vapi.vxlan_gpe_tunnel_v2_dump(INDEX_INVALID)
|
||||
|
||||
src_port = DEFAULT_PORT
|
||||
if s_port != UNDEFINED_PORT:
|
||||
src_port = s_port
|
||||
|
||||
dst_port = DEFAULT_PORT
|
||||
if d_port != UNDEFINED_PORT:
|
||||
dst_port = d_port
|
||||
|
||||
for t in ts:
|
||||
if src == str(t.local) and \
|
||||
dst == str(t.remote) and \
|
||||
src_port == t.local_port and \
|
||||
dst_port == t.remote_port and \
|
||||
t.vni == vni:
|
||||
return t.sw_if_index
|
||||
return INDEX_INVALID
|
||||
|
||||
|
||||
class VppVxlanGpeTunnel(VppInterface):
|
||||
"""
|
||||
VPP VXLAN GPE interface
|
||||
"""
|
||||
|
||||
def __init__(self, test, src_addr, dst_addr, vni,
|
||||
src_port=UNDEFINED_PORT, dst_port=UNDEFINED_PORT,
|
||||
mcast_sw_if_index=INDEX_INVALID,
|
||||
encap_vrf_id=None,
|
||||
decap_vrf_id=None, protocol=3):
|
||||
""" Create VXLAN GPE Tunnel interface """
|
||||
super(VppVxlanGpeTunnel, self).__init__(test)
|
||||
self.src = src_addr
|
||||
self.dst = dst_addr
|
||||
self.vni = vni
|
||||
self.src_port = src_port
|
||||
self.dst_port = dst_port
|
||||
self.mcast_sw_if_index = mcast_sw_if_index
|
||||
self.encap_vrf_id = encap_vrf_id
|
||||
self.decap_vrf_id = decap_vrf_id
|
||||
self.protocol = 3
|
||||
|
||||
def add_vpp_config(self):
|
||||
reply = self.test.vapi.vxlan_gpe_add_del_tunnel_v2(
|
||||
is_add=1, local=self.src, remote=self.dst, vni=self.vni,
|
||||
local_port=self.src_port, remote_port=self.dst_port,
|
||||
mcast_sw_if_index=self.mcast_sw_if_index,
|
||||
encap_vrf_id=self.encap_vrf_id,
|
||||
decap_vrf_id=self.decap_vrf_id,
|
||||
protocol=self.protocol)
|
||||
self.set_sw_if_index(reply.sw_if_index)
|
||||
self._test.registry.register(self, self._test.logger)
|
||||
|
||||
def remove_vpp_config(self):
|
||||
self.test.vapi.vxlan_gpe_add_del_tunnel_v2(
|
||||
is_add=0, local=self.src, remote=self.dst, vni=self.vni,
|
||||
local_port=self.src_port, remote_port=self.dst_port,
|
||||
mcast_sw_if_index=self.mcast_sw_if_index,
|
||||
encap_vrf_id=self.encap_vrf_id,
|
||||
decap_vrf_id=self.decap_vrf_id,
|
||||
protocol=self.protocol)
|
||||
|
||||
def query_vpp_config(self):
|
||||
return (INDEX_INVALID != find_vxlan_gpe_tunnel(self._test,
|
||||
self.src,
|
||||
self.dst,
|
||||
self.src_port,
|
||||
self.dst_port,
|
||||
self.vni))
|
||||
|
||||
def object_id(self):
|
||||
return "vxlan-%d-%d-%s-%s" % (self.sw_if_index, self.vni,
|
||||
self.src, self.dst)
|
Reference in New Issue
Block a user