2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #include <vlib/vlib.h>
16 #include <vnet/vnet.h>
17 #include <vnet/pg/pg.h>
18 #include <vppinfra/error.h>
20 #include <vnet/ip/ip.h>
22 #include <vppinfra/hash.h>
23 #include <vppinfra/error.h>
24 #include <vppinfra/elog.h>
26 #include <vnet/ip/ip6_hop_by_hop.h>
28 /* Timestamp precision multipliers for seconds, milliseconds, microseconds
29 * and nanoseconds respectively.
31 static f64 trace_tsp_mul[4] = {1, 1e3, 1e6, 1e9};
33 char *ppc_state[] = {"None", "Encap", "Decap"};
35 ip6_hop_by_hop_main_t ip6_hop_by_hop_main;
38 * ip6 hop-by-hop option handling. We push pkts with h-b-h options to
39 * ip6_hop_by_hop_node_fn from ip6-lookup at a cost of ~2 clocks/pkt in
42 * We parse through the h-b-h option TLVs, specifically looking for
43 * HBH_OPTION_TYPE_IOAM_DATA_LIST. [Someone needs to get bananas from
44 * IANA, aka to actually allocate the option TLV codes.]
46 * If we find the indicated option type, and we have remaining list
47 * elements in the trace list, allocate and populate the trace list
50 * At the ingress edge: punch in the h-b-h rewrite, then visit the
51 * standard h-b-h option handler. We have to be careful in the standard
52 * h-b-h handler, to avoid looping until we run out of rewrite space.
53 * Ask me how I know that.
56 * decide on egress point "pop and count" scheme
57 * time stamp handling: usec since the top of the hour?
58 * configure the node id
59 * trace list application data support
60 * cons up analysis / steering plug-in(s)
61 * add configuration binary APIs, vpp_api_test_support, yang models and
63 * perf tune: dual loop, replace memcpy w/ N x 8-byte load/stores
68 * primary h-b-h handler trace support
69 * We work pretty hard on the problem for obvious reasons
74 u32 timestamp_msbs; /* Store the top set of bits of timestamp */
76 } ip6_hop_by_hop_trace_t;
84 fetch_trace_data_size(u8 trace_type)
86 u8 trace_data_size = 0;
88 if (trace_type == TRACE_TYPE_IF_TS_APP)
89 trace_data_size = sizeof(ioam_trace_if_ts_app_t);
90 else if(trace_type == TRACE_TYPE_IF)
91 trace_data_size = sizeof(ioam_trace_if_t);
92 else if(trace_type == TRACE_TYPE_TS)
93 trace_data_size = sizeof(ioam_trace_ts_t);
94 else if(trace_type == TRACE_TYPE_APP)
95 trace_data_size = sizeof(ioam_trace_app_t);
96 else if(trace_type == TRACE_TYPE_TS_APP)
97 trace_data_size = sizeof(ioam_trace_ts_app_t);
99 return trace_data_size;
102 static u8 * format_ioam_data_list_element (u8 * s, va_list * args)
104 u32 *elt = va_arg (*args, u32 *);
105 u8 *trace_type_p = va_arg (*args, u8 *);
106 u8 trace_type = *trace_type_p;
109 if (trace_type & BIT_TTL_NODEID)
111 u32 ttl_node_id_host_byte_order = clib_net_to_host_u32 (*elt);
112 s = format (s, "ttl 0x%x node id 0x%x ",
113 ttl_node_id_host_byte_order>>24,
114 ttl_node_id_host_byte_order & 0x00FFFFFF);
119 if (trace_type & BIT_ING_INTERFACE && trace_type & BIT_ING_INTERFACE)
121 u32 ingress_host_byte_order = clib_net_to_host_u32(*elt);
122 s = format (s, "ingress 0x%x egress 0x%x ",
123 ingress_host_byte_order >> 16,
124 ingress_host_byte_order &0xFFFF);
128 if (trace_type & BIT_TIMESTAMP)
130 u32 ts_in_host_byte_order = clib_net_to_host_u32 (*elt);
131 s = format (s, "ts 0x%x \n", ts_in_host_byte_order);
135 if (trace_type & BIT_APPDATA)
137 u32 appdata_in_host_byte_order = clib_net_to_host_u32 (*elt);
138 s = format (s, "app 0x%x ", appdata_in_host_byte_order);
145 static u8 * format_ip6_hop_by_hop_trace (u8 * s, va_list * args)
147 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
148 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
149 ip6_hop_by_hop_trace_t * t = va_arg (*args, ip6_hop_by_hop_trace_t *);
150 ip6_hop_by_hop_header_t *hbh0;
151 ip6_hop_by_hop_option_t *opt0, *limit0;
152 ioam_trace_option_t * trace0;
153 u8 trace_data_size_in_words = 0;
158 hbh0 = (ip6_hop_by_hop_header_t *)t->option_data;
160 s = format (s, "IP6_HOP_BY_HOP: next index %d len %d traced %d\n",
161 t->next_index, (hbh0->length+1)<<3, t->trace_len);
163 opt0 = (ip6_hop_by_hop_option_t *) (hbh0+1);
164 limit0 = (ip6_hop_by_hop_option_t *) ((u8 *)hbh0) + t->trace_len;
166 while (opt0 < limit0)
168 type0 = opt0->type & HBH_OPTION_TYPE_MASK;
172 case HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST:
173 trace0 = (ioam_trace_option_t *)opt0;
174 s = format (s, " Trace Type 0x%x , %d elts left ts msb(s) 0x%x\n",
175 trace0->ioam_trace_type, trace0->data_list_elts_left,
177 trace_data_size_in_words =
178 fetch_trace_data_size(trace0->ioam_trace_type)/4;
179 elt0 = &trace0->elts[0];
181 ((u8 *)(&trace0->elts[0]) + trace0->hdr.length - 2
182 /* -2 accounts for ioam_trace_type,elts_left */))
184 s = format (s, " [%d] %U\n",elt_index,
185 format_ioam_data_list_element,
186 elt0, &trace0->ioam_trace_type);
188 elt0 += trace_data_size_in_words;
191 opt0 = (ip6_hop_by_hop_option_t *)
192 (((u8 *)opt0) + opt0->length
193 + sizeof (ip6_hop_by_hop_option_t));
196 case HBH_OPTION_TYPE_IOAM_PROOF_OF_WORK:
197 s = format (s, " POW opt present\n");
198 opt0 = (ip6_hop_by_hop_option_t *)
199 (((u8 *)opt0) + sizeof (ioam_pow_option_t));
202 case 0: /* Pad, just stop */
203 opt0 = (ip6_hop_by_hop_option_t *) ((u8 *)opt0) + 1;
207 s = format (s, "Unknown %d", type0);
208 opt0 = (ip6_hop_by_hop_option_t *)
209 (((u8 *)opt0) + opt0->length
210 + sizeof (ip6_hop_by_hop_option_t));
217 vlib_node_registration_t ip6_hop_by_hop_node;
219 #define foreach_ip6_hop_by_hop_error \
220 _(PROCESSED, "Pkts with ip6 hop-by-hop options") \
221 _(UNKNOWN_OPTION, "Unknown ip6 hop-by-hop options")
224 #define _(sym,str) IP6_HOP_BY_HOP_ERROR_##sym,
225 foreach_ip6_hop_by_hop_error
227 IP6_HOP_BY_HOP_N_ERROR,
228 } ip6_hop_by_hop_error_t;
230 static char * ip6_hop_by_hop_error_strings[] = {
231 #define _(sym,string) string,
232 foreach_ip6_hop_by_hop_error
237 ip6_hop_by_hop_node_fn (vlib_main_t * vm,
238 vlib_node_runtime_t * node,
239 vlib_frame_t * frame)
241 ip6_main_t * im = &ip6_main;
242 ip_lookup_main_t * lm = &im->lookup_main;
243 ip6_hop_by_hop_main_t * hm = &ip6_hop_by_hop_main;
244 u32 n_left_from, * from, * to_next;
245 ip_lookup_next_t next_index;
246 u32 processed = 0, unknown_opts = 0;
251 from = vlib_frame_vector_args (frame);
252 n_left_from = frame->n_vectors;
253 next_index = node->cached_next_index;
255 while (n_left_from > 0)
259 vlib_get_next_frame (vm, node, next_index,
260 to_next, n_left_to_next);
262 #if 0 /* $$$ DUAL-LOOP ME */
263 while (n_left_from >= 4 && n_left_to_next >= 2)
265 u32 next0 = IP6_HOP_BY_HOP_NEXT_INTERFACE_OUTPUT;
266 u32 next1 = IP6_HOP_BY_HOP_NEXT_INTERFACE_OUTPUT;
267 u32 sw_if_index0, sw_if_index1;
269 ethernet_header_t *en0, *en1;
271 vlib_buffer_t * b0, * b1;
273 /* Prefetch next iteration. */
275 vlib_buffer_t * p2, * p3;
277 p2 = vlib_get_buffer (vm, from[2]);
278 p3 = vlib_get_buffer (vm, from[3]);
280 vlib_prefetch_buffer_header (p2, LOAD);
281 vlib_prefetch_buffer_header (p3, LOAD);
283 CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
284 CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE);
287 /* speculatively enqueue b0 and b1 to the current next frame */
288 to_next[0] = bi0 = from[0];
289 to_next[1] = bi1 = from[1];
295 b0 = vlib_get_buffer (vm, bi0);
296 b1 = vlib_get_buffer (vm, bi1);
298 /* $$$$$ Dual loop: process 2 x packets here $$$$$ */
299 ASSERT (b0->current_data == 0);
300 ASSERT (b1->current_data == 0);
302 ip0 = vlib_buffer_get_current (b0);
303 ip1 = vlib_buffer_get_current (b0);
305 sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
306 sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX];
308 /* $$$$$ End of processing 2 x packets $$$$$ */
310 if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)))
312 if (b0->flags & VLIB_BUFFER_IS_TRACED)
314 ip6_hop_by_hop_trace_t *t =
315 vlib_add_trace (vm, node, b0, sizeof (*t));
316 t->sw_if_index = sw_if_index0;
317 t->next_index = next0;
319 if (b1->flags & VLIB_BUFFER_IS_TRACED)
321 ip6_hop_by_hop_trace_t *t =
322 vlib_add_trace (vm, node, b1, sizeof (*t));
323 t->sw_if_index = sw_if_index1;
324 t->next_index = next1;
328 /* verify speculative enqueues, maybe switch current next frame */
329 vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
330 to_next, n_left_to_next,
331 bi0, bi1, next0, next1);
335 while (n_left_from > 0 && n_left_to_next > 0)
342 ip_adjacency_t * adj0;
343 ip6_hop_by_hop_header_t *hbh0;
344 ip6_hop_by_hop_option_t *opt0, *limit0;
345 ioam_trace_option_t * trace0;
349 /* speculatively enqueue b0 to the current next frame */
357 b0 = vlib_get_buffer (vm, bi0);
359 ip0 = vlib_buffer_get_current (b0);
360 adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
361 adj0 = ip_get_adjacency (lm, adj_index0);
362 hbh0 = (ip6_hop_by_hop_header_t *)(ip0+1);
363 opt0 = (ip6_hop_by_hop_option_t *)(hbh0+1);
364 limit0 = (ip6_hop_by_hop_option_t *)
365 ((u8 *)hbh0 + ((hbh0->length+1)<<3));
367 /* Scan the set of h-b-h options, process ones that we understand */
368 while (opt0 < limit0)
370 type0 = opt0->type & HBH_OPTION_TYPE_MASK;
373 case HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST:
374 trace0 = (ioam_trace_option_t *)opt0;
375 if (PREDICT_TRUE (trace0->data_list_elts_left))
377 trace0->data_list_elts_left--;
378 /* fetch_trace_data_size returns in bytes. Convert it to 4-bytes
379 * to skip to this node's location.
381 elt_index = trace0->data_list_elts_left *
382 fetch_trace_data_size(trace0->ioam_trace_type)/4;
383 elt0 = &trace0->elts[elt_index];
384 if (trace0->ioam_trace_type & BIT_TTL_NODEID)
387 clib_host_to_net_u32 ((ip0->hop_limit<<24)
392 if (trace0->ioam_trace_type & BIT_ING_INTERFACE)
395 (vnet_buffer(b0)->sw_if_index[VLIB_RX]&0xFFFF) << 16 | (adj0->rewrite_header.sw_if_index & 0xFFFF);
396 *elt0 = clib_host_to_net_u32(*elt0);
400 if (trace0->ioam_trace_type & BIT_TIMESTAMP)
402 /* Send least significant 32 bits */
403 f64 time_f64 = (f64)(((f64)hm->unix_time_0) +
404 (vlib_time_now(hm->vlib_main) - hm->vlib_time_0));
407 time_f64 * trace_tsp_mul[hm->trace_tsp];
408 *elt0 = clib_host_to_net_u32(time_u64.as_u32[0]);
412 if (trace0->ioam_trace_type & BIT_APPDATA)
414 /* $$$ set elt0->app_data */
415 *elt0 = clib_host_to_net_u32(hm->app_data);
420 opt0 = (ip6_hop_by_hop_option_t *)
421 (((u8 *)opt0) + opt0->length
422 + sizeof (ip6_hop_by_hop_option_t));
425 case HBH_OPTION_TYPE_IOAM_PROOF_OF_WORK:
426 opt0 = (ip6_hop_by_hop_option_t *)
427 (((u8 *)opt0) + sizeof (ioam_pow_option_t));
431 opt0 = (ip6_hop_by_hop_option_t *) ((u8 *)opt0) + 1;
435 opt0 = (ip6_hop_by_hop_option_t *)
436 (((u8 *)opt0) + opt0->length
437 + sizeof (ip6_hop_by_hop_option_t));
446 * Since we push pkts here from the h-b-h header imposition code
447 * we have to be careful what we wish for...
449 next0 = adj0->lookup_next_index != IP_LOOKUP_NEXT_ADD_HOP_BY_HOP ?
450 adj0->lookup_next_index : adj0->saved_lookup_next_index;
452 if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)
453 && (b0->flags & VLIB_BUFFER_IS_TRACED)))
455 ip6_hop_by_hop_trace_t *t =
456 vlib_add_trace (vm, node, b0, sizeof (*t));
457 u32 trace_len = (hbh0->length+1)<<3;
458 t->next_index = next0;
459 /* Capture the h-b-h option verbatim */
460 trace_len = trace_len < ARRAY_LEN(t->option_data) ?
461 trace_len : ARRAY_LEN(t->option_data);
462 t->trace_len = trace_len;
463 t->timestamp_msbs = time_u64.as_u32[1];
464 memcpy (t->option_data, hbh0, trace_len);
469 /* verify speculative enqueue, maybe switch current next frame */
470 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
471 to_next, n_left_to_next,
475 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
478 if (PREDICT_FALSE(unknown_opts > 0)) {
479 vlib_node_increment_counter (vm, ip6_hop_by_hop_node.index,
480 IP6_HOP_BY_HOP_ERROR_UNKNOWN_OPTION, unknown_opts);
483 vlib_node_increment_counter (vm, ip6_hop_by_hop_node.index,
484 IP6_HOP_BY_HOP_ERROR_PROCESSED, processed);
485 return frame->n_vectors;
488 VLIB_REGISTER_NODE (ip6_hop_by_hop_node) = {
489 .function = ip6_hop_by_hop_node_fn,
490 .name = "ip6-hop-by-hop",
491 .vector_size = sizeof (u32),
492 .format_trace = format_ip6_hop_by_hop_trace,
493 .type = VLIB_NODE_TYPE_INTERNAL,
495 .n_errors = ARRAY_LEN(ip6_hop_by_hop_error_strings),
496 .error_strings = ip6_hop_by_hop_error_strings,
498 /* See ip/lookup.h */
499 .n_next_nodes = IP_LOOKUP_N_NEXT,
501 [IP_LOOKUP_NEXT_MISS] = "ip6-miss",
502 [IP_LOOKUP_NEXT_DROP] = "ip6-drop",
503 [IP_LOOKUP_NEXT_PUNT] = "ip6-punt",
504 [IP_LOOKUP_NEXT_LOCAL] = "ip6-local",
505 [IP_LOOKUP_NEXT_ARP] = "ip6-discover-neighbor",
506 [IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite",
507 [IP_LOOKUP_NEXT_CLASSIFY] = "ip6-classify",
508 [IP_LOOKUP_NEXT_MAP] = "ip6-map",
509 [IP_LOOKUP_NEXT_MAP_T] = "ip6-map-t",
510 [IP_LOOKUP_NEXT_SIXRD] = "ip6-sixrd",
511 /* Next 3 arcs probably never used */
512 [IP_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop",
513 [IP_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip6-add-hop-by-hop",
514 [IP_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip6-pop-hop-by-hop",
518 /* The main h-b-h tracer will be invoked, no need to do much here */
521 } ip6_add_hop_by_hop_trace_t;
523 /* packet trace format function */
524 static u8 * format_ip6_add_hop_by_hop_trace (u8 * s, va_list * args)
526 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
527 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
528 ip6_add_hop_by_hop_trace_t * t = va_arg (*args,
529 ip6_add_hop_by_hop_trace_t *);
531 s = format (s, "IP6_ADD_HOP_BY_HOP: next index %d",
536 vlib_node_registration_t ip6_add_hop_by_hop_node;
538 #define foreach_ip6_add_hop_by_hop_error \
539 _(PROCESSED, "Pkts w/ added ip6 hop-by-hop options")
542 #define _(sym,str) IP6_ADD_HOP_BY_HOP_ERROR_##sym,
543 foreach_ip6_add_hop_by_hop_error
545 IP6_ADD_HOP_BY_HOP_N_ERROR,
546 } ip6_add_hop_by_hop_error_t;
548 static char * ip6_add_hop_by_hop_error_strings[] = {
549 #define _(sym,string) string,
550 foreach_ip6_add_hop_by_hop_error
555 ip6_add_hop_by_hop_node_fn (vlib_main_t * vm,
556 vlib_node_runtime_t * node,
557 vlib_frame_t * frame)
559 ip6_hop_by_hop_main_t * hm = &ip6_hop_by_hop_main;
560 u32 n_left_from, * from, * to_next;
561 ip_lookup_next_t next_index;
563 u8 * rewrite = hm->rewrite;
564 u32 rewrite_length = vec_len (rewrite);
566 from = vlib_frame_vector_args (frame);
567 n_left_from = frame->n_vectors;
568 next_index = node->cached_next_index;
570 while (n_left_from > 0)
574 vlib_get_next_frame (vm, node, next_index,
575 to_next, n_left_to_next);
578 while (n_left_from >= 4 && n_left_to_next >= 2)
580 u32 next0 = IP6_ADD_HOP_BY_HOP_NEXT_INTERFACE_OUTPUT;
581 u32 next1 = IP6_ADD_HOP_BY_HOP_NEXT_INTERFACE_OUTPUT;
582 u32 sw_if_index0, sw_if_index1;
584 ethernet_header_t *en0, *en1;
586 vlib_buffer_t * b0, * b1;
588 /* Prefetch next iteration. */
590 vlib_buffer_t * p2, * p3;
592 p2 = vlib_get_buffer (vm, from[2]);
593 p3 = vlib_get_buffer (vm, from[3]);
595 vlib_prefetch_buffer_header (p2, LOAD);
596 vlib_prefetch_buffer_header (p3, LOAD);
598 CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
599 CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE);
602 /* speculatively enqueue b0 and b1 to the current next frame */
603 to_next[0] = bi0 = from[0];
604 to_next[1] = bi1 = from[1];
610 b0 = vlib_get_buffer (vm, bi0);
611 b1 = vlib_get_buffer (vm, bi1);
613 /* $$$$$ Dual loop: process 2 x packets here $$$$$ */
614 ASSERT (b0->current_data == 0);
615 ASSERT (b1->current_data == 0);
617 ip0 = vlib_buffer_get_current (b0);
618 ip1 = vlib_buffer_get_current (b0);
620 sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
621 sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX];
623 /* $$$$$ End of processing 2 x packets $$$$$ */
625 if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)))
627 if (b0->flags & VLIB_BUFFER_IS_TRACED)
629 ip6_add_hop_by_hop_trace_t *t =
630 vlib_add_trace (vm, node, b0, sizeof (*t));
631 t->sw_if_index = sw_if_index0;
632 t->next_index = next0;
634 if (b1->flags & VLIB_BUFFER_IS_TRACED)
636 ip6_add_hop_by_hop_trace_t *t =
637 vlib_add_trace (vm, node, b1, sizeof (*t));
638 t->sw_if_index = sw_if_index1;
639 t->next_index = next1;
643 /* verify speculative enqueues, maybe switch current next frame */
644 vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
645 to_next, n_left_to_next,
646 bi0, bi1, next0, next1);
650 while (n_left_from > 0 && n_left_to_next > 0)
656 ip6_hop_by_hop_header_t * hbh0;
657 u64 * copy_src0, * copy_dst0;
660 /* speculatively enqueue b0 to the current next frame */
668 b0 = vlib_get_buffer (vm, bi0);
670 ip0 = vlib_buffer_get_current (b0);
672 /* Copy the ip header left by the required amount */
673 copy_dst0 = (u64 *)(((u8 *)ip0) - rewrite_length);
674 copy_src0 = (u64 *) ip0;
676 copy_dst0 [0] = copy_src0 [0];
677 copy_dst0 [1] = copy_src0 [1];
678 copy_dst0 [2] = copy_src0 [2];
679 copy_dst0 [3] = copy_src0 [3];
680 copy_dst0 [4] = copy_src0 [4];
681 vlib_buffer_advance (b0, - (word)rewrite_length);
682 ip0 = vlib_buffer_get_current (b0);
684 hbh0 = (ip6_hop_by_hop_header_t *)(ip0 + 1);
685 /* $$$ tune, rewrite_length is a multiple of 8 */
686 memcpy (hbh0, rewrite, rewrite_length);
687 /* Patch the protocol chain, insert the h-b-h (type 0) header */
688 hbh0->protocol = ip0->protocol;
690 new_l0 = clib_net_to_host_u16 (ip0->payload_length) + rewrite_length;
691 ip0->payload_length = clib_host_to_net_u16 (new_l0);
693 /* Populate the (first) h-b-h list elt */
694 next0 = IP_LOOKUP_NEXT_HOP_BY_HOP;
696 if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)
697 && (b0->flags & VLIB_BUFFER_IS_TRACED)))
699 ip6_add_hop_by_hop_trace_t *t =
700 vlib_add_trace (vm, node, b0, sizeof (*t));
701 t->next_index = next0;
706 /* verify speculative enqueue, maybe switch current next frame */
707 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
708 to_next, n_left_to_next,
712 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
715 vlib_node_increment_counter (vm, ip6_add_hop_by_hop_node.index,
716 IP6_ADD_HOP_BY_HOP_ERROR_PROCESSED, processed);
717 return frame->n_vectors;
720 VLIB_REGISTER_NODE (ip6_add_hop_by_hop_node) = {
721 .function = ip6_add_hop_by_hop_node_fn,
722 .name = "ip6-add-hop-by-hop",
723 .vector_size = sizeof (u32),
724 .format_trace = format_ip6_add_hop_by_hop_trace,
725 .type = VLIB_NODE_TYPE_INTERNAL,
727 .n_errors = ARRAY_LEN(ip6_add_hop_by_hop_error_strings),
728 .error_strings = ip6_add_hop_by_hop_error_strings,
730 /* See ip/lookup.h */
731 .n_next_nodes = IP_LOOKUP_N_NEXT,
733 [IP_LOOKUP_NEXT_MISS] = "ip6-miss",
734 [IP_LOOKUP_NEXT_DROP] = "ip6-drop",
735 [IP_LOOKUP_NEXT_PUNT] = "ip6-punt",
736 [IP_LOOKUP_NEXT_LOCAL] = "ip6-local",
737 [IP_LOOKUP_NEXT_ARP] = "ip6-discover-neighbor",
738 [IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite",
739 [IP_LOOKUP_NEXT_CLASSIFY] = "ip6-classify",
740 [IP_LOOKUP_NEXT_MAP] = "ip6-map",
741 [IP_LOOKUP_NEXT_MAP_T] = "ip6-map-t",
742 [IP_LOOKUP_NEXT_SIXRD] = "ip6-sixrd",
743 /* Next 3 arcs probably never used */
744 [IP_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop",
745 [IP_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip6-add-hop-by-hop",
746 [IP_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip6-pop-hop-by-hop",
751 /* The main h-b-h tracer was already invoked, no need to do much here */
754 } ip6_pop_hop_by_hop_trace_t;
756 /* packet trace format function */
757 static u8 * format_ip6_pop_hop_by_hop_trace (u8 * s, va_list * args)
759 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
760 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
761 ip6_pop_hop_by_hop_trace_t * t = va_arg (*args, ip6_pop_hop_by_hop_trace_t *);
763 s = format (s, "IP6_POP_HOP_BY_HOP: next index %d",
768 vlib_node_registration_t ip6_pop_hop_by_hop_node;
770 #define foreach_ip6_pop_hop_by_hop_error \
771 _(PROCESSED, "Pkts w/ removed ip6 hop-by-hop options") \
772 _(NO_HOHO, "Pkts w/ no ip6 hop-by-hop options")
775 #define _(sym,str) IP6_POP_HOP_BY_HOP_ERROR_##sym,
776 foreach_ip6_pop_hop_by_hop_error
778 IP6_POP_HOP_BY_HOP_N_ERROR,
779 } ip6_pop_hop_by_hop_error_t;
781 static char * ip6_pop_hop_by_hop_error_strings[] = {
782 #define _(sym,string) string,
783 foreach_ip6_pop_hop_by_hop_error
788 ip6_pop_hop_by_hop_node_fn (vlib_main_t * vm,
789 vlib_node_runtime_t * node,
790 vlib_frame_t * frame)
792 ip6_hop_by_hop_main_t * hm = &ip6_hop_by_hop_main;
793 ip6_main_t * im = &ip6_main;
794 ip_lookup_main_t * lm = &im->lookup_main;
795 u32 n_left_from, * from, * to_next;
796 ip_lookup_next_t next_index;
799 u32 (*ioam_end_of_path_cb) (vlib_main_t *, vlib_node_runtime_t *,
800 vlib_buffer_t *, ip6_header_t *,
803 ioam_end_of_path_cb = hm->ioam_end_of_path_cb;
805 from = vlib_frame_vector_args (frame);
806 n_left_from = frame->n_vectors;
807 next_index = node->cached_next_index;
809 while (n_left_from > 0)
813 vlib_get_next_frame (vm, node, next_index,
814 to_next, n_left_to_next);
817 while (n_left_from >= 4 && n_left_to_next >= 2)
819 u32 next0 = IP6_POP_HOP_BY_HOP_NEXT_INTERFACE_OUTPUT;
820 u32 next1 = IP6_POP_HOP_BY_HOP_NEXT_INTERFACE_OUTPUT;
821 u32 sw_if_index0, sw_if_index1;
823 ethernet_header_t *en0, *en1;
825 vlib_buffer_t * b0, * b1;
827 /* Prefetch next iteration. */
829 vlib_buffer_t * p2, * p3;
831 p2 = vlib_get_buffer (vm, from[2]);
832 p3 = vlib_get_buffer (vm, from[3]);
834 vlib_prefetch_buffer_header (p2, LOAD);
835 vlib_prefetch_buffer_header (p3, LOAD);
837 CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
838 CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE);
841 /* speculatively enqueue b0 and b1 to the current next frame */
842 to_next[0] = bi0 = from[0];
843 to_next[1] = bi1 = from[1];
849 b0 = vlib_get_buffer (vm, bi0);
850 b1 = vlib_get_buffer (vm, bi1);
852 /* $$$$$ Dual loop: process 2 x packets here $$$$$ */
853 ASSERT (b0->current_data == 0);
854 ASSERT (b1->current_data == 0);
856 ip0 = vlib_buffer_get_current (b0);
857 ip1 = vlib_buffer_get_current (b0);
859 sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
860 sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX];
862 /* $$$$$ End of processing 2 x packets $$$$$ */
864 if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)))
866 if (b0->flags & VLIB_BUFFER_IS_TRACED)
868 ip6_pop_hop_by_hop_trace_t *t =
869 vlib_add_trace (vm, node, b0, sizeof (*t));
870 t->sw_if_index = sw_if_index0;
871 t->next_index = next0;
873 if (b1->flags & VLIB_BUFFER_IS_TRACED)
875 ip6_pop_hop_by_hop_trace_t *t =
876 vlib_add_trace (vm, node, b1, sizeof (*t));
877 t->sw_if_index = sw_if_index1;
878 t->next_index = next1;
882 /* verify speculative enqueues, maybe switch current next frame */
883 vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
884 to_next, n_left_to_next,
885 bi0, bi1, next0, next1);
889 while (n_left_from > 0 && n_left_to_next > 0)
896 ip_adjacency_t * adj0;
897 ip6_hop_by_hop_header_t *hbh0;
898 u64 * copy_dst0, * copy_src0;
901 /* speculatively enqueue b0 to the current next frame */
909 b0 = vlib_get_buffer (vm, bi0);
911 ip0 = vlib_buffer_get_current (b0);
912 adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
913 adj0 = ip_get_adjacency (lm, adj_index0);
915 /* Perfectly normal to end up here w/ out h-b-h header */
916 if (PREDICT_TRUE (ip0->protocol == 0))
918 hbh0 = (ip6_hop_by_hop_header_t *)(ip0+1);
920 /* Collect data from trace via callback */
921 next0 = ioam_end_of_path_cb ?
922 ioam_end_of_path_cb (vm, node, b0, ip0, adj0)
923 : adj0->saved_lookup_next_index;
926 /* Pop the trace data */
927 vlib_buffer_advance (b0, (hbh0->length+1)<<3);
928 new_l0 = clib_net_to_host_u16 (ip0->payload_length) -
929 ((hbh0->length+1)<<3);
930 ip0->payload_length = clib_host_to_net_u16 (new_l0);
931 ip0->protocol = hbh0->protocol;
932 copy_src0 = (u64 *)ip0;
933 copy_dst0 = copy_src0 + (hbh0->length+1);
934 copy_dst0 [4] = copy_src0[4];
935 copy_dst0 [3] = copy_src0[3];
936 copy_dst0 [2] = copy_src0[2];
937 copy_dst0 [1] = copy_src0[1];
938 copy_dst0 [0] = copy_src0[0];
943 next0 = adj0->saved_lookup_next_index;
947 if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)
948 && (b0->flags & VLIB_BUFFER_IS_TRACED)))
950 ip6_pop_hop_by_hop_trace_t *t =
951 vlib_add_trace (vm, node, b0, sizeof (*t));
952 t->next_index = next0;
955 /* verify speculative enqueue, maybe switch current next frame */
956 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
957 to_next, n_left_to_next,
961 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
964 vlib_node_increment_counter (vm, ip6_pop_hop_by_hop_node.index,
965 IP6_POP_HOP_BY_HOP_ERROR_PROCESSED, processed);
966 vlib_node_increment_counter (vm, ip6_pop_hop_by_hop_node.index,
967 IP6_POP_HOP_BY_HOP_ERROR_NO_HOHO, no_header);
968 return frame->n_vectors;
971 VLIB_REGISTER_NODE (ip6_pop_hop_by_hop_node) = {
972 .function = ip6_pop_hop_by_hop_node_fn,
973 .name = "ip6-pop-hop-by-hop",
974 .vector_size = sizeof (u32),
975 .format_trace = format_ip6_pop_hop_by_hop_trace,
976 .type = VLIB_NODE_TYPE_INTERNAL,
978 .n_errors = ARRAY_LEN(ip6_pop_hop_by_hop_error_strings),
979 .error_strings = ip6_pop_hop_by_hop_error_strings,
981 /* See ip/lookup.h */
982 .n_next_nodes = IP_LOOKUP_N_NEXT,
984 [IP_LOOKUP_NEXT_MISS] = "ip6-miss",
985 [IP_LOOKUP_NEXT_DROP] = "ip6-drop",
986 [IP_LOOKUP_NEXT_PUNT] = "ip6-punt",
987 [IP_LOOKUP_NEXT_LOCAL] = "ip6-local",
988 [IP_LOOKUP_NEXT_ARP] = "ip6-discover-neighbor",
989 [IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite",
990 [IP_LOOKUP_NEXT_CLASSIFY] = "ip6-classify",
991 [IP_LOOKUP_NEXT_MAP] = "ip6-map",
992 [IP_LOOKUP_NEXT_MAP_T] = "ip6-map-t",
993 [IP_LOOKUP_NEXT_SIXRD] = "ip6-sixrd",
994 /* Next 3 arcs probably never used */
995 [IP_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop",
996 [IP_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip6-add-hop-by-hop",
997 [IP_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip6-pop-hop-by-hop",
1002 static clib_error_t *
1003 ip6_hop_by_hop_init (vlib_main_t * vm)
1005 ip6_hop_by_hop_main_t * hm = &ip6_hop_by_hop_main;
1008 hm->vnet_main = vnet_get_main();
1009 hm->unix_time_0 = (u32) time (0); /* Store starting time */
1010 hm->vlib_time_0 = vlib_time_now (vm);
1011 hm->ioam_flag = IOAM_HBYH_MOD;
1012 hm->trace_tsp = TSP_MICROSECONDS; /* Micro seconds */
1017 VLIB_INIT_FUNCTION (ip6_hop_by_hop_init);
1019 int ip6_ioam_set_rewrite (u8 **rwp, u32 trace_type, u32 trace_option_elts,
1020 int has_pow_option, int has_ppc_option)
1024 ip6_hop_by_hop_header_t *hbh;
1025 ioam_trace_option_t * trace_option;
1026 ioam_pow_option_t * pow_option;
1028 u8 trace_data_size = 0;
1032 if (trace_option_elts == 0 && has_pow_option == 0)
1035 /* Work out how much space we need */
1036 size = sizeof (ip6_hop_by_hop_header_t);
1038 if (trace_option_elts)
1040 size += sizeof (ip6_hop_by_hop_option_t);
1042 trace_data_size = fetch_trace_data_size(trace_type);
1043 if (trace_data_size == 0)
1044 return VNET_API_ERROR_INVALID_VALUE;
1046 if (trace_option_elts * trace_data_size > 254)
1047 return VNET_API_ERROR_INVALID_VALUE;
1049 size += trace_option_elts * trace_data_size;
1053 size += sizeof (ip6_hop_by_hop_option_t);
1054 size += sizeof (ioam_pow_option_t);
1057 /* Round to a multiple of 8 octets */
1058 rnd_size = (size + 7) & ~7;
1060 /* allocate it, zero-fill / pad by construction */
1061 vec_validate (rewrite, rnd_size-1);
1063 hbh = (ip6_hop_by_hop_header_t *) rewrite;
1064 /* Length of header in 8 octet units, not incl first 8 octets */
1065 hbh->length = (rnd_size>>3) - 1;
1066 current = (u8 *)(hbh+1);
1068 if (trace_option_elts)
1070 trace_option = (ioam_trace_option_t *)current;
1071 trace_option->hdr.type = HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST
1072 | HBH_OPTION_TYPE_DATA_CHANGE_ENROUTE;
1073 trace_option->hdr.length =
1074 2 /*ioam_trace_type,data_list_elts_left */ +
1075 trace_option_elts * trace_data_size;
1076 trace_option->ioam_trace_type = trace_type & TRACE_TYPE_MASK;
1077 trace_option->data_list_elts_left = trace_option_elts;
1078 current += sizeof (ioam_trace_option_t) +
1079 trace_option_elts * trace_data_size;
1083 pow_option = (ioam_pow_option_t *)current;
1084 pow_option->hdr.type = HBH_OPTION_TYPE_IOAM_PROOF_OF_WORK
1085 | HBH_OPTION_TYPE_DATA_CHANGE_ENROUTE;
1086 pow_option->hdr.length = sizeof (ioam_pow_option_t) -
1087 sizeof (ip6_hop_by_hop_option_t);
1088 current += sizeof (ioam_pow_option_t);
1096 clear_ioam_rewrite_fn(void)
1098 ip6_hop_by_hop_main_t *hm = &ip6_hop_by_hop_main;
1100 vec_free(hm->rewrite);
1105 hm->trace_option_elts = 0;
1106 hm->has_pow_option = 0;
1107 hm->has_ppc_option = 0;
1108 hm->trace_tsp = TSP_MICROSECONDS;
1113 clib_error_t * clear_ioam_rewrite_command_fn (vlib_main_t * vm,
1114 unformat_input_t * input,
1115 vlib_cli_command_t * cmd)
1117 return(clear_ioam_rewrite_fn());
1120 VLIB_CLI_COMMAND (ip6_clear_ioam_trace_cmd, static) = {
1121 .path = "clear ioam rewrite",
1122 .short_help = "clear ioam rewrite",
1123 .function = clear_ioam_rewrite_command_fn,
1127 ip6_ioam_trace_profile_set(u32 trace_option_elts, u32 trace_type, u32 node_id,
1128 u32 app_data, int has_pow_option, u32 trace_tsp,
1132 ip6_hop_by_hop_main_t *hm = &ip6_hop_by_hop_main;
1133 rv = ip6_ioam_set_rewrite (&hm->rewrite, trace_type, trace_option_elts,
1134 has_pow_option, has_ppc_option);
1139 hm->node_id = node_id;
1140 hm->app_data = app_data;
1141 hm->trace_type = trace_type;
1142 hm->trace_option_elts = trace_option_elts;
1143 hm->has_pow_option = has_pow_option;
1144 hm->has_ppc_option = has_ppc_option;
1145 hm->trace_tsp = trace_tsp;
1149 return clib_error_return_code(0, rv, 0, "ip6_ioam_set_rewrite returned %d", rv);
1156 static clib_error_t *
1157 ip6_set_ioam_rewrite_command_fn (vlib_main_t * vm,
1158 unformat_input_t * input,
1159 vlib_cli_command_t * cmd)
1161 u32 trace_option_elts = 0;
1162 u32 trace_type = 0, node_id = 0;
1163 u32 app_data = 0, trace_tsp = TSP_MICROSECONDS;
1164 int has_pow_option = 0;
1165 int has_ppc_option = 0;
1166 clib_error_t * rv = 0;
1168 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1170 if (unformat (input, "trace-type 0x%x trace-elts %d "
1171 "trace-tsp %d node-id 0x%x app-data 0x%x",
1172 &trace_type, &trace_option_elts, &trace_tsp,
1173 &node_id, &app_data))
1175 else if (unformat (input, "pow"))
1177 else if (unformat (input, "ppc encap"))
1178 has_ppc_option = PPC_ENCAP;
1179 else if (unformat (input, "ppc decap"))
1180 has_ppc_option = PPC_DECAP;
1181 else if (unformat (input, "ppc none"))
1182 has_ppc_option = PPC_NONE;
1188 rv = ip6_ioam_trace_profile_set(trace_option_elts, trace_type, node_id,
1189 app_data, has_pow_option, trace_tsp, has_ppc_option);
1195 VLIB_CLI_COMMAND (ip6_set_ioam_rewrite_cmd, static) = {
1196 .path = "set ioam rewrite",
1197 .short_help = "set ioam rewrite trace-type <0x1f|0x3|0x9|0x11|0x19> trace-elts <nn> trace-tsp <0|1|2|3> node-id <node id in hex> app-data <app_data in hex> [pow] [ppc <encap|decap>]",
1198 .function = ip6_set_ioam_rewrite_command_fn,
1201 static clib_error_t *
1202 ip6_show_ioam_summary_cmd_fn (vlib_main_t * vm,
1203 unformat_input_t * input,
1204 vlib_cli_command_t * cmd)
1206 ip6_hop_by_hop_main_t *hm = &ip6_hop_by_hop_main;
1210 if (!is_zero_ip6_address(&hm->adj))
1212 s = format(s, " REWRITE FLOW CONFIGS - \n");
1213 s = format(s, " Destination Address : %U\n",
1214 format_ip6_address, &hm->adj, sizeof(ip6_address_t));
1215 s = format(s, " Flow operation : %d (%s)\n", hm->ioam_flag,
1216 (hm->ioam_flag == IOAM_HBYH_ADD) ? "Add" :
1217 ((hm->ioam_flag == IOAM_HBYH_MOD) ? "Mod" : "Pop"));
1221 s = format(s, " REWRITE FLOW CONFIGS - Not configured\n");
1224 if (hm->trace_option_elts)
1226 s = format(s, " HOP BY HOP OPTIONS - TRACE CONFIG - \n");
1227 s = format(s, " Trace Type : 0x%x (%d)\n",
1228 hm->trace_type, hm->trace_type);
1229 s = format(s, " Trace timestamp precision : %d (%s)\n", hm->trace_tsp,
1230 (hm->trace_tsp == TSP_SECONDS) ? "Seconds" :
1231 ((hm->trace_tsp == TSP_MILLISECONDS) ? "Milliseconds" :
1232 (((hm->trace_tsp == TSP_MICROSECONDS) ? "Microseconds" : "Nanoseconds"))));
1233 s = format(s, " Num of trace nodes : %d\n",
1234 hm->trace_option_elts);
1235 s = format(s, " Node-id : 0x%x (%d)\n",
1236 hm->node_id, hm->node_id);
1237 s = format(s, " App Data : 0x%x (%d)\n",
1238 hm->app_data, hm->app_data);
1242 s = format(s, " HOP BY HOP OPTIONS - TRACE CONFIG - Not configured\n");
1245 s = format(s, " POW OPTION - %d (%s)\n",
1246 hm->has_pow_option, (hm->has_pow_option?"Enabled":"Disabled"));
1247 if (hm->has_pow_option)
1248 s = format(s, "Try 'show ioam sc-profile' for more information\n");
1250 s = format(s, " EDGE TO EDGE - PPC OPTION - %d (%s)\n",
1251 hm->has_ppc_option, ppc_state[hm->has_ppc_option]);
1252 if (hm->has_ppc_option)
1253 s = format(s, "Try 'show ioam ppc' for more information\n");
1255 vlib_cli_output(vm, "%v", s);
1260 VLIB_CLI_COMMAND (ip6_show_ioam_run_cmd, static) = {
1261 .path = "show ioam summary",
1262 .short_help = "Summary of IOAM configuration",
1263 .function = ip6_show_ioam_summary_cmd_fn,
1266 int ip6_ioam_set_destination (ip6_address_t *addr, u32 mask_width, u32 vrf_id,
1267 int is_add, int is_pop, int is_none)
1269 ip6_main_t * im = &ip6_main;
1270 ip6_hop_by_hop_main_t * hm = &ip6_hop_by_hop_main;
1271 ip_lookup_main_t * lm = &im->lookup_main;
1272 ip_adjacency_t * adj;
1277 BVT(clib_bihash_kv) kv, value;
1279 if ((is_add + is_pop + is_none) != 1)
1280 return VNET_API_ERROR_INVALID_VALUE_2;
1282 /* Go find the adjacency we're supposed to tickle */
1283 p = hash_get (im->fib_index_by_table_id, vrf_id);
1286 return VNET_API_ERROR_NO_SUCH_FIB;
1290 len = vec_len (im->prefix_lengths_in_search_order);
1292 for (i = 0; i < len; i++)
1294 int dst_address_length = im->prefix_lengths_in_search_order[i];
1295 ip6_address_t * mask = &im->fib_masks[dst_address_length];
1297 if (dst_address_length != mask_width)
1300 kv.key[0] = addr->as_u64[0] & mask->as_u64[0];
1301 kv.key[1] = addr->as_u64[1] & mask->as_u64[1];
1302 kv.key[2] = ((u64)((fib_index))<<32) | dst_address_length;
1304 rv = BV(clib_bihash_search_inline_2)(&im->ip6_lookup_table, &kv, &value);
1309 return VNET_API_ERROR_NO_SUCH_ENTRY;
1313 /* Got it, modify as directed... */
1314 adj_index = value.value;
1315 adj = ip_get_adjacency (lm, adj_index);
1317 /* Restore original lookup-next action */
1318 if (adj->saved_lookup_next_index)
1320 adj->lookup_next_index = adj->saved_lookup_next_index;
1321 adj->saved_lookup_next_index = 0;
1324 /* Save current action */
1325 if (is_add || is_pop)
1326 adj->saved_lookup_next_index = adj->lookup_next_index;
1329 adj->lookup_next_index = IP_LOOKUP_NEXT_ADD_HOP_BY_HOP;
1332 adj->lookup_next_index = IP_LOOKUP_NEXT_POP_HOP_BY_HOP;
1335 hm->ioam_flag = (is_add ? IOAM_HBYH_ADD :
1336 (is_pop ? IOAM_HBYH_POP : IOAM_HBYH_MOD));
1340 static clib_error_t *
1341 ip6_set_ioam_destination_command_fn (vlib_main_t * vm,
1342 unformat_input_t * input,
1343 vlib_cli_command_t * cmd)
1346 u32 mask_width = ~0;
1353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1355 if (unformat (input, "%U/%d",
1356 unformat_ip6_address, &addr, &mask_width))
1358 else if (unformat (input, "vrf-id %d", &vrf_id))
1360 else if (unformat (input, "add"))
1362 else if (unformat (input, "pop"))
1364 else if (unformat (input, "none"))
1370 if ((is_add + is_pop + is_none) != 1)
1371 return clib_error_return (0, "One of (add, pop, none) required");
1372 if (mask_width == ~0)
1373 return clib_error_return (0, "<address>/<mask-width> required");
1375 rv = ip6_ioam_set_destination (&addr, mask_width, vrf_id,
1376 is_add, is_pop, is_none);
1383 return clib_error_return (0, "ip6_ioam_set_destination returned %d", rv);
1389 VLIB_CLI_COMMAND (ip6_set_ioam_destination_cmd, static) = {
1390 .path = "set ioam destination",
1391 .short_help = "set ioam destination <ip6-address>/<width> add | pop | none",
1392 .function = ip6_set_ioam_destination_command_fn,
1395 void vnet_register_ioam_end_of_path_callback (void *cb)
1397 ip6_hop_by_hop_main_t * hm = &ip6_hop_by_hop_main;
1399 hm->ioam_end_of_path_cb = cb;