36 memset (h, 0,
sizeof (*h));
40 h->ip4.ip_version_and_header_length = 0x45;
41 h->ip4.length = clib_host_to_net_u16 (
sizeof (*h));
43 h->ip4.protocol = IP_PROTOCOL_ICMP;
50 h->icmp.type = ICMP4_echo_request;
51 h->id = clib_host_to_net_u16 (t->
id);
57 sizeof (h->icmp) +
sizeof (h->id) +
58 sizeof (h->seq) +
sizeof (h->data));
60 h->icmp.checksum = csum;
77 return VNET_API_ERROR_NO_SUCH_FIB;
81 key = ((
u64) fib_index << 32) | (dst_address->
as_u32);
87 return VNET_API_ERROR_INVALID_REGISTRATION;
90 memset (t, 0,
sizeof (*t));
106 return VNET_API_ERROR_NO_SUCH_ENTRY;
137 else if (
unformat (input,
"fib %d", &fib_id))
159 .short_help =
"oam [add|del] target <ip4-address> fib <fib-id>",
168 uword *event_data = 0;
176 u32 ip4_lookup_node_index;
180 oam_template_copy_t *copy_src, *copy_dst;
186 ip4_lookup_node_index = ip4_lookup_node->
index;
216 if ((t->seq - t->last_heard_seq) >= om->misses_allowed)
218 if (t->state == OAM_STATE_ALIVE)
221 clib_warning (
"oam target %U now DEAD",
222 format_ip4_address, &t->dst_address);
223 t->state = OAM_STATE_DEAD;
229 if (t->state == OAM_STATE_DEAD)
232 clib_warning (
"oam target %U now ALIVE",
233 format_ip4_address, &t->dst_address);
234 t->state = OAM_STATE_ALIVE;
241 new_seq = clib_host_to_net_u16 (t->
seq);
251 copy_dst = (oam_template_copy_t *) b0->
data;
252 copy_src = (oam_template_copy_t *) t->
template;
254 copy_dst->v8[0] = copy_src->v8[0];
255 copy_dst->v8[1] = copy_src->v8[1];
256 copy_dst->v8[2] = copy_src->v8[2];
257 copy_dst->v8[3] = copy_src->v8[3];
258 copy_dst->v4 = copy_src->v4;
264 sum0 = h0->icmp.checksum;
266 new_seq, oam_template_t, seq);
291 .name =
"vpe-oam-process",
304 if (
unformat (input,
"interval %f", &interval))
306 else if (
unformat (input,
"misses-allowed %d", &misses_allowed))
341 int verbose = va_arg (*args,
int);
344 return format (s,
"%=6s%=14s%=14s%=12s%=10s",
345 "Fib",
"Src",
"Dst",
"Last Heard",
"State");
347 s =
format (s,
"%=6d%=14U%=14U%=12.2f%=10s",
376 vlib_cli_output (vm,
"%U", format_oam_target, t, verbose);
386 .short_help =
"show oam",
405 s =
format (s,
"OAM: rx from address %U, target index %d",
411 #define foreach_oam_error \ 412 _(PROCESSED, "vpe icmp4 oam replies processed") \ 413 _(DROPPED, "icmp4 replies dropped (no registration)") 417 #define _(sym,str) OAM_ERROR_##sym, 424 #define _(sym,string) string, 455 u32 n_left_from, *from, *to_next;
461 oam_template_t *oam0, *oam1;
462 u32 fib_index0, fib_index1;
471 while (n_left_from > 0)
477 while (n_left_from >= 4 && n_left_to_next >= 2)
481 u32 sw_if_index0, sw_if_index1;
498 to_next[0] = bi0 = from[0];
499 to_next[1] = bi1 = from[1];
516 key0 = ((
u64) fib_index0 << 32) | oam0->ip4.src_address.as_u32;
528 key1 = ((
u64) fib_index1 << 32) | oam1->ip4.src_address.as_u32;
562 to_next, n_left_to_next,
563 bi0, bi1, next0, next1);
566 while (n_left_from > 0 && n_left_to_next > 0)
568 u32 bi0, sw_if_index0;
586 key0 = ((
u64) fib_index0 << 32) | oam0->ip4.src_address.as_u32;
611 to_next, n_left_to_next,
624 .name =
"vpe-icmp4-oam",
625 .vector_size =
sizeof (
u32),
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
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.
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)
sll srl srl sll sra u16x4 i
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)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
void send_oam_event(oam_target_t *t)
static f64 vlib_time_now(vlib_main_t *vm)
struct _vlib_node_registration vlib_node_registration_t
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#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)
vnet_main_t * vnet_get_main(void)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#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)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define clib_warning(format, 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.
#define pool_put(P, E)
Free an object E in pool P.
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define foreach_oam_error
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#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).
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
static vlib_node_registration_t oam_process_node
(constructor) VLIB_REGISTER_NODE (oam_process_node)
#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)
int vpe_oam_add_del_target(ip4_address_t *src_address, ip4_address_t *dst_address, u32 fib_id, int is_add)
void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
#define VLIB_NODE_FLAG_TRACE
u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static char * oam_error_strings[]
#define VLIB_BUFFER_IS_TRACED
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.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
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)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static u32 random_u32(u32 *seed)
32-bit random number generator
#define VLIB_REGISTER_NODE(x,...)
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)
#define clib_error_return(e, args...)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
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
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.