X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fsrv6-mobile%2Fgtp4_dt.c;h=c4752b77557a2516f59acc86139af6c1325d5ea7;hb=68ac24428;hp=1f6bab1d0551150091829e347975a1945a5cc537;hpb=69f800fbfd559c8db21d064ceeca5f81fb1f0021;p=vpp.git diff --git a/src/plugins/srv6-mobile/gtp4_dt.c b/src/plugins/srv6-mobile/gtp4_dt.c index 1f6bab1d055..c4752b77557 100644 --- a/src/plugins/srv6-mobile/gtp4_dt.c +++ b/src/plugins/srv6-mobile/gtp4_dt.c @@ -90,11 +90,31 @@ clb_format_srv6_t_m_gtp4_dt (u8 * s, va_list * args) return s; } +void +alloc_param_srv6_t_m_gtp4_dt (void **plugin_mem_p, const u32 fib_index, + const u32 local_fib_index, const u8 type) +{ + srv6_t_gtp4_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_GTP4_DT6 || type == SRV6_GTP4_DT46) + { + ls_mem->local_fib_index = + fib_table_find (FIB_PROTOCOL_IP6, local_fib_index); + } + + ls_mem->type = type; +} + static uword clb_unformat_srv6_t_m_gtp4_dt (unformat_input_t * input, va_list * args) { void **plugin_mem_p = va_arg (*args, void **); - srv6_t_gtp4_dt_param_t *ls_mem; u32 fib_index = 0; u32 local_fib_index = 0; u32 type; @@ -118,20 +138,8 @@ clb_unformat_srv6_t_m_gtp4_dt (unformat_input_t * input, va_list * args) return 0; } - 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_GTP4_DT6 || type == SRV6_GTP4_DT46) - { - ls_mem->local_fib_index = - fib_table_find (FIB_PROTOCOL_IP6, local_fib_index); - } - - ls_mem->type = type; + alloc_param_srv6_t_m_gtp4_dt (plugin_mem_p, fib_index, local_fib_index, + type); return 1; }