aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-11-10 15:46:31 -0500
committerDave Barach <dave@barachs.net>2019-11-10 15:54:28 -0500
commitd318a996b7bdcf0246b2d9927a918a3773a88fa6 (patch)
tree6af0ec47f6f1093c42c85140c7be118b77a01ce1
parentf83194c2f45bcc736edc8246b510a29c1df15756 (diff)
dhcp: ipv6 prefix delegation improvements
Autoconfigure router advertisements for delegated prefixes. Clean up a longstanding issue. If vpp receives a dhcpv6 renew reply, do NOT reset per-delegated-prefix timers. That prevented vpp from sending a solicit to renew the delegation on time. That, in turn caused the RA code to send advertisements with valid_time = preferred_time = 0. That causes almost any downstream client to throw away its delegated address. Miscellaneous changes o src/vnet/ip/ip6_neighbor.c - always memset elements allocated from pools to zero. DGMS. o Remove debug spew from the ipv6 connection-tracker plugin Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I428feccdc47efdc413898600e0d62916928a6eb7
-rw-r--r--src/plugins/ct6/ct6_in2out.c4
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_cp.c106
-rw-r--r--src/plugins/mdata/FEATURE.yaml2
-rw-r--r--src/vnet/ip/ip6_neighbor.c18
4 files changed, 116 insertions, 14 deletions
diff --git a/src/plugins/ct6/ct6_in2out.c b/src/plugins/ct6/ct6_in2out.c
index 2e151f771c1..34744ec43be 100644
--- a/src/plugins/ct6/ct6_in2out.c
+++ b/src/plugins/ct6/ct6_in2out.c
@@ -90,11 +90,11 @@ ct6_create_or_recycle_session (ct6_main_t * cmp,
s0 = pool_elt_at_index (cmp->sessions[my_thread_index],
cmp->last_index[my_thread_index]);
- if (s0->expires < now)
+ if (CLIB_DEBUG > 0 && s0->expires < now)
clib_warning ("session %d expired %.2f time now %.2f",
s0 - cmp->sessions[my_thread_index], s0->expires, now);
- if (pool_elts (cmp->sessions[my_thread_index]) >=
+ if (CLIB_DEBUG > 0 && pool_elts (cmp->sessions[my_thread_index]) >=
cmp->max_sessions_per_worker)
clib_warning ("recycle session %d have %d max %d",
s0 - cmp->sessions[my_thread_index],
diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp.c b/src/plugins/dhcp/dhcp6_pd_client_cp.c
index 45921d34f97..14f127d7cf8 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_cp.c
+++ b/src/plugins/dhcp/dhcp6_pd_client_cp.c
@@ -19,6 +19,7 @@
#include <dhcp/dhcp6_pd_client_dp.h>
#include <vnet/ip/ip.h>
#include <vnet/ip/ip6.h>
+#include <vnet/ip/ip6_neighbor.h>
#include <float.h>
#include <math.h>
#include <string.h>
@@ -412,11 +413,15 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
if (address_prefix_present)
{
- prefix_info->preferred_lt = preferred_time;
- prefix_info->valid_lt = valid_time;
- prefix_info->due_time = current_time + valid_time;
- if (prefix_info->due_time > rm->max_valid_due_time)
- rm->max_valid_due_time = prefix_info->due_time;
+ /*
+ * We found the prefix. Move along.
+ * Don't touch the prefix timers!
+ * If we happen to receive a renew reply just before we
+ * would have sent a solicit to renew the prefix delegation,
+ * we forget to renew the delegation. Worse luck, we start
+ * sending router advertisements with a valid time of zero,
+ * and the wheels fall off...
+ */
continue;
}
@@ -685,7 +690,16 @@ cp_ip6_address_add_del_now (ip6_address_info_t * address_info, u8 is_add)
clib_warning ("Failed adding IPv6 address: %U",
format_clib_error, error);
else
- address_info->configured_in_data_plane = 1;
+ {
+ if (CLIB_DEBUG > 0)
+ clib_warning ("Add address %U on %U",
+ format_ip6_address_and_length,
+ &addr, address_info->prefix_length,
+ format_vnet_sw_if_index_name,
+ vnet_get_main (), address_info->sw_if_index);
+
+ address_info->configured_in_data_plane = 1;
+ }
}
else
{
@@ -700,7 +714,17 @@ cp_ip6_address_add_del_now (ip6_address_info_t * address_info, u8 is_add)
clib_warning ("Failed adding IPv6 address: %U",
format_clib_error, error);
else
- address_info->configured_in_data_plane = 1;
+ {
+ if (CLIB_DEBUG > 0)
+ clib_warning ("Add address %U on %U",
+ format_ip6_address_and_length,
+ &addr, address_info->prefix_length,
+ format_vnet_sw_if_index_name,
+ vnet_get_main (),
+ address_info->sw_if_index);
+
+ address_info->configured_in_data_plane = 1;
+ }
}
}
}
@@ -760,6 +784,54 @@ cp_ip6_address_find_new_active_prefix (u32 prefix_group_index,
}
static void
+cp_ip6_advertise_prefix (prefix_info_t * prefix_info,
+ ip6_address_info_t * address_info, int enable)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ ip6_main_t *im = &ip6_main;
+ u32 prefix_index;
+ ip6_address_t addr;
+ int rv;
+
+ prefix_index =
+ active_prefix_index_by_prefix_group_index_get
+ (address_info->prefix_group_index);
+
+ if (cp_ip6_construct_address (address_info, prefix_index, &addr) != 0)
+ {
+ clib_warning ("address construction FAIL");
+ return;
+ }
+
+ /* The RA code assumes that host bits are zero, so clear them */
+ addr.as_u64[0] &= im->fib_masks[address_info->prefix_length].as_u64[0];
+ addr.as_u64[1] &= im->fib_masks[address_info->prefix_length].as_u64[1];
+
+ rv = ip6_neighbor_ra_prefix (vm, address_info->sw_if_index,
+ &addr, address_info->prefix_length,
+ 0 /* use_default */ ,
+ prefix_info->valid_lt,
+ prefix_info->preferred_lt,
+ 0 /* no_advertise */ ,
+ 0 /* off_link */ ,
+ 0 /* no_autoconfig */ ,
+ 0 /* no_onlink */ ,
+ enable == 0 /* is_no */ );
+ if (rv != 0)
+ {
+ clib_warning ("ip6_neighbor_ra_prefix returned %d", rv);
+ return;
+ }
+
+ if (CLIB_DEBUG > 0)
+ clib_warning ("Advertise prefix %U valid lt %u preferred lt %u",
+ format_ip6_address_and_length, &addr,
+ address_info->prefix_length, prefix_info->valid_lt,
+ prefix_info->preferred_lt);
+}
+
+
+static void
cp_ip6_address_prefix_add_del_handler (u32 prefix_index, u8 is_add)
{
ip6_address_with_prefix_main_t *apm = &ip6_address_with_prefix_main;
@@ -784,7 +856,13 @@ cp_ip6_address_prefix_add_del_handler (u32 prefix_index, u8 is_add)
{
address_info = &apm->addresses[i];
if (address_info->prefix_group_index == prefix_group_index)
- cp_ip6_address_add_del_now (address_info, 1 /* add */ );
+ {
+ /* Add the prefix to the interface */
+ cp_ip6_address_add_del_now (address_info, 1 /* add */ );
+ /* And advertise the prefix on the interface */
+ cp_ip6_advertise_prefix (prefix, address_info,
+ 1 /* enable */ );
+ }
}
}
}
@@ -797,7 +875,11 @@ cp_ip6_address_prefix_add_del_handler (u32 prefix_index, u8 is_add)
{
address_info = &apm->addresses[i];
if (address_info->prefix_group_index == prefix_group_index)
- cp_ip6_address_add_del_now (address_info, 0 /* del */ );
+ {
+ cp_ip6_advertise_prefix (prefix, address_info,
+ 0 /* enable */ );
+ cp_ip6_address_add_del_now (address_info, 0 /* del */ );
+ }
}
active_prefix_index_by_prefix_group_index_set
(prefix_group_index, ~0);
@@ -812,7 +894,11 @@ cp_ip6_address_prefix_add_del_handler (u32 prefix_index, u8 is_add)
{
address_info = &apm->addresses[i];
if (address_info->prefix_group_index == prefix_group_index)
- cp_ip6_address_add_del_now (address_info, 1 /* add */ );
+ {
+ cp_ip6_address_add_del_now (address_info, 1 /* add */ );
+ cp_ip6_advertise_prefix (prefix, address_info,
+ 1 /* enable */ );
+ }
}
}
}
diff --git a/src/plugins/mdata/FEATURE.yaml b/src/plugins/mdata/FEATURE.yaml
index 8415e584702..d25a71d41e9 100644
--- a/src/plugins/mdata/FEATURE.yaml
+++ b/src/plugins/mdata/FEATURE.yaml
@@ -3,7 +3,7 @@ name: Buffer Metadata Change Tracker (mdata)
maintainer: Dave Barach <dave@barachs.net>
features:
- Buffer Metadata Change Tracker
- description: |-
+description: |-
Buffer Metadata Change Tracker
Uses the before / after graph node main loop performance
callback hooks to snapshoot buffer metadata, then
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index 071d3eb6673..363be4e42d2 100644
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -807,7 +807,10 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm,
return -2;
}
else
- pool_get (nm->neighbor_pool, n);
+ {
+ pool_get (nm->neighbor_pool, n);
+ memset (n, 0, sizeof (*n));
+ }
mhash_set (&nm->neighbor_index_by_key, &k, n - nm->neighbor_pool,
/* old value */ 0);
@@ -1784,6 +1787,14 @@ icmp6_router_solicitation (vlib_main_t * vm,
}
h.unused = 0;
+ clib_warning ("Prefix %U valid %u preferred %u",
+ format_ip6_address, &pr_info->prefix,
+ ntohl(h.valid_time),
+ ntohl(h.preferred_time));
+
+ if (h.valid_time == 0)
+ clib_warning ("WARNING: valid_time 0!!!");
+
clib_memcpy(&h.dst_address, &pr_info->prefix, sizeof(ip6_address_t));
payload_length += sizeof( icmp6_neighbor_discovery_prefix_information_option_t);
@@ -2533,6 +2544,7 @@ ip6_neighbor_add_mld_prefix (ip6_radv_t * radv_info, ip6_address_t * addr)
/* add */
u32 mi;
pool_get (radv_info->mldp_group_pool, mcast_group_info);
+ memset (mcast_group_info, 0, sizeof (*mcast_group_info));
mi = mcast_group_info - radv_info->mldp_group_pool;
mhash_set (&radv_info->address_to_mldp_index, addr, mi, /* old_value */
@@ -2651,6 +2663,7 @@ ip6_neighbor_sw_interface_add_del (vnet_main_t * vnm,
if (is_add)
{
pool_get (nm->if_radv_pool, a);
+ memset (a, 0, sizeof (*a));
ri = a - nm->if_radv_pool;
nm->if_radv_pool_index_by_sw_if_index[sw_if_index] = ri;
@@ -3552,6 +3565,7 @@ ip6_neighbor_ra_prefix (vlib_main_t * vm, u32 sw_if_index,
/* add */
u32 pi;
pool_get (radv_info->adv_prefixes_pool, prefix);
+ memset (prefix, 0, sizeof (*prefix));
pi = prefix - radv_info->adv_prefixes_pool;
mhash_set (&radv_info->address_to_prefix_index, prefix_addr, pi,
/* old_value */ 0);
@@ -4658,6 +4672,7 @@ vnet_register_ip6_neighbor_resolution_event (vnet_main_t * vnm,
pending_resolution_t *pr;
pool_get (nm->pending_resolutions, pr);
+ memset (pr, 0, sizeof (*pr));
pr->next_index = ~0;
pr->node_index = node_index;
@@ -4707,6 +4722,7 @@ vnet_add_del_ip6_nd_change_event (vnet_main_t * vnm,
return VNET_API_ERROR_ENTRY_ALREADY_EXISTS;
pool_get (nm->mac_changes, mc);
+ memset (mc, 0, sizeof (*mc));
/* *INDENT-OFF* */
*mc = (pending_resolution_t)
{