diff options
Diffstat (limited to 'src/plugins/srv6-mobile/gtp6_d_di.c')
-rw-r--r-- | src/plugins/srv6-mobile/gtp6_d_di.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/plugins/srv6-mobile/gtp6_d_di.c b/src/plugins/srv6-mobile/gtp6_d_di.c index 14318562e84..94bc684161d 100644 --- a/src/plugins/srv6-mobile/gtp6_d_di.c +++ b/src/plugins/srv6-mobile/gtp6_d_di.c @@ -66,7 +66,7 @@ static u8 param_str[] = "<sr-prefix>/<sr-prefixlen> [nhtype <nhtype>]"; static u8 * clb_format_srv6_end_m_gtp6_d_di (u8 * s, va_list * args) { - srv6_end_gtp6_param_t *ls_mem = va_arg (*args, void *); + srv6_end_gtp6_d_param_t *ls_mem = va_arg (*args, void *); s = format (s, "SRv6 End gtp6.d Drop-in\n\t"); @@ -91,11 +91,24 @@ clb_format_srv6_end_m_gtp6_d_di (u8 * s, va_list * args) return s; } +void +alloc_param_srv6_end_m_gtp6_di (void **plugin_mem_p, const void *sr_prefix, + const u32 sr_prefixlen, const u8 nhtype) +{ + srv6_end_gtp6_d_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->sr_prefixlen = sr_prefixlen; + memcpy (&ls_mem->sr_prefix, sr_prefix, sizeof (ip6_address_t)); + ls_mem->nhtype = nhtype; +} + static uword clb_unformat_srv6_end_m_gtp6_d_di (unformat_input_t * input, va_list * args) { void **plugin_mem_p = va_arg (*args, void **); - srv6_end_gtp6_param_t *ls_mem; ip6_address_t sr_prefix; u32 sr_prefixlen = 0; u8 nhtype; @@ -125,13 +138,8 @@ clb_unformat_srv6_end_m_gtp6_d_di (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->sr_prefix = sr_prefix; - ls_mem->sr_prefixlen = sr_prefixlen; - ls_mem->nhtype = nhtype; + alloc_param_srv6_end_m_gtp6_di (plugin_mem_p, &sr_prefix, sr_prefixlen, + nhtype); return 1; } @@ -145,7 +153,7 @@ clb_creation_srv6_end_m_gtp6_d_di (ip6_sr_localsid_t * localsid) static int clb_removal_srv6_end_m_gtp6_d_di (ip6_sr_localsid_t * localsid) { - srv6_end_gtp6_param_t *ls_mem; + srv6_end_gtp6_d_param_t *ls_mem; ls_mem = localsid->plugin_mem; @@ -198,7 +206,6 @@ srv6_end_m_gtp6_d_di_init (vlib_main_t * vm) return 0; } -/* *INDENT-OFF* */ VNET_FEATURE_INIT (srv6_end_m_gtp6_d_di, static) = { .arc_name = "ip6-unicast", @@ -207,7 +214,6 @@ VNET_FEATURE_INIT (srv6_end_m_gtp6_d_di, static) = }; VLIB_INIT_FUNCTION (srv6_end_m_gtp6_d_di_init); -/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON |