aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-02-20 16:17:58 -0500
committerDamjan Marion <dmarion@me.com>2020-02-21 09:52:42 +0000
commitd1586962a5f8f14fb81c930174d12d0453adaab8 (patch)
tree2e7bfc5cde108ef32d811e7bec6bd5a0030e3388 /src
parent269549491ae6c8d9c35d6b4fa9441ad15e6b82f0 (diff)
dhcp: update secondary radv_info structures
For details, see the Jira ticket below. Fix gerrit 23350. Type: fix Fixes: 28a6eb7 Ticket: VPP-1840 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Ic9248734bb330eadb302f8410e8db9c64723f075
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_cp.c69
-rw-r--r--src/vnet/ip6-nd/ip6_ra.c75
-rw-r--r--src/vnet/ip6-nd/ip6_ra.h5
3 files changed, 122 insertions, 27 deletions
diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp.c b/src/plugins/dhcp/dhcp6_pd_client_cp.c
index 18466270800..1c0b286bd30 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_cp.c
+++ b/src/plugins/dhcp/dhcp6_pd_client_cp.c
@@ -70,6 +70,8 @@ typedef struct
{
prefix_info_t *prefix_pool;
const u8 **prefix_group_name_by_index;
+ /* vector of active prefix pool indicies, prep-H for pool_foreach(..) */
+ u32 *indices;
} ip6_prefix_main_t;
static ip6_prefix_main_t ip6_prefix_main;
@@ -277,6 +279,7 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
f64 current_time;
clib_error_t *error = 0;
u32 i;
+ prefix_info_t *prefix_info;
current_time = vlib_time_now (vm);
@@ -363,13 +366,26 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
send_client_message_start_stop (sw_if_index, server_index,
mp->msg_type, 0, 0);
+ vec_reset_length (pm->indices);
+ /*
+ * We're going to loop through the pool multiple times,
+ * so collect active indices.
+ */
+ /* *INDENT-OFF* */
+ pool_foreach (prefix_info, pm->prefix_pool,
+ ({
+ vec_add1 (pm->indices, prefix_info - pm->prefix_pool);
+ }));
+ /* *INDENT-ON* */
+
for (i = 0; i < n_prefixes; i++)
{
- prefix_info_t *prefix_info = 0;
u8 prefix_length;
u32 valid_time;
u32 preferred_time;
+ int j;
+ prefix_info = 0;
api_prefix = &mp->prefixes[i];
prefix = (ip6_address_t *) api_prefix->prefix.address;
@@ -386,32 +402,40 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
continue;
u8 address_prefix_present = 0;
- /* *INDENT-OFF* */
- pool_foreach (prefix_info, pm->prefix_pool,
- ({
- if (is_dhcpv6_pd_prefix (prefix_info) &&
- prefix_info->opaque_data == sw_if_index &&
- prefix_info->prefix_length == prefix_length &&
- ip6_prefixes_equal (&prefix_info->prefix, prefix, prefix_length))
- {
- address_prefix_present = 1;
- goto prefix_pool_foreach_out;
- }
- }));
- /* *INDENT-ON* */
- prefix_pool_foreach_out:
+
+ /* Look for a matching prefix_info */
+ for (j = 0; j < vec_len (pm->indices); j++)
+ {
+ prefix_info = pool_elt_at_index (pm->prefix_pool, pm->indices[j]);
+
+ if (is_dhcpv6_pd_prefix (prefix_info) &&
+ prefix_info->opaque_data == sw_if_index &&
+ prefix_info->prefix_length == prefix_length &&
+ ip6_prefixes_equal (&prefix_info->prefix, prefix,
+ prefix_length))
+ {
+ address_prefix_present = 1;
+ break;
+ }
+ }
if (address_prefix_present)
{
+ /* Found the (primary) prefix, update prefix timers */
+ 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...
+ * Tell the RA code to update any secondary per-interface
+ * timers that it might be hoarding.
*/
+ ip6_ra_update_secondary_radv_info
+ (prefix, prefix_length,
+ prefix_info->opaque_data /* sw_if_index */ ,
+ valid_time, preferred_time);
continue;
}
@@ -419,6 +443,7 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
continue;
pool_get (pm->prefix_pool, prefix_info);
+ vec_add1 (pm->indices, prefix_info - pm->prefix_pool);
prefix_info->prefix_group_index = client_state->prefix_group_index;
set_is_dhcpv6_pd_prefix (prefix_info, 1);
prefix_info->opaque_data = sw_if_index;
diff --git a/src/vnet/ip6-nd/ip6_ra.c b/src/vnet/ip6-nd/ip6_ra.c
index ebc2c4be417..c8e16d0c0ee 100644
--- a/src/vnet/ip6-nd/ip6_ra.c
+++ b/src/vnet/ip6-nd/ip6_ra.c
@@ -559,13 +559,18 @@ icmp6_router_solicitation (vlib_main_t * vm,
}
h.unused = 0;
- clib_warning ("Prefix %U valid %u preferred %u",
- format_ip6_address, &pr_info->prefix,
- clib_net_to_host_u32 (h.valid_time),
- clib_net_to_host_u32 (h.preferred_time));
+ /* Handy for debugging, but too noisy... */
+ if (0 && CLIB_DEBUG > 0)
+ clib_warning
+ ("send RA for prefix %U/%d "
+ "sw_if_index %d valid %u preferred %u",
+ format_ip6_address, &pr_info->prefix,
+ pr_info->prefix_len, sw_if_index0,
+ clib_net_to_host_u32 (h.valid_time),
+ clib_net_to_host_u32 (h.preferred_time));
if (h.valid_time == 0)
- clib_warning ("WARNING: valid_time 0!!!");
+ clib_warning ("BUG: send RA with valid_time 0");
clib_memcpy(&h.dst_address, &pr_info->prefix, sizeof(ip6_address_t));
@@ -1414,6 +1419,66 @@ ip6_ra_delegate_disable (index_t rai)
pool_put (ip6_ra_pool, radv_info);
}
+void
+ip6_ra_update_secondary_radv_info (ip6_address_t * address, u8 prefix_len,
+ u32 primary_sw_if_index,
+ u32 valid_time, u32 preferred_time)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ static u32 *radv_indices;
+ ip6_ra_t *radv_info;
+ int i;
+ ip6_address_t mask;
+ ip6_address_mask_from_width (&mask, prefix_len);
+
+ vec_reset_length (radv_indices);
+ /* *INDENT-OFF* */
+ pool_foreach (radv_info, ip6_ra_pool,
+ ({
+ vec_add1 (radv_indices, radv_info - ip6_ra_pool);
+ }));
+ /* *INDENT-ON* */
+
+ /*
+ * If we have another customer for this prefix,
+ * tell the RA code about it...
+ */
+ for (i = 0; i < vec_len (radv_indices); i++)
+ {
+ ip6_radv_prefix_t *this_prefix;
+ radv_info = pool_elt_at_index (ip6_ra_pool, radv_indices[i]);
+
+ /* We already took care of these timers... */
+ if (radv_info->sw_if_index == primary_sw_if_index)
+ continue;
+
+ /* *INDENT-OFF* */
+ pool_foreach (this_prefix, radv_info->adv_prefixes_pool,
+ ({
+ if (this_prefix->prefix_len == prefix_len
+ && ip6_address_is_equal_masked (&this_prefix->prefix, address,
+ &mask))
+ {
+ int rv = ip6_ra_prefix (vm,
+ radv_info->sw_if_index,
+ address,
+ prefix_len,
+ 0 /* use_default */,
+ valid_time,
+ preferred_time,
+ 0 /* no_advertise */,
+ 0 /* off_link */,
+ 0 /* no_autoconfig */,
+ 0 /* no_onlink */,
+ 0 /* is_no */);
+ if (rv != 0)
+ clib_warning ("ip6_neighbor_ra_prefix returned %d", rv);
+ }
+ }));
+ /* *INDENT-ON*/
+ }
+}
+
/* send a RA or update the timer info etc.. */
static uword
ip6_ra_process_timer_event (vlib_main_t * vm,
diff --git a/src/vnet/ip6-nd/ip6_ra.h b/src/vnet/ip6-nd/ip6_ra.h
index 4efd92e6968..d09e8c0c975 100644
--- a/src/vnet/ip6-nd/ip6_ra.h
+++ b/src/vnet/ip6-nd/ip6_ra.h
@@ -77,6 +77,11 @@ typedef void (*ip6_ra_report_notify_t) (const ip6_ra_report_t * rap);
extern void ip6_ra_report_register (ip6_ra_report_notify_t fn);
extern void ip6_ra_report_unregister (ip6_ra_report_notify_t fn);
+extern void ip6_ra_update_secondary_radv_info (ip6_address_t * address,
+ u8 prefix_len,
+ u32 primary_sw_if_index,
+ u32 valid_time,
+ u32 preferred_time);
#endif /* included_ip6_neighbor_h */