X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fdhcp%2Fdhcp6_pd_client_cp.c;h=14f127d7cf873b213d26f225b18a293b5c11c5a9;hb=d318a996b7bdcf0246b2d9927a918a3773a88fa6;hp=6f151430e5844c99bf5a9119c7d641ba9f79b0f2;hpb=02bfd641b69aab83397e217b9ca4e35a6aab05c8;p=vpp.git diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp.c b/src/plugins/dhcp/dhcp6_pd_client_cp.c index 6f151430e58..14f127d7cf8 100644 --- a/src/plugins/dhcp/dhcp6_pd_client_cp.c +++ b/src/plugins/dhcp/dhcp6_pd_client_cp.c @@ -19,9 +19,11 @@ #include #include #include +#include #include #include #include +#include typedef struct { @@ -411,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; } @@ -684,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 { @@ -699,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; + } } } } @@ -758,6 +783,54 @@ cp_ip6_address_find_new_active_prefix (u32 prefix_group_index, return ~0; } +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) { @@ -783,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 */ ); + } } } } @@ -796,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); @@ -811,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 */ ); + } } } }