diff options
author | Damjan Marion <damarion@cisco.com> | 2021-03-10 14:35:28 +0100 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2021-03-11 17:30:34 +0000 |
commit | a31698bb7401f6e2389c0e805bf280ae52278524 (patch) | |
tree | 05d7940ef2e137cf885941f682a0b39402adb424 /src/vlib/node_format.c | |
parent | aa479bb91d0c75b603e6c8828e6fffa0c70c5a0c (diff) |
vlib: refactor node function variants
It allows default variant selection from startup.conf
Type: improvement
Change-Id: Idff95e12dd0c105dab7c905089548b05a6e974e0
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/node_format.c')
-rw-r--r-- | src/vlib/node_format.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/vlib/node_format.c b/src/vlib/node_format.c index 822a8f64e1a..54cea9ff804 100644 --- a/src/vlib/node_format.c +++ b/src/vlib/node_format.c @@ -178,6 +178,27 @@ format_vlib_cpu_time (u8 * s, va_list * va) return format (s, "%U", format_vlib_time, vm, dt); } +uword +unformat_vlib_node_variant (unformat_input_t *input, va_list *args) +{ + vlib_main_t *vm = vlib_get_main (); + u32 *march_variant = va_arg (*args, u32 *); + uword *p; + u8 *str = 0; + + if (unformat (input, "%s", &str) == 0) + return 0; + + p = hash_get (vm->node_main.node_fn_march_variant_by_suffix, str); + + vec_free (str); + + if (p) + *march_variant = p[0]; + + return p ? 1 : 0; +} + /* * fd.io coding-style-patch-verification: ON * |