X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fvnet%2Fip6-nd%2Fip6_ra.c;h=270e428afaddd219bcbf908a2da7bd902f2c485c;hb=26c6fffa7ac30bda79432a6d46d6dd5d286b7cb6;hp=ebc2c4be417b457cb9fae0552596cff63f2c8dbc;hpb=cbe25aab3be72154f2c706c39eeba6a77f34450f;p=vpp.git diff --git a/src/vnet/ip6-nd/ip6_ra.c b/src/vnet/ip6-nd/ip6_ra.c index ebc2c4be417..270e428afad 100644 --- a/src/vnet/ip6-nd/ip6_ra.c +++ b/src/vnet/ip6-nd/ip6_ra.c @@ -252,9 +252,10 @@ ip6_neighbor_syslog (vlib_main_t * vm, int priority, char *fmt, ...) { u32 s[2]; } *ed; - ed = ELOG_DATA (&vm->elog_main, e); - ed->s[0] = elog_string (&vm->elog_main, log_level_strings[priority]); - ed->s[1] = elog_string (&vm->elog_main, (char *) what); + ed = ELOG_DATA (vlib_get_elog_main (), e); + ed->s[0] = + elog_string (vlib_get_elog_main (), log_level_strings[priority]); + ed->s[1] = elog_string (vlib_get_elog_main (), (char *) what); } va_end (va); return; @@ -368,11 +369,15 @@ icmp6_router_solicitation (vlib_main_t * vm, if (PREDICT_TRUE (error0 == ICMP6_ERROR_NONE && o0 != 0 && !is_unspecified && !is_link_local)) { + /* *INDENT-OFF* */ ip_neighbor_learn_t learn = { - .type = IP46_TYPE_IP6, .sw_if_index = sw_if_index0, - .ip.ip6 = ip0->src_address, + .ip = { + .ip.ip6 = ip0->src_address, + .version = AF_IP6, + }, }; + /* *INDENT-ON* */ memcpy (&learn.mac, o0->ethernet_address, sizeof (learn.mac)); ip_neighbor_learn_dp (&learn); } @@ -477,7 +482,7 @@ icmp6_router_solicitation (vlib_main_t * vm, /* copy ll address */ clib_memcpy (&h.ethernet_address[0], - eth_if0->address, 6); + ð_if0->address, 6); if (vlib_buffer_add_data (vm, &bi0, (void *) &h, @@ -521,8 +526,8 @@ icmp6_router_solicitation (vlib_main_t * vm, ip6_radv_prefix_t *pr_info; /* *INDENT-OFF* */ - pool_foreach (pr_info, radv_info->adv_prefixes_pool, - ({ + pool_foreach (pr_info, radv_info->adv_prefixes_pool) + { if(pr_info->enabled && (!pr_info->decrement_lifetime_flag || (pr_info->pref_lifetime_expires >0))) @@ -559,13 +564,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)); @@ -580,7 +590,7 @@ icmp6_router_solicitation (vlib_main_t * vm, } } - })); + } /* *INDENT-ON* */ /* add additional options before here */ @@ -628,7 +638,7 @@ icmp6_router_solicitation (vlib_main_t * vm, eth0 = vlib_buffer_get_current (p0); clib_memcpy (eth0->dst_address, eth0->src_address, 6); - clib_memcpy (eth0->src_address, eth_if0->address, + clib_memcpy (eth0->src_address, ð_if0->address, 6); next0 = is_dropped ? next0 : @@ -998,8 +1008,8 @@ icmp6_router_advertisement (vlib_main_t * vm, /* look for matching prefix - if we our advertising it, it better be consistant */ /* *INDENT-OFF* */ - pool_foreach (pr_info, radv_info->adv_prefixes_pool, - ({ + pool_foreach (pr_info, radv_info->adv_prefixes_pool) + { ip6_address_t mask; ip6_address_mask_from_width(&mask, pr_info->prefix_len); @@ -1027,7 +1037,7 @@ icmp6_router_advertisement (vlib_main_t * vm, } } break; - })); + } /* *INDENT-ON* */ break; } @@ -1122,7 +1132,6 @@ create_buffer_for_rs (vlib_main_t * vm, ip6_ra_t * radv_info) } p0 = vlib_get_buffer (vm, bi0); - VLIB_BUFFER_TRACE_TRAJECTORY_INIT (p0); p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED; vnet_buffer (p0)->sw_if_index[VLIB_RX] = sw_if_index; @@ -1214,6 +1223,9 @@ check_send_rs (vlib_main_t * vm, ip6_ra_t * radv_info, f64 current_time, next_index = ip6_rewrite_mcast_node.index; c0 = vlib_buffer_copy (vm, p0); + if (c0 == NULL) + return radv_info->keep_sending_rs; + ci0 = vlib_get_buffer_index (vm, c0); f = vlib_get_frame_to_node (vm, next_index); @@ -1266,12 +1278,12 @@ send_rs_process (vlib_main_t * vm, vlib_node_runtime_t * rt, { due_time = current_time + 1e9; /* *INDENT-OFF* */ - pool_foreach (radv_info, ip6_ra_pool, - ({ + pool_foreach (radv_info, ip6_ra_pool) + { if (check_send_rs (vm, radv_info, current_time, &dt) && (dt < due_time)) due_time = dt; - })); + } /* *INDENT-ON* */ current_time = vlib_time_now (vm); } @@ -1414,6 +1426,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, @@ -1432,8 +1504,8 @@ ip6_ra_process_timer_event (vlib_main_t * vm, /* Interface ip6 radv info list */ /* *INDENT-OFF* */ - pool_foreach (radv_info, ip6_ra_pool, - ({ + pool_foreach (radv_info, ip6_ra_pool) + { if( !vnet_sw_interface_is_admin_up (vnm, radv_info->sw_if_index)) { radv_info->initial_adverts_sent = radv_info->initial_adverts_count-1; @@ -1520,7 +1592,7 @@ ip6_ra_process_timer_event (vlib_main_t * vm, f = 0; } } - })); + } /* *INDENT-ON* */ if (f) @@ -1533,19 +1605,23 @@ ip6_ra_process_timer_event (vlib_main_t * vm, } static void -ip6_ra_handle_report (const ip6_ra_report_t * rap) +ip6_ra_handle_report (ip6_ra_report_t * rap) { u32 ii; vec_foreach_index (ii, ip6_ra_listeners) ip6_ra_listeners[ii] (rap); + vec_free (rap->prefixes); + clib_mem_free (rap); } static uword ip6_ra_event_process (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { - ip6_ra_report_t *r, *rs; + ip6_ra_report_t *r; uword event_type; + uword *event_data = 0; + int i; /* init code here */ @@ -1553,9 +1629,9 @@ ip6_ra_event_process (vlib_main_t * vm, { vlib_process_wait_for_event_or_clock (vm, 1. /* seconds */ ); - rs = vlib_process_get_event_data (vm, &event_type); + event_type = vlib_process_get_events (vm, &event_data); - if (NULL == rs) + if (event_type == ~0) { /* No events found: timer expired. */ /* process interface list and send RAs as appropriate, update timer info */ @@ -1563,17 +1639,25 @@ ip6_ra_event_process (vlib_main_t * vm, } else { - vec_foreach (r, rs) ip6_ra_handle_report (r); - vec_reset_length (rs); + for (i = 0; i < vec_len (event_data); i++) + { + r = (void *) (event_data[i]); + ip6_ra_handle_report (r); + } + vec_reset_length (event_data); } } return frame->n_vectors; } +/* *INDENT-OFF* */ VLIB_REGISTER_NODE (ip6_ra_process_node) = { -.function = ip6_ra_event_process,.name = "ip6-ra-process",.type = - VLIB_NODE_TYPE_PROCESS,}; + .function = ip6_ra_event_process, + .name = "ip6-ra-process", + .type = VLIB_NODE_TYPE_PROCESS, +}; +/* *INDENT-ON* */ static void ip6_ra_signal_report (ip6_ra_report_t * r) @@ -1584,10 +1668,10 @@ ip6_ra_signal_report (ip6_ra_report_t * r) if (!vec_len (ip6_ra_listeners)) return; - q = vlib_process_signal_event_data (vm, - ip6_ra_process_node.index, - 0, 1, sizeof *q); + q = clib_mem_alloc (sizeof (*q)); *q = *r; + + vlib_process_signal_event (vm, ip6_ra_process_node.index, 0, (uword) q); } static int @@ -1882,34 +1966,28 @@ ip6_ra_cmd (vlib_main_t * vm, unformat_ip6_address, &ip6_addr, &addr_len)) { add_radv_info = 0; - break; } else if (unformat (line_input, "ra-managed-config-flag")) { managed = 1; - break; } else if (unformat (line_input, "ra-other-config-flag")) { other = 1; - break; } else if (unformat (line_input, "ra-suppress") || unformat (line_input, "ra-surpress")) { suppress = 1; - break; } else if (unformat (line_input, "ra-suppress-link-layer") || unformat (line_input, "ra-surpress-link-layer")) { suppress_ll_option = 1; - break; } else if (unformat (line_input, "ra-send-unicast")) { send_unicast = 1; - break; } else if (unformat (line_input, "ra-lifetime")) { @@ -1919,7 +1997,6 @@ ip6_ra_cmd (vlib_main_t * vm, goto done; } use_lifetime = 1; - break; } else if (unformat (line_input, "ra-initial")) { @@ -1929,7 +2006,6 @@ ip6_ra_cmd (vlib_main_t * vm, error = unformat_parse_error (line_input); goto done; } - break; } else if (unformat (line_input, "ra-interval")) { @@ -1941,12 +2017,10 @@ ip6_ra_cmd (vlib_main_t * vm, if (!unformat (line_input, "%d", &ra_min_interval)) ra_min_interval = 0; - break; } else if (unformat (line_input, "ra-cease")) { cease = 1; - break; } else { @@ -2044,12 +2118,12 @@ format_ip6_ra (u8 * s, va_list * args) indent += 2; /* *INDENT-OFF* */ - pool_foreach (p, radv_info->adv_prefixes_pool, - ({ + pool_foreach (p, radv_info->adv_prefixes_pool) + { s = format (s, "%Uprefix %U, length %d\n", format_white_space, indent+2, format_ip6_address, &p->prefix, p->prefix_len); - })); + } /* *INDENT-ON* */ s = format (s, "%UMTU is %d\n",