Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 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. |
| 14 | */ |
| 15 | #include <vlib/vlib.h> |
| 16 | #include <vnet/vnet.h> |
| 17 | #include <vnet/pg/pg.h> |
| 18 | #include <vppinfra/error.h> |
| 19 | |
| 20 | #include <vnet/ip/ip.h> |
| 21 | |
| 22 | #include <vppinfra/hash.h> |
| 23 | #include <vppinfra/error.h> |
| 24 | #include <vppinfra/elog.h> |
| 25 | |
| 26 | #include <vnet/ip/ip6_hop_by_hop.h> |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 27 | #include <vnet/fib/ip6_fib.h> |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 28 | #include <vnet/classify/vnet_classify.h> |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 29 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 30 | /** |
| 31 | * @file |
| 32 | * @brief In-band OAM (iOAM). |
| 33 | * |
| 34 | * In-band OAM (iOAM) is an implementation study to record operational |
| 35 | * information in the packet while the packet traverses a path between |
| 36 | * two points in the network. |
| 37 | * |
| 38 | * VPP can function as in-band OAM encapsulating, transit and |
| 39 | * decapsulating node. In this version of VPP in-band OAM data is |
| 40 | * transported as options in an IPv6 hop-by-hop extension header. Hence |
| 41 | * in-band OAM can be enabled for IPv6 traffic. |
| 42 | */ |
| 43 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 44 | #ifndef CLIB_MARCH_VARIANT |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 45 | ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main; |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 46 | #endif /* CLIB_MARCH_VARIANT */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 47 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 48 | #define foreach_ip6_hbyh_ioam_input_next \ |
| 49 | _(IP6_REWRITE, "ip6-rewrite") \ |
| 50 | _(IP6_LOOKUP, "ip6-lookup") \ |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 51 | _(DROP, "ip6-drop") |
rangan | f5bf6dd | 2016-04-15 17:31:46 +0530 | [diff] [blame] | 52 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 53 | typedef enum |
| 54 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 55 | #define _(s,n) IP6_HBYH_IOAM_INPUT_NEXT_##s, |
| 56 | foreach_ip6_hbyh_ioam_input_next |
rangan | f5bf6dd | 2016-04-15 17:31:46 +0530 | [diff] [blame] | 57 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 58 | IP6_HBYH_IOAM_INPUT_N_NEXT, |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 59 | } ip6_hbyh_ioam_input_next_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 60 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 61 | #ifndef CLIB_MARCH_VARIANT |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 62 | static uword |
| 63 | unformat_opaque_ioam (unformat_input_t * input, va_list * args) |
| 64 | { |
| 65 | u64 *opaquep = va_arg (*args, u64 *); |
| 66 | u8 *flow_name = NULL; |
| 67 | uword ret = 0; |
| 68 | |
| 69 | if (unformat (input, "ioam-encap %s", &flow_name)) |
| 70 | { |
| 71 | *opaquep = ioam_flow_add (1, flow_name); |
| 72 | ret = 1; |
| 73 | } |
| 74 | else if (unformat (input, "ioam-decap %s", &flow_name)) |
| 75 | { |
| 76 | *opaquep = ioam_flow_add (0, flow_name); |
| 77 | ret = 1; |
| 78 | } |
| 79 | |
| 80 | vec_free (flow_name); |
| 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | u8 * |
| 85 | get_flow_name_from_flow_ctx (u32 flow_ctx) |
| 86 | { |
| 87 | flow_data_t *flow = NULL; |
| 88 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 89 | u32 index; |
| 90 | |
| 91 | index = IOAM_MASK_DECAP_BIT (flow_ctx); |
| 92 | |
| 93 | if (pool_is_free_index (hm->flows, index)) |
| 94 | return NULL; |
| 95 | |
| 96 | flow = pool_elt_at_index (hm->flows, index); |
| 97 | return (flow->flow_name); |
| 98 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 99 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 100 | /* The main h-b-h tracer will be invoked, no need to do much here */ |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 101 | int |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 102 | ip6_hbh_add_register_option (u8 option, |
| 103 | u8 size, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 104 | int rewrite_options (u8 * rewrite_string, |
| 105 | u8 * rewrite_size)) |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 106 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 107 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 108 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 109 | ASSERT ((u32) option < ARRAY_LEN (hm->add_options)); |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 110 | |
| 111 | /* Already registered */ |
| 112 | if (hm->add_options[option]) |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 113 | return (-1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 114 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 115 | hm->add_options[option] = rewrite_options; |
| 116 | hm->options_size[option] = size; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 117 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 118 | return (0); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 119 | } |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 120 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 121 | int |
| 122 | ip6_hbh_add_unregister_option (u8 option) |
| 123 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 124 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 125 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 126 | ASSERT ((u32) option < ARRAY_LEN (hm->add_options)); |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 127 | |
| 128 | /* Not registered */ |
| 129 | if (!hm->add_options[option]) |
| 130 | return (-1); |
| 131 | |
| 132 | hm->add_options[option] = NULL; |
| 133 | hm->options_size[option] = 0; |
| 134 | return (0); |
| 135 | } |
| 136 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 137 | /* Config handler registration */ |
| 138 | int |
| 139 | ip6_hbh_config_handler_register (u8 option, |
| 140 | int config_handler (void *data, u8 disable)) |
| 141 | { |
| 142 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 143 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 144 | ASSERT ((u32) option < ARRAY_LEN (hm->config_handler)); |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 145 | |
| 146 | /* Already registered */ |
| 147 | if (hm->config_handler[option]) |
| 148 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 149 | |
| 150 | hm->config_handler[option] = config_handler; |
| 151 | |
| 152 | return (0); |
| 153 | } |
| 154 | |
| 155 | int |
| 156 | ip6_hbh_config_handler_unregister (u8 option) |
| 157 | { |
| 158 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 159 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 160 | ASSERT ((u32) option < ARRAY_LEN (hm->config_handler)); |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 161 | |
| 162 | /* Not registered */ |
| 163 | if (!hm->config_handler[option]) |
| 164 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 165 | |
| 166 | hm->config_handler[option] = NULL; |
| 167 | return (0); |
| 168 | } |
| 169 | |
| 170 | /* Flow handler registration */ |
| 171 | int |
| 172 | ip6_hbh_flow_handler_register (u8 option, |
| 173 | u32 ioam_flow_handler (u32 flow_ctx, u8 add)) |
| 174 | { |
| 175 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 176 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 177 | ASSERT ((u32) option < ARRAY_LEN (hm->flow_handler)); |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 178 | |
| 179 | /* Already registered */ |
| 180 | if (hm->flow_handler[option]) |
| 181 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 182 | |
| 183 | hm->flow_handler[option] = ioam_flow_handler; |
| 184 | |
| 185 | return (0); |
| 186 | } |
| 187 | |
| 188 | int |
| 189 | ip6_hbh_flow_handler_unregister (u8 option) |
| 190 | { |
| 191 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 192 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 193 | ASSERT ((u32) option < ARRAY_LEN (hm->flow_handler)); |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 194 | |
| 195 | /* Not registered */ |
| 196 | if (!hm->flow_handler[option]) |
| 197 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 198 | |
| 199 | hm->flow_handler[option] = NULL; |
| 200 | return (0); |
| 201 | } |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 202 | #endif /* CLIB_MARCH_VARIANT */ |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 203 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 204 | typedef struct |
| 205 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 206 | u32 next_index; |
| 207 | } ip6_add_hop_by_hop_trace_t; |
| 208 | |
| 209 | /* packet trace format function */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 210 | static u8 * |
| 211 | format_ip6_add_hop_by_hop_trace (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 212 | { |
| 213 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 214 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 215 | ip6_add_hop_by_hop_trace_t *t = va_arg (*args, |
| 216 | ip6_add_hop_by_hop_trace_t *); |
| 217 | |
| 218 | s = format (s, "IP6_ADD_HOP_BY_HOP: next index %d", t->next_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 219 | return s; |
| 220 | } |
| 221 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 222 | extern vlib_node_registration_t ip6_add_hop_by_hop_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 223 | |
| 224 | #define foreach_ip6_add_hop_by_hop_error \ |
| 225 | _(PROCESSED, "Pkts w/ added ip6 hop-by-hop options") |
| 226 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 227 | typedef enum |
| 228 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 229 | #define _(sym,str) IP6_ADD_HOP_BY_HOP_ERROR_##sym, |
| 230 | foreach_ip6_add_hop_by_hop_error |
| 231 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 232 | IP6_ADD_HOP_BY_HOP_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 233 | } ip6_add_hop_by_hop_error_t; |
| 234 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 235 | static char *ip6_add_hop_by_hop_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 236 | #define _(sym,string) string, |
| 237 | foreach_ip6_add_hop_by_hop_error |
| 238 | #undef _ |
| 239 | }; |
| 240 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 241 | VLIB_NODE_FN (ip6_add_hop_by_hop_node) (vlib_main_t * vm, |
| 242 | vlib_node_runtime_t * node, |
| 243 | vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 244 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 245 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 246 | u32 n_left_from, *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 247 | ip_lookup_next_t next_index; |
| 248 | u32 processed = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 249 | u8 *rewrite = hm->rewrite; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 250 | u32 rewrite_length = vec_len (rewrite); |
| 251 | |
| 252 | from = vlib_frame_vector_args (frame); |
| 253 | n_left_from = frame->n_vectors; |
| 254 | next_index = node->cached_next_index; |
| 255 | |
| 256 | while (n_left_from > 0) |
| 257 | { |
| 258 | u32 n_left_to_next; |
| 259 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 260 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 261 | while (n_left_from >= 4 && n_left_to_next >= 2) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 262 | { |
| 263 | u32 bi0, bi1; |
| 264 | vlib_buffer_t *b0, *b1; |
| 265 | u32 next0, next1; |
| 266 | ip6_header_t *ip0, *ip1; |
| 267 | ip6_hop_by_hop_header_t *hbh0, *hbh1; |
| 268 | u64 *copy_src0, *copy_dst0, *copy_src1, *copy_dst1; |
| 269 | u16 new_l0, new_l1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 270 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 271 | /* Prefetch next iteration. */ |
| 272 | { |
| 273 | vlib_buffer_t *p2, *p3; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 274 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 275 | p2 = vlib_get_buffer (vm, from[2]); |
| 276 | p3 = vlib_get_buffer (vm, from[3]); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 277 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 278 | vlib_prefetch_buffer_header (p2, LOAD); |
| 279 | vlib_prefetch_buffer_header (p3, LOAD); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 280 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 281 | CLIB_PREFETCH (p2->data - rewrite_length, |
| 282 | 2 * CLIB_CACHE_LINE_BYTES, STORE); |
| 283 | CLIB_PREFETCH (p3->data - rewrite_length, |
| 284 | 2 * CLIB_CACHE_LINE_BYTES, STORE); |
| 285 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 286 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 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]; |
| 290 | from += 2; |
| 291 | to_next += 2; |
| 292 | n_left_from -= 2; |
| 293 | n_left_to_next -= 2; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 294 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 295 | b0 = vlib_get_buffer (vm, bi0); |
| 296 | b1 = vlib_get_buffer (vm, bi1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 297 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 298 | /* $$$$$ Dual loop: process 2 x packets here $$$$$ */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 299 | ip0 = vlib_buffer_get_current (b0); |
| 300 | ip1 = vlib_buffer_get_current (b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 301 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 302 | /* Copy the ip header left by the required amount */ |
| 303 | copy_dst0 = (u64 *) (((u8 *) ip0) - rewrite_length); |
| 304 | copy_dst1 = (u64 *) (((u8 *) ip1) - rewrite_length); |
| 305 | copy_src0 = (u64 *) ip0; |
| 306 | copy_src1 = (u64 *) ip1; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 307 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 308 | copy_dst0[0] = copy_src0[0]; |
| 309 | copy_dst0[1] = copy_src0[1]; |
| 310 | copy_dst0[2] = copy_src0[2]; |
| 311 | copy_dst0[3] = copy_src0[3]; |
| 312 | copy_dst0[4] = copy_src0[4]; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 313 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 314 | copy_dst1[0] = copy_src1[0]; |
| 315 | copy_dst1[1] = copy_src1[1]; |
| 316 | copy_dst1[2] = copy_src1[2]; |
| 317 | copy_dst1[3] = copy_src1[3]; |
| 318 | copy_dst1[4] = copy_src1[4]; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 319 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 320 | vlib_buffer_advance (b0, -(word) rewrite_length); |
| 321 | vlib_buffer_advance (b1, -(word) rewrite_length); |
| 322 | ip0 = vlib_buffer_get_current (b0); |
| 323 | ip1 = vlib_buffer_get_current (b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 324 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 325 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 326 | hbh1 = (ip6_hop_by_hop_header_t *) (ip1 + 1); |
| 327 | /* $$$ tune, rewrite_length is a multiple of 8 */ |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 328 | clib_memcpy_fast (hbh0, rewrite, rewrite_length); |
| 329 | clib_memcpy_fast (hbh1, rewrite, rewrite_length); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 330 | /* Patch the protocol chain, insert the h-b-h (type 0) header */ |
| 331 | hbh0->protocol = ip0->protocol; |
| 332 | hbh1->protocol = ip1->protocol; |
| 333 | ip0->protocol = 0; |
| 334 | ip1->protocol = 0; |
| 335 | new_l0 = |
| 336 | clib_net_to_host_u16 (ip0->payload_length) + rewrite_length; |
| 337 | new_l1 = |
| 338 | clib_net_to_host_u16 (ip1->payload_length) + rewrite_length; |
| 339 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
| 340 | ip1->payload_length = clib_host_to_net_u16 (new_l1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 341 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 342 | /* Populate the (first) h-b-h list elt */ |
| 343 | next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP; |
| 344 | next1 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 345 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 346 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 347 | /* $$$$$ End of processing 2 x packets $$$$$ */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 348 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 349 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) |
| 350 | { |
| 351 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 352 | { |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 353 | ip6_add_hop_by_hop_trace_t *t = |
| 354 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 355 | t->next_index = next0; |
| 356 | } |
| 357 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
| 358 | { |
| 359 | ip6_add_hop_by_hop_trace_t *t = |
| 360 | vlib_add_trace (vm, node, b1, sizeof (*t)); |
| 361 | t->next_index = next1; |
| 362 | } |
| 363 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 364 | processed += 2; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 365 | /* verify speculative enqueues, maybe switch current next frame */ |
| 366 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, |
| 367 | to_next, n_left_to_next, |
| 368 | bi0, bi1, next0, next1); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 369 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 370 | while (n_left_from > 0 && n_left_to_next > 0) |
| 371 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 372 | u32 bi0; |
| 373 | vlib_buffer_t *b0; |
| 374 | u32 next0; |
| 375 | ip6_header_t *ip0; |
| 376 | ip6_hop_by_hop_header_t *hbh0; |
| 377 | u64 *copy_src0, *copy_dst0; |
| 378 | u16 new_l0; |
| 379 | |
| 380 | /* speculatively enqueue b0 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 381 | bi0 = from[0]; |
| 382 | to_next[0] = bi0; |
| 383 | from += 1; |
| 384 | to_next += 1; |
| 385 | n_left_from -= 1; |
| 386 | n_left_to_next -= 1; |
| 387 | |
| 388 | b0 = vlib_get_buffer (vm, bi0); |
| 389 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 390 | ip0 = vlib_buffer_get_current (b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 391 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 392 | /* Copy the ip header left by the required amount */ |
| 393 | copy_dst0 = (u64 *) (((u8 *) ip0) - rewrite_length); |
| 394 | copy_src0 = (u64 *) ip0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 395 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 396 | copy_dst0[0] = copy_src0[0]; |
| 397 | copy_dst0[1] = copy_src0[1]; |
| 398 | copy_dst0[2] = copy_src0[2]; |
| 399 | copy_dst0[3] = copy_src0[3]; |
| 400 | copy_dst0[4] = copy_src0[4]; |
| 401 | vlib_buffer_advance (b0, -(word) rewrite_length); |
| 402 | ip0 = vlib_buffer_get_current (b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 403 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 404 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 405 | /* $$$ tune, rewrite_length is a multiple of 8 */ |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 406 | clib_memcpy_fast (hbh0, rewrite, rewrite_length); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 407 | /* Patch the protocol chain, insert the h-b-h (type 0) header */ |
| 408 | hbh0->protocol = ip0->protocol; |
| 409 | ip0->protocol = 0; |
| 410 | new_l0 = |
| 411 | clib_net_to_host_u16 (ip0->payload_length) + rewrite_length; |
| 412 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 413 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 414 | /* Populate the (first) h-b-h list elt */ |
| 415 | next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 416 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 417 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) |
| 418 | && (b0->flags & VLIB_BUFFER_IS_TRACED))) |
| 419 | { |
| 420 | ip6_add_hop_by_hop_trace_t *t = |
| 421 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 422 | t->next_index = next0; |
| 423 | } |
| 424 | |
| 425 | processed++; |
| 426 | |
| 427 | /* verify speculative enqueue, maybe switch current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 428 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 429 | to_next, n_left_to_next, |
| 430 | bi0, next0); |
| 431 | } |
| 432 | |
| 433 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 434 | } |
| 435 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 436 | vlib_node_increment_counter (vm, ip6_add_hop_by_hop_node.index, |
| 437 | IP6_ADD_HOP_BY_HOP_ERROR_PROCESSED, processed); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 438 | return frame->n_vectors; |
| 439 | } |
| 440 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 441 | /* *INDENT-OFF* */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 442 | VLIB_REGISTER_NODE (ip6_add_hop_by_hop_node) = /* *INDENT-OFF* */ |
| 443 | { |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 444 | .name = |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 445 | "ip6-add-hop-by-hop",.vector_size = sizeof (u32),.format_trace = |
| 446 | format_ip6_add_hop_by_hop_trace,.type = |
| 447 | VLIB_NODE_TYPE_INTERNAL,.n_errors = |
| 448 | ARRAY_LEN (ip6_add_hop_by_hop_error_strings),.error_strings = |
| 449 | ip6_add_hop_by_hop_error_strings, |
| 450 | /* See ip/lookup.h */ |
| 451 | .n_next_nodes = IP6_HBYH_IOAM_INPUT_N_NEXT,.next_nodes = |
| 452 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 453 | #define _(s,n) [IP6_HBYH_IOAM_INPUT_NEXT_##s] = n, |
| 454 | foreach_ip6_hbyh_ioam_input_next |
rangan | f5bf6dd | 2016-04-15 17:31:46 +0530 | [diff] [blame] | 455 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 456 | } |
| 457 | ,}; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 458 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 459 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 460 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 461 | |
| 462 | /* The main h-b-h tracer was already invoked, no need to do much here */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 463 | typedef struct |
| 464 | { |
| 465 | u32 next_index; |
| 466 | } ip6_pop_hop_by_hop_trace_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 467 | |
| 468 | /* packet trace format function */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 469 | static u8 * |
| 470 | format_ip6_pop_hop_by_hop_trace (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 471 | { |
| 472 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 473 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 474 | ip6_pop_hop_by_hop_trace_t *t = |
| 475 | va_arg (*args, ip6_pop_hop_by_hop_trace_t *); |
| 476 | |
| 477 | s = format (s, "IP6_POP_HOP_BY_HOP: next index %d", t->next_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 478 | return s; |
| 479 | } |
| 480 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 481 | #ifndef CLIB_MARCH_VARIANT |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 482 | int |
| 483 | ip6_hbh_pop_register_option (u8 option, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 484 | int options (vlib_buffer_t * b, |
| 485 | ip6_header_t * ip, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 486 | ip6_hop_by_hop_option_t * opt)) |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 487 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 488 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 489 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 490 | ASSERT ((u32) option < ARRAY_LEN (hm->pop_options)); |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 491 | |
| 492 | /* Already registered */ |
| 493 | if (hm->pop_options[option]) |
| 494 | return (-1); |
| 495 | |
| 496 | hm->pop_options[option] = options; |
| 497 | |
| 498 | return (0); |
| 499 | } |
| 500 | |
| 501 | int |
| 502 | ip6_hbh_pop_unregister_option (u8 option) |
| 503 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 504 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 505 | |
Neale Ranns | 756cd94 | 2018-04-06 09:18:11 -0700 | [diff] [blame] | 506 | ASSERT ((u32) option < ARRAY_LEN (hm->pop_options)); |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 507 | |
| 508 | /* Not registered */ |
| 509 | if (!hm->pop_options[option]) |
| 510 | return (-1); |
| 511 | |
| 512 | hm->pop_options[option] = NULL; |
| 513 | return (0); |
| 514 | } |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 515 | #endif /* CLIB_MARCH_VARIANT */ |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 516 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 517 | extern vlib_node_registration_t ip6_pop_hop_by_hop_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 518 | |
| 519 | #define foreach_ip6_pop_hop_by_hop_error \ |
| 520 | _(PROCESSED, "Pkts w/ removed ip6 hop-by-hop options") \ |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 521 | _(NO_HOHO, "Pkts w/ no ip6 hop-by-hop options") \ |
| 522 | _(OPTION_FAILED, "ip6 pop hop-by-hop failed to process") |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 523 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 524 | typedef enum |
| 525 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 526 | #define _(sym,str) IP6_POP_HOP_BY_HOP_ERROR_##sym, |
| 527 | foreach_ip6_pop_hop_by_hop_error |
| 528 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 529 | IP6_POP_HOP_BY_HOP_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 530 | } ip6_pop_hop_by_hop_error_t; |
| 531 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 532 | static char *ip6_pop_hop_by_hop_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 533 | #define _(sym,string) string, |
| 534 | foreach_ip6_pop_hop_by_hop_error |
| 535 | #undef _ |
| 536 | }; |
| 537 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 538 | static inline void |
| 539 | ioam_pop_hop_by_hop_processing (vlib_main_t * vm, |
| 540 | ip6_header_t * ip0, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 541 | ip6_hop_by_hop_header_t * hbh0, |
| 542 | vlib_buffer_t * b) |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 543 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 544 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 545 | ip6_hop_by_hop_option_t *opt0, *limit0; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 546 | u8 type0; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 547 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 548 | if (!hbh0 || !ip0) |
| 549 | return; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 550 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 551 | opt0 = (ip6_hop_by_hop_option_t *) (hbh0 + 1); |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 552 | limit0 = (ip6_hop_by_hop_option_t *) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 553 | ((u8 *) hbh0 + ((hbh0->length + 1) << 3)); |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 554 | |
| 555 | /* Scan the set of h-b-h options, process ones that we understand */ |
| 556 | while (opt0 < limit0) |
| 557 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 558 | type0 = opt0->type; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 559 | switch (type0) |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 560 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 561 | case 0: /* Pad1 */ |
| 562 | opt0 = (ip6_hop_by_hop_option_t *) ((u8 *) opt0) + 1; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 563 | continue; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 564 | case 1: /* PadN */ |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 565 | break; |
| 566 | default: |
| 567 | if (hm->pop_options[type0]) |
| 568 | { |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 569 | if ((*hm->pop_options[type0]) (b, ip0, opt0) < 0) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 570 | { |
| 571 | vlib_node_increment_counter (vm, |
| 572 | ip6_pop_hop_by_hop_node.index, |
| 573 | IP6_POP_HOP_BY_HOP_ERROR_OPTION_FAILED, |
| 574 | 1); |
| 575 | } |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 576 | } |
| 577 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 578 | opt0 = |
| 579 | (ip6_hop_by_hop_option_t *) (((u8 *) opt0) + opt0->length + |
| 580 | sizeof (ip6_hop_by_hop_option_t)); |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 581 | } |
| 582 | } |
| 583 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 584 | VLIB_NODE_FN (ip6_pop_hop_by_hop_node) (vlib_main_t * vm, |
| 585 | vlib_node_runtime_t * node, |
| 586 | vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 587 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 588 | u32 n_left_from, *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 589 | ip_lookup_next_t next_index; |
| 590 | u32 processed = 0; |
| 591 | u32 no_header = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 592 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 593 | from = vlib_frame_vector_args (frame); |
| 594 | n_left_from = frame->n_vectors; |
| 595 | next_index = node->cached_next_index; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 596 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 597 | while (n_left_from > 0) |
| 598 | { |
| 599 | u32 n_left_to_next; |
| 600 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 601 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 602 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 603 | while (n_left_from >= 4 && n_left_to_next >= 2) |
| 604 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 605 | u32 bi0, bi1; |
| 606 | vlib_buffer_t *b0, *b1; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 607 | u32 next0, next1; |
| 608 | u32 adj_index0, adj_index1; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 609 | ip6_header_t *ip0, *ip1; |
| 610 | ip_adjacency_t *adj0, *adj1; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 611 | ip6_hop_by_hop_header_t *hbh0, *hbh1; |
| 612 | u64 *copy_dst0, *copy_src0, *copy_dst1, *copy_src1; |
| 613 | u16 new_l0, new_l1; |
| 614 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 615 | /* Prefetch next iteration. */ |
| 616 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 617 | vlib_buffer_t *p2, *p3; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 618 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 619 | p2 = vlib_get_buffer (vm, from[2]); |
| 620 | p3 = vlib_get_buffer (vm, from[3]); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 621 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 622 | vlib_prefetch_buffer_header (p2, LOAD); |
| 623 | vlib_prefetch_buffer_header (p3, LOAD); |
| 624 | |
| 625 | CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 626 | CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 627 | } |
| 628 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 629 | /* speculatively enqueue b0 and b1 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 630 | to_next[0] = bi0 = from[0]; |
| 631 | to_next[1] = bi1 = from[1]; |
| 632 | from += 2; |
| 633 | to_next += 2; |
| 634 | n_left_from -= 2; |
| 635 | n_left_to_next -= 2; |
| 636 | |
| 637 | b0 = vlib_get_buffer (vm, bi0); |
| 638 | b1 = vlib_get_buffer (vm, bi1); |
| 639 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 640 | /* $$$$$ Dual loop: process 2 x packets here $$$$$ */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 641 | ip0 = vlib_buffer_get_current (b0); |
| 642 | ip1 = vlib_buffer_get_current (b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 643 | adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; |
| 644 | adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; |
Neale Ranns | 107e7d4 | 2017-04-11 09:55:19 -0700 | [diff] [blame] | 645 | adj0 = adj_get (adj_index0); |
| 646 | adj1 = adj_get (adj_index1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 647 | |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 648 | next0 = adj0->lookup_next_index; |
| 649 | next1 = adj1->lookup_next_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 650 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 651 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 652 | hbh1 = (ip6_hop_by_hop_header_t *) (ip1 + 1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 653 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 654 | ioam_pop_hop_by_hop_processing (vm, ip0, hbh0, b0); |
| 655 | ioam_pop_hop_by_hop_processing (vm, ip1, hbh1, b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 656 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 657 | vlib_buffer_advance (b0, (hbh0->length + 1) << 3); |
| 658 | vlib_buffer_advance (b1, (hbh1->length + 1) << 3); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 659 | |
| 660 | new_l0 = clib_net_to_host_u16 (ip0->payload_length) - |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 661 | ((hbh0->length + 1) << 3); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 662 | new_l1 = clib_net_to_host_u16 (ip1->payload_length) - |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 663 | ((hbh1->length + 1) << 3); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 664 | |
| 665 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
| 666 | ip1->payload_length = clib_host_to_net_u16 (new_l1); |
| 667 | |
| 668 | ip0->protocol = hbh0->protocol; |
| 669 | ip1->protocol = hbh1->protocol; |
| 670 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 671 | copy_src0 = (u64 *) ip0; |
| 672 | copy_src1 = (u64 *) ip1; |
| 673 | copy_dst0 = copy_src0 + (hbh0->length + 1); |
| 674 | copy_dst0[4] = copy_src0[4]; |
| 675 | copy_dst0[3] = copy_src0[3]; |
| 676 | copy_dst0[2] = copy_src0[2]; |
| 677 | copy_dst0[1] = copy_src0[1]; |
| 678 | copy_dst0[0] = copy_src0[0]; |
| 679 | copy_dst1 = copy_src1 + (hbh1->length + 1); |
| 680 | copy_dst1[4] = copy_src1[4]; |
| 681 | copy_dst1[3] = copy_src1[3]; |
| 682 | copy_dst1[2] = copy_src1[2]; |
| 683 | copy_dst1[1] = copy_src1[1]; |
| 684 | copy_dst1[0] = copy_src1[0]; |
| 685 | processed += 2; |
| 686 | /* $$$$$ End of processing 2 x packets $$$$$ */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 687 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 688 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) |
| 689 | { |
| 690 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 691 | { |
| 692 | ip6_pop_hop_by_hop_trace_t *t = |
| 693 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 694 | t->next_index = next0; |
| 695 | } |
| 696 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
| 697 | { |
| 698 | ip6_pop_hop_by_hop_trace_t *t = |
| 699 | vlib_add_trace (vm, node, b1, sizeof (*t)); |
| 700 | t->next_index = next1; |
| 701 | } |
| 702 | } |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 703 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 704 | /* verify speculative enqueues, maybe switch current next frame */ |
| 705 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, |
| 706 | to_next, n_left_to_next, |
| 707 | bi0, bi1, next0, next1); |
| 708 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 709 | |
| 710 | while (n_left_from > 0 && n_left_to_next > 0) |
| 711 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 712 | u32 bi0; |
| 713 | vlib_buffer_t *b0; |
| 714 | u32 next0; |
| 715 | u32 adj_index0; |
| 716 | ip6_header_t *ip0; |
| 717 | ip_adjacency_t *adj0; |
| 718 | ip6_hop_by_hop_header_t *hbh0; |
| 719 | u64 *copy_dst0, *copy_src0; |
| 720 | u16 new_l0; |
| 721 | |
| 722 | /* speculatively enqueue b0 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 723 | bi0 = from[0]; |
| 724 | to_next[0] = bi0; |
| 725 | from += 1; |
| 726 | to_next += 1; |
| 727 | n_left_from -= 1; |
| 728 | n_left_to_next -= 1; |
| 729 | |
| 730 | b0 = vlib_get_buffer (vm, bi0); |
| 731 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 732 | ip0 = vlib_buffer_get_current (b0); |
| 733 | adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; |
Neale Ranns | 107e7d4 | 2017-04-11 09:55:19 -0700 | [diff] [blame] | 734 | adj0 = adj_get (adj_index0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 735 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 736 | /* Default use the next_index from the adjacency. */ |
| 737 | next0 = adj0->lookup_next_index; |
| 738 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 739 | /* Perfectly normal to end up here w/ out h-b-h header */ |
| 740 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 741 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 742 | /* TODO:Temporarily doing it here.. do this validation in end_of_path_cb */ |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 743 | ioam_pop_hop_by_hop_processing (vm, ip0, hbh0, b0); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 744 | /* Pop the trace data */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 745 | vlib_buffer_advance (b0, (hbh0->length + 1) << 3); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 746 | new_l0 = clib_net_to_host_u16 (ip0->payload_length) - |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 747 | ((hbh0->length + 1) << 3); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 748 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
| 749 | ip0->protocol = hbh0->protocol; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 750 | copy_src0 = (u64 *) ip0; |
| 751 | copy_dst0 = copy_src0 + (hbh0->length + 1); |
| 752 | copy_dst0[4] = copy_src0[4]; |
| 753 | copy_dst0[3] = copy_src0[3]; |
| 754 | copy_dst0[2] = copy_src0[2]; |
| 755 | copy_dst0[1] = copy_src0[1]; |
| 756 | copy_dst0[0] = copy_src0[0]; |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 757 | processed++; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 758 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 759 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) |
| 760 | && (b0->flags & VLIB_BUFFER_IS_TRACED))) |
| 761 | { |
| 762 | ip6_pop_hop_by_hop_trace_t *t = |
| 763 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 764 | t->next_index = next0; |
| 765 | } |
| 766 | |
| 767 | /* verify speculative enqueue, maybe switch current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 768 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 769 | to_next, n_left_to_next, |
| 770 | bi0, next0); |
| 771 | } |
| 772 | |
| 773 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 774 | } |
| 775 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 776 | vlib_node_increment_counter (vm, ip6_pop_hop_by_hop_node.index, |
| 777 | IP6_POP_HOP_BY_HOP_ERROR_PROCESSED, processed); |
| 778 | vlib_node_increment_counter (vm, ip6_pop_hop_by_hop_node.index, |
| 779 | IP6_POP_HOP_BY_HOP_ERROR_NO_HOHO, no_header); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 780 | return frame->n_vectors; |
| 781 | } |
| 782 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 783 | /* *INDENT-OFF* */ |
| 784 | VLIB_REGISTER_NODE (ip6_pop_hop_by_hop_node) = |
| 785 | { |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 786 | .name = |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 787 | "ip6-pop-hop-by-hop",.vector_size = sizeof (u32),.format_trace = |
| 788 | format_ip6_pop_hop_by_hop_trace,.type = |
| 789 | VLIB_NODE_TYPE_INTERNAL,.sibling_of = "ip6-lookup",.n_errors = |
| 790 | ARRAY_LEN (ip6_pop_hop_by_hop_error_strings),.error_strings = |
| 791 | ip6_pop_hop_by_hop_error_strings, |
| 792 | /* See ip/lookup.h */ |
| 793 | .n_next_nodes = 0,}; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 794 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 795 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 796 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 797 | #ifndef CLIB_MARCH_VARIANT |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 798 | static clib_error_t * |
| 799 | ip6_hop_by_hop_ioam_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 800 | { |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 801 | clib_error_t *error; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 802 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 803 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 804 | if ((error = vlib_call_init_function (vm, ip_main_init))) |
| 805 | return (error); |
| 806 | |
| 807 | if ((error = vlib_call_init_function (vm, ip6_lookup_init))) |
| 808 | return error; |
| 809 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 810 | hm->vlib_main = vm; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 811 | hm->vnet_main = vnet_get_main (); |
| 812 | hm->unix_time_0 = (u32) time (0); /* Store starting time */ |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 813 | hm->vlib_time_0 = vlib_time_now (vm); |
| 814 | hm->ioam_flag = IOAM_HBYH_MOD; |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 815 | clib_memset (hm->add_options, 0, sizeof (hm->add_options)); |
| 816 | clib_memset (hm->pop_options, 0, sizeof (hm->pop_options)); |
| 817 | clib_memset (hm->options_size, 0, sizeof (hm->options_size)); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 818 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 819 | vnet_classify_register_unformat_opaque_index_fn (unformat_opaque_ioam); |
| 820 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 821 | return (0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 822 | } |
| 823 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 824 | VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_init); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 825 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 826 | int |
| 827 | ip6_ioam_set_rewrite (u8 ** rwp, int has_trace_option, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 828 | int has_pot_option, int has_seqno_option) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 829 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 830 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 831 | u8 *rewrite = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 832 | u32 size, rnd_size; |
| 833 | ip6_hop_by_hop_header_t *hbh; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 834 | u8 *current; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 835 | u8 *trace_data_size = NULL; |
| 836 | u8 *pot_data_size = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 837 | |
| 838 | vec_free (*rwp); |
| 839 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 840 | if (has_trace_option == 0 && has_pot_option == 0) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 841 | return -1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 842 | |
| 843 | /* Work out how much space we need */ |
| 844 | size = sizeof (ip6_hop_by_hop_header_t); |
| 845 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 846 | //if (has_trace_option && hm->get_sizeof_options[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] != 0) |
| 847 | if (has_trace_option |
| 848 | && hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 849 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 850 | size += hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 851 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 852 | if (has_pot_option |
| 853 | && hm->add_options[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 854 | { |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 855 | size += hm->options_size[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 856 | } |
| 857 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 858 | if (has_seqno_option) |
| 859 | { |
| 860 | size += hm->options_size[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]; |
| 861 | } |
| 862 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 863 | /* Round to a multiple of 8 octets */ |
| 864 | rnd_size = (size + 7) & ~7; |
| 865 | |
| 866 | /* allocate it, zero-fill / pad by construction */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 867 | vec_validate (rewrite, rnd_size - 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 868 | |
| 869 | hbh = (ip6_hop_by_hop_header_t *) rewrite; |
| 870 | /* Length of header in 8 octet units, not incl first 8 octets */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 871 | hbh->length = (rnd_size >> 3) - 1; |
| 872 | current = (u8 *) (hbh + 1); |
| 873 | |
| 874 | if (has_trace_option |
| 875 | && hm->add_options[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 876 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 877 | if (0 != (hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST])) |
| 878 | { |
| 879 | trace_data_size = |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 880 | &hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 881 | if (0 == |
| 882 | hm->add_options[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] (current, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 883 | trace_data_size)) |
| 884 | current += *trace_data_size; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 885 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 886 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 887 | if (has_pot_option |
| 888 | && hm->add_options[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 889 | { |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 890 | pot_data_size = |
| 891 | &hm->options_size[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 892 | if (0 == |
| 893 | hm->add_options[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] (current, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 894 | pot_data_size)) |
| 895 | current += *pot_data_size; |
| 896 | } |
| 897 | |
| 898 | if (has_seqno_option && |
| 899 | (hm->add_options[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] != 0)) |
| 900 | { |
| 901 | if (0 == hm->add_options[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] (current, |
| 902 | & |
| 903 | (hm->options_size |
| 904 | [HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]))) |
| 905 | current += hm->options_size[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 906 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 907 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 908 | *rwp = rewrite; |
| 909 | return 0; |
| 910 | } |
| 911 | |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 912 | clib_error_t * |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 913 | clear_ioam_rewrite_fn (void) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 914 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 915 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 916 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 917 | vec_free (hm->rewrite); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 918 | hm->rewrite = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 919 | hm->has_trace_option = 0; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 920 | hm->has_pot_option = 0; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 921 | hm->has_seqno_option = 0; |
| 922 | hm->has_analyse_option = 0; |
| 923 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]) |
| 924 | hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] (NULL, 1); |
| 925 | |
| 926 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]) |
| 927 | hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] (NULL, 1); |
| 928 | |
| 929 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]) |
| 930 | { |
| 931 | hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] ((void *) |
| 932 | &hm->has_analyse_option, |
| 933 | 1); |
| 934 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 935 | |
| 936 | return 0; |
| 937 | } |
Shwetha | 20a64f5 | 2016-03-25 10:55:01 +0000 | [diff] [blame] | 938 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 939 | clib_error_t * |
| 940 | clear_ioam_rewrite_command_fn (vlib_main_t * vm, |
| 941 | unformat_input_t * input, |
| 942 | vlib_cli_command_t * cmd) |
Shwetha | 20a64f5 | 2016-03-25 10:55:01 +0000 | [diff] [blame] | 943 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 944 | return (clear_ioam_rewrite_fn ()); |
Shwetha | 20a64f5 | 2016-03-25 10:55:01 +0000 | [diff] [blame] | 945 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 946 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 947 | /*? |
| 948 | * This command clears all the In-band OAM (iOAM) features enabled by |
| 949 | * the '<em>set ioam rewrite</em>' command. Use '<em>show ioam summary</em>' to |
| 950 | * verify the configured settings cleared. |
| 951 | * |
| 952 | * @cliexpar |
| 953 | * Example of how to clear iOAM features: |
| 954 | * @cliexcmd{clear ioam rewrite} |
| 955 | ?*/ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 956 | /* *INDENT-OFF* */ |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 957 | VLIB_CLI_COMMAND (ip6_clear_ioam_rewrite_cmd, static) = { |
| 958 | .path = "clear ioam rewrite", |
| 959 | .short_help = "clear ioam rewrite", |
| 960 | .function = clear_ioam_rewrite_command_fn, |
| 961 | }; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 962 | /* *INDENT-ON* */ |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 963 | |
| 964 | clib_error_t * |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 965 | ip6_ioam_enable (int has_trace_option, int has_pot_option, |
| 966 | int has_seqno_option, int has_analyse_option) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 967 | { |
| 968 | int rv; |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 969 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 970 | rv = ip6_ioam_set_rewrite (&hm->rewrite, has_trace_option, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 971 | has_pot_option, has_seqno_option); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 972 | |
| 973 | switch (rv) |
| 974 | { |
| 975 | case 0: |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 976 | if (has_trace_option) |
| 977 | { |
| 978 | hm->has_trace_option = has_trace_option; |
| 979 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]) |
| 980 | hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] (NULL, |
| 981 | 0); |
| 982 | } |
| 983 | |
| 984 | if (has_pot_option) |
| 985 | { |
| 986 | hm->has_pot_option = has_pot_option; |
| 987 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]) |
| 988 | hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] (NULL, |
| 989 | 0); |
| 990 | } |
| 991 | hm->has_analyse_option = has_analyse_option; |
| 992 | if (has_seqno_option) |
| 993 | { |
| 994 | hm->has_seqno_option = has_seqno_option; |
| 995 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]) |
| 996 | { |
| 997 | hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] ((void *) |
| 998 | &has_analyse_option, |
| 999 | 0); |
| 1000 | } |
| 1001 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1002 | break; |
| 1003 | |
| 1004 | default: |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1005 | return clib_error_return_code (0, rv, 0, |
| 1006 | "ip6_ioam_set_rewrite returned %d", rv); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
| 1012 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1013 | static clib_error_t * |
rangan | 2375fbd | 2016-03-04 22:23:25 +0530 | [diff] [blame] | 1014 | ip6_set_ioam_rewrite_command_fn (vlib_main_t * vm, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1015 | unformat_input_t * input, |
| 1016 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1017 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1018 | int has_trace_option = 0; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 1019 | int has_pot_option = 0; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1020 | int has_seqno_option = 0; |
| 1021 | int has_analyse_option = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1022 | clib_error_t *rv = 0; |
| 1023 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1024 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 1025 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1026 | if (unformat (input, "trace")) |
| 1027 | has_trace_option = 1; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 1028 | else if (unformat (input, "pot")) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1029 | has_pot_option = 1; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1030 | else if (unformat (input, "seqno")) |
| 1031 | has_seqno_option = 1; |
| 1032 | else if (unformat (input, "analyse")) |
| 1033 | has_analyse_option = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1034 | else |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1035 | break; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1036 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1037 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1038 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1039 | rv = ip6_ioam_enable (has_trace_option, has_pot_option, |
| 1040 | has_seqno_option, has_analyse_option); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1041 | |
| 1042 | return rv; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1043 | } |
| 1044 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1045 | /*? |
| 1046 | * This command is used to enable In-band OAM (iOAM) features on IPv6. |
| 1047 | * '<em>trace</em>' is used to enable iOAM trace feature. '<em>pot</em>' is used to |
| 1048 | * enable the Proof Of Transit feature. '<em>ppc</em>' is used to indicate the |
| 1049 | * Per Packet Counter feature for Edge to Edge processing. '<em>ppc</em>' is |
| 1050 | * used to indicate if this node is an '<em>encap</em>' node (iOAM edge node |
| 1051 | * where packet enters iOAM domain), a '<em>decap</em>' node (iOAM edge node |
| 1052 | * where packet leaves iOAM domain) or '<em>none</em>' (iOAM node where packet |
| 1053 | * is in-transit through the iOAM domain). '<em>ppc</em>' can only be set if |
| 1054 | * '<em>trace</em>' or '<em>pot</em>' is enabled. |
| 1055 | * |
| 1056 | * Use '<em>clear ioam rewrite</em>' to disable all features enabled by this |
| 1057 | * command. Use '<em>show ioam summary</em>' to verify the configured settings. |
| 1058 | * |
| 1059 | * @cliexpar |
| 1060 | * Example of how to enable trace and pot with ppc set to encap: |
| 1061 | * @cliexcmd{set ioam rewrite trace pot ppc encap} |
| 1062 | ?*/ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1063 | /* *INDENT-OFF* */ |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1064 | VLIB_CLI_COMMAND (ip6_set_ioam_rewrite_cmd, static) = { |
| 1065 | .path = "set ioam rewrite", |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1066 | .short_help = "set ioam [trace] [pot] [seqno] [analyse]", |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1067 | .function = ip6_set_ioam_rewrite_command_fn, |
| 1068 | }; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1069 | /* *INDENT-ON* */ |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1070 | |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1071 | static clib_error_t * |
| 1072 | ip6_show_ioam_summary_cmd_fn (vlib_main_t * vm, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1073 | unformat_input_t * input, |
| 1074 | vlib_cli_command_t * cmd) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1075 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 1076 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1077 | u8 *s = 0; |
| 1078 | |
| 1079 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1080 | if (!is_zero_ip6_address (&hm->adj)) |
| 1081 | { |
| 1082 | s = format (s, " REWRITE FLOW CONFIGS - \n"); |
| 1083 | s = format (s, " Destination Address : %U\n", |
| 1084 | format_ip6_address, &hm->adj, sizeof (ip6_address_t)); |
| 1085 | s = |
| 1086 | format (s, " Flow operation : %d (%s)\n", |
| 1087 | hm->ioam_flag, |
| 1088 | (hm->ioam_flag == |
| 1089 | IOAM_HBYH_ADD) ? "Add" : ((hm->ioam_flag == |
| 1090 | IOAM_HBYH_MOD) ? "Mod" : "Pop")); |
| 1091 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1092 | else |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1093 | { |
| 1094 | s = format (s, " REWRITE FLOW CONFIGS - Not configured\n"); |
| 1095 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1096 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1097 | |
| 1098 | s = format (s, " TRACE OPTION - %d (%s)\n", |
| 1099 | hm->has_trace_option, |
| 1100 | (hm->has_trace_option ? "Enabled" : "Disabled")); |
| 1101 | if (hm->has_trace_option) |
| 1102 | s = |
| 1103 | format (s, |
| 1104 | "Try 'show ioam trace and show ioam-trace profile' for more information\n"); |
| 1105 | |
| 1106 | |
| 1107 | s = format (s, " POT OPTION - %d (%s)\n", |
| 1108 | hm->has_pot_option, |
| 1109 | (hm->has_pot_option ? "Enabled" : "Disabled")); |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 1110 | if (hm->has_pot_option) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1111 | s = |
| 1112 | format (s, |
| 1113 | "Try 'show ioam pot and show pot profile' for more information\n"); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1114 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1115 | s = format (s, " EDGE TO EDGE - SeqNo OPTION - %d (%s)\n", |
| 1116 | hm->has_seqno_option, |
| 1117 | hm->has_seqno_option ? "Enabled" : "Disabled"); |
| 1118 | if (hm->has_seqno_option) |
| 1119 | s = format (s, "Try 'show ioam e2e' for more information\n"); |
| 1120 | |
| 1121 | s = format (s, " iOAM Analyse OPTION - %d (%s)\n", |
| 1122 | hm->has_analyse_option, |
| 1123 | hm->has_analyse_option ? "Enabled" : "Disabled"); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1124 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1125 | vlib_cli_output (vm, "%v", s); |
| 1126 | vec_free (s); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1127 | return 0; |
| 1128 | } |
| 1129 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1130 | /*? |
| 1131 | * This command displays the current configuration data for In-band |
| 1132 | * OAM (iOAM). |
| 1133 | * |
| 1134 | * @cliexpar |
| 1135 | * Example to show the iOAM configuration: |
| 1136 | * @cliexstart{show ioam summary} |
| 1137 | * REWRITE FLOW CONFIGS - |
| 1138 | * Destination Address : ff02::1 |
| 1139 | * Flow operation : 2 (Pop) |
| 1140 | * TRACE OPTION - 1 (Enabled) |
| 1141 | * Try 'show ioam trace and show ioam-trace profile' for more information |
| 1142 | * POT OPTION - 1 (Enabled) |
| 1143 | * Try 'show ioam pot and show pot profile' for more information |
| 1144 | * EDGE TO EDGE - PPC OPTION - 1 (Encap) |
| 1145 | * @cliexend |
| 1146 | ?*/ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1147 | /* *INDENT-OFF* */ |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1148 | VLIB_CLI_COMMAND (ip6_show_ioam_run_cmd, static) = { |
| 1149 | .path = "show ioam summary", |
| 1150 | .short_help = "show ioam summary", |
| 1151 | .function = ip6_show_ioam_summary_cmd_fn, |
| 1152 | }; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1153 | /* *INDENT-ON* */ |
| 1154 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1155 | void |
| 1156 | vnet_register_ioam_end_of_path_callback (void *cb) |
| 1157 | { |
| 1158 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1159 | |
| 1160 | hm->ioam_end_of_path_cb = cb; |
| 1161 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1162 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 1163 | #endif /* CLIB_MARCH_VARIANT */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1164 | /* |
| 1165 | * fd.io coding-style-patch-verification: ON |
| 1166 | * |
| 1167 | * Local Variables: |
| 1168 | * eval: (c-set-style "gnu") |
| 1169 | * End: |
| 1170 | */ |