*/
#include <vnet/ip-neighbor/ip6_neighbor.h>
+#include <vnet/ip-neighbor/ip_neighbor.api_enum.h>
#include <vnet/util/throttle.h>
#include <vnet/fib/fib_sas.h>
#include <vnet/ip/ip_sas.h>
#define log_debug(fmt, ...) \
vlib_log_debug (ip6_neighbor_log.class, fmt, __VA_ARGS__)
void
-ip6_neighbor_probe_dst (u32 sw_if_index, const ip6_address_t * dst)
+ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index,
+ const ip6_address_t *dst)
{
ip6_address_t src;
if (fib_sas6_get (sw_if_index, dst, &src) ||
ip6_sas_by_sw_if_index (sw_if_index, dst, &src))
- ip6_neighbor_probe (vlib_get_main (), vnet_get_main (),
- sw_if_index, &src, dst);
+ ip6_neighbor_probe (vlib_get_main (), vnet_get_main (), sw_if_index,
+ thread_index, &src, dst);
}
void
-ip6_neighbor_advertise (vlib_main_t * vm,
- vnet_main_t * vnm,
- u32 sw_if_index, const ip6_address_t * addr)
+ip6_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index,
+ u32 thread_index, const ip6_address_t *addr)
{
vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
ip6_main_t *i6m = &ip6_main;
to_next[0] = bi;
f->n_vectors = 1;
vlib_put_frame_to_node (vm, hi->output_node_index, f);
+
+ vlib_increment_simple_counter (
+ &ip_neighbor_counters[AF_IP6].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_GRAT],
+ thread_index, sw_if_index, 1);
}
}
IP6_NBR_N_NEXT,
} ip6_discover_neighbor_next_t;
-typedef enum
-{
- IP6_NBR_ERROR_DROP,
- IP6_NBR_ERROR_REQUEST_SENT,
- IP6_NBR_ERROR_NO_SOURCE_ADDRESS,
- IP6_NBR_ERROR_NO_BUFFERS,
-} ip6_discover_neighbor_error_t;
-
static uword
ip6_discover_neighbor_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
to_next_drop += 1;
n_left_to_next_drop -= 1;
+ if (drop0)
+ {
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_THROTTLED];
+ continue;
+ }
+
hw_if0 = vnet_get_sup_hw_interface (vnm, sw_if_index0);
/* If the interface is link-down, drop the pkt */
if (drop0)
{
- p0->error = node->errors[IP6_NBR_ERROR_DROP];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_DROP];
continue;
}
* Choose source address based on destination lookup
* adjacency.
*/
- if (!fib_sas6_get (sw_if_index0, &ip0->dst_address, &src) ||
- !ip6_sas_by_sw_if_index (sw_if_index0, &ip0->dst_address, &src))
+ const ip6_address_t *ll = ip6_get_link_local_address (sw_if_index0);
+ if (!ll)
{
/* There is no address on the interface */
- p0->error = node->errors[IP6_NBR_ERROR_NO_SOURCE_ADDRESS];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_NO_SOURCE_ADDRESS];
continue;
}
+ ip6_address_copy (&src, ll);
- b0 = ip6_neighbor_probe (vm, vnm, sw_if_index0,
- &src, &ip0->dst_address);
+ b0 = ip6_neighbor_probe (vm, vnm, sw_if_index0, thread_index, &src,
+ &ip0->dst_address);
if (PREDICT_TRUE (NULL != b0))
{
sizeof (p0->opaque2));
b0->flags |= p0->flags & VLIB_BUFFER_IS_TRACED;
b0->trace_handle = p0->trace_handle;
- p0->error = node->errors[IP6_NBR_ERROR_REQUEST_SENT];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_REQUEST_SENT];
}
else
{
/* There is no address on the interface */
- p0->error = node->errors[IP6_NBR_ERROR_NO_BUFFERS];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_NO_BUFFERS];
continue;
}
}
return (ip6_discover_neighbor_inline (vm, node, frame, 1));
}
-static char *ip6_discover_neighbor_error_strings[] = {
- [IP6_NBR_ERROR_DROP] = "address overflow drops",
- [IP6_NBR_ERROR_REQUEST_SENT] = "neighbor solicitations sent",
- [IP6_NBR_ERROR_NO_SOURCE_ADDRESS] = "no source address for ND solicitation",
- [IP6_NBR_ERROR_NO_BUFFERS] = "no buffers",
-};
-
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (ip6_glean_node) =
{
.name = "ip6-glean",
.vector_size = sizeof (u32),
.format_trace = format_ip6_forward_next_trace,
- .n_errors = ARRAY_LEN (ip6_discover_neighbor_error_strings),
- .error_strings = ip6_discover_neighbor_error_strings,
+ .n_errors = IP6_NEIGHBOR_N_ERROR,
+ .error_counters = ip6_neighbor_error_counters,
.n_next_nodes = IP6_NBR_N_NEXT,
.next_nodes =
{
.name = "ip6-discover-neighbor",
.vector_size = sizeof (u32),
.format_trace = format_ip6_forward_next_trace,
- .n_errors = ARRAY_LEN (ip6_discover_neighbor_error_strings),
- .error_strings = ip6_discover_neighbor_error_strings,
+ .n_errors = IP6_NEIGHBOR_N_ERROR,
+ .error_counters = ip6_neighbor_error_counters,
.n_next_nodes = IP6_NBR_N_NEXT,
.next_nodes =
{
{
vlib_thread_main_t *tm = &vlib_thread_main;
- throttle_init (&nd_throttle, tm->n_vlib_mains, 1e-3);
+ throttle_init (&nd_throttle, tm->n_vlib_mains, THROTTLE_BITS, 1e-3);
return 0;
}