aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2020-04-23 14:23:36 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2020-05-04 15:19:41 +0200
commit43d0ecbb1a1f7e1f72bf85441547b1678aed4350 (patch)
tree3da1d867acb6c8b735fbd76eeec51189b5d3996f /libtransport
parentc1b56d5861829a23289f42cecd716e681b520cf0 (diff)
[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 <acompagn+fdio@cisco.com> Change-Id: Ib4f7f45ba0b99253d60a9da2b295d6e783e5cd51
Diffstat (limited to 'libtransport')
-rw-r--r--libtransport/src/core/hicn_forwarder_interface.cc2
-rw-r--r--libtransport/src/core/hicn_forwarder_interface.h2
-rw-r--r--libtransport/src/core/hicn_vapi.c45
-rw-r--r--libtransport/src/core/hicn_vapi.h6
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.cc2
-rw-r--r--libtransport/src/core/vpp_forwarder_interface.h1
6 files changed, 40 insertions, 18 deletions
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 <hicn/transport/utils/log.h>
-
#include <core/hicn_vapi.h>
#define HICN_VPP_PLUGIN
@@ -31,10 +30,10 @@
#include <vlibmemory/api.h>
#include <vppinfra/error.h>
-#include <vnet/fib/fib_types.h>
#include <vnet/ip/format.h>
#include <vnet/ip/ip4_packet.h>
#include <vnet/ip/ip6_packet.h>
+#include <vapi/ip.api.vapi.h>
#include <vapi/hicn.api.vapi.h>
#include <vpp_plugins/hicn/error.h>
@@ -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_, &params);
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 <hicn/transport/core/prefix.h>
+
#ifdef always_inline
#undef always_inline
#endif