Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
VPP-321: Fix filtering in LISP EID dump call
[vpp.git]
/
vpp
/
vpp-api
/
api.c
diff --git
a/vpp/vpp-api/api.c
b/vpp/vpp-api/api.c
index
6315534
..
4c87476
100644
(file)
--- a/
vpp/vpp-api/api.c
+++ b/
vpp/vpp-api/api.c
@@
-2588,9
+2588,11
@@
vl_api_sw_interface_clear_stats_t_handler (vl_api_sw_interface_clear_stats_t *
vlib_combined_counter_main_t *cm;
static vnet_main_t **my_vnet_mains;
int i, j, n_counters;
vlib_combined_counter_main_t *cm;
static vnet_main_t **my_vnet_mains;
int i, j, n_counters;
-
int rv = 0;
int rv = 0;
+ if (mp->sw_if_index != ~0)
+ VALIDATE_SW_IF_INDEX(mp);
+
vec_reset_length (my_vnet_mains);
for (i = 0; i < vec_len (vnet_mains); i++)
vec_reset_length (my_vnet_mains);
for (i = 0; i < vec_len (vnet_mains); i++)
@@
-2632,6
+2634,8
@@
vl_api_sw_interface_clear_stats_t_handler (vl_api_sw_interface_clear_stats_t *
}
}
}
}
+ BAD_SW_IF_INDEX_LABEL;
+
REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
}
REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
}
@@
-5658,32
+5662,25
@@
send_lisp_eid_table_details (mapping_t * mapit,
u32 context, u8 filter)
{
vl_api_lisp_eid_table_details_t *rmp = NULL;
u32 context, u8 filter)
{
vl_api_lisp_eid_table_details_t *rmp = NULL;
- lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
- locator_set_t *ls = NULL;
gid_address_t *gid = NULL;
u8 *mac = 0;
ip_prefix_t *ip_prefix = NULL;
gid_address_t *gid = NULL;
u8 *mac = 0;
ip_prefix_t *ip_prefix = NULL;
- ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
-
switch (filter)
{
switch (filter)
{
- case 0:
+ case 0:
/* all mappings */
break;
break;
- case 1:
- if (!ls->local)
- {
- return;
- }
+
+ case 1: /* local only */
+ if (!mapit->local)
+ return;
break;
break;
- case 2:
- if (ls->local)
- {
- return;
- }
+ case 2: /* remote only */
+ if (mapit->local)
+ return;
break;
default:
break;
default:
- clib_warning ("Filter error, unknown filter: %d
\n
", filter);
+ clib_warning ("Filter error, unknown filter: %d", filter);
return;
}
return;
}
@@
-5695,7
+5692,7
@@
send_lisp_eid_table_details (mapping_t * mapit,
memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS);
rmp->locator_set_index = mapit->locator_set_index;
memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS);
rmp->locator_set_index = mapit->locator_set_index;
- rmp->is_local =
ls
->local;
+ rmp->is_local =
mapit
->local;
rmp->ttl = mapit->ttl;
rmp->authoritative = mapit->authoritative;
rmp->ttl = mapit->ttl;
rmp->authoritative = mapit->authoritative;
@@
-5756,7
+5753,8
@@
vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp)
return;
mapit = pool_elt_at_index (lcm->mapping_pool, mi);
return;
mapit = pool_elt_at_index (lcm->mapping_pool, mi);
- send_lisp_eid_table_details (mapit, q, mp->context, mp->filter);
+ send_lisp_eid_table_details (mapit, q, mp->context,
+ 0 /* ignore filter */);
}
else
{
}
else
{
@@
-5994,7
+5992,7
@@
vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp)
return;
}
return;
}
- if (
~0 == lcm->pitr_map_index
)
+ if (
!lcm->lisp_pitr
)
{
tmp_str = format (0, "N/A");
}
{
tmp_str = format (0, "N/A");
}
@@
-7768,6
+7766,8
@@
vl_api_ipfix_dump_t_handler (vl_api_ipfix_dump_t * mp)
vl_api_ipfix_details_t *rmp;
q = vl_api_client_index_to_input_queue (mp->client_index);
vl_api_ipfix_details_t *rmp;
q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (!q)
+ return;
rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
@@
-7919,8
+7919,7
@@
static void
}
// Validate mask_length
}
// Validate mask_length
- if (mask_length < 0 ||
- (is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
+ if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
{
rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
goto reply;
{
rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
goto reply;
@@
-8140,11
+8139,12
@@
api_segment_config (vlib_main_t * vm, unformat_input_t * input)
{
u8 *chroot_path;
int uid, gid, rv;
{
u8 *chroot_path;
int uid, gid, rv;
- char *s, buf[128];
+ const int max_buf_size = 4096;
+ char *s, *buf;
struct passwd _pw, *pw;
struct group _grp, *grp;
clib_error_t *e;
struct passwd _pw, *pw;
struct group _grp, *grp;
clib_error_t *e;
-
+ buf = vec_new(char,128);
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "prefix %s", &chroot_path))
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "prefix %s", &chroot_path))
@@
-8160,7
+8160,10
@@
api_segment_config (vlib_main_t * vm, unformat_input_t * input)
{
/* lookup the username */
pw = NULL;
{
/* lookup the username */
pw = NULL;
- rv = getpwnam_r (s, &_pw, buf, sizeof (buf), &pw);
+ while (((rv = getpwnam_r (s, &_pw, buf, sizeof (buf), &pw)) == ERANGE) && ( vec_len(buf) <= max_buf_size ))
+ {
+ vec_resize(buf,vec_len(buf)*2);
+ }
if (rv < 0)
{
e = clib_error_return_code (0, rv,
if (rv < 0)
{
e = clib_error_return_code (0, rv,
@@
-8168,6
+8171,7
@@
api_segment_config (vlib_main_t * vm, unformat_input_t * input)
CLIB_ERROR_FATAL,
"cannot fetch username %s", s);
vec_free (s);
CLIB_ERROR_FATAL,
"cannot fetch username %s", s);
vec_free (s);
+ vec_free (buf);
return e;
}
if (pw == NULL)
return e;
}
if (pw == NULL)
@@
-8175,6
+8179,7
@@
api_segment_config (vlib_main_t * vm, unformat_input_t * input)
e =
clib_error_return_fatal (0, "username %s does not exist", s);
vec_free (s);
e =
clib_error_return_fatal (0, "username %s does not exist", s);
vec_free (s);
+ vec_free (buf);
return e;
}
vec_free (s);
return e;
}
vec_free (s);
@@
-8184,7
+8189,10
@@
api_segment_config (vlib_main_t * vm, unformat_input_t * input)
{
/* lookup the group name */
grp = NULL;
{
/* lookup the group name */
grp = NULL;
- rv = getgrnam_r (s, &_grp, buf, sizeof (buf), &grp);
+ while ( ( (rv = getgrnam_r (s, &_grp, buf, vec_len(buf), &grp)) == ERANGE ) && ( vec_len(buf) <= max_buf_size ) )
+ {
+ vec_resize(buf,vec_len(buf)*2);
+ }
if (rv != 0)
{
e = clib_error_return_code (0, rv,
if (rv != 0)
{
e = clib_error_return_code (0, rv,
@@
-8192,15
+8200,18
@@
api_segment_config (vlib_main_t * vm, unformat_input_t * input)
CLIB_ERROR_FATAL,
"cannot fetch group %s", s);
vec_free (s);
CLIB_ERROR_FATAL,
"cannot fetch group %s", s);
vec_free (s);
+ vec_free (buf);
return e;
}
if (grp == NULL)
{
e = clib_error_return_fatal (0, "group %s does not exist", s);
vec_free (s);
return e;
}
if (grp == NULL)
{
e = clib_error_return_fatal (0, "group %s does not exist", s);
vec_free (s);
+ vec_free (buf);
return e;
}
vec_free (s);
return e;
}
vec_free (s);
+ vec_free (buf);
vl_set_memory_gid (grp->gr_gid);
}
else
vl_set_memory_gid (grp->gr_gid);
}
else