summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/fib/fib_entry.h5
-rw-r--r--src/vnet/fib/fib_entry_src_api.c1
-rw-r--r--src/vnet/ipip/ipip.api5
-rw-r--r--src/vnet/ipip/ipip.h8
-rw-r--r--src/vnet/ipip/ipip_api.c54
-rw-r--r--src/vnet/ipip/ipip_cli.c83
-rw-r--r--src/vnet/ipip/sixrd.c46
-rw-r--r--src/vnet/mfib/mfib_types.h2
-rw-r--r--test/test_ipip.py17
-rw-r--r--test/test_sixrd.py150
-rw-r--r--test/vpp_papi_provider.py11
11 files changed, 283 insertions, 99 deletions
diff --git a/src/vnet/fib/fib_entry.h b/src/vnet/fib/fib_entry.h
index dcc310e8fbc..bdd848f7968 100644
--- a/src/vnet/fib/fib_entry.h
+++ b/src/vnet/fib/fib_entry.h
@@ -65,6 +65,10 @@ typedef enum fib_source_t_ {
*/
FIB_SOURCE_BIER,
/**
+ * From 6RD.
+ */
+ FIB_SOURCE_6RD,
+ /**
* From the control plane API
*/
FIB_SOURCE_API,
@@ -157,6 +161,7 @@ STATIC_ASSERT (sizeof(fib_source_t) == 1,
[FIB_SOURCE_INTERFACE] = "interface", \
[FIB_SOURCE_PROXY] = "proxy", \
[FIB_SOURCE_BIER] = "BIER", \
+ [FIB_SOURCE_6RD] = "6RD", \
[FIB_SOURCE_API] = "API", \
[FIB_SOURCE_CLI] = "CLI", \
[FIB_SOURCE_ADJ] = "adjacency", \
diff --git a/src/vnet/fib/fib_entry_src_api.c b/src/vnet/fib/fib_entry_src_api.c
index cc3c78c187f..be93cc23c36 100644
--- a/src/vnet/fib/fib_entry_src_api.c
+++ b/src/vnet/fib/fib_entry_src_api.c
@@ -166,6 +166,7 @@ fib_entry_src_api_register (void)
fib_entry_src_register(FIB_SOURCE_PLUGIN_LOW, &api_src_vft);
fib_entry_src_register(FIB_SOURCE_API, &api_src_vft);
fib_entry_src_register(FIB_SOURCE_CLI, &api_src_vft);
+ fib_entry_src_register(FIB_SOURCE_6RD, &api_src_vft);
fib_entry_src_register(FIB_SOURCE_DHCP, &api_src_vft);
fib_entry_src_register(FIB_SOURCE_IP6_ND_PROXY, &api_src_vft);
fib_entry_src_register(FIB_SOURCE_IP6_ND, &api_src_vft);
diff --git a/src/vnet/ipip/ipip.api b/src/vnet/ipip/ipip.api
index 95fc48a5962..5cad28f2814 100644
--- a/src/vnet/ipip/ipip.api
+++ b/src/vnet/ipip/ipip.api
@@ -61,7 +61,7 @@ define ipip_add_tunnel
u32 instance; /* If non-~0, specifies a custom dev instance */
u8 src_address[16];
u8 dst_address[16];
- u32 fib_index;
+ u32 table_id;
u8 tc_tos; /* If ~0, the TOS/TC value is copied from
inner packet, otherwise set to value */
};
@@ -90,7 +90,8 @@ define ipip_6rd_add_tunnel
{
u32 client_index;
u32 context;
- u32 fib_index;
+ u32 ip6_table_id;
+ u32 ip4_table_id;
u8 ip6_prefix[16];
u8 ip4_prefix[4];
u8 ip4_src[4];
diff --git a/src/vnet/ipip/ipip.h b/src/vnet/ipip/ipip.h
index 6afb188f8ee..35916e01625 100644
--- a/src/vnet/ipip/ipip.h
+++ b/src/vnet/ipip/ipip.h
@@ -51,10 +51,10 @@ typedef enum
typedef struct
{
- ipip_transport_t transport;
- u32 fib_index;
ip46_address_t src;
ip46_address_t dst;
+ ipip_transport_t transport;
+ u32 fib_index;
} __attribute__ ((packed)) ipip_tunnel_key_t;
typedef enum
@@ -99,6 +99,7 @@ typedef struct
u8 ip4_prefix_len;
u8 shift;
bool security_check;
+ u32 ip6_fib_index;
} sixrd;
};
} ipip_tunnel_t;
@@ -154,7 +155,8 @@ int ipip_del_tunnel (u32 sw_if_index);
int sixrd_add_tunnel (ip6_address_t * ip6_prefix, u8 ip6_prefix_len,
ip4_address_t * ip4_prefix, u8 ip4_prefix_len,
ip4_address_t * ip4_src, bool security_check,
- u32 fib_index, u32 * sw_if_index);
+ u32 ip4_fib_index, u32 ip6_fib_index,
+ u32 * sw_if_index);
int sixrd_del_tunnel (u32 sw_if_index);
void ipip_tunnel_db_add (ipip_tunnel_t * t, ipip_tunnel_key_t * key);
void ipip_tunnel_db_remove (ipip_tunnel_t * t);
diff --git a/src/vnet/ipip/ipip_api.c b/src/vnet/ipip/ipip_api.c
index 455792ba133..b3fc0817a85 100644
--- a/src/vnet/ipip/ipip_api.c
+++ b/src/vnet/ipip/ipip_api.c
@@ -51,7 +51,7 @@ vl_api_ipip_add_tunnel_t_handler (vl_api_ipip_add_tunnel_t * mp)
{
vl_api_ipip_add_tunnel_reply_t *rmp;
int rv = 0;
- u32 sw_if_index = ~0;
+ u32 fib_index, sw_if_index = ~0;
ip46_address_t src = ip46_address_initializer, dst =
ip46_address_initializer;
@@ -67,13 +67,27 @@ vl_api_ipip_add_tunnel_t_handler (vl_api_ipip_add_tunnel_t * mp)
clib_memcpy (&dst.ip4, mp->dst_address, 4);
}
- rv = ipip_add_tunnel (mp->is_ipv6 ? IPIP_TRANSPORT_IP6 : IPIP_TRANSPORT_IP4,
- ntohl (mp->instance), &src, &dst,
- ntohl (mp->fib_index), mp->tc_tos, &sw_if_index);
+ fib_index =
+ fib_table_find (fib_ip_proto (mp->is_ipv6), ntohl (mp->table_id));
+
+ if (~0 == fib_index)
+ {
+ rv = VNET_API_ERROR_NO_SUCH_FIB;
+ }
+ else
+ {
+ rv = ipip_add_tunnel ((mp->is_ipv6 ?
+ IPIP_TRANSPORT_IP6 :
+ IPIP_TRANSPORT_IP4),
+ ntohl (mp->instance), &src, &dst,
+ fib_index, mp->tc_tos, &sw_if_index);
+ }
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_IPIP_ADD_TUNNEL_REPLY,
- ({ rmp->sw_if_index = ntohl(sw_if_index); }));
+ ({
+ rmp->sw_if_index = ntohl(sw_if_index);
+ }));
/* *INDENT-ON* */
}
@@ -153,21 +167,35 @@ static void
vl_api_ipip_6rd_add_tunnel_t_handler (vl_api_ipip_6rd_add_tunnel_t * mp)
{
vl_api_ipip_6rd_add_tunnel_reply_t *rmp;
- u32 sixrd_tunnel_index;
+ u32 sixrd_tunnel_index, ip4_fib_index, ip6_fib_index;
+ int rv;
+
+ ip4_fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->ip4_table_id));
+ ip6_fib_index = fib_table_find (FIB_PROTOCOL_IP6, ntohl (mp->ip6_table_id));
+
+ if (~0 == ip4_fib_index || ~0 == ip6_fib_index)
- int rv = sixrd_add_tunnel ((ip6_address_t *) & mp->ip6_prefix,
+ {
+ rv = VNET_API_ERROR_NO_SUCH_FIB;
+ }
+ else
+ {
+ rv = sixrd_add_tunnel ((ip6_address_t *) & mp->ip6_prefix,
mp->ip6_prefix_len,
(ip4_address_t *) & mp->ip4_prefix,
mp->ip4_prefix_len,
(ip4_address_t *) & mp->ip4_src,
mp->security_check,
- ntohl (mp->fib_index), &sixrd_tunnel_index);
+ ip4_fib_index, ip6_fib_index,
+ &sixrd_tunnel_index);
+ }
- REPLY_MACRO2 (VL_API_IPIP_6RD_ADD_TUNNEL_REPLY, (
- {
- rmp->sw_if_index =
- htonl
- (sixrd_tunnel_index);}));
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_IPIP_6RD_ADD_TUNNEL_REPLY,
+ ({
+ rmp->sw_if_index = htonl (sixrd_tunnel_index);
+ }));
+ /* *INDENT-ON* */
}
static void
diff --git a/src/vnet/ipip/ipip_cli.c b/src/vnet/ipip/ipip_cli.c
index 7a68c20319e..307d0f4953e 100644
--- a/src/vnet/ipip/ipip_cli.c
+++ b/src/vnet/ipip/ipip_cli.c
@@ -16,6 +16,7 @@
#include "ipip.h"
#include <vppinfra/error.h>
#include <vnet/vnet.h>
+#include <vnet/fib/fib_table.h>
static clib_error_t *create_ipip_tunnel_command_fn(vlib_main_t *vm,
unformat_input_t *input,
@@ -24,6 +25,7 @@ static clib_error_t *create_ipip_tunnel_command_fn(vlib_main_t *vm,
ip46_address_t src = ip46_address_initializer, dst = ip46_address_initializer;
u32 instance = ~0;
u32 fib_index = 0;
+ u32 table_id = 0;
int rv;
u32 num_m_args = 0;
u32 sw_if_index;
@@ -49,7 +51,7 @@ static clib_error_t *create_ipip_tunnel_command_fn(vlib_main_t *vm,
} else if (unformat(line_input, "dst %U", unformat_ip6_address, &dst.ip6)) {
num_m_args++;
ip6_set = true;
- } else if (unformat(line_input, "outer-fib-id %d", &fib_index))
+ } else if (unformat(line_input, "outer-table-id %d", &table_id))
;
else {
error = clib_error_return(0, "unknown input `%U'", format_unformat_error,
@@ -67,15 +69,24 @@ static clib_error_t *create_ipip_tunnel_command_fn(vlib_main_t *vm,
goto done;
}
- rv = ipip_add_tunnel(ip6_set ? IPIP_TRANSPORT_IP6 : IPIP_TRANSPORT_IP4,
- instance,
- &src,
- &dst,
- fib_index,
- 0,
- &sw_if_index);
+ fib_index = fib_table_find(fib_ip_proto(ip6_set), table_id);
- switch (rv) {
+ if (~0 == fib_index)
+ {
+ rv = VNET_API_ERROR_NO_SUCH_FIB;
+ }
+ else
+ {
+ rv = ipip_add_tunnel(ip6_set ? IPIP_TRANSPORT_IP6 : IPIP_TRANSPORT_IP4,
+ instance,
+ &src,
+ &dst,
+ fib_index,
+ 0,
+ &sw_if_index);
+ }
+
+ switch (rv) {
case 0:
vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(),
sw_if_index);
@@ -144,7 +155,7 @@ done:
VLIB_CLI_COMMAND(create_ipip_tunnel_command, static) = {
.path = "create ipip tunnel",
.short_help = "create ipip tunnel src <addr> dst <addr> [instance <n>] "
- "[outer-fib-id <fib>]",
+ "[outer-table-id <ID>]",
.function = create_ipip_tunnel_command_fn,
};
VLIB_CLI_COMMAND(delete_ipip_tunnel_command, static) = {
@@ -158,21 +169,27 @@ static u8 *format_ipip_tunnel(u8 *s, va_list *args) {
ipip_tunnel_t *t = va_arg(*args, ipip_tunnel_t *);
ip46_type_t type = (t->transport == IPIP_TRANSPORT_IP4) ? IP46_TYPE_IP4 : IP46_TYPE_IP6;
+ u32 table_id;
+
+ table_id = fib_table_get_table_id(t->fib_index,
+ (t->transport == IPIP_TRANSPORT_IP4 ?
+ FIB_PROTOCOL_IP4 :
+ FIB_PROTOCOL_IP6));
switch (t->mode) {
case IPIP_MODE_6RD:
- s = format(s, "[%d] 6rd src %U ip6-pfx %U/%d fib-idx %d sw-if-idx %d ",
+ s = format(s, "[%d] 6rd src %U ip6-pfx %U/%d table-ID %d sw-if-idx %d ",
t->dev_instance,
format_ip46_address, &t->tunnel_src, type,
format_ip6_address, &t->sixrd.ip6_prefix, t->sixrd.ip6_prefix_len,
- t->fib_index, t->sw_if_index);
+ table_id, t->sw_if_index);
break;
case IPIP_MODE_P2P:
default:
- s = format(s, "[%d] instance %d src %U dst %U fib-idx %d sw-if-idx %d ",
+ s = format(s, "[%d] instance %d src %U dst %U table-ID %d sw-if-idx %d ",
t->dev_instance, t->user_instance,
format_ip46_address, &t->tunnel_src, type,
format_ip46_address, &t->tunnel_dst, type,
- t->fib_index, t->sw_if_index);
+ table_id, t->sw_if_index);
break;
}
@@ -226,9 +243,11 @@ static clib_error_t *create_sixrd_tunnel_command_fn(vlib_main_t *vm,
u32 ip6_prefix_len = 0, ip4_prefix_len = 0, sixrd_tunnel_index;
u32 num_m_args = 0;
/* Optional arguments */
- u32 fib_index = 0;
+ u32 ip4_table_id = 0, ip4_fib_index;
+ u32 ip6_table_id = 0, ip6_fib_index;
clib_error_t *error = 0;
bool security_check = false;
+ int rv;
/* Get a line of input. */
if (!unformat_user(input, unformat_line_input, line_input))
@@ -244,7 +263,9 @@ static clib_error_t *create_sixrd_tunnel_command_fn(vlib_main_t *vm,
num_m_args++;
else if (unformat(line_input, "ip4-src %U", unformat_ip4_address, &ip4_src))
num_m_args++;
- else if (unformat(line_input, "fib-id %d", &fib_index))
+ else if (unformat(line_input, "ip4-table-id %d", &ip4_table_id))
+ ;
+ else if (unformat(line_input, "ip6-table-id %d", &ip6_table_id))
;
else {
error = clib_error_return(0, "unknown input `%U'", format_unformat_error,
@@ -257,13 +278,31 @@ static clib_error_t *create_sixrd_tunnel_command_fn(vlib_main_t *vm,
error = clib_error_return(0, "mandatory argument(s) missing");
goto done;
}
- int rv = sixrd_add_tunnel(&ip6_prefix, ip6_prefix_len, &ip4_prefix,
+ ip4_fib_index = fib_table_find(FIB_PROTOCOL_IP4, ip4_table_id);
+ ip6_fib_index = fib_table_find(FIB_PROTOCOL_IP6, ip6_table_id);
+
+ if (~0 == ip4_fib_index)
+ {
+ error = clib_error_return(0, "No such IP4 table %d", ip4_table_id);
+ rv = VNET_API_ERROR_NO_SUCH_FIB;
+ }
+ else if (~0 == ip6_fib_index)
+ {
+ error = clib_error_return(0, "No such IP6 table %d", ip6_table_id);
+ rv = VNET_API_ERROR_NO_SUCH_FIB;
+ }
+ else
+ {
+ rv = sixrd_add_tunnel(&ip6_prefix, ip6_prefix_len, &ip4_prefix,
ip4_prefix_len, &ip4_src, security_check,
- fib_index, &sixrd_tunnel_index);
- if (rv)
- error = clib_error_return(0, "adding tunnel failed %d", rv);
+ ip4_fib_index, ip6_fib_index,
+ &sixrd_tunnel_index);
- done:
+ if (rv)
+ error = clib_error_return(0, "adding tunnel failed %d", rv);
+ }
+
+done:
unformat_free(line_input);
return error;
@@ -308,7 +347,7 @@ done:
VLIB_CLI_COMMAND(create_sixrd_tunnel_command, static) = {
.path = "create 6rd tunnel",
.short_help = "create 6rd tunnel ip6-pfx <ip6-pfx> ip4-pfx <ip4-pfx> "
- "ip4-src <ip4-addr> [del]",
+ "ip4-src <ip4-addr> table-id <ID> [del]",
.function = create_sixrd_tunnel_command_fn,
};
VLIB_CLI_COMMAND(delete_sixrd_tunnel_command, static) = {
diff --git a/src/vnet/ipip/sixrd.c b/src/vnet/ipip/sixrd.c
index 38ca899f274..71d607450c0 100644
--- a/src/vnet/ipip/sixrd.c
+++ b/src/vnet/ipip/sixrd.c
@@ -177,6 +177,7 @@ sixrd_tunnel_stack (adj_index_t ai, u32 fib_index)
LOOKUP_UNICAST, LOOKUP_INPUT_DST_ADDR,
LOOKUP_TABLE_FROM_CONFIG, &dpo);
adj_nbr_midchain_stack (ai, &dpo);
+ dpo_reset (&dpo);
}
const static ip46_address_t sixrd_special_nh = {
@@ -281,14 +282,11 @@ int
sixrd_add_tunnel (ip6_address_t * ip6_prefix, u8 ip6_prefix_len,
ip4_address_t * ip4_prefix, u8 ip4_prefix_len,
ip4_address_t * ip4_src, bool security_check,
- u32 fib_index, u32 * sw_if_index)
+ u32 ip4_fib_index, u32 ip6_fib_index, u32 * sw_if_index)
{
ipip_main_t *gm = &ipip_main;
ipip_tunnel_t *t;
- if (fib_index == ~0)
- return VNET_API_ERROR_NO_SUCH_FIB;
-
if ((ip6_prefix_len + 32 - ip4_prefix_len) > 64)
return VNET_API_ERROR_INVALID_VALUE;
@@ -296,8 +294,9 @@ sixrd_add_tunnel (ip6_address_t * ip6_prefix, u8 ip6_prefix_len,
ip46_address_t src = ip46_address_initializer, dst =
ip46_address_initializer;
ip_set (&src, ip4_src, true);
- ipip_tunnel_key_t key = {.transport = IPIP_TRANSPORT_IP4,
- .fib_index = fib_index,
+ ipip_tunnel_key_t key = {
+ .transport = IPIP_TRANSPORT_IP4,
+ .fib_index = ip4_fib_index,
.src = src,
.dst = dst
};
@@ -317,6 +316,7 @@ sixrd_add_tunnel (ip6_address_t * ip6_prefix, u8 ip6_prefix_len,
t->sixrd.ip4_prefix_len = ip4_prefix_len;
t->sixrd.ip6_prefix = *ip6_prefix;
t->sixrd.ip6_prefix_len = ip6_prefix_len;
+ t->sixrd.ip6_fib_index = ip6_fib_index;
t->tunnel_src = src;
t->sixrd.security_check = security_check;
t->sixrd.shift =
@@ -332,7 +332,7 @@ sixrd_add_tunnel (ip6_address_t * ip6_prefix, u8 ip6_prefix_len,
vnet_hw_interface_t *hi =
vnet_get_hw_interface (vnet_get_main (), hw_if_index);
t->hw_if_index = hw_if_index;
- t->fib_index = fib_index;
+ t->fib_index = ip4_fib_index;
t->sw_if_index = hi->sw_if_index;
t->dev_instance = t_idx;
t->user_instance = t_idx;
@@ -349,24 +349,26 @@ sixrd_add_tunnel (ip6_address_t * ip6_prefix, u8 ip6_prefix_len,
VNET_HW_INTERFACE_FLAG_LINK_UP);
vnet_sw_interface_set_flags (vnet_get_main (), hi->sw_if_index,
VNET_SW_INTERFACE_FLAG_ADMIN_UP);
- ip6_sw_interface_enable_disable (hi->sw_if_index, true);
+ ip6_sw_interface_enable_disable (t->sw_if_index, true);
/* Create IPv6 route/adjacency */
+ /* *INDENT-OFF* */
fib_prefix_t pfx6 = {
.fp_proto = FIB_PROTOCOL_IP6,
.fp_len = t->sixrd.ip6_prefix_len,
.fp_addr = {
- .ip6 = t->sixrd.ip6_prefix,
- }
- ,
+ .ip6 = t->sixrd.ip6_prefix,
+ },
};
+ /* *INDENT-ON* */
- fib_table_entry_update_one_path (fib_index, &pfx6, FIB_SOURCE_CLI,
+ fib_table_lock (ip6_fib_index, FIB_PROTOCOL_IP6, FIB_SOURCE_6RD);
+ fib_table_entry_update_one_path (ip6_fib_index, &pfx6, FIB_SOURCE_6RD,
FIB_ENTRY_FLAG_ATTACHED, DPO_PROTO_IP6,
- &sixrd_special_nh, hi->sw_if_index, ~0, 1,
+ &sixrd_special_nh, t->sw_if_index, ~0, 1,
NULL, FIB_ROUTE_PATH_FLAG_NONE);
- *sw_if_index = hi->sw_if_index;
+ *sw_if_index = t->sw_if_index;
if (!gm->ip4_protocol_registered)
{
@@ -394,15 +396,23 @@ sixrd_del_tunnel (u32 sw_if_index)
return -1;
}
+ /* *INDENT-OFF* */
fib_prefix_t pfx6 = {
.fp_proto = FIB_PROTOCOL_IP6,
.fp_len = t->sixrd.ip6_prefix_len,
.fp_addr = {
- .ip6 = t->sixrd.ip6_prefix,
- }
- ,
+ .ip6 = t->sixrd.ip6_prefix,
+ },
};
- fib_table_entry_special_remove (0, &pfx6, FIB_SOURCE_CLI);
+ /* *INDENT-ON* */
+
+ fib_table_entry_path_remove (t->sixrd.ip6_fib_index, &pfx6,
+ FIB_SOURCE_6RD,
+ DPO_PROTO_IP6,
+ &sixrd_special_nh, t->sw_if_index, ~0, 1,
+ FIB_ROUTE_PATH_FLAG_NONE);
+ fib_table_unlock (t->sixrd.ip6_fib_index, FIB_PROTOCOL_IP6, FIB_SOURCE_6RD);
+
vnet_sw_interface_set_flags (vnet_get_main (), t->sw_if_index,
0 /* down */ );
ip6_sw_interface_enable_disable (t->sw_if_index, false);
diff --git a/src/vnet/mfib/mfib_types.h b/src/vnet/mfib/mfib_types.h
index 2ab0f7d4fef..14d1288cff3 100644
--- a/src/vnet/mfib/mfib_types.h
+++ b/src/vnet/mfib/mfib_types.h
@@ -161,6 +161,7 @@ typedef enum mfib_itf_flags_t_
typedef enum mfib_source_t_
{
MFIB_SOURCE_SPECIAL,
+ MFIB_SOURCE_6RD,
MFIB_SOURCE_API,
MFIB_SOURCE_CLI,
MFIB_SOURCE_VXLAN,
@@ -176,6 +177,7 @@ typedef enum mfib_source_t_
#define MFIB_SOURCE_NAMES { \
[MFIB_SOURCE_SPECIAL] = "Special", \
+ [MFIB_SOURCE_6RD] = "6RD", \
[MFIB_SOURCE_API] = "API", \
[MFIB_SOURCE_CLI] = "CLI", \
[MFIB_SOURCE_DHCP] = "DHCP", \
diff --git a/test/test_ipip.py b/test/test_ipip.py
index 00721ec90a0..a425f9c489c 100644
--- a/test/test_ipip.py
+++ b/test/test_ipip.py
@@ -4,7 +4,7 @@
import unittest
from scapy.layers.inet6 import IPv6, Ether, IP, UDP
from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto
+from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto, VppIpTable
from socket import AF_INET, AF_INET6, inet_pton
""" Testipip is a subclass of VPPTestCase classes.
@@ -213,6 +213,21 @@ class TestIPIP(VppTestCase):
sw_if_index = rv.sw_if_index
self.vapi.ipip_del_tunnel(sw_if_index)
+ def test_ipip_vrf_create(self):
+ """ ipip create / delete interface VRF test """
+
+ t = VppIpTable(self, 20)
+ t.add_vpp_config()
+ rv = self.vapi.ipip_add_tunnel(
+ src_address=inet_pton(AF_INET, '1.2.3.4'),
+ dst_address=inet_pton(AF_INET, '2.3.4.5'), is_ipv6=0,
+ table_id=20)
+ sw_if_index = rv.sw_if_index
+ self.vapi.ipip_del_tunnel(sw_if_index)
+
+ def payload(self, len):
+ return 'x' * len
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
diff --git a/test/test_sixrd.py b/test/test_sixrd.py
index c6b3c088516..7656c3f4e7c 100644
--- a/test/test_sixrd.py
+++ b/test/test_sixrd.py
@@ -6,7 +6,7 @@ from scapy.layers.inet import IP, UDP, Ether
from scapy.layers.inet6 import IPv6
from scapy.packet import Raw
from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto
+from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto, VppIpTable
from socket import AF_INET, AF_INET6, inet_pton
""" Test6rd is a subclass of VPPTestCase classes.
@@ -22,13 +22,23 @@ class Test6RD(VppTestCase):
@classmethod
def setUpClass(cls):
super(Test6RD, cls).setUpClass()
- cls.create_pg_interfaces(range(2))
+ cls.create_pg_interfaces(range(4))
cls.interfaces = list(cls.pg_interfaces)
- def setUp(cls):
- super(Test6RD, cls).setUp()
- for i in cls.interfaces:
+ def setUp(self):
+ super(Test6RD, self).setUp()
+ t4 = VppIpTable(self, 10)
+ t6 = VppIpTable(self, 20, True)
+
+ t4.add_vpp_config()
+ t6.add_vpp_config()
+
+ for n in range(4):
+ i = self.pg_interfaces[n]
i.admin_up()
+ if (n > 1):
+ i.set_table_ip4(10)
+ i.set_table_ip6(20)
i.config_ip4()
i.config_ip6()
i.disable_ipv6_ra()
@@ -36,17 +46,12 @@ class Test6RD(VppTestCase):
i.resolve_ndp()
def tearDown(self):
+ for i in self.pg_interfaces:
+ i.unconfig_ip4()
+ i.unconfig_ip6()
+ i.set_table_ip4(0)
+ i.set_table_ip6(0)
super(Test6RD, self).tearDown()
- if not self.vpp_dead:
- for i in self.pg_interfaces:
- i.unconfig_ip4()
- i.unconfig_ip6()
- i.admin_down()
- if type(self.tunnel_index) is list:
- for sw_if_index in self.tunnel_index:
- self.vapi.ipip_6rd_del_tunnel(sw_if_index)
- else:
- self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
def validate_6in4(self, rx, expected):
if IP not in rx:
@@ -80,7 +85,7 @@ class Test6RD(VppTestCase):
rv = self.vapi.ipip_6rd_add_tunnel(
0, inet_pton(AF_INET6, '2002::'), 16,
- inet_pton(AF_INET, '0.0.0.0'), 0,
+ 0, inet_pton(AF_INET, '0.0.0.0'), 0,
self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
@@ -105,20 +110,55 @@ class Test6RD(VppTestCase):
proto='ipv6') / p_ip6)
rx = self.send_and_assert_no_replies(self.pg0, p*10)
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
+
+ def test_6rd_ip6_to_ip4_vrf(self):
+ """ ip6 -> ip4 (encap) 6rd VRF test """
+ p_ether = Ether(src=self.pg2.remote_mac, dst=self.pg2.local_mac)
+ p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1", nh='UDP')
+
+ rv = self.vapi.ipip_6rd_add_tunnel(
+ 20, inet_pton(AF_INET6, '2002::'), 16,
+ 10, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg2.local_ip4n, True)
+ self.tunnel_index = rv.sw_if_index
+
+ self.vapi.cli("show ip6 fib")
+ p_payload = UDP(sport=1234, dport=1234)
+ p = (p_ether / p_ip6 / p_payload)
+
+ p_reply = (IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4,
+ proto='ipv6') / p_ip6)
+
+ rx = self.send_and_expect(self.pg2, p*10, self.pg3)
+ for p in rx:
+ self.validate_6in4(p, p_reply)
+
+ # MTU tests (default is 1480)
+ plen = 1481 - 40 - 8
+ p_ip6 = IPv6(src="1::1", dst="2002:AC10:0402::1")
+ p_payload = UDP(sport=1234, dport=1234) / Raw(self.payload(plen))
+ p = (p_ether / p_ip6 / p_payload)
+
+ p_reply = (IP(src=self.pg2.local_ip4, dst=self.pg3.remote_ip4,
+ proto='ipv6') / p_ip6)
+
+ rx = self.send_and_assert_no_replies(self.pg0, p*10)
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
def test_6rd_ip4_to_ip6(self):
""" ip4 -> ip6 (decap) 6rd test """
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, inet_pton(AF_INET6, '2002::'),
- 16, inet_pton(AF_INET, '0.0.0.0'),
- 0, self.pg0.local_ip4n, True)
+ 0, inet_pton(AF_INET6, '2002::'), 16,
+ 0, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, inet_pton(AF_INET6, '2002::'),
- 16, inet_pton(AF_INET, '0.0.0.0'),
- 0, self.pg0.local_ip4n, True)
+ 0, inet_pton(AF_INET6, '2002::'), 16,
+ 0, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
p_ip6 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) /
@@ -134,21 +174,54 @@ class Test6RD(VppTestCase):
rx = self.send_and_expect(self.pg0, p*10, self.pg1)
for p in rx:
self.validate_4in6(p, p_reply)
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
+
+ def test_6rd_ip4_to_ip6_vrf(self):
+ """ ip4 -> ip6 (decap) 6rd VRF test """
+
+ rv = self.vapi.ipip_6rd_add_tunnel(
+ 20, inet_pton(AF_INET6, '2002::'), 16,
+ 10, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg2.local_ip4n, True)
+ self.tunnel_index = rv.sw_if_index
+ rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
+ rv = self.vapi.ipip_6rd_add_tunnel(
+ 20, inet_pton(AF_INET6, '2002::'), 16,
+ 10, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg2.local_ip4n, True)
+ self.tunnel_index = rv.sw_if_index
+ self.vapi.sw_interface_set_table(self.tunnel_index, 1, 20)
+
+ p_ip6 = (IPv6(src="2002:AC10:0402::1", dst=self.pg3.remote_ip6) /
+ UDP(sport=1234, dport=1234))
+
+ p = (Ether(src=self.pg2.remote_mac,
+ dst=self.pg2.local_mac) /
+ IP(src=self.pg3.remote_ip4, dst=self.pg2.local_ip4) /
+ p_ip6)
+
+ p_reply = p_ip6
+
+ rx = self.send_and_expect(self.pg2, p*10, self.pg3)
+ for p in rx:
+ self.validate_4in6(p, p_reply)
+ self.vapi.sw_interface_set_table(self.tunnel_index, 1, 0)
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
def test_6rd_ip4_to_ip6_multiple(self):
""" ip4 -> ip6 (decap) 6rd test """
self.tunnel_index = []
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, inet_pton(AF_INET6, '2002::'),
- 16, inet_pton(AF_INET, '0.0.0.0'),
- 0, self.pg0.local_ip4n, True)
+ 0, inet_pton(AF_INET6, '2002::'), 16,
+ 0, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg0.local_ip4n, True)
self.tunnel_index.append(rv.sw_if_index)
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, inet_pton(AF_INET6, '2003::'),
- 16, inet_pton(AF_INET, '0.0.0.0'),
- 0, self.pg1.local_ip4n, True)
+ 0, inet_pton(AF_INET6, '2003::'), 16,
+ 0, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg1.local_ip4n, True)
self.tunnel_index.append(rv.sw_if_index)
self.vapi.cli("show ip6 fib")
@@ -168,13 +241,15 @@ class Test6RD(VppTestCase):
rx = self.send_and_expect(self.pg0, p*10, self.pg1)
for p in rx:
self.validate_4in6(p, p_ip6_2)
+ for i in self.tunnel_index:
+ self.vapi.ipip_6rd_del_tunnel(i)
def test_6rd_ip4_to_ip6_suffix(self):
""" ip4 -> ip6 (decap) 6rd test """
rv = self.vapi.ipip_6rd_add_tunnel(
0, inet_pton(AF_INET6, '2002::'), 16,
- inet_pton(AF_INET, '172.0.0.0'), 8,
+ 0, inet_pton(AF_INET, '172.0.0.0'), 8,
self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
@@ -189,14 +264,15 @@ class Test6RD(VppTestCase):
rx = self.send_and_expect(self.pg0, p*10, self.pg1)
for p in rx:
self.validate_4in6(p, p_ip6)
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
def test_6rd_ip4_to_ip6_sec_check(self):
""" ip4 -> ip6 (decap) security check 6rd test """
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, inet_pton(AF_INET6, '2002::'),
- 16, inet_pton(AF_INET, '0.0.0.0'),
- 0, self.pg0.local_ip4n, True)
+ 0, inet_pton(AF_INET6, '2002::'), 16,
+ 0, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
self.vapi.cli("show ip6 fib")
@@ -221,14 +297,15 @@ class Test6RD(VppTestCase):
IP(src=self.pg1.remote_ip4, dst=self.pg0.local_ip4) /
p_ip6_fail)
rx = self.send_and_assert_no_replies(self.pg0, p*10)
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
def test_6rd_bgp_tunnel(self):
""" 6rd BGP tunnel """
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, inet_pton(AF_INET6, '2002::'),
- 16, inet_pton(AF_INET, '0.0.0.0'),
- 0, self.pg0.local_ip4n, False)
+ 0, inet_pton(AF_INET6, '2002::'), 16,
+ 0, inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg0.local_ip4n, False)
self.tunnel_index = rv.sw_if_index
default_route = VppIpRoute(
@@ -269,6 +346,9 @@ class Test6RD(VppTestCase):
rx = self.send_and_expect(self.pg0, p*10, self.pg1)
for p in rx:
self.validate_4in6(p, p_reply)
+ ip4_route.remove_vpp_config()
+ default_route.remove_vpp_config()
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
if __name__ == '__main__':
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 5383b07fc4c..8bfc18e5a5c 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -3411,12 +3411,13 @@ class VppPapiProvider(object):
""" GBP contract Dump """
return self.api(self.papi.gbp_contract_dump, {})
- def ipip_6rd_add_tunnel(self, fib_index, ip6_prefix, ip6_prefix_len,
- ip4_prefix, ip4_prefix_len, ip4_src,
+ def ipip_6rd_add_tunnel(self, ip6_table_id, ip6_prefix, ip6_prefix_len,
+ ip4_table_id, ip4_prefix, ip4_prefix_len, ip4_src,
security_check):
""" 6RD tunnel Add """
return self.api(self.papi.ipip_6rd_add_tunnel,
- {'fib_index': fib_index,
+ {'ip4_table_id': ip4_table_id,
+ 'ip6_table_id': ip6_table_id,
'ip6_prefix': ip6_prefix,
'ip6_prefix_len': ip6_prefix_len,
'ip4_prefix': ip4_prefix,
@@ -3430,14 +3431,14 @@ class VppPapiProvider(object):
{'sw_if_index': sw_if_index})
def ipip_add_tunnel(self, src_address, dst_address, is_ipv6=1,
- instance=0xFFFFFFFF, fib_index=0, tc_tos=0):
+ instance=0xFFFFFFFF, table_id=0, tc_tos=0):
""" IPIP tunnel Add/Del """
return self.api(self.papi.ipip_add_tunnel,
{'is_ipv6': is_ipv6,
'instance': instance,
'src_address': src_address,
'dst_address': dst_address,
- 'fib_index': fib_index,
+ 'table_id': table_id,
'tc_tos': tc_tos})
def ipip_del_tunnel(self, sw_if_index):