35 memset (h, 0,
sizeof (*h));
39 h->ip4.ip_version_and_header_length = 0x45;
40 h->ip4.length = clib_host_to_net_u16 (
sizeof(*h));
42 h->ip4.protocol = IP_PROTOCOL_ICMP;
49 h->icmp.type = ICMP4_echo_request;
50 h->id = clib_host_to_net_u16 (t->
id);
56 sizeof(h->icmp) +
sizeof (h->id) +
57 sizeof (h->seq) +
sizeof (h->data));
59 h->icmp.checksum = csum;
75 return VNET_API_ERROR_NO_SUCH_FIB;
79 key = ((
u64)fib_index<<32) | (dst_address->
as_u32);
84 return VNET_API_ERROR_INVALID_REGISTRATION;
87 memset (t, 0,
sizeof (*t));
101 return VNET_API_ERROR_NO_SUCH_ENTRY;
133 else if (
unformat (input,
"fib %d", &fib_id))
154 .short_help =
"oam [add|del] target <ip4-address> fib <fib-id>",
164 uword *event_data = 0;
171 u32 * to_next, * from;
172 u32 ip4_lookup_node_index;
175 static u32 * buffers;
176 oam_template_copy_t * copy_src, * copy_dst;
182 ip4_lookup_node_index = ip4_lookup_node->
index;
209 if ((t->seq - t->last_heard_seq) >= om->misses_allowed) {
210 if (t->state == OAM_STATE_ALIVE) {
212 clib_warning (
"oam target %U now DEAD",
213 format_ip4_address, &t->dst_address);
214 t->state = OAM_STATE_DEAD;
218 if (t->state == OAM_STATE_DEAD) {
220 clib_warning (
"oam target %U now ALIVE",
221 format_ip4_address, &t->dst_address);
222 t->state = OAM_STATE_ALIVE;
229 new_seq = clib_host_to_net_u16 (t->
seq);
239 copy_dst = (oam_template_copy_t *) b0->
data;
240 copy_src = (oam_template_copy_t *) t->
template;
242 copy_dst->v8[0] = copy_src->v8[0];
243 copy_dst->v8[1] = copy_src->v8[1];
244 copy_dst->v8[2] = copy_src->v8[2];
245 copy_dst->v8[3] = copy_src->v8[3];
246 copy_dst->v4 = copy_src->v4;
252 sum0 = h0->icmp.checksum;
254 new_seq, oam_template_t, seq);
276 .name =
"vpe-oam-process",
287 if (
unformat (input,
"interval %f", &interval))
289 else if (
unformat (input,
"misses-allowed %d", &misses_allowed))
322 int verbose = va_arg (*args,
int);
325 return format(s,
"%=6s%=14s%=14s%=12s%=10s",
326 "Fib",
"Src",
"Dst",
"Last Heard",
"State");
328 s =
format (s,
"%=6d%=14U%=14U%=12.2f%=10s",
335 s =
format (s,
" seq %d last_heard_seq %d",
359 vlib_cli_output (vm,
"%U", format_oam_target, t, verbose);
367 .short_help =
"show oam",
383 s =
format (s,
"OAM: rx from address %U, target index %d",
389 #define foreach_oam_error \ 390 _(PROCESSED, "vpe icmp4 oam replies processed") \ 391 _(DROPPED, "icmp4 replies dropped (no registration)") 394 #define _(sym,str) OAM_ERROR_##sym, 401 #define _(sym,string) string, 432 u32 n_left_from, * from, * to_next;
437 oam_template_t * oam0, * oam1;
438 u32 fib_index0, fib_index1;
447 while (n_left_from > 0)
452 to_next, n_left_to_next);
454 while (n_left_from >= 4 && n_left_to_next >= 2)
458 u32 sw_if_index0, sw_if_index1;
475 to_next[0] = bi0 = from[0];
476 to_next[1] = bi1 = from[1];
493 key0 = ((
u64)fib_index0<<32) | oam0->ip4.src_address.as_u32;
503 key1 = ((
u64)fib_index1<<32) | oam1->ip4.src_address.as_u32;
536 to_next, n_left_to_next,
537 bi0, bi1, next01, next01);
540 while (n_left_from > 0 && n_left_to_next > 0)
542 u32 bi0, sw_if_index0;
560 key0 = ((
u64)fib_index0<<32) | oam0->ip4.src_address.as_u32;
583 to_next, n_left_to_next,
595 .name =
"vpe-icmp4-oam",
596 .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)
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)
void(* os_punt_frame)(struct vlib_main_t *vm, struct vlib_node_runtime_t *node, vlib_frame_t *frame)
sll srl srl sll sra u16x4 i
#define hash_unset(h, key)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
struct _vlib_node_registration vlib_node_registration_t
u32 * fib_index_by_sw_if_index
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
void send_oam_event(oam_target_t *t)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
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)
ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
#define VLIB_INIT_FUNCTION(x)
always_inline uword pool_elts(void *v)
#define clib_warning(format, args...)
static clib_error_t * oam_init(vlib_main_t *vm)
always_inline u32 random_u32(u32 *seed)
32-bit random number generator
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
uword * target_by_address_and_fib_id
void ip4_icmp_register_type(vlib_main_t *vm, icmp4_type_t type, u32 node_index)
always_inline u16 ip_csum_fold(ip_csum_t c)
#define pool_elt_at_index(p, i)
uword * fib_index_by_table_id
void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
u16 current_length
Nbytes between current data and the end of this buffer.
static vlib_node_registration_t oam_node
(constructor) VLIB_REGISTER_NODE (oam_node)
always_inline f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
#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)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
always_inline u16 ip4_header_checksum(ip4_header_t *i)
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
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)
#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
#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)
#define ip_csum_update(sum, old, new, type, field)
static u8 * format_oam_target(u8 *s, va_list *args)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
always_inline f64 vlib_time_now(vlib_main_t *vm)
#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
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.