BFD: IPv6 support
Change-Id: Iaa9538c7cca500c04cf2704e5bf87480543cfcdf Signed-off-by: Klement Sekera <ksekera@cisco.com>
This commit is contained in:

committed by
Damjan Marion

parent
a18c7c0d5c
commit
46a87adf10
@ -34,16 +34,9 @@ bfd_us_to_clocks (bfd_main_t * bm, u64 us)
|
|||||||
|
|
||||||
static vlib_node_registration_t bfd_process_node;
|
static vlib_node_registration_t bfd_process_node;
|
||||||
|
|
||||||
typedef enum
|
/* set to 0 here, real values filled at startup */
|
||||||
{
|
static u32 bfd_node_index_by_transport[] = {
|
||||||
#define F(t, n) BFD_OUTPUT_##t,
|
#define F(t, n) [BFD_TRANSPORT_##t] = 0,
|
||||||
foreach_bfd_transport (F)
|
|
||||||
#undef F
|
|
||||||
BFD_OUTPUT_N_NEXT,
|
|
||||||
} bfd_output_next_t;
|
|
||||||
|
|
||||||
static u32 bfd_next_index_by_transport[] = {
|
|
||||||
#define F(t, n) [BFD_TRANSPORT_##t] = BFD_OUTPUT_##t,
|
|
||||||
foreach_bfd_transport (F)
|
foreach_bfd_transport (F)
|
||||||
#undef F
|
#undef F
|
||||||
};
|
};
|
||||||
@ -378,7 +371,7 @@ bfd_input_format_trace (u8 * s, va_list * args)
|
|||||||
clib_net_to_host_u32 (pkt->des_min_tx));
|
clib_net_to_host_u32 (pkt->des_min_tx));
|
||||||
s = format (s, " required min rx interval: %u\n",
|
s = format (s, " required min rx interval: %u\n",
|
||||||
clib_net_to_host_u32 (pkt->req_min_rx));
|
clib_net_to_host_u32 (pkt->req_min_rx));
|
||||||
s = format (s, " required min echo rx interval: %u\n",
|
s = format (s, " required min echo rx interval: %u",
|
||||||
clib_net_to_host_u32 (pkt->req_min_echo_rx));
|
clib_net_to_host_u32 (pkt->req_min_echo_rx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,10 +419,12 @@ bfd_add_transport_layer (vlib_main_t * vm, vlib_buffer_t * b,
|
|||||||
switch (bs->transport)
|
switch (bs->transport)
|
||||||
{
|
{
|
||||||
case BFD_TRANSPORT_UDP4:
|
case BFD_TRANSPORT_UDP4:
|
||||||
/* fallthrough */
|
BFD_DBG ("Transport bfd via udp4, bs_idx=%u", bs->bs_idx);
|
||||||
|
bfd_add_udp4_transport (vm, b, &bs->udp);
|
||||||
|
break;
|
||||||
case BFD_TRANSPORT_UDP6:
|
case BFD_TRANSPORT_UDP6:
|
||||||
BFD_DBG ("Transport bfd via udp, bs_idx=%u", bs->bs_idx);
|
BFD_DBG ("Transport bfd via udp6, bs_idx=%u", bs->bs_idx);
|
||||||
bfd_add_udp_transport (vm, b, &bs->udp);
|
bfd_add_udp6_transport (vm, b, &bs->udp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,17 +443,14 @@ bfd_create_frame (vlib_main_t * vm, vlib_node_runtime_t * rt,
|
|||||||
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
|
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
|
||||||
ASSERT (b->current_data == 0);
|
ASSERT (b->current_data == 0);
|
||||||
|
|
||||||
u32 *to_next;
|
vlib_frame_t *f =
|
||||||
u32 n_left_to_next;
|
vlib_get_frame_to_node (vm, bfd_node_index_by_transport[bs->transport]);
|
||||||
|
|
||||||
vlib_get_next_frame (vm, rt, bfd_next_index_by_transport[bs->transport],
|
|
||||||
to_next, n_left_to_next);
|
|
||||||
|
|
||||||
|
u32 *to_next = vlib_frame_vector_args (f);
|
||||||
to_next[0] = bi;
|
to_next[0] = bi;
|
||||||
n_left_to_next -= 1;
|
f->n_vectors = 1;
|
||||||
|
|
||||||
vlib_put_next_frame (vm, rt, bfd_next_index_by_transport[bs->transport],
|
vlib_put_frame_to_node (vm, bfd_node_index_by_transport[bs->transport], f);
|
||||||
n_left_to_next);
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,13 +672,8 @@ VLIB_REGISTER_NODE (bfd_process_node, static) = {
|
|||||||
.function = bfd_process,
|
.function = bfd_process,
|
||||||
.type = VLIB_NODE_TYPE_PROCESS,
|
.type = VLIB_NODE_TYPE_PROCESS,
|
||||||
.name = "bfd-process",
|
.name = "bfd-process",
|
||||||
.n_next_nodes = BFD_OUTPUT_N_NEXT,
|
.n_next_nodes = 0,
|
||||||
.next_nodes =
|
.next_nodes = {},
|
||||||
{
|
|
||||||
#define F(t, n) [BFD_OUTPUT_##t] = n,
|
|
||||||
foreach_bfd_transport (F)
|
|
||||||
#undef F
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
@ -734,6 +721,13 @@ bfd_main_init (vlib_main_t * vm)
|
|||||||
timing_wheel_init (&bm->wheel, now, bm->cpu_cps);
|
timing_wheel_init (&bm->wheel, now, bm->cpu_cps);
|
||||||
bm->wheel_inaccuracy = 2 << bm->wheel.log2_clocks_per_bin;
|
bm->wheel_inaccuracy = 2 << bm->wheel.log2_clocks_per_bin;
|
||||||
|
|
||||||
|
vlib_node_t *node = NULL;
|
||||||
|
#define F(t, n) \
|
||||||
|
node = vlib_get_node_by_name (vm, (u8 *)n); \
|
||||||
|
bfd_node_index_by_transport[BFD_TRANSPORT_##t] = node->index;\
|
||||||
|
BFD_DBG("node '%s' has index %u", n, node->index);
|
||||||
|
foreach_bfd_transport (F);
|
||||||
|
#undef F
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <vnet/bfd/bfd_udp.h>
|
#include <vnet/bfd/bfd_udp.h>
|
||||||
|
|
||||||
#define foreach_bfd_transport(F) \
|
#define foreach_bfd_transport(F) \
|
||||||
F (UDP4, "ip4-rewrite") \
|
F (UDP4, "ip4-rewrite") \
|
||||||
F (UDP6, "ip6-rewrite")
|
F (UDP6, "ip6-rewrite")
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -31,53 +31,80 @@ static vlib_node_registration_t bfd_udp6_input_node;
|
|||||||
|
|
||||||
bfd_udp_main_t bfd_udp_main;
|
bfd_udp_main_t bfd_udp_main;
|
||||||
|
|
||||||
void bfd_udp_transport_to_buffer (vlib_main_t *vm, vlib_buffer_t *b,
|
void bfd_add_udp4_transport (vlib_main_t *vm, vlib_buffer_t *b,
|
||||||
bfd_udp_session_t *bus)
|
bfd_udp_session_t *bus)
|
||||||
{
|
{
|
||||||
udp_header_t *udp;
|
udp_header_t *udp;
|
||||||
u16 udp_length, ip_length;
|
const bfd_udp_key_t *key = &bus->key;
|
||||||
bfd_udp_key_t *key = &bus->key;
|
|
||||||
|
|
||||||
b->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;
|
b->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;
|
||||||
if (ip46_address_is_ip4 (&key->local_addr))
|
|
||||||
{
|
|
||||||
ip4_header_t *ip4;
|
|
||||||
const size_t data_size = sizeof (*ip4) + sizeof (*udp);
|
|
||||||
vlib_buffer_advance (b, -data_size);
|
|
||||||
ip4 = vlib_buffer_get_current (b);
|
|
||||||
udp = (udp_header_t *)(ip4 + 1);
|
|
||||||
memset (ip4, 0, data_size);
|
|
||||||
ip4->ip_version_and_header_length = 0x45;
|
|
||||||
ip4->ttl = 255;
|
|
||||||
ip4->protocol = IP_PROTOCOL_UDP;
|
|
||||||
ip4->src_address.as_u32 = key->local_addr.ip4.as_u32;
|
|
||||||
ip4->dst_address.as_u32 = key->peer_addr.ip4.as_u32;
|
|
||||||
|
|
||||||
udp->src_port = clib_host_to_net_u16 (50000); /* FIXME */
|
|
||||||
udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd4);
|
|
||||||
|
|
||||||
/* fix ip length, checksum and udp length */
|
|
||||||
ip_length = vlib_buffer_length_in_chain (vm, b);
|
|
||||||
|
|
||||||
ip4->length = clib_host_to_net_u16 (ip_length);
|
|
||||||
ip4->checksum = ip4_header_checksum (ip4);
|
|
||||||
|
|
||||||
udp_length = ip_length - (sizeof (*ip4));
|
|
||||||
udp->length = clib_host_to_net_u16 (udp_length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BFD_ERR ("not implemented");
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void bfd_add_udp_transport (vlib_main_t *vm, vlib_buffer_t *b,
|
|
||||||
bfd_udp_session_t *bus)
|
|
||||||
{
|
|
||||||
vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
|
vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
|
||||||
vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
|
vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
|
||||||
bfd_udp_transport_to_buffer (vm, b, bus);
|
ip4_header_t *ip4;
|
||||||
|
const size_t headers_size = sizeof (*ip4) + sizeof (*udp);
|
||||||
|
vlib_buffer_advance (b, -headers_size);
|
||||||
|
ip4 = vlib_buffer_get_current (b);
|
||||||
|
udp = (udp_header_t *)(ip4 + 1);
|
||||||
|
memset (ip4, 0, headers_size);
|
||||||
|
ip4->ip_version_and_header_length = 0x45;
|
||||||
|
ip4->ttl = 255;
|
||||||
|
ip4->protocol = IP_PROTOCOL_UDP;
|
||||||
|
ip4->src_address.as_u32 = key->local_addr.ip4.as_u32;
|
||||||
|
ip4->dst_address.as_u32 = key->peer_addr.ip4.as_u32;
|
||||||
|
|
||||||
|
udp->src_port = clib_host_to_net_u16 (50000); /* FIXME */
|
||||||
|
udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd4);
|
||||||
|
|
||||||
|
/* fix ip length, checksum and udp length */
|
||||||
|
const u16 ip_length = vlib_buffer_length_in_chain (vm, b);
|
||||||
|
|
||||||
|
ip4->length = clib_host_to_net_u16 (ip_length);
|
||||||
|
ip4->checksum = ip4_header_checksum (ip4);
|
||||||
|
|
||||||
|
const u16 udp_length = ip_length - (sizeof (*ip4));
|
||||||
|
udp->length = clib_host_to_net_u16 (udp_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bfd_add_udp6_transport (vlib_main_t *vm, vlib_buffer_t *b,
|
||||||
|
bfd_udp_session_t *bus)
|
||||||
|
{
|
||||||
|
udp_header_t *udp;
|
||||||
|
const bfd_udp_key_t *key = &bus->key;
|
||||||
|
|
||||||
|
b->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;
|
||||||
|
vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
|
||||||
|
vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
|
||||||
|
ip6_header_t *ip6;
|
||||||
|
const size_t headers_size = sizeof (*ip6) + sizeof (*udp);
|
||||||
|
vlib_buffer_advance (b, -headers_size);
|
||||||
|
ip6 = vlib_buffer_get_current (b);
|
||||||
|
udp = (udp_header_t *)(ip6 + 1);
|
||||||
|
memset (ip6, 0, headers_size);
|
||||||
|
ip6->ip_version_traffic_class_and_flow_label =
|
||||||
|
clib_host_to_net_u32 (0x6 << 28);
|
||||||
|
ip6->hop_limit = 255;
|
||||||
|
ip6->protocol = IP_PROTOCOL_UDP;
|
||||||
|
clib_memcpy (&ip6->src_address, &key->local_addr.ip6,
|
||||||
|
sizeof (ip6->src_address));
|
||||||
|
clib_memcpy (&ip6->dst_address, &key->peer_addr.ip6,
|
||||||
|
sizeof (ip6->dst_address));
|
||||||
|
|
||||||
|
udp->src_port = clib_host_to_net_u16 (50000); /* FIXME */
|
||||||
|
udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd6);
|
||||||
|
|
||||||
|
/* fix ip payload length and udp length */
|
||||||
|
const u16 udp_length = vlib_buffer_length_in_chain (vm, b) - (sizeof (*ip6));
|
||||||
|
udp->length = clib_host_to_net_u16 (udp_length);
|
||||||
|
ip6->payload_length = udp->length;
|
||||||
|
|
||||||
|
/* IPv6 UDP checksum is mandatory */
|
||||||
|
int bogus = 0;
|
||||||
|
udp->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus);
|
||||||
|
ASSERT (bogus == 0);
|
||||||
|
if (udp->checksum == 0)
|
||||||
|
{
|
||||||
|
udp->checksum = 0xffff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bfd_session_t *bfd_lookup_session (bfd_udp_main_t *bum,
|
static bfd_session_t *bfd_lookup_session (bfd_udp_main_t *bum,
|
||||||
@ -345,29 +372,29 @@ static bfd_udp_error_t bfd_udp4_verify_transport (const ip4_header_t *ip4,
|
|||||||
const bfd_udp_key_t *key = &bus->key;
|
const bfd_udp_key_t *key = &bus->key;
|
||||||
if (ip4->src_address.as_u32 != key->peer_addr.ip4.as_u32)
|
if (ip4->src_address.as_u32 != key->peer_addr.ip4.as_u32)
|
||||||
{
|
{
|
||||||
BFD_ERR ("IP src addr mismatch, got %U, expected %U", format_ip4_address,
|
BFD_ERR ("IPv4 src addr mismatch, got %U, expected %U",
|
||||||
ip4->src_address.as_u32, format_ip4_address,
|
format_ip4_address, ip4->src_address.as_u8, format_ip4_address,
|
||||||
key->peer_addr.ip4.as_u32);
|
key->peer_addr.ip4.as_u8);
|
||||||
return BFD_UDP_ERROR_BAD;
|
return BFD_UDP_ERROR_BAD;
|
||||||
}
|
}
|
||||||
if (ip4->dst_address.as_u32 != key->local_addr.ip4.as_u32)
|
if (ip4->dst_address.as_u32 != key->local_addr.ip4.as_u32)
|
||||||
{
|
{
|
||||||
BFD_ERR ("IP dst addr mismatch, got %U, expected %U", format_ip4_address,
|
BFD_ERR ("IPv4 dst addr mismatch, got %U, expected %U",
|
||||||
ip4->dst_address.as_u32, format_ip4_address,
|
format_ip4_address, ip4->dst_address.as_u8, format_ip4_address,
|
||||||
key->local_addr.ip4.as_u32);
|
key->local_addr.ip4.as_u8);
|
||||||
return BFD_UDP_ERROR_BAD;
|
return BFD_UDP_ERROR_BAD;
|
||||||
}
|
}
|
||||||
const u8 expected_ttl = 255;
|
const u8 expected_ttl = 255;
|
||||||
if (ip4->ttl != expected_ttl)
|
if (ip4->ttl != expected_ttl)
|
||||||
{
|
{
|
||||||
BFD_ERR ("IP unexpected TTL value %d, expected %d", ip4->ttl,
|
BFD_ERR ("IPv4 unexpected TTL value %u, expected %u", ip4->ttl,
|
||||||
expected_ttl);
|
expected_ttl);
|
||||||
return BFD_UDP_ERROR_BAD;
|
return BFD_UDP_ERROR_BAD;
|
||||||
}
|
}
|
||||||
if (clib_net_to_host_u16 (udp->src_port) < 49152 ||
|
if (clib_net_to_host_u16 (udp->src_port) < 49152 ||
|
||||||
clib_net_to_host_u16 (udp->src_port) > 65535)
|
clib_net_to_host_u16 (udp->src_port) > 65535)
|
||||||
{
|
{
|
||||||
BFD_ERR ("Invalid UDP src port %d, out of range <49152,65535>",
|
BFD_ERR ("Invalid UDP src port %u, out of range <49152,65535>",
|
||||||
udp->src_port);
|
udp->src_port);
|
||||||
}
|
}
|
||||||
return BFD_UDP_ERROR_NONE;
|
return BFD_UDP_ERROR_NONE;
|
||||||
@ -460,10 +487,128 @@ static bfd_udp_error_t bfd_udp4_scan (vlib_main_t *vm, vlib_node_runtime_t *rt,
|
|||||||
return BFD_UDP_ERROR_NONE;
|
return BFD_UDP_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bfd_udp_error_t bfd_udp6_scan (vlib_main_t *vm, vlib_buffer_t *b)
|
static void bfd_udp6_find_headers (vlib_buffer_t *b, const ip6_header_t **ip6,
|
||||||
|
const udp_header_t **udp)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* sanity check first */
|
||||||
return BFD_UDP_ERROR_BAD;
|
const i32 start = vnet_buffer (b)->ip.start_of_ip_header;
|
||||||
|
if (start < 0 && start < sizeof (b->pre_data))
|
||||||
|
{
|
||||||
|
BFD_ERR ("Start of ip header is before pre_data, ignoring");
|
||||||
|
*ip6 = NULL;
|
||||||
|
*udp = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*ip6 = (ip6_header_t *)(b->data + start);
|
||||||
|
if ((u8 *)*ip6 > (u8 *)vlib_buffer_get_current (b))
|
||||||
|
{
|
||||||
|
BFD_ERR ("Start of ip header is beyond current data, ignoring");
|
||||||
|
*ip6 = NULL;
|
||||||
|
*udp = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*udp = (udp_header_t *)((*ip6) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bfd_udp_error_t bfd_udp6_verify_transport (const ip6_header_t *ip6,
|
||||||
|
const udp_header_t *udp,
|
||||||
|
const bfd_session_t *bs)
|
||||||
|
{
|
||||||
|
const bfd_udp_session_t *bus = &bs->udp;
|
||||||
|
const bfd_udp_key_t *key = &bus->key;
|
||||||
|
if (ip6->src_address.as_u64[0] != key->peer_addr.ip6.as_u64[0] &&
|
||||||
|
ip6->src_address.as_u64[1] != key->peer_addr.ip6.as_u64[1])
|
||||||
|
{
|
||||||
|
BFD_ERR ("IP src addr mismatch, got %U, expected %U", format_ip6_address,
|
||||||
|
ip6, format_ip6_address, &key->peer_addr.ip6);
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
if (ip6->dst_address.as_u64[0] != key->local_addr.ip6.as_u64[0] &&
|
||||||
|
ip6->dst_address.as_u64[1] != key->local_addr.ip6.as_u64[1])
|
||||||
|
{
|
||||||
|
BFD_ERR ("IP dst addr mismatch, got %U, expected %U", format_ip6_address,
|
||||||
|
ip6, format_ip6_address, &key->local_addr.ip6);
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
const u8 expected_hop_limit = 255;
|
||||||
|
if (ip6->hop_limit != expected_hop_limit)
|
||||||
|
{
|
||||||
|
BFD_ERR ("IPv6 unexpected hop-limit value %u, expected %u",
|
||||||
|
ip6->hop_limit, expected_hop_limit);
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
if (clib_net_to_host_u16 (udp->src_port) < 49152 ||
|
||||||
|
clib_net_to_host_u16 (udp->src_port) > 65535)
|
||||||
|
{
|
||||||
|
BFD_ERR ("Invalid UDP src port %u, out of range <49152,65535>",
|
||||||
|
udp->src_port);
|
||||||
|
}
|
||||||
|
return BFD_UDP_ERROR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bfd_udp_error_t bfd_udp6_scan (vlib_main_t *vm, vlib_node_runtime_t *rt,
|
||||||
|
vlib_buffer_t *b, bfd_session_t **bs_out)
|
||||||
|
{
|
||||||
|
const bfd_pkt_t *pkt = vlib_buffer_get_current (b);
|
||||||
|
if (sizeof (*pkt) > b->current_length)
|
||||||
|
{
|
||||||
|
BFD_ERR (
|
||||||
|
"Payload size %d too small to hold bfd packet of minimum size %d",
|
||||||
|
b->current_length, sizeof (*pkt));
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
const ip6_header_t *ip6;
|
||||||
|
const udp_header_t *udp;
|
||||||
|
bfd_udp6_find_headers (b, &ip6, &udp);
|
||||||
|
if (!ip6 || !udp)
|
||||||
|
{
|
||||||
|
BFD_ERR ("Couldn't find ip6 or udp header");
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
if (!bfd_verify_pkt_common (pkt))
|
||||||
|
{
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
bfd_session_t *bs = NULL;
|
||||||
|
if (pkt->your_disc)
|
||||||
|
{
|
||||||
|
BFD_DBG ("Looking up BFD session using discriminator %u",
|
||||||
|
pkt->your_disc);
|
||||||
|
bs = bfd_find_session_by_disc (bfd_udp_main.bfd_main, pkt->your_disc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bfd_udp_key_t key;
|
||||||
|
memset (&key, 0, sizeof (key));
|
||||||
|
key.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
|
||||||
|
key.local_addr.ip6.as_u64[0] = ip6->dst_address.as_u64[0];
|
||||||
|
key.local_addr.ip6.as_u64[1] = ip6->dst_address.as_u64[1];
|
||||||
|
key.peer_addr.ip6.as_u64[0] = ip6->src_address.as_u64[0];
|
||||||
|
key.peer_addr.ip6.as_u64[1] = ip6->src_address.as_u64[1];
|
||||||
|
BFD_DBG ("Looking up BFD session using key (sw_if_index=%u, local=%U, "
|
||||||
|
"peer=%U)",
|
||||||
|
key.sw_if_index, format_ip6_address, &key.local_addr,
|
||||||
|
format_ip6_address, &key.peer_addr);
|
||||||
|
bs = bfd_lookup_session (&bfd_udp_main, &key);
|
||||||
|
}
|
||||||
|
if (!bs)
|
||||||
|
{
|
||||||
|
BFD_ERR ("BFD session lookup failed - no session matches BFD pkt");
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
BFD_DBG ("BFD session found, bs_idx=%u", bs->bs_idx);
|
||||||
|
if (!bfd_verify_pkt_session (pkt, b->current_length, bs))
|
||||||
|
{
|
||||||
|
return BFD_UDP_ERROR_BAD;
|
||||||
|
}
|
||||||
|
bfd_udp_error_t err;
|
||||||
|
if (BFD_UDP_ERROR_NONE != (err = bfd_udp6_verify_transport (ip6, udp, bs)))
|
||||||
|
{
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
bfd_rpc_update_session (bs->bs_idx, pkt);
|
||||||
|
*bs_out = bs;
|
||||||
|
return BFD_UDP_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -504,7 +649,7 @@ static uword bfd_udp_input (vlib_main_t *vm, vlib_node_runtime_t *rt,
|
|||||||
/* scan this bfd pkt. error0 is the counter index to bmp */
|
/* scan this bfd pkt. error0 is the counter index to bmp */
|
||||||
if (is_ipv6)
|
if (is_ipv6)
|
||||||
{
|
{
|
||||||
error0 = bfd_udp6_scan (vm, b0);
|
error0 = bfd_udp6_scan (vm, rt, b0, &bs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -42,8 +42,10 @@ typedef struct
|
|||||||
adj_index_t adj_index;
|
adj_index_t adj_index;
|
||||||
} bfd_udp_session_t;
|
} bfd_udp_session_t;
|
||||||
|
|
||||||
void bfd_add_udp_transport (vlib_main_t * vm, vlib_buffer_t * b,
|
void bfd_add_udp4_transport (vlib_main_t * vm, vlib_buffer_t * b,
|
||||||
bfd_udp_session_t * bs);
|
bfd_udp_session_t * bs);
|
||||||
|
void bfd_add_udp6_transport (vlib_main_t * vm, vlib_buffer_t * b,
|
||||||
|
bfd_udp_session_t * bs);
|
||||||
|
|
||||||
#endif /* __included_bfd_udp_h__ */
|
#endif /* __included_bfd_udp_h__ */
|
||||||
|
|
||||||
|
14
test/bfd.py
14
test/bfd.py
@ -111,14 +111,24 @@ class VppBFDUDPSession(VppObject):
|
|||||||
def local_addr(self):
|
def local_addr(self):
|
||||||
""" BFD session local address (VPP address) """
|
""" BFD session local address (VPP address) """
|
||||||
if self._local_addr is None:
|
if self._local_addr is None:
|
||||||
return self._interface.local_ip4
|
if self.af == AF_INET:
|
||||||
|
return self._interface.local_ip4
|
||||||
|
elif self.af == AF_INET6:
|
||||||
|
return self._interface.local_ip6
|
||||||
|
else:
|
||||||
|
raise Exception("Unexpected af %s' % af" % self.af)
|
||||||
return self._local_addr
|
return self._local_addr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def local_addr_n(self):
|
def local_addr_n(self):
|
||||||
""" BFD session local address (VPP address) - raw, suitable for API """
|
""" BFD session local address (VPP address) - raw, suitable for API """
|
||||||
if self._local_addr is None:
|
if self._local_addr is None:
|
||||||
return self._interface.local_ip4n
|
if self.af == AF_INET:
|
||||||
|
return self._interface.local_ip4n
|
||||||
|
elif self.af == AF_INET6:
|
||||||
|
return self._interface.local_ip6n
|
||||||
|
else:
|
||||||
|
raise Exception("Unexpected af %s' % af" % self.af)
|
||||||
return self._local_addr_n
|
return self._local_addr_n
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
221
test/test_bfd.py
221
test/test_bfd.py
@ -62,36 +62,14 @@ class BFDAPITestCase(VppTestCase):
|
|||||||
session1.bs_index)
|
session1.bs_index)
|
||||||
|
|
||||||
|
|
||||||
def create_packet(interface, ttl=255, src_port=50000, **kwargs):
|
|
||||||
p = (Ether(src=interface.remote_mac, dst=interface.local_mac) /
|
|
||||||
IP(src=interface.remote_ip4, dst=interface.local_ip4, ttl=ttl) /
|
|
||||||
UDP(sport=src_port, dport=BFD.udp_dport) /
|
|
||||||
BFD(*kwargs))
|
|
||||||
return p
|
|
||||||
|
|
||||||
|
|
||||||
def verify_ip(test, packet, local_ip, remote_ip):
|
|
||||||
""" Verify correctness of IP layer. """
|
|
||||||
ip = packet[IP]
|
|
||||||
test.assert_equal(ip.src, local_ip, "IP source address")
|
|
||||||
test.assert_equal(ip.dst, remote_ip, "IP destination address")
|
|
||||||
test.assert_equal(ip.ttl, 255, "IP TTL")
|
|
||||||
|
|
||||||
|
|
||||||
def verify_udp(test, packet):
|
|
||||||
""" Verify correctness of UDP layer. """
|
|
||||||
udp = packet[UDP]
|
|
||||||
test.assert_equal(udp.dport, BFD.udp_dport, "UDP destination port")
|
|
||||||
test.assert_in_range(udp.sport, BFD.udp_sport_min, BFD.udp_sport_max,
|
|
||||||
"UDP source port")
|
|
||||||
|
|
||||||
|
|
||||||
class BFDTestSession(object):
|
class BFDTestSession(object):
|
||||||
""" BFD session as seen from test framework side """
|
""" BFD session as seen from test framework side """
|
||||||
|
|
||||||
def __init__(self, test, interface, detect_mult=3):
|
def __init__(self, test, interface, af, detect_mult=3):
|
||||||
self.test = test
|
self.test = test
|
||||||
|
self.af = af
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
|
self.udp_sport = 50000
|
||||||
self.bfd_values = {
|
self.bfd_values = {
|
||||||
'my_discriminator': 0,
|
'my_discriminator': 0,
|
||||||
'desired_min_tx_interval': 100000,
|
'desired_min_tx_interval': 100000,
|
||||||
@ -103,7 +81,22 @@ class BFDTestSession(object):
|
|||||||
self.bfd_values.update(kwargs)
|
self.bfd_values.update(kwargs)
|
||||||
|
|
||||||
def create_packet(self):
|
def create_packet(self):
|
||||||
packet = create_packet(self.interface)
|
if self.af == AF_INET6:
|
||||||
|
packet = (Ether(src=self.interface.remote_mac,
|
||||||
|
dst=self.interface.local_mac) /
|
||||||
|
IPv6(src=self.interface.remote_ip6,
|
||||||
|
dst=self.interface.local_ip6,
|
||||||
|
hlim=255) /
|
||||||
|
UDP(sport=self.udp_sport, dport=BFD.udp_dport) /
|
||||||
|
BFD())
|
||||||
|
else:
|
||||||
|
packet = (Ether(src=self.interface.remote_mac,
|
||||||
|
dst=self.interface.local_mac) /
|
||||||
|
IP(src=self.interface.remote_ip4,
|
||||||
|
dst=self.interface.local_ip4,
|
||||||
|
ttl=255) /
|
||||||
|
UDP(sport=self.udp_sport, dport=BFD.udp_dport) /
|
||||||
|
BFD())
|
||||||
self.test.logger.debug("BFD: Creating packet")
|
self.test.logger.debug("BFD: Creating packet")
|
||||||
for name, value in self.bfd_values.iteritems():
|
for name, value in self.bfd_values.iteritems():
|
||||||
self.test.logger.debug("BFD: setting packet.%s=%s", name, value)
|
self.test.logger.debug("BFD: setting packet.%s=%s", name, value)
|
||||||
@ -125,41 +118,52 @@ class BFDTestSession(object):
|
|||||||
"BFD - your discriminator")
|
"BFD - your discriminator")
|
||||||
|
|
||||||
|
|
||||||
@unittest.skip("")
|
class BFDCommonCode:
|
||||||
class BFDTestCase(VppTestCase):
|
"""Common code used by both IPv4 and IPv6 Test Cases"""
|
||||||
"""Bidirectional Forwarding Detection (BFD)"""
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
super(BFDTestCase, cls).setUpClass()
|
|
||||||
try:
|
|
||||||
cls.create_pg_interfaces([0])
|
|
||||||
cls.pg0.config_ip4()
|
|
||||||
cls.pg0.generate_remote_hosts()
|
|
||||||
cls.pg0.configure_ipv4_neighbors()
|
|
||||||
cls.pg0.admin_up()
|
|
||||||
cls.pg0.resolve_arp()
|
|
||||||
|
|
||||||
except Exception:
|
|
||||||
super(BFDTestCase, cls).tearDownClass()
|
|
||||||
raise
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(BFDTestCase, self).setUp()
|
|
||||||
self.vapi.want_bfd_events()
|
|
||||||
self.vpp_session = VppBFDUDPSession(
|
|
||||||
self, self.pg0, self.pg0.remote_ip4)
|
|
||||||
self.vpp_session.add_vpp_config()
|
|
||||||
self.vpp_session.admin_up()
|
|
||||||
self.test_session = BFDTestSession(self, self.pg0)
|
|
||||||
self.test_session.update(required_min_rx_interval=100000)
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.vapi.collect_events() # clear the event queue
|
self.vapi.collect_events() # clear the event queue
|
||||||
if not self.vpp_dead:
|
if not self.vpp_dead:
|
||||||
self.vapi.want_bfd_events(enable_disable=0)
|
self.vapi.want_bfd_events(enable_disable=0)
|
||||||
self.vpp_session.remove_vpp_config()
|
self.vpp_session.remove_vpp_config()
|
||||||
super(BFDTestCase, self).tearDown()
|
|
||||||
|
def bfd_session_up(self):
|
||||||
|
self.pg_enable_capture([self.pg0])
|
||||||
|
self.logger.info("BFD: Waiting for slow hello")
|
||||||
|
p, timeout = self.wait_for_bfd_packet(2)
|
||||||
|
self.logger.info("BFD: Sending Init")
|
||||||
|
self.test_session.update(my_discriminator=randint(0, 40000000),
|
||||||
|
your_discriminator=p[BFD].my_discriminator,
|
||||||
|
state=BFDState.init,
|
||||||
|
required_min_rx_interval=100000)
|
||||||
|
self.test_session.send_packet()
|
||||||
|
self.logger.info("BFD: Waiting for event")
|
||||||
|
e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
|
||||||
|
self.verify_event(e, expected_state=BFDState.up)
|
||||||
|
self.logger.info("BFD: Session is Up")
|
||||||
|
self.test_session.update(state=BFDState.up)
|
||||||
|
|
||||||
|
def verify_ip(self, packet):
|
||||||
|
""" Verify correctness of IP layer. """
|
||||||
|
if self.vpp_session.af == AF_INET6:
|
||||||
|
ip = packet[IPv6]
|
||||||
|
local_ip = self.pg0.local_ip6
|
||||||
|
remote_ip = self.pg0.remote_ip6
|
||||||
|
self.assert_equal(ip.hlim, 255, "IPv6 hop limit")
|
||||||
|
else:
|
||||||
|
ip = packet[IP]
|
||||||
|
local_ip = self.pg0.local_ip4
|
||||||
|
remote_ip = self.pg0.remote_ip4
|
||||||
|
self.assert_equal(ip.ttl, 255, "IPv4 TTL")
|
||||||
|
self.assert_equal(ip.src, local_ip, "IP source address")
|
||||||
|
self.assert_equal(ip.dst, remote_ip, "IP destination address")
|
||||||
|
|
||||||
|
def verify_udp(self, packet):
|
||||||
|
""" Verify correctness of UDP layer. """
|
||||||
|
udp = packet[UDP]
|
||||||
|
self.assert_equal(udp.dport, BFD.udp_dport, "UDP destination port")
|
||||||
|
self.assert_in_range(udp.sport, BFD.udp_sport_min, BFD.udp_sport_max,
|
||||||
|
"UDP source port")
|
||||||
|
|
||||||
def verify_event(self, event, expected_state):
|
def verify_event(self, event, expected_state):
|
||||||
""" Verify correctness of event values. """
|
""" Verify correctness of event values. """
|
||||||
@ -198,35 +202,64 @@ class BFDTestCase(VppTestCase):
|
|||||||
before = time.time()
|
before = time.time()
|
||||||
p = self.pg0.wait_for_packet(timeout=timeout)
|
p = self.pg0.wait_for_packet(timeout=timeout)
|
||||||
after = time.time()
|
after = time.time()
|
||||||
|
self.logger.debug(ppp("Got packet:", p))
|
||||||
bfd = p[BFD]
|
bfd = p[BFD]
|
||||||
if bfd is None:
|
if bfd is None:
|
||||||
raise Exception(ppp("Unexpected or invalid BFD packet:", p))
|
raise Exception(ppp("Unexpected or invalid BFD packet:", p))
|
||||||
if bfd.payload:
|
if bfd.payload:
|
||||||
raise Exception(ppp("Unexpected payload in BFD packet:", bfd))
|
raise Exception(ppp("Unexpected payload in BFD packet:", bfd))
|
||||||
verify_ip(self, p, self.pg0.local_ip4, self.pg0.remote_ip4)
|
self.verify_ip(p)
|
||||||
verify_udp(self, p)
|
self.verify_udp(p)
|
||||||
self.test_session.verify_packet(p)
|
self.test_session.verify_packet(p)
|
||||||
return p, after - before
|
return p, after - before
|
||||||
|
|
||||||
def bfd_session_up(self):
|
|
||||||
self.pg_enable_capture([self.pg0])
|
|
||||||
self.logger.info("BFD: Waiting for slow hello")
|
|
||||||
p, ttp = self.wait_for_bfd_packet()
|
|
||||||
self.logger.info("BFD: Sending Init")
|
|
||||||
self.test_session.update(my_discriminator=randint(0, 40000000),
|
|
||||||
your_discriminator=p[BFD].my_discriminator,
|
|
||||||
state=BFDState.init)
|
|
||||||
self.test_session.send_packet()
|
|
||||||
self.logger.info("BFD: Waiting for event")
|
|
||||||
e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
|
|
||||||
self.verify_event(e, expected_state=BFDState.up)
|
|
||||||
self.logger.info("BFD: Session is Up")
|
|
||||||
self.test_session.update(state=BFDState.up)
|
|
||||||
|
|
||||||
def test_session_up(self):
|
def test_session_up(self):
|
||||||
""" bring BFD session up """
|
""" bring BFD session up """
|
||||||
self.bfd_session_up()
|
self.bfd_session_up()
|
||||||
|
|
||||||
|
def test_hold_up(self):
|
||||||
|
""" hold BFD session up """
|
||||||
|
self.bfd_session_up()
|
||||||
|
for i in range(5):
|
||||||
|
self.wait_for_bfd_packet()
|
||||||
|
self.test_session.send_packet()
|
||||||
|
|
||||||
|
|
||||||
|
class BFD4TestCase(VppTestCase, BFDCommonCode):
|
||||||
|
"""Bidirectional Forwarding Detection (BFD)"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(BFD4TestCase, cls).setUpClass()
|
||||||
|
try:
|
||||||
|
cls.create_pg_interfaces([0])
|
||||||
|
cls.pg0.config_ip4()
|
||||||
|
cls.pg0.generate_remote_hosts()
|
||||||
|
cls.pg0.configure_ipv4_neighbors()
|
||||||
|
cls.pg0.admin_up()
|
||||||
|
cls.pg0.resolve_arp()
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
super(BFD4TestCase, cls).tearDownClass()
|
||||||
|
raise
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(BFD4TestCase, self).setUp()
|
||||||
|
self.vapi.want_bfd_events()
|
||||||
|
try:
|
||||||
|
self.vpp_session = VppBFDUDPSession(self, self.pg0,
|
||||||
|
self.pg0.remote_ip4)
|
||||||
|
self.vpp_session.add_vpp_config()
|
||||||
|
self.vpp_session.admin_up()
|
||||||
|
self.test_session = BFDTestSession(self, self.pg0, AF_INET)
|
||||||
|
except:
|
||||||
|
self.vapi.want_bfd_events(enable_disable=0)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
BFDCommonCode.tearDown(self)
|
||||||
|
super(BFD4TestCase, self).tearDown()
|
||||||
|
|
||||||
def test_slow_timer(self):
|
def test_slow_timer(self):
|
||||||
""" verify slow periodic control frames while session down """
|
""" verify slow periodic control frames while session down """
|
||||||
self.pg_enable_capture([self.pg0])
|
self.pg_enable_capture([self.pg0])
|
||||||
@ -261,13 +294,6 @@ class BFDTestCase(VppTestCase):
|
|||||||
return
|
return
|
||||||
raise Exception(ppp("Received unexpected BFD packet:", p))
|
raise Exception(ppp("Received unexpected BFD packet:", p))
|
||||||
|
|
||||||
def test_hold_up(self):
|
|
||||||
""" hold BFD session up """
|
|
||||||
self.bfd_session_up()
|
|
||||||
for i in range(5):
|
|
||||||
self.wait_for_bfd_packet()
|
|
||||||
self.test_session.send_packet()
|
|
||||||
|
|
||||||
def test_conn_down(self):
|
def test_conn_down(self):
|
||||||
""" verify session goes down after inactivity """
|
""" verify session goes down after inactivity """
|
||||||
self.bfd_session_up()
|
self.bfd_session_up()
|
||||||
@ -324,5 +350,42 @@ class BFDTestCase(VppTestCase):
|
|||||||
1.10 * interval / us_in_sec,
|
1.10 * interval / us_in_sec,
|
||||||
"time between BFD packets")
|
"time between BFD packets")
|
||||||
|
|
||||||
|
|
||||||
|
class BFD6TestCase(VppTestCase, BFDCommonCode):
|
||||||
|
"""Bidirectional Forwarding Detection (BFD) (IPv6) """
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(BFD6TestCase, cls).setUpClass()
|
||||||
|
try:
|
||||||
|
cls.create_pg_interfaces([0])
|
||||||
|
cls.pg0.config_ip6()
|
||||||
|
cls.pg0.configure_ipv6_neighbors()
|
||||||
|
cls.pg0.admin_up()
|
||||||
|
cls.pg0.resolve_ndp()
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
super(BFD6TestCase, cls).tearDownClass()
|
||||||
|
raise
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(BFD6TestCase, self).setUp()
|
||||||
|
self.vapi.want_bfd_events()
|
||||||
|
try:
|
||||||
|
self.vpp_session = VppBFDUDPSession(self, self.pg0,
|
||||||
|
self.pg0.remote_ip6,
|
||||||
|
af=AF_INET6)
|
||||||
|
self.vpp_session.add_vpp_config()
|
||||||
|
self.vpp_session.admin_up()
|
||||||
|
self.test_session = BFDTestSession(self, self.pg0, AF_INET6)
|
||||||
|
self.logger.debug(self.vapi.cli("show adj nbr"))
|
||||||
|
except:
|
||||||
|
self.vapi.want_bfd_events(enable_disable=0)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
BFDCommonCode.tearDown(self)
|
||||||
|
super(BFD6TestCase, self).tearDown()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(testRunner=VppTestRunner)
|
unittest.main(testRunner=VppTestRunner)
|
||||||
|
11
test/util.py
11
test/util.py
@ -76,19 +76,24 @@ class Host(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def ip4(self):
|
def ip4(self):
|
||||||
""" IPv4 address """
|
""" IPv4 address - string """
|
||||||
return self._ip4
|
return self._ip4
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ip4n(self):
|
def ip4n(self):
|
||||||
""" IPv4 address """
|
""" IPv4 address of remote host - raw, suitable as API parameter."""
|
||||||
return socket.inet_pton(socket.AF_INET, self._ip4)
|
return socket.inet_pton(socket.AF_INET, self._ip4)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ip6(self):
|
def ip6(self):
|
||||||
""" IPv6 address """
|
""" IPv6 address - string """
|
||||||
return self._ip6
|
return self._ip6
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ip6n(self):
|
||||||
|
""" IPv6 address of remote host - raw, suitable as API parameter."""
|
||||||
|
return socket.inet_pton(socket.AF_INET6, self._ip6)
|
||||||
|
|
||||||
def __init__(self, mac=None, ip4=None, ip6=None):
|
def __init__(self, mac=None, ip4=None, ip6=None):
|
||||||
self._mac = mac
|
self._mac = mac
|
||||||
self._ip4 = ip4
|
self._ip4 = ip4
|
||||||
|
@ -131,7 +131,7 @@ class VppInterface(object):
|
|||||||
2, count + 2): # 0: network address, 1: local vpp address
|
2, count + 2): # 0: network address, 1: local vpp address
|
||||||
mac = "02:%02x:00:00:ff:%02x" % (self.sw_if_index, i)
|
mac = "02:%02x:00:00:ff:%02x" % (self.sw_if_index, i)
|
||||||
ip4 = "172.16.%u.%u" % (self.sw_if_index, i)
|
ip4 = "172.16.%u.%u" % (self.sw_if_index, i)
|
||||||
ip6 = "fd01:%04x::%04x" % (self.sw_if_index, i)
|
ip6 = "fd01:%x::%x" % (self.sw_if_index, i)
|
||||||
host = Host(mac, ip4, ip6)
|
host = Host(mac, ip4, ip6)
|
||||||
self._remote_hosts.append(host)
|
self._remote_hosts.append(host)
|
||||||
self._hosts_by_mac[mac] = host
|
self._hosts_by_mac[mac] = host
|
||||||
@ -155,7 +155,7 @@ class VppInterface(object):
|
|||||||
self.has_ip4_config = False
|
self.has_ip4_config = False
|
||||||
self.ip4_table_id = 0
|
self.ip4_table_id = 0
|
||||||
|
|
||||||
self._local_ip6 = "fd01:%04x::1" % self.sw_if_index
|
self._local_ip6 = "fd01:%x::1" % self.sw_if_index
|
||||||
self._local_ip6n = socket.inet_pton(socket.AF_INET6, self.local_ip6)
|
self._local_ip6n = socket.inet_pton(socket.AF_INET6, self.local_ip6)
|
||||||
self.local_ip6_prefix_len = 64
|
self.local_ip6_prefix_len = 64
|
||||||
self.has_ip6_config = False
|
self.has_ip6_config = False
|
||||||
@ -226,6 +226,13 @@ class VppInterface(object):
|
|||||||
self.has_ip6_config = False
|
self.has_ip6_config = False
|
||||||
self.has_ip6_config = False
|
self.has_ip6_config = False
|
||||||
|
|
||||||
|
def configure_ipv6_neighbors(self):
|
||||||
|
"""For every remote host assign neighbor's MAC to IPv6 address."""
|
||||||
|
for host in self._remote_hosts:
|
||||||
|
macn = host.mac.replace(":", "").decode('hex')
|
||||||
|
self.test.vapi.ip_neighbor_add_del(
|
||||||
|
self.sw_if_index, macn, host.ip6n, is_ipv6=1)
|
||||||
|
|
||||||
def unconfig(self):
|
def unconfig(self):
|
||||||
"""Unconfigure IPv6 and IPv4 address on the VPP interface."""
|
"""Unconfigure IPv6 and IPv4 address on the VPP interface."""
|
||||||
self.unconfig_ip4()
|
self.unconfig_ip4()
|
||||||
|
Reference in New Issue
Block a user