From 43d0ecbb1a1f7e1f72bf85441547b1678aed4350 Mon Sep 17 00:00:00 2001 From: Alberto Compagno Date: Thu, 23 Apr 2020 14:23:36 +0200 Subject: [HICN-603] Cleanup code for managing route - Remove old code to add and remove hicn route. Routes are now added only through the ip route commands/apis - Adjusted the cli to set the strategy for a particular prefix - Adjusted libtransport consumer and producer app creation - Adjusted sysrepo plugin. Added hicn enable and disable and removed old api related to hicn routes and hicn faces - Adjusted libhicnctrl. Only routes api and listener are now available for hicn-plugin Signed-off-by: Alberto Compagno Change-Id: Ib4f7f45ba0b99253d60a9da2b295d6e783e5cd51 --- libtransport/src/core/hicn_forwarder_interface.cc | 2 +- libtransport/src/core/hicn_forwarder_interface.h | 2 +- libtransport/src/core/hicn_vapi.c | 45 ++++++++++++++++------- libtransport/src/core/hicn_vapi.h | 6 ++- libtransport/src/core/vpp_forwarder_interface.cc | 2 +- libtransport/src/core/vpp_forwarder_interface.h | 1 + 6 files changed, 40 insertions(+), 18 deletions(-) (limited to 'libtransport/src') diff --git a/libtransport/src/core/hicn_forwarder_interface.cc b/libtransport/src/core/hicn_forwarder_interface.cc index 810daba3a..5a0faa360 100644 --- a/libtransport/src/core/hicn_forwarder_interface.cc +++ b/libtransport/src/core/hicn_forwarder_interface.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2017-2020 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: diff --git a/libtransport/src/core/hicn_forwarder_interface.h b/libtransport/src/core/hicn_forwarder_interface.h index 6969f4a6b..c4138c6c2 100644 --- a/libtransport/src/core/hicn_forwarder_interface.h +++ b/libtransport/src/core/hicn_forwarder_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2017-2020 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: diff --git a/libtransport/src/core/hicn_vapi.c b/libtransport/src/core/hicn_vapi.c index d19e36346..be556f3aa 100644 --- a/libtransport/src/core/hicn_vapi.c +++ b/libtransport/src/core/hicn_vapi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2017-2020 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -18,7 +18,6 @@ #ifdef __vpp__ #include - #include #define HICN_VPP_PLUGIN @@ -31,10 +30,10 @@ #include #include -#include #include #include #include +#include #include #include @@ -54,6 +53,7 @@ u8 *format_vl_api_address_union(u8 *s, va_list *args) { return NULL; } /*********************************************************************************/ DEFINE_VAPI_MSG_IDS_HICN_API_JSON +DEFINE_VAPI_MSG_IDS_IP_API_JSON static vapi_error_e register_prod_app_cb( vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv, bool is_last, @@ -184,7 +184,7 @@ int hicn_vapi_face_cons_del(vapi_ctx_t ctx, static vapi_error_e reigster_route_cb( vapi_ctx_t ctx, void *callback_ctx, vapi_error_e rv, bool is_last, - vapi_payload_hicn_api_route_nhops_add_reply *reply) { + vapi_payload_ip_route_add_del_reply *reply) { if (reply == NULL) return rv; return reply->retval; @@ -193,17 +193,36 @@ static vapi_error_e reigster_route_cb( int hicn_vapi_register_route(vapi_ctx_t ctx, hicn_producer_set_route_params *input_params) { vapi_lock(); - vapi_msg_hicn_api_route_nhops_add *msg = - vapi_alloc_hicn_api_route_nhops_add(ctx); + vapi_msg_ip_route_add_del *msg = vapi_alloc_ip_route_add_del(ctx, 1); + + msg->payload.is_add = 1; + if (ip46_address_is_ip4((ip46_address_t *)(input_params->prod_addr))) { + memcpy(&msg->payload.route.prefix.address.un.ip4, &input_params->prefix->address.v4, + sizeof(ip4_address_t)); + msg->payload.route.prefix.address.af = ADDRESS_IP4; + msg->payload.route.prefix.len = input_params->prefix->len; + } else { + memcpy(&msg->payload.route.prefix.address.un.ip6, &input_params->prefix->address.v6, + sizeof(ip6_address_t)); + msg->payload.route.prefix.address.af = ADDRESS_IP6; + msg->payload.route.prefix.len = input_params->prefix->len; + } + + msg->payload.route.paths[0].sw_if_index = ~0; + msg->payload.route.paths[0].table_id = 0; + if (ip46_address_is_ip4((ip46_address_t *)(input_params->prod_addr))) { + memcpy(&(msg->payload.route.paths[0].nh.address.ip4), input_params->prod_addr->v4.as_u8, sizeof(ip4_address_t)); + msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP4; + } + else{ + memcpy(&(msg->payload.route.paths[0].nh.address.ip6), input_params->prod_addr->v6.as_u8, sizeof(ip6_address_t)); + msg->payload.route.paths[0].proto = FIB_API_PATH_NH_PROTO_IP6; + } - fib_prefix_t prefix; - memcpy(&prefix.fp_addr, &input_params->prefix->address, - sizeof(ip46_address_t)); - prefix.fp_len = input_params->prefix->len; - msg->payload.face_ids[0] = input_params->face_id; - msg->payload.n_faces = 1; + msg->payload.route.paths[0].type = FIB_API_PATH_FLAG_NONE; + msg->payload.route.paths[0].flags = FIB_API_PATH_FLAG_NONE; - int ret = vapi_hicn_api_route_nhops_add(ctx, msg, reigster_route_cb, NULL); + int ret = vapi_ip_route_add_del(ctx, msg, reigster_route_cb, NULL); vapi_unlock(); return ret; diff --git a/libtransport/src/core/hicn_vapi.h b/libtransport/src/core/hicn_vapi.h index f2718e6f5..f5d61e7ef 100644 --- a/libtransport/src/core/hicn_vapi.h +++ b/libtransport/src/core/hicn_vapi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2017-2020 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -20,6 +20,8 @@ #ifdef __vpp__ + + #ifdef __cplusplus extern "C" { #endif @@ -57,7 +59,7 @@ typedef struct { typedef struct { ip_prefix_t* prefix; - uint32_t face_id; + ip_address_t* prod_addr; } hicn_producer_set_route_params; int hicn_vapi_register_prod_app( diff --git a/libtransport/src/core/vpp_forwarder_interface.cc b/libtransport/src/core/vpp_forwarder_interface.cc index 7b4298592..28a2560b3 100644 --- a/libtransport/src/core/vpp_forwarder_interface.cc +++ b/libtransport/src/core/vpp_forwarder_interface.cc @@ -167,7 +167,7 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) { params.prefix->address = addr.address; params.prefix->family = addr.family; params.prefix->len = addr.len; - params.face_id = face_id1_; + params.prod_addr = &producer_locator; int ret = hicn_vapi_register_route(VPPForwarderInterface::sock_, ¶ms); diff --git a/libtransport/src/core/vpp_forwarder_interface.h b/libtransport/src/core/vpp_forwarder_interface.h index eb759f8bc..bc83f476e 100644 --- a/libtransport/src/core/vpp_forwarder_interface.h +++ b/libtransport/src/core/vpp_forwarder_interface.h @@ -21,6 +21,7 @@ #include + #ifdef always_inline #undef always_inline #endif -- cgit 1.2.3-korg