summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Kotucek <pkotucek@cisco.com>2016-12-21 15:50:08 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2016-12-22 16:33:14 +0000
commitabea9664983b723023e692d77fd4fe3ca29c1e34 (patch)
treeca7751bcdfd7c456cb165c0cc53bd7afbe5d0294
parentcfb7be88783d443a013d904de6d69a1ef169c5d2 (diff)
API refactoring : lisp-gpe
Change-Id: I47b38a9b5ae8ead2a161402974205982669851a7 Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
-rw-r--r--vnet/Makefile.am13
-rw-r--r--vnet/vnet/lisp-cp/lisp.api22
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe.api143
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe_api.c304
-rw-r--r--vnet/vnet/vnet_all_api_h.h1
-rw-r--r--vpp-api/java/Makefile.am4
-rw-r--r--vpp/vpp-api/api.c105
-rw-r--r--vpp/vpp-api/vpe.api101
8 files changed, 461 insertions, 232 deletions
diff --git a/vnet/Makefile.am b/vnet/Makefile.am
index c3ba6e72fd8..ef6a6e7ed49 100644
--- a/vnet/Makefile.am
+++ b/vnet/Makefile.am
@@ -49,7 +49,9 @@ BUILT_SOURCES = \
vnet/ipsec-gre/ipsec_gre.api.h \
vnet/ipsec-gre/ipsec_gre.api.json \
vnet/lisp-cp/lisp.api.h \
- vnet/lisp-cp/lisp.api.json
+ vnet/lisp-cp/lisp.api.json \
+ vnet/lisp-gpe/lisp_gpe.api.h \
+ vnet/lisp-gpe/lisp_gpe.api.json
libvnet_la_SOURCES =
libvnetplugin_la_SOURCES =
@@ -621,14 +623,16 @@ libvnet_la_SOURCES += \
vnet/lisp-gpe/lisp_gpe_fwd_entry.c \
vnet/lisp-gpe/lisp_gpe_tenant.c \
vnet/lisp-gpe/interface.c \
- vnet/lisp-gpe/decap.c
+ vnet/lisp-gpe/decap.c \
+ vnet/lisp-gpe/lisp_gpe_api.c
nobase_include_HEADERS += \
vnet/lisp-gpe/lisp_gpe.h \
vnet/lisp-gpe/lisp_gpe_fwd_entry.h \
vnet/lisp-gpe/lisp_gpe_tenant.h \
vnet/lisp-gpe/lisp_gpe_packet.h \
- vnet/lisp-gpe/lisp_gpe_error.def
+ vnet/lisp-gpe/lisp_gpe_error.def \
+ vnet/lisp-gpe/lisp_gpe.api.h
if ENABLE_TESTS
TESTS += test_test
@@ -992,7 +996,8 @@ api_DATA = \
vnet/bfd/bfd.api.json \
vnet/ipsec/ipsec.api.json \
vnet/ipsec-gre/ipsec_gre.api.json \
- vnet/lisp-cp/lisp.api.json
+ vnet/lisp-cp/lisp.api.json \
+ vnet/lisp-gpe/lisp_gpe.api.json
# The actual %.api.h rule is in .../build-data/packages/suffix-rules.mk
# and requires a symbolic link at the top of the vnet source tree
diff --git a/vnet/vnet/lisp-cp/lisp.api b/vnet/vnet/lisp-cp/lisp.api
index 26fa9bbeff6..20c17aa39b1 100644
--- a/vnet/vnet/lisp-cp/lisp.api
+++ b/vnet/vnet/lisp-cp/lisp.api
@@ -174,28 +174,6 @@ define lisp_add_del_map_resolver_reply
i32 retval;
};
-/** \brief enable or disable lisp-gpe protocol
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_en - enable protocol if non-zero, else disable
-*/
-define lisp_gpe_enable_disable
-{
- u32 client_index;
- u32 context;
- u8 is_en;
-};
-
-/** \brief Reply for gpe enable/disable
- @param context - returned sender context, to match reply w/ request
- @param retval - return code
-*/
-define lisp_gpe_enable_disable_reply
-{
- u32 context;
- i32 retval;
-};
-
/** \brief enable or disable LISP feature
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe.api b/vnet/vnet/lisp-gpe/lisp_gpe.api
new file mode 100644
index 00000000000..3956b97d6a1
--- /dev/null
+++ b/vnet/vnet/lisp-gpe/lisp_gpe.api
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2015-2016 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** \brief add or delete lisp gpe tunnel
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_add - add address if non-zero, else delete
+ @param eid_type -
+ 0 : ipv4
+ 1 : ipv6
+ 2 : mac
+ @param rmt_eid - remote eid
+ @param lcl_eid - local eid
+ @param rmt_len - remote prefix len
+ @param lcl_len - local prefix len
+ @param vni - virtual network identifier
+ @param dp_table - vrf/bridge domain id
+ @param loc_num - number of locators
+ @param lcl_locs - array of local locators
+ @param rmt_locs - array of remote locators
+ @param action - negative action when 0 locators configured
+*/
+define lisp_gpe_add_del_fwd_entry
+{
+ u32 client_index;
+ u32 context;
+ u8 is_add;
+ u8 eid_type;
+ u8 rmt_eid[16];
+ u8 lcl_eid[16];
+ u8 rmt_len;
+ u8 lcl_len;
+ u32 vni;
+ u32 dp_table;
+ u32 loc_num;
+ u8 lcl_locs[loc_num];
+ u8 rmt_locs[loc_num];
+ u8 action;
+};
+
+/** \brief Reply for gpe_fwd_entry add/del
+ @param context - returned sender context, to match reply w/ request
+ @param retval - return code
+*/
+define lisp_gpe_add_del_fwd_entry_reply
+{
+ u32 context;
+ i32 retval;
+};
+
+/** \brief enable or disable lisp-gpe protocol
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_en - enable protocol if non-zero, else disable
+*/
+define lisp_gpe_enable_disable
+{
+ u32 client_index;
+ u32 context;
+ u8 is_en;
+};
+
+/** \brief Reply for gpe enable/disable
+ @param context - returned sender context, to match reply w/ request
+ @param retval - return code
+*/
+define lisp_gpe_enable_disable_reply
+{
+ u32 context;
+ i32 retval;
+};
+
+/** \brief add or delete gpe_iface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_add - add address if non-zero, else delete
+*/
+define lisp_gpe_add_del_iface
+{
+ u32 client_index;
+ u32 context;
+ u8 is_add;
+ u8 is_l2;
+ u32 dp_table;
+ u32 vni;
+};
+
+/** \brief Reply for gpe_iface add/del
+ @param context - returned sender context, to match reply w/ request
+ @param retval - return code
+*/
+define lisp_gpe_add_del_iface_reply
+{
+ u32 context;
+ i32 retval;
+};
+
+define lisp_gpe_tunnel_details
+{
+ u32 context;
+ u32 tunnels;
+ u8 is_ipv6;
+ u8 source_ip[16];
+ u8 destination_ip[16];
+ u32 encap_fib_id;
+ u32 decap_fib_id;
+ u32 dcap_next;
+ u8 lisp_ver;
+ u8 next_protocol;
+ u8 flags;
+ u8 ver_res;
+ u8 res;
+ u32 iid;
+};
+
+/** \brief Request for gpe tunnel summary status
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ */
+define lisp_gpe_tunnel_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+/*
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
+ \ No newline at end of file
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe_api.c b/vnet/vnet/lisp-gpe/lisp_gpe_api.c
new file mode 100644
index 00000000000..176ded501cd
--- /dev/null
+++ b/vnet/vnet/lisp-gpe/lisp_gpe_api.c
@@ -0,0 +1,304 @@
+/*
+ *------------------------------------------------------------------
+ * lisp_gpe_api.c - lisp_gpe api
+ *
+ * Copyright (c) 2016 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <vnet/vnet.h>
+#include <vlibmemory/api.h>
+
+#include <vnet/interface.h>
+#include <vnet/api_errno.h>
+#include <vnet/lisp-gpe/lisp_gpe.h>
+#include <vnet/lisp-gpe/lisp_gpe_fwd_entry.h>
+#include <vnet/lisp-gpe/lisp_gpe_tenant.h>
+
+#include <vnet/vnet_msg_enum.h>
+
+#define vl_typedefs /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_typedefs
+
+#define vl_endianfun /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_endianfun
+
+/* instantiate all the print functions we know about */
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+#define vl_printfun
+#include <vnet/vnet_all_api_h.h>
+#undef vl_printfun
+
+#include <vlibapi/api_helper_macros.h>
+
+#define foreach_vpe_api_msg \
+_(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry) \
+_(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
+_(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
+_(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump)
+
+/** Used for transferring locators via VPP API */
+/* *INDENT-OFF* */
+typedef CLIB_PACKED (struct {
+ u8 is_ip4; /**< is locator an IPv4 address */
+ u8 priority; /**< locator priority */
+ u8 weight; /**< locator weight */
+ u8 addr[16]; /**< IPv4/IPv6 address */
+}) rloc_t;
+/* *INDENT-ON* */
+
+static locator_pair_t *
+unformat_lisp_loc_pairs (void *lcl_locs, void *rmt_locs, u32 rloc_num)
+{
+ u32 i;
+ locator_pair_t *pairs = 0, pair;
+ rloc_t *r;
+
+ for (i = 0; i < rloc_num; i++)
+ {
+ /* local locator */
+ r = &((rloc_t *) lcl_locs)[i];
+ memset (&pair.lcl_loc, 0, sizeof (pair.lcl_loc));
+ ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+
+ /* remote locators */
+ r = &((rloc_t *) rmt_locs)[i];
+ memset (&pair.rmt_loc, 0, sizeof (pair.rmt_loc));
+ ip_address_set (&pair.rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+
+ pair.priority = r->priority;
+ pair.weight = r->weight;
+
+ vec_add1 (pairs, pair);
+ }
+ return pairs;
+}
+
+static int
+unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
+ u8 len)
+{
+ switch (type)
+ {
+ case 0: /* ipv4 */
+ gid_address_type (dst) = GID_ADDR_IP_PREFIX;
+ gid_address_ip_set (dst, src, IP4);
+ gid_address_ippref_len (dst) = len;
+ ip_prefix_normalize (&gid_address_ippref (dst));
+ break;
+ case 1: /* ipv6 */
+ gid_address_type (dst) = GID_ADDR_IP_PREFIX;
+ gid_address_ip_set (dst, src, IP6);
+ gid_address_ippref_len (dst) = len;
+ ip_prefix_normalize (&gid_address_ippref (dst));
+ break;
+ case 2: /* l2 mac */
+ gid_address_type (dst) = GID_ADDR_MAC;
+ clib_memcpy (&gid_address_mac (dst), src, 6);
+ break;
+ default:
+ /* unknown type */
+ return VNET_API_ERROR_INVALID_VALUE;
+ }
+
+ gid_address_vni (dst) = vni;
+
+ return 0;
+}
+
+static void
+ vl_api_lisp_gpe_add_del_fwd_entry_t_handler
+ (vl_api_lisp_gpe_add_del_fwd_entry_t * mp)
+{
+ vl_api_lisp_gpe_add_del_fwd_entry_reply_t *rmp;
+ vnet_lisp_gpe_add_del_fwd_entry_args_t _a, *a = &_a;
+ locator_pair_t *pairs = 0;
+ int rv = 0;
+
+ memset (a, 0, sizeof (a[0]));
+
+ rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
+ mp->rmt_eid, mp->rmt_len);
+ rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
+ mp->lcl_eid, mp->lcl_len);
+
+ pairs = unformat_lisp_loc_pairs (mp->lcl_locs, mp->rmt_locs, mp->loc_num);
+
+ if (rv || 0 == pairs)
+ goto send_reply;
+
+ a->is_add = mp->is_add;
+ a->locator_pairs = pairs;
+ a->dp_table = mp->dp_table;
+ a->vni = mp->vni;
+ a->action = mp->action;
+
+ rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
+ vec_free (pairs);
+send_reply:
+ REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
+}
+
+static void
+vl_api_lisp_gpe_enable_disable_t_handler (vl_api_lisp_gpe_enable_disable_t *
+ mp)
+{
+ vl_api_lisp_gpe_enable_disable_reply_t *rmp;
+ int rv = 0;
+ vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a;
+
+ a->is_en = mp->is_en;
+ vnet_lisp_gpe_enable_disable (a);
+
+ REPLY_MACRO (VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
+}
+
+static void
+vl_api_lisp_gpe_add_del_iface_t_handler (vl_api_lisp_gpe_add_del_iface_t * mp)
+{
+ vl_api_lisp_gpe_add_del_iface_reply_t *rmp;
+ int rv = 0;
+
+ if (mp->is_l2)
+ {
+ if (mp->is_add)
+ {
+ if (~0 ==
+ lisp_gpe_tenant_l2_iface_add_or_lock (mp->vni, mp->dp_table))
+ rv = 1;
+ }
+ else
+ lisp_gpe_tenant_l2_iface_unlock (mp->vni);
+ }
+ else
+ {
+ if (mp->is_add)
+ {
+ if (~0 ==
+ lisp_gpe_tenant_l3_iface_add_or_lock (mp->vni, mp->dp_table))
+ rv = 1;
+ }
+ else
+ lisp_gpe_tenant_l3_iface_unlock (mp->vni);
+ }
+
+ REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
+}
+
+static void
+send_lisp_gpe_fwd_entry_details (lisp_gpe_fwd_entry_t * lfe,
+ unix_shared_memory_queue_t * q, u32 context)
+{
+ vl_api_lisp_gpe_tunnel_details_t *rmp;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs (VL_API_LISP_GPE_TUNNEL_DETAILS);
+
+ rmp->tunnels = lfe - lgm->lisp_fwd_entry_pool;
+
+ rmp->is_ipv6 = ip_prefix_version (&(lfe->key->rmt.ippref)) == IP6 ? 1 : 0;
+ ip_address_copy_addr (rmp->source_ip,
+ &ip_prefix_addr (&(lfe->key->rmt.ippref)));
+ ip_address_copy_addr (rmp->destination_ip,
+ &ip_prefix_addr (&(lfe->key->rmt.ippref)));
+
+ rmp->encap_fib_id = htonl (0);
+ rmp->decap_fib_id = htonl (lfe->eid_fib_index);
+ rmp->iid = htonl (lfe->key->vni);
+ rmp->context = context;
+
+ vl_msg_api_send_shmem (q, (u8 *) & rmp);
+}
+
+static void
+vl_api_lisp_gpe_tunnel_dump_t_handler (vl_api_lisp_gpe_tunnel_dump_t * mp)
+{
+ unix_shared_memory_queue_t *q = NULL;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
+ lisp_gpe_fwd_entry_t *lfe = NULL;
+
+ if (pool_elts (lgm->lisp_fwd_entry_pool) == 0)
+ {
+ return;
+ }
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ {
+ return;
+ }
+
+ /* *INDENT-OFF* */
+ pool_foreach(lfe, lgm->lisp_fwd_entry_pool,
+ ({
+ send_lisp_gpe_fwd_entry_details(lfe, q, mp->context);
+ }));
+ /* *INDENT-ON* */
+}
+
+/*
+ * lisp_gpe_api_hookup
+ * Add vpe's API message handlers to the table.
+ * vlib has alread mapped shared memory and
+ * added the client registration handlers.
+ * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
+ */
+#define vl_msg_name_crc_list
+#include <vnet/vnet_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (api_main_t * am)
+{
+#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
+ foreach_vl_msg_name_crc_lisp_gpe;
+#undef _
+}
+
+static clib_error_t *
+lisp_gpe_api_hookup (vlib_main_t * vm)
+{
+ api_main_t *am = &api_main;
+
+#define _(N,n) \
+ vl_msg_api_set_handlers(VL_API_##N, #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_vpe_api_msg;
+#undef _
+
+ /*
+ * Set up the (msg_name, crc, message-id) table
+ */
+ setup_message_id_table (am);
+
+ return 0;
+}
+
+VLIB_API_INIT_FUNCTION (lisp_gpe_api_hookup);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/vnet_all_api_h.h b/vnet/vnet/vnet_all_api_h.h
index 4143fad1620..1b4d6c45ef2 100644
--- a/vnet/vnet/vnet_all_api_h.h
+++ b/vnet/vnet/vnet_all_api_h.h
@@ -46,6 +46,7 @@
#include <vnet/ipsec/ipsec.api.h>
#include <vnet/ipsec-gre/ipsec_gre.api.h>
#include <vnet/lisp-cp/lisp.api.h>
+#include <vnet/lisp-gpe/lisp_gpe.api.h>
/*
* fd.io coding-style-patch-verification: ON
diff --git a/vpp-api/java/Makefile.am b/vpp-api/java/Makefile.am
index 9b2081ed4e2..e07e038a396 100644
--- a/vpp-api/java/Makefile.am
+++ b/vpp-api/java/Makefile.am
@@ -99,7 +99,8 @@ jvpp-core/io_fd_vpp_jvpp_core_JVppCoreImpl.h: \
$(prefix)/../vnet/vnet/bfd.api.json \
$(prefix)/../vnet/vnet/ipsec.api.json \
$(prefix)/../vnet/vnet/ipsec_gre.api.json \
- $(prefix)/../vnet/vnet/lisp.api.json
+ $(prefix)/../vnet/vnet/lisp.api.json \
+ $(prefix)/../vnet/vnet/lisp_gpe.api.json
cp -rf @srcdir@/jvpp-core/* -t jvpp-core/
mkdir -p jvpp-core/target
cd jvpp-core \
@@ -123,6 +124,7 @@ jvpp-core/io_fd_vpp_jvpp_core_JVppCoreImpl.h: \
$(prefix)/../vnet/vnet/ipsec.api.json \
$(prefix)/../vnet/vnet/ipsec_gre.api.json \
$(prefix)/../vnet/vnet/lisp.api.json \
+ $(prefix)/../vnet/vnet/lisp_gpe.api.json \
&& cp -rf types dto future callfacade callback notification *.java -t $(packagedir_jvpp_core) \
&& rm -rf types dto future callfacade callback notification *.java
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 2e080d6667a..01022608ac6 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -72,9 +72,6 @@
#include <vnet/vxlan/vxlan.h>
#include <vnet/l2/l2_vtr.h>
#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/lisp-gpe/lisp_gpe.h>
-#include <vnet/lisp-gpe/lisp_gpe_fwd_entry.h>
-#include <vnet/lisp-gpe/lisp_gpe_tenant.h>
#include <vnet/map/map.h>
#include <vnet/cop/cop.h>
#include <vnet/ip/ip6_hop_by_hop.h>
@@ -187,9 +184,6 @@ _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
_(GET_NODE_GRAPH, get_node_graph) \
_(IOAM_ENABLE, ioam_enable) \
_(IOAM_DISABLE, ioam_disable) \
-_(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
-_(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
-_(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
_(POLICER_ADD_DEL, policer_add_del) \
_(POLICER_DUMP, policer_dump) \
@@ -2980,105 +2974,6 @@ static void vl_api_vxlan_gpe_tunnel_dump_t_handler
}
static void
-vl_api_lisp_gpe_enable_disable_t_handler (vl_api_lisp_gpe_enable_disable_t *
- mp)
-{
- vl_api_lisp_gpe_enable_disable_reply_t *rmp;
- int rv = 0;
- vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a;
-
- a->is_en = mp->is_en;
- vnet_lisp_gpe_enable_disable (a);
-
- REPLY_MACRO (VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
-}
-
-static void
-vl_api_lisp_gpe_add_del_iface_t_handler (vl_api_lisp_gpe_add_del_iface_t * mp)
-{
- vl_api_lisp_gpe_add_del_iface_reply_t *rmp;
- int rv = 0;
-
- if (mp->is_l2)
- {
- if (mp->is_add)
- {
- if (~0 ==
- lisp_gpe_tenant_l2_iface_add_or_lock (mp->vni, mp->dp_table))
- rv = 1;
- }
- else
- lisp_gpe_tenant_l2_iface_unlock (mp->vni);
- }
- else
- {
- if (mp->is_add)
- {
- if (~0 ==
- lisp_gpe_tenant_l3_iface_add_or_lock (mp->vni, mp->dp_table))
- rv = 1;
- }
- else
- lisp_gpe_tenant_l3_iface_unlock (mp->vni);
- }
-
- REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
-}
-
-static void
-send_lisp_gpe_fwd_entry_details (lisp_gpe_fwd_entry_t * lfe,
- unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_lisp_gpe_tunnel_details_t *rmp;
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_LISP_GPE_TUNNEL_DETAILS);
-
- rmp->tunnels = lfe - lgm->lisp_fwd_entry_pool;
-
- rmp->is_ipv6 = ip_prefix_version (&(lfe->key->rmt.ippref)) == IP6 ? 1 : 0;
- ip_address_copy_addr (rmp->source_ip,
- &ip_prefix_addr (&(lfe->key->rmt.ippref)));
- ip_address_copy_addr (rmp->destination_ip,
- &ip_prefix_addr (&(lfe->key->rmt.ippref)));
-
- rmp->encap_fib_id = htonl (0);
- rmp->decap_fib_id = htonl (lfe->eid_fib_index);
- rmp->iid = htonl (lfe->key->vni);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_lisp_gpe_tunnel_dump_t_handler (vl_api_lisp_gpe_tunnel_dump_t * mp)
-{
- unix_shared_memory_queue_t *q = NULL;
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
- lisp_gpe_fwd_entry_t *lfe = NULL;
-
- if (pool_elts (lgm->lisp_fwd_entry_pool) == 0)
- {
- return;
- }
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
-
- /* *INDENT-OFF* */
- pool_foreach(lfe, lgm->lisp_fwd_entry_pool,
- ({
- send_lisp_gpe_fwd_entry_details(lfe, q, mp->context);
- }));
- /* *INDENT-ON* */
-}
-
-static void
vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *
mp)
{
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index 9c173653b1d..abd0e8f1cba 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -36,6 +36,7 @@
* IPSEC APIs: see .../vnet/vnet/ipsec/{ipsec.api, ipsec_api.c}
* IPSEC-GRE APIs: see .../vnet/vnet/ipsec-gre/{ipsec_gre.api, ipsec_gre_api.c}
* LISP APIs: see .../vnet/vnet/lisp/{lisp.api, lisp_api.c}
+ * LISP-GPE APIs: see .../vnet/vnet/lisp-gpe/{lisp_gpe.api, lisp_gpe_api.c}
*/
/** \brief Create a new subinterface with the given vlan id
@@ -1491,106 +1492,6 @@ define l2_fib_table_dump
u32 bd_id;
};
-/** \brief add or delete lisp gpe tunnel
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - add address if non-zero, else delete
- @param eid_type -
- 0 : ipv4
- 1 : ipv6
- 2 : mac
- @param rmt_eid - remote eid
- @param lcl_eid - local eid
- @param rmt_len - remote prefix len
- @param lcl_len - local prefix len
- @param vni - virtual network identifier
- @param dp_table - vrf/bridge domain id
- @param loc_num - number of locators
- @param lcl_locs - array of local locators
- @param rmt_locs - array of remote locators
- @param action - negative action when 0 locators configured
-*/
-define lisp_gpe_add_del_fwd_entry
-{
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 eid_type;
- u8 rmt_eid[16];
- u8 lcl_eid[16];
- u8 rmt_len;
- u8 lcl_len;
- u32 vni;
- u32 dp_table;
- u32 loc_num;
- u8 lcl_locs[loc_num];
- u8 rmt_locs[loc_num];
- u8 action;
-};
-
-/** \brief Reply for gpe_fwd_entry add/del
- @param context - returned sender context, to match reply w/ request
- @param retval - return code
-*/
-define lisp_gpe_add_del_fwd_entry_reply
-{
- u32 context;
- i32 retval;
-};
-
-/** \brief add or delete gpe_iface
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param is_add - add address if non-zero, else delete
-*/
-define lisp_gpe_add_del_iface
-{
- u32 client_index;
- u32 context;
- u8 is_add;
- u8 is_l2;
- u32 dp_table;
- u32 vni;
-};
-
-/** \brief Reply for gpe_iface add/del
- @param context - returned sender context, to match reply w/ request
- @param retval - return code
-*/
-define lisp_gpe_add_del_iface_reply
-{
- u32 context;
- i32 retval;
-};
-
-define lisp_gpe_tunnel_details
-{
- u32 context;
- u32 tunnels;
- u8 is_ipv6;
- u8 source_ip[16];
- u8 destination_ip[16];
- u32 encap_fib_id;
- u32 decap_fib_id;
- u32 dcap_next;
- u8 lisp_ver;
- u8 next_protocol;
- u8 flags;
- u8 ver_res;
- u8 res;
- u32 iid;
-};
-
-/** \brief Request for gpe tunnel summary status
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- */
-define lisp_gpe_tunnel_dump
-{
- u32 client_index;
- u32 context;
-};
-
/* Gross kludge, DGMS */
define interface_name_renumber
{
pan class="s">"%10s %-32s %20u %20u\n", "", "Detect multiplier", bs->local_detect_mult, bs->remote_detect_mult); s = format (s, "%10s %-32s %20u %20llu\n", "", "Required Min Rx Interval (usec)", bs->config_required_min_rx_usec, bs->remote_min_rx_usec); s = format (s, "%10s %-32s %20u %20u\n", "", "Desired Min Tx Interval (usec)", bs->config_desired_min_tx_usec, bfd_clocks_to_usec (bm, bs->remote_desired_min_tx_clocks)); s = format (s, "%10s %-32s %20u\n", "", "Transmit interval", bfd_clocks_to_usec (bm, bs->transmit_interval_clocks)); u64 now = clib_cpu_time_now (); u8 *tmp = NULL; if (bs->last_tx_clocks > 0) { tmp = format (tmp, "%.2fs ago", (now - bs->last_tx_clocks) * vm->clib_time.seconds_per_clock); s = format (s, "%10s %-32s %20v\n", "", "Last control frame tx", tmp); vec_reset_length (tmp); } if (bs->last_rx_clocks) { tmp = format (tmp, "%.2fs ago", (now - bs->last_rx_clocks) * vm->clib_time.seconds_per_clock); s = format (s, "%10s %-32s %20v\n", "", "Last control frame rx", tmp); vec_reset_length (tmp); } s = format (s, "%10s %-32s %20u %20llu\n", "", "Min Echo Rx Interval (usec)", 1, bs->remote_min_echo_rx_usec); if (bs->echo) { s = format (s, "%10s %-32s %20u\n", "", "Echo transmit interval", bfd_clocks_to_usec (bm, bs->echo_transmit_interval_clocks)); tmp = format (tmp, "%.2fs ago", (now - bs->echo_last_tx_clocks) * vm->clib_time.seconds_per_clock); s = format (s, "%10s %-32s %20v\n", "", "Last echo frame tx", tmp); vec_reset_length (tmp); tmp = format (tmp, "%.6fs", (bs->echo_last_rx_clocks - bs->echo_last_tx_clocks) * vm->clib_time.seconds_per_clock); s = format (s, "%10s %-32s %20v\n", "", "Last echo frame roundtrip time", tmp); } vec_free (tmp); tmp = NULL; s = format (s, "%10s %-32s %20s %20s\n", "", "Demand mode", "no", bs->remote_demand ? "yes" : "no"); s = format (s, "%10s %-32s %20s\n", "", "Poll state", bfd_poll_state_string (bs->poll_state)); if (bs->auth.curr_key) { s = format (s, "%10s %-32s %20u\n", "", "Authentication config key ID", bs->auth.curr_key->conf_key_id); s = format (s, "%10s %-32s %20u\n", "", "Authentication BFD key ID", bs->auth.curr_bfd_key_id); s = format (s, "%10s %-32s %20u %20u\n", "", "Sequence number", bs->auth.local_seq_number, bs->auth.remote_seq_number); } return s; } static clib_error_t * show_bfd (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { bfd_main_t *bm = &bfd_main; bfd_session_t *bs = NULL; unformat_input_t _line_input, *line_input = &_line_input; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; if (unformat (line_input, "keys")) { bfd_auth_key_t *key = NULL; u8 *s = format (NULL, "%=10s %=25s %=10s\n", "Configuration Key ID", "Type", "Use Count"); /* *INDENT-OFF* */ pool_foreach (key, bm->auth_keys, { s = format (s, "%10u %-25s %10u\n", key->conf_key_id, bfd_auth_type_str (key->auth_type), key->use_count); }); /* *INDENT-ON* */ vlib_cli_output (vm, "%v\n", s); vec_free (s); vlib_cli_output (vm, "Number of configured BFD keys: %lu\n", (u64) pool_elts (bm->auth_keys)); } else if (unformat (line_input, "sessions")) { u8 *s = format (NULL, "%=10s %=32s %=20s %=20s\n", "Index", "Property", "Local value", "Remote value"); /* *INDENT-OFF* */ pool_foreach (bs, bm->sessions, { s = format (s, "%U", format_bfd_session_cli, vm, bm, bs); }); /* *INDENT-ON* */ vlib_cli_output (vm, "%v", s); vec_free (s); vlib_cli_output (vm, "Number of configured BFD sessions: %lu\n", (u64) pool_elts (bm->sessions)); } else if (unformat (line_input, "echo-source")) { int is_set; u32 sw_if_index; int have_usable_ip4; ip4_address_t ip4; int have_usable_ip6; ip6_address_t ip6; bfd_udp_get_echo_source (&is_set, &sw_if_index, &have_usable_ip4, &ip4, &have_usable_ip6, &ip6); if (is_set) { vnet_sw_interface_t *sw_if = vnet_get_sw_interface_safe (&vnet_main, sw_if_index); vnet_hw_interface_t *hw_if = vnet_get_hw_interface (&vnet_main, sw_if->hw_if_index); u8 *s = format (NULL, "UDP echo source is: %v\n", hw_if->name); s = format (s, "IPv4 address usable as echo source: "); if (have_usable_ip4) { s = format (s, "%U\n", format_ip4_address, &ip4); } else { s = format (s, "none\n"); } s = format (s, "IPv6 address usable as echo source: "); if (have_usable_ip6) { s = format (s, "%U\n", format_ip6_address, &ip6); } else { s = format (s, "none\n"); } vlib_cli_output (vm, "%v", s); vec_free (s); } else { vlib_cli_output (vm, "UDP echo source is not set.\n"); } } else { vlib_cli_output (vm, "Number of configured BFD sessions: %lu\n", (u64) pool_elts (bm->sessions)); vlib_cli_output (vm, "Number of configured BFD keys: %lu\n", (u64) pool_elts (bm->auth_keys)); } return 0; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_bfd_command, static) = { .path = "show bfd", .short_help = "show bfd [keys|sessions|echo-source]", .function = show_bfd, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_key_add (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; int have_key_id = 0; u32 key_id = 0; u8 *vec_auth_type = NULL; bfd_auth_type_e auth_type = BFD_AUTH_TYPE_reserved; u8 *secret = NULL; unformat_input_t _line_input, *line_input = &_line_input; static const u8 keyed_sha1[] = "keyed-sha1"; static const u8 meticulous_keyed_sha1[] = "meticulous-keyed-sha1"; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "conf-key-id %u", &key_id)) { have_key_id = 1; } else if (unformat (line_input, "type %U", unformat_token, "a-zA-Z0-9-", &vec_auth_type)) { if (vec_len (vec_auth_type) == sizeof (keyed_sha1) - 1 && 0 == memcmp (vec_auth_type, keyed_sha1, sizeof (keyed_sha1) - 1)) { auth_type = BFD_AUTH_TYPE_keyed_sha1; } else if (vec_len (vec_auth_type) == sizeof (meticulous_keyed_sha1) - 1 && 0 == memcmp (vec_auth_type, meticulous_keyed_sha1, sizeof (meticulous_keyed_sha1) - 1)) { auth_type = BFD_AUTH_TYPE_meticulous_keyed_sha1; } else { ret = clib_error_return (0, "invalid type `%v'", vec_auth_type); goto out; } } else if (unformat (line_input, "secret %U", unformat_hex_string, &secret)) { /* nothing to do here */ } else { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } if (!have_key_id) { ret = clib_error_return (0, "required parameter missing: `conf-key-id'"); goto out; } if (!vec_auth_type) { ret = clib_error_return (0, "required parameter missing: `type'"); goto out; } if (!secret) { ret = clib_error_return (0, "required parameter missing: `secret'"); goto out; } vnet_api_error_t rv = bfd_auth_set_key (key_id, auth_type, vec_len (secret), secret); if (rv) { ret = clib_error_return (0, "`bfd_auth_set_key' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); } out: vec_free (vec_auth_type); return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_key_add_command, static) = { .path = "bfd key set", .short_help = "bfd key set" " conf-key-id <id>" " type <keyed-sha1|meticulous-keyed-sha1> " " secret <secret>", .function = bfd_cli_key_add, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_key_del (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; u32 key_id = 0; unformat_input_t _line_input, *line_input = &_line_input; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (!unformat (line_input, "conf-key-id %u", &key_id)) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } vnet_api_error_t rv = bfd_auth_del_key (key_id); if (rv) { ret = clib_error_return (0, "`bfd_auth_del_key' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_key_del_command, static) = { .path = "bfd key del", .short_help = "bfd key del conf-key-id <id>", .function = bfd_cli_key_del, }; /* *INDENT-ON* */ #define INTERFACE_STR "interface" #define LOCAL_ADDR_STR "local-addr" #define PEER_ADDR_STR "peer-addr" #define CONF_KEY_ID_STR "conf-key-id" #define BFD_KEY_ID_STR "bfd-key-id" #define DESIRED_MIN_TX_STR "desired-min-tx" #define REQUIRED_MIN_RX_STR "required-min-rx" #define DETECT_MULT_STR "detect-mult" #define ADMIN_STR "admin" #define DELAYED_STR "delayed" static const unsigned mandatory = 1; static const unsigned optional = 0; #define DECLARE(t, n, s, r, ...) \ int have_##n = 0; \ t n; #define UNFORMAT(t, n, s, r, ...) \ if (unformat (line_input, s " " __VA_ARGS__, &n)) \ { \ something_parsed = 1; \ have_##n = 1; \ } #define CHECK_MANDATORY(t, n, s, r, ...) \ WARN_OFF(tautological-compare) \ if (mandatory == r && !have_##n) \ { \ WARN_ON(tautological-compare) \ ret = clib_error_return (0, "Required parameter `%s' missing.", s); \ goto out; \ } static clib_error_t * bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_add_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u") \ F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u") \ F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u") \ F (u32, conf_key_id, CONF_KEY_ID_STR, optional, "%u") \ F (u32, bfd_key_id, BFD_KEY_ID_STR, optional, "%u") foreach_bfd_cli_udp_session_add_cli_param (DECLARE); /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_add_cli_param (UNFORMAT); if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } foreach_bfd_cli_udp_session_add_cli_param (CHECK_MANDATORY); if (1 == have_conf_key_id + have_bfd_key_id) { ret = clib_error_return (0, "Incompatible parameter combination, `%s' " "and `%s' must be either both specified or none", CONF_KEY_ID_STR, BFD_KEY_ID_STR); goto out; } if (detect_mult > 255) { ret = clib_error_return (0, "%s value `%u' out of range <1,255>", DETECT_MULT_STR, detect_mult); goto out; } if (have_bfd_key_id && bfd_key_id > 255) { ret = clib_error_return (0, "%s value `%u' out of range <1,255>", BFD_KEY_ID_STR, bfd_key_id); goto out; } vnet_api_error_t rv = bfd_udp_add_session (sw_if_index, &local_addr, &peer_addr, desired_min_tx, required_min_rx, detect_mult, have_conf_key_id, conf_key_id, bfd_key_id); if (rv) { ret = clib_error_return (0, "`bfd_add_add_session' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); goto out; } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_session_add_command, static) = { .path = "bfd udp session add", .short_help = "bfd udp session add" " interface <interface>" " local-addr <local-address>" " peer-addr <peer-address>" " desired-min-tx <desired min tx interval>" " required-min-rx <required min rx interval>" " detect-mult <detect multiplier> " "[" " conf-key-id <config key ID>" " bfd-key-id <BFD key ID>" "]", .function = bfd_cli_udp_session_add, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_mod_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u") \ F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u") \ F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u") foreach_bfd_cli_udp_session_mod_cli_param (DECLARE); /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_mod_cli_param (UNFORMAT); if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } foreach_bfd_cli_udp_session_mod_cli_param (CHECK_MANDATORY); if (detect_mult > 255) { ret = clib_error_return (0, "%s value `%u' out of range <1,255>", DETECT_MULT_STR, detect_mult); goto out; } vnet_api_error_t rv = bfd_udp_mod_session (sw_if_index, &local_addr, &peer_addr, desired_min_tx, required_min_rx, detect_mult); if (rv) { ret = clib_error_return (0, "`bfd_udp_mod_session' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); goto out; } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_session_mod_command, static) = { .path = "bfd udp session mod", .short_help = "bfd udp session mod interface" " <interface> local-addr" " <local-address> peer-addr" " <peer-address> desired-min-tx" " <desired min tx interval> required-min-rx" " <required min rx interval> detect-mult" " <detect multiplier> ", .function = bfd_cli_udp_session_mod, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_del_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) foreach_bfd_cli_udp_session_del_cli_param (DECLARE); /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_del_cli_param (UNFORMAT); if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } foreach_bfd_cli_udp_session_del_cli_param (CHECK_MANDATORY); vnet_api_error_t rv = bfd_udp_del_session (sw_if_index, &local_addr, &peer_addr); if (rv) { ret = clib_error_return (0, "`bfd_udp_del_session' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); goto out; } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_session_del_command, static) = { .path = "bfd udp session del", .short_help = "bfd udp session del interface" " <interface> local-addr" " <local-address> peer-addr" "<peer-address> ", .function = bfd_cli_udp_session_del, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_set_flags_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (u8 *, admin_up_down_token, ADMIN_STR, mandatory, "%v", \ &admin_up_down_token) foreach_bfd_cli_udp_session_set_flags_cli_param (DECLARE); /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_set_flags_cli_param (UNFORMAT); if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } foreach_bfd_cli_udp_session_set_flags_cli_param (CHECK_MANDATORY); u8 admin_up_down; static const char up[] = "up"; static const char down[] = "down"; if (!memcmp (admin_up_down_token, up, sizeof (up) - 1)) { admin_up_down = 1; } else if (!memcmp (admin_up_down_token, down, sizeof (down) - 1)) { admin_up_down = 0; } else { ret = clib_error_return (0, "Unrecognized value for `%s' parameter: `%v'", ADMIN_STR, admin_up_down_token); goto out; } vnet_api_error_t rv = bfd_udp_session_set_flags (sw_if_index, &local_addr, &peer_addr, admin_up_down); if (rv) { ret = clib_error_return (0, "`bfd_udp_session_set_flags' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); goto out; } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_session_set_flags_command, static) = { .path = "bfd udp session set-flags", .short_help = "bfd udp session set-flags" " interface <interface>" " local-addr <local-address>" " peer-addr <peer-address>" " admin <up|down>", .function = bfd_cli_udp_session_set_flags, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_udp_session_auth_activate (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_auth_activate_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (u8 *, delayed_token, DELAYED_STR, optional, "%v") \ F (u32, conf_key_id, CONF_KEY_ID_STR, mandatory, "%u") \ F (u32, bfd_key_id, BFD_KEY_ID_STR, mandatory, "%u") foreach_bfd_cli_udp_session_auth_activate_cli_param (DECLARE); /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_auth_activate_cli_param (UNFORMAT); if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } foreach_bfd_cli_udp_session_auth_activate_cli_param (CHECK_MANDATORY); u8 is_delayed = 0; if (have_delayed_token) { static const char yes[] = "yes"; static const char no[] = "no"; if (!memcmp (delayed_token, yes, sizeof (yes) - 1)) { is_delayed = 1; } else if (!memcmp (delayed_token, no, sizeof (no) - 1)) { is_delayed = 0; } else { ret = clib_error_return (0, "Unrecognized value for `%s' parameter: `%v'", DELAYED_STR, delayed_token); goto out; } } if (have_bfd_key_id && bfd_key_id > 255) { ret = clib_error_return (0, "%s value `%u' out of range <1,255>", BFD_KEY_ID_STR, bfd_key_id); goto out; } vnet_api_error_t rv = bfd_udp_auth_activate (sw_if_index, &local_addr, &peer_addr, conf_key_id, bfd_key_id, is_delayed); if (rv) { ret = clib_error_return (0, "`bfd_udp_auth_activate' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); goto out; } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_activate_command, static) = { .path = "bfd udp session auth activate", .short_help = "bfd udp session auth activate" " interface <interface>" " local-addr <local-address>" " peer-addr <peer-address>" " conf-key-id <config key ID>" " bfd-key-id <BFD key ID>" " [ delayed <yes|no> ]", .function = bfd_cli_udp_session_auth_activate, }; static clib_error_t * bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED (vlib_cli_command_t *lmd)) { clib_error_t *ret = NULL; unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_session_auth_deactivate_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) \ F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ unformat_ip46_address) \ F (u8 *, delayed_token, DELAYED_STR, optional, "%v") foreach_bfd_cli_udp_session_auth_deactivate_cli_param (DECLARE); /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_session_auth_deactivate_cli_param (UNFORMAT); if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, input); goto out; } } foreach_bfd_cli_udp_session_auth_deactivate_cli_param (CHECK_MANDATORY); u8 is_delayed = 0; if (have_delayed_token) { static const char yes[] = "yes"; static const char no[] = "no"; if (!memcmp (delayed_token, yes, sizeof (yes) - 1)) { is_delayed = 1; } else if (!memcmp (delayed_token, no, sizeof (no) - 1)) { is_delayed = 0; } else { ret = clib_error_return ( 0, "Unrecognized value for `%s' parameter: `%v'", DELAYED_STR, delayed_token); goto out; } } vnet_api_error_t rv = bfd_udp_auth_deactivate (sw_if_index, &local_addr, &peer_addr, is_delayed); if (rv) { ret = clib_error_return ( 0, "`bfd_udp_auth_deactivate' API call failed, rv=%d:%U", (int)rv, format_vnet_api_errno, rv); goto out; } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_deactivate_command, static) = { .path = "bfd udp session auth deactivate", .short_help = "bfd udp session auth deactivate" " interface <interface>" " local-addr <local-address>" " peer-addr <peer-address>" "[ delayed <yes|no> ]", .function = bfd_cli_udp_session_auth_deactivate, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_udp_set_echo_source (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { clib_error_t *ret = NULL; unformat_input_t _line_input, *line_input = &_line_input; #define foreach_bfd_cli_udp_set_echo_source_cli_param(F) \ F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ unformat_vnet_sw_interface, &vnet_main) foreach_bfd_cli_udp_set_echo_source_cli_param (DECLARE); /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { int something_parsed = 0; foreach_bfd_cli_udp_set_echo_source_cli_param (UNFORMAT); if (!something_parsed) { ret = clib_error_return (0, "Unknown input `%U'", format_unformat_error, line_input); goto out; } } foreach_bfd_cli_udp_set_echo_source_cli_param (CHECK_MANDATORY); vnet_api_error_t rv = bfd_udp_set_echo_source (sw_if_index); if (rv) { ret = clib_error_return (0, "`bfd_udp_set_echo_source' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); goto out; } out: return ret; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_set_echo_source_cmd, static) = { .path = "bfd udp echo-source set", .short_help = "bfd udp echo-source set interface <interface>", .function = bfd_cli_udp_set_echo_source, }; /* *INDENT-ON* */ static clib_error_t * bfd_cli_udp_del_echo_source (vlib_main_t * vm, unformat_input_t * input, CLIB_UNUSED (vlib_cli_command_t * lmd)) { vnet_api_error_t rv = bfd_udp_del_echo_source (); if (rv) { return clib_error_return (0, "`bfd_udp_del_echo_source' API call failed, rv=%d:%U", (int) rv, format_vnet_api_errno, rv); } return 0; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (bfd_cli_udp_del_echo_source_cmd, static) = { .path = "bfd udp echo-source del", .short_help = "bfd udp echo-source del", .function = bfd_cli_udp_del_echo_source, }; /* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */