aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2017-03-10 13:18:02 +0100
committerFlorin Coras <florin.coras@gmail.com>2017-03-10 19:14:10 +0000
commit67a99f8927c3807c8731e00107dff72bc6b6cde2 (patch)
treec7c9493e7b271800250c9cff89c80c521d4e0022 /src
parentb6391a90c4940f2828ad7a637fca39ccbdd1fd07 (diff)
LISP: fix Proxy-ETR show command, VPP-660
Change-Id: I8b7dc3bf631bd228db23679534e04b8af7ac4ec7 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c146
-rw-r--r--src/vnet/lisp-cp/lisp_api.c21
-rw-r--r--src/vnet/lisp-cp/one.api4
-rw-r--r--src/vnet/lisp-cp/one_api.c21
4 files changed, 184 insertions, 8 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 0da31208347..e6e4acd9ea6 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -3235,6 +3235,66 @@ static void
}
static void
+ vl_api_show_one_use_petr_reply_t_handler
+ (vl_api_show_one_use_petr_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ i32 retval = ntohl (mp->retval);
+
+ if (0 <= retval)
+ {
+ print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
+ if (mp->status)
+ {
+ print (vam->ofp, "Proxy-ETR address; %U",
+ mp->is_ip4 ? format_ip4_address : format_ip6_address,
+ mp->address);
+ }
+ }
+
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
+static void
+ vl_api_show_one_use_petr_reply_t_handler_json
+ (vl_api_show_one_use_petr_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t node;
+ u8 *status = 0;
+ struct in_addr ip4;
+ struct in6_addr ip6;
+
+ status = format (0, "%s", mp->status ? "enabled" : "disabled");
+ vec_add1 (status, 0);
+
+ vat_json_init_object (&node);
+ vat_json_object_add_string_copy (&node, "status", status);
+ if (mp->status)
+ {
+ if (mp->is_ip4)
+ {
+ clib_memcpy (&ip6, mp->address, sizeof (ip6));
+ vat_json_object_add_ip6 (&node, "address", ip6);
+ }
+ else
+ {
+ clib_memcpy (&ip4, mp->address, sizeof (ip4));
+ vat_json_object_add_ip4 (&node, "address", ip4);
+ }
+ }
+
+ vec_free (status);
+
+ vat_json_print (vam->ofp, &node);
+ vat_json_free (&node);
+
+ vam->retval = ntohl (mp->retval);
+ vam->result_ready = 1;
+}
+
+static void
vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
{
vat_main_t *vam = &vat_main;
@@ -3979,6 +4039,7 @@ _(one_pitr_set_locator_set_reply) \
_(one_map_request_mode_reply) \
_(one_add_del_map_request_itr_rlocs_reply) \
_(one_eid_table_add_del_map_reply) \
+_(one_use_petr_reply) \
_(gpe_add_del_fwd_entry_reply) \
_(gpe_enable_disable_reply) \
_(gpe_set_encap_mode_reply) \
@@ -4191,6 +4252,7 @@ _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
_(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
one_rloc_probe_enable_disable_reply) \
_(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
+_(ONE_USE_PETR_REPLY, one_use_petr_reply) \
_(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
_(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
_(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
@@ -4215,6 +4277,7 @@ _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
_(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
one_get_map_request_itr_rlocs_reply) \
_(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
+_(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
_(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
_(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
_(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
@@ -14281,6 +14344,85 @@ api_show_one_pitr (vat_main_t * vam)
#define api_show_lisp_pitr api_show_one_pitr
+static int
+api_one_use_petr (vat_main_t * vam)
+{
+ unformat_input_t *input = vam->input;
+ vl_api_one_use_petr_t *mp;
+ u8 is_add = 0;
+ ip_address_t ip;
+ int ret;
+
+ memset (&ip, 0, sizeof (ip));
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "disable"))
+ is_add = 0;
+ else
+ if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
+ {
+ is_add = 1;
+ ip_addr_version (&ip) = IP4;
+ }
+ else
+ if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
+ {
+ is_add = 1;
+ ip_addr_version (&ip) = IP6;
+ }
+ else
+ {
+ errmsg ("parse error '%U'", format_unformat_error, input);
+ return -99;
+ }
+ }
+
+ M (ONE_USE_PETR, mp);
+
+ mp->is_add = is_add;
+ if (is_add)
+ {
+ mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
+ if (mp->is_ip4)
+ clib_memcpy (mp->address, &ip, 4);
+ else
+ clib_memcpy (mp->address, &ip, 16);
+ }
+
+ /* send */
+ S (mp);
+
+ /* wait for reply */
+ W (ret);
+ return ret;
+}
+
+#define api_lisp_use_petr api_one_use_petr
+
+static int
+api_show_one_use_petr (vat_main_t * vam)
+{
+ vl_api_show_one_use_petr_t *mp;
+ int ret;
+
+ if (!vam->json_output)
+ {
+ print (vam->ofp, "%=20s", "Proxy-ETR status:");
+ }
+
+ M (SHOW_ONE_USE_PETR, mp);
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+#define api_show_lisp_use_petr api_show_one_use_petr
+
/**
* Add/delete mapping between vni and vrf
*/
@@ -18241,6 +18383,7 @@ _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
_(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
"<local-eid>") \
_(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
+_(one_use_petr, "ip-address> | disable") \
_(one_map_request_mode, "src-dst|dst-only") \
_(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
_(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
@@ -18258,6 +18401,7 @@ _(show_one_map_register_state, "") \
_(show_one_status, "") \
_(one_get_map_request_itr_rlocs, "") \
_(show_one_pitr, "") \
+_(show_one_use_petr, "") \
_(show_one_map_request_mode, "") \
_(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
" sw_if_index <sw_if_index> p <priority> " \
@@ -18282,6 +18426,7 @@ _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
_(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
"<local-eid>") \
_(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
+_(lisp_use_petr, "<ip-address> | disable") \
_(lisp_map_request_mode, "src-dst|dst-only") \
_(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
_(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
@@ -18307,6 +18452,7 @@ _(show_lisp_map_register_state, "") \
_(show_lisp_status, "") \
_(lisp_get_map_request_itr_rlocs, "") \
_(show_lisp_pitr, "") \
+_(show_lisp_use_petr, "") \
_(show_lisp_map_request_mode, "") \
_(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
_(af_packet_delete, "name <host interface name>") \
diff --git a/src/vnet/lisp-cp/lisp_api.c b/src/vnet/lisp-cp/lisp_api.c
index d91f9907752..6c82d4cf049 100644
--- a/src/vnet/lisp-cp/lisp_api.c
+++ b/src/vnet/lisp-cp/lisp_api.c
@@ -445,9 +445,24 @@ vl_api_show_lisp_use_petr_t_handler (vl_api_show_lisp_use_petr_t * mp)
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY,
{
- rmp->status = status;
- gid_address_put (rmp->address, &addr);
- rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
+ rmp->status = status;
+ ip_address_t *ip = &gid_address_ip (&addr);
+ switch (ip_addr_version (ip))
+ {
+ case IP4:
+ clib_memcpy (rmp->address, &ip_addr_v4 (ip),
+ sizeof (ip_addr_v4 (ip)));
+ break;
+
+ case IP6:
+ clib_memcpy (rmp->address, &ip_addr_v6 (ip),
+ sizeof (ip_addr_v6 (ip)));
+ break;
+
+ default:
+ ASSERT (0);
+ }
+ rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
});
/* *INDENT-ON* */
}
diff --git a/src/vnet/lisp-cp/one.api b/src/vnet/lisp-cp/one.api
index 436c8089ade..7cc9068c337 100644
--- a/src/vnet/lisp-cp/one.api
+++ b/src/vnet/lisp-cp/one.api
@@ -225,7 +225,7 @@ define one_pitr_set_locator_set_reply
@param context - sender context, to match reply w/ request
@param is_ip4 - Address is IPv4 if set and IPv6 otherwise
@param address - PETR IP address
- @param is_add - add locator set if non-zero, else disable pitr
+ @param is_add - add locator set if non-zero, else disable PETR
*/
define one_use_petr
{
@@ -236,7 +236,7 @@ define one_use_petr
u8 is_add;
};
-/** \brief Reply for one_pitr_set_locator_set
+/** \brief Reply for one_use_petr
@param context - returned sender context, to match reply w/ request
@param retval - return code
*/
diff --git a/src/vnet/lisp-cp/one_api.c b/src/vnet/lisp-cp/one_api.c
index ff00bf5bfce..4faf624014b 100644
--- a/src/vnet/lisp-cp/one_api.c
+++ b/src/vnet/lisp-cp/one_api.c
@@ -448,9 +448,24 @@ vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
{
- rmp->status = status;
- gid_address_put (rmp->address, &addr);
- rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
+ rmp->status = status;
+ ip_address_t *ip = &gid_address_ip (&addr);
+ switch (ip_addr_version (ip))
+ {
+ case IP4:
+ clib_memcpy (rmp->address, &ip_addr_v4 (ip),
+ sizeof (ip_addr_v4 (ip)));
+ break;
+
+ case IP6:
+ clib_memcpy (rmp->address, &ip_addr_v6 (ip),
+ sizeof (ip_addr_v6 (ip)));
+ break;
+
+ default:
+ ASSERT (0);
+ }
+ rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
});
/* *INDENT-ON* */
}