From b4243aaa7ac53075a3d02e4e1fed4435250e8078 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Wed, 14 Jun 2017 14:39:42 +0200 Subject: Add VAT handlers for LISP-GPE API Change-Id: Id1139533c41cabef48394b5d79750608e0b74179 Signed-off-by: Filip Tehlar --- src/vnet/lisp-gpe/lisp_gpe_api.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/vnet/lisp-gpe/lisp_gpe_api.c') diff --git a/src/vnet/lisp-gpe/lisp_gpe_api.c b/src/vnet/lisp-gpe/lisp_gpe_api.c index cb18b4bb980..f026e8b08e8 100644 --- a/src/vnet/lisp-gpe/lisp_gpe_api.c +++ b/src/vnet/lisp-gpe/lisp_gpe_api.c @@ -441,26 +441,33 @@ static void vl_api_gpe_add_del_native_fwd_rpath_t_handler (vl_api_gpe_add_del_native_fwd_rpath_t * mp) { - vl_api_gpe_add_del_fwd_entry_reply_t *rmp; + vl_api_gpe_add_del_native_fwd_rpath_reply_t *rmp; vnet_gpe_native_fwd_rpath_args_t _a, *a = &_a; int rv = 0; memset (a, 0, sizeof (a[0])); if (mp->is_ip4) - clib_memcpy (&a->rpath.frp_addr, mp->nh_addr, sizeof (ip4_address_t)); + clib_memcpy (&a->rpath.frp_addr.ip4, mp->nh_addr, sizeof (ip4_address_t)); else - clib_memcpy (&a->rpath.frp_addr, mp->nh_addr, sizeof (ip6_address_t)); + clib_memcpy (&a->rpath.frp_addr.ip6, mp->nh_addr, sizeof (ip6_address_t)); a->is_add = mp->is_add; a->rpath.frp_proto = mp->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6; a->rpath.frp_fib_index = fib_table_find (a->rpath.frp_proto, clib_net_to_host_u32 (mp->table_id)); + if (~0 == a->rpath.frp_fib_index) + { + rv = VNET_API_ERROR_INVALID_VALUE; + goto done; + } + a->rpath.frp_sw_if_index = clib_net_to_host_u32 (mp->nh_sw_if_index); a->rpath.frp_weight = 1; rv = vnet_gpe_add_del_native_fwd_rpath (a); +done: REPLY_MACRO (VL_API_GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY); } @@ -477,8 +484,11 @@ gpe_native_fwd_rpaths_copy (vl_api_gpe_native_fwd_rpath_t * dst, dst[i].fib_index = e->frp_fib_index; dst[i].nh_sw_if_index = e->frp_sw_if_index; dst[i].is_ip4 = is_ip4; - clib_memcpy (&dst[i].nh_addr, &e->frp_addr, - is_ip4 ? sizeof (ip4_address_t) : sizeof (ip6_address_t)); + if (is_ip4) + clib_memcpy (&dst[i].nh_addr, &e->frp_addr.ip4, sizeof (ip4_address_t)); + else + clib_memcpy (&dst[i].nh_addr, &e->frp_addr.ip6, sizeof (ip6_address_t)); + i++; } } @@ -513,15 +523,17 @@ vl_api_gpe_native_fwd_rpaths_get_t_handler (vl_api_gpe_native_fwd_rpaths_get_t u32 size = 0; int rv = 0; - size = vec_len (lgm->native_fwd_rpath[mp->is_ip4]) + u8 rpath_index = mp->is_ip4 ? 0 : 1; + + size = vec_len (lgm->native_fwd_rpath[rpath_index]) * sizeof (vl_api_gpe_native_fwd_rpath_t); /* *INDENT-OFF* */ REPLY_MACRO4 (VL_API_GPE_NATIVE_FWD_RPATHS_GET_REPLY, size, { - rmp->count = vec_len (lgm->native_fwd_rpath[mp->is_ip4]); + rmp->count = vec_len (lgm->native_fwd_rpath[rpath_index]); gpe_native_fwd_rpaths_copy (rmp->entries, - lgm->native_fwd_rpath[mp->is_ip4], + lgm->native_fwd_rpath[rpath_index], mp->is_ip4); gpe_native_fwd_rpaths_get_reply_t_host_to_net (rmp); }); -- cgit 1.2.3-korg