32 memset (h, 0,
sizeof (*h));
36 h->ip4.ip_version_and_header_length = 0x45;
37 h->ip4.length = clib_host_to_net_u16 (
sizeof (*h));
39 h->ip4.protocol = IP_PROTOCOL_ICMP;
46 h->icmp.type = ICMP4_echo_request;
47 h->id = clib_host_to_net_u16 (t->
id);
53 sizeof (h->icmp) +
sizeof (h->id) +
54 sizeof (h->seq) +
sizeof (h->data));
56 h->icmp.checksum = csum;
73 return VNET_API_ERROR_NO_SUCH_FIB;
77 key = ((
u64) fib_index << 32) | (dst_address->
as_u32);
83 return VNET_API_ERROR_INVALID_REGISTRATION;
86 memset (t, 0,
sizeof (*t));
102 return VNET_API_ERROR_NO_SUCH_ENTRY;
133 else if (
unformat (input,
"fib %d", &fib_id))
155 .short_help =
"oam [add|del] target <ip4-address> fib <fib-id>",
164 uword *event_data = 0;
172 u32 ip4_lookup_node_index;
176 oam_template_copy_t *copy_src, *copy_dst;
182 ip4_lookup_node_index = ip4_lookup_node->
index;
212 if ((t->seq - t->last_heard_seq) >= om->misses_allowed)
214 if (t->state == OAM_STATE_ALIVE)
217 clib_warning (
"oam target %U now DEAD",
218 format_ip4_address, &t->dst_address);
219 t->state = OAM_STATE_DEAD;
225 if (t->state == OAM_STATE_DEAD)
228 clib_warning (
"oam target %U now ALIVE",
229 format_ip4_address, &t->dst_address);
230 t->state = OAM_STATE_ALIVE;
237 new_seq = clib_host_to_net_u16 (t->
seq);
247 copy_dst = (oam_template_copy_t *) b0->
data;
248 copy_src = (oam_template_copy_t *) t->
template;
250 copy_dst->v8[0] = copy_src->v8[0];
251 copy_dst->v8[1] = copy_src->v8[1];
252 copy_dst->v8[2] = copy_src->v8[2];
253 copy_dst->v8[3] = copy_src->v8[3];
254 copy_dst->v4 = copy_src->v4;
260 sum0 = h0->icmp.checksum;
262 new_seq, oam_template_t, seq);
287 .name =
"vpe-oam-process",
300 if (
unformat (input,
"interval %f", &interval))
302 else if (
unformat (input,
"misses-allowed %d", &misses_allowed))
337 int verbose = va_arg (*args,
int);
340 return format (s,
"%=6s%=14s%=14s%=12s%=10s",
341 "Fib",
"Src",
"Dst",
"Last Heard",
"State");
343 s =
format (s,
"%=6d%=14U%=14U%=12.2f%=10s",
372 vlib_cli_output (vm,
"%U", format_oam_target, t, verbose);
382 .short_help =
"show oam",
401 s =
format (s,
"OAM: rx from address %U, target index %d",
407 #define foreach_oam_error \ 408 _(PROCESSED, "vpe icmp4 oam replies processed") \ 409 _(DROPPED, "icmp4 replies dropped (no registration)") 413 #define _(sym,str) OAM_ERROR_##sym, 420 #define _(sym,string) string, 451 u32 n_left_from, *from, *to_next;
457 oam_template_t *oam0, *oam1;
458 u32 fib_index0, fib_index1;
467 while (n_left_from > 0)
473 while (n_left_from >= 4 && n_left_to_next >= 2)
477 u32 sw_if_index0, sw_if_index1;
494 to_next[0] = bi0 = from[0];
495 to_next[1] = bi1 = from[1];
512 key0 = ((
u64) fib_index0 << 32) | oam0->ip4.src_address.as_u32;
524 key1 = ((
u64) fib_index1 << 32) | oam1->ip4.src_address.as_u32;
538 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
544 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
558 to_next, n_left_to_next,
559 bi0, bi1, next0, next1);
562 while (n_left_from > 0 && n_left_to_next > 0)
564 u32 bi0, sw_if_index0;
582 key0 = ((
u64) fib_index0 << 32) | oam0->ip4.src_address.as_u32;
595 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
607 to_next, n_left_to_next,
620 .name =
"vpe-icmp4-oam",
621 .vector_size =
sizeof (
u32),
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static clib_error_t * oam_config(vlib_main_t *vm, unformat_input_t *input)
static void init_oam_packet_template(oam_main_t *om, oam_target_t *t)
#define hash_set(h, key, value)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
#define hash_unset(h, key)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
vnet_main_t * vnet_get_main(void)
static f64 vlib_time_now(vlib_main_t *vm)
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
vlib_error_t * errors
Vector of errors for this node.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
oam_template_t * template
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
void send_oam_event(oam_target_t *t)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
#define VLIB_INIT_FUNCTION(x)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
#define clib_error_return(e, args...)
static clib_error_t * oam_init(vlib_main_t *vm)
static vlib_node_registration_t oam_node
(constructor) VLIB_REGISTER_NODE (oam_node)
uword * target_by_address_and_fib_id
void ip4_icmp_register_type(vlib_main_t *vm, icmp4_type_t type, u32 node_index)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
u16 current_length
Nbytes between current data and the end of this buffer.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define foreach_oam_error
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static vlib_node_registration_t oam_process_node
(constructor) VLIB_REGISTER_NODE (oam_process_node)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define VLIB_CLI_COMMAND(x,...)
static uword oam_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword oam_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f_arg)
#define hash_create(elts, value_bytes)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
int vpe_oam_add_del_target(ip4_address_t *src_address, ip4_address_t *dst_address, u32 fib_id, int is_add)
static char * oam_error_strings[]
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
struct _vlib_node_registration vlib_node_registration_t
static clib_error_t * show_oam_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip4_address_t src_address
static u8 * format_swap_trace(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip_csum_update(sum, old, new, type, field)
static u8 * format_oam_target(u8 *s, va_list *args)
static u32 random_u32(u32 *seed)
32-bit random number generator
ip4_main_t ip4_main
Global ip4 main structure.
void(* os_punt_frame)(struct vlib_main_t *vm, struct vlib_node_runtime_t *node, vlib_frame_t *frame)
u16 flags
Copy of main node flags.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static clib_error_t * oam_add_del_target_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip4_address_t dst_address
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static u16 ip_csum_fold(ip_csum_t c)
static uword pool_elts(void *v)
Number of active elements in a pool.