diff options
Diffstat (limited to 'src/plugins/srv6-mobile/gtp6_dt.c')
-rw-r--r-- | src/plugins/srv6-mobile/gtp6_dt.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/plugins/srv6-mobile/gtp6_dt.c b/src/plugins/srv6-mobile/gtp6_dt.c index cbd2327cc47..c4d4175e321 100644 --- a/src/plugins/srv6-mobile/gtp6_dt.c +++ b/src/plugins/srv6-mobile/gtp6_dt.c @@ -84,11 +84,31 @@ clb_format_srv6_end_m_gtp6_dt (u8 * s, va_list * args) return s; } +void +alloc_param_srv6_end_m_gtp6_dt (void **plugin_mem_p, const u32 fib_index, + const u32 local_fib_index, const u32 type) +{ + srv6_end_gtp6_dt_param_t *ls_mem; + ls_mem = clib_mem_alloc (sizeof *ls_mem); + clib_memset (ls_mem, 0, sizeof *ls_mem); + *plugin_mem_p = ls_mem; + + ls_mem->fib4_index = fib_table_find (FIB_PROTOCOL_IP4, fib_index); + ls_mem->fib6_index = fib_table_find (FIB_PROTOCOL_IP6, fib_index); + + if (type == SRV6_GTP6_DT6 || type == SRV6_GTP6_DT46) + { + ls_mem->local_fib_index = + fib_table_find (FIB_PROTOCOL_IP6, local_fib_index); + } + + ls_mem->type = type; +} + static uword clb_unformat_srv6_end_m_gtp6_dt (unformat_input_t * input, va_list * args) { void **plugin_mem_p = va_arg (*args, void **); - srv6_end_gtp6_dt_param_t *ls_mem; u32 fib_index = 0; u32 local_fib_index = 0; u32 type; @@ -111,22 +131,8 @@ clb_unformat_srv6_end_m_gtp6_dt (unformat_input_t * input, va_list * args) { return 0; } - - ls_mem = clib_mem_alloc_aligned_at_offset (sizeof *ls_mem, 0, 0, 1); - clib_memset (ls_mem, 0, sizeof *ls_mem); - *plugin_mem_p = ls_mem; - - ls_mem->fib4_index = fib_table_find (FIB_PROTOCOL_IP4, fib_index); - ls_mem->fib6_index = fib_table_find (FIB_PROTOCOL_IP6, fib_index); - - if (type == SRV6_GTP6_DT6 || type == SRV6_GTP6_DT46) - { - ls_mem->local_fib_index = - fib_table_find (FIB_PROTOCOL_IP6, local_fib_index); - } - - ls_mem->type = type; - + alloc_param_srv6_end_m_gtp6_dt (plugin_mem_p, fib_index, local_fib_index, + type); return 1; } @@ -179,7 +185,6 @@ srv6_end_m_gtp6_dt_init (vlib_main_t * vm) return 0; } -/* *INDENT-OFF* */ VNET_FEATURE_INIT (srv6_end_m_gtp6_dt, static) = { .arc_name = "ip6-unicast", @@ -188,7 +193,6 @@ VNET_FEATURE_INIT (srv6_end_m_gtp6_dt, static) = }; VLIB_INIT_FUNCTION (srv6_end_m_gtp6_dt_init); -/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON |