#include <vppinfra/format.h>
#include <vppinfra/byte_order.h>
#include <vppinfra/error.h>
+#include <vppinfra/elog.h>
#include <svm/queue.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
return vl_msg_api_alloc_internal (nbytes, pool, 0 /* may_return_null */ );
}
+void *
+vl_msg_api_alloc_zero (int nbytes)
+{
+ void *ret;
+
+ ret = vl_msg_api_alloc (nbytes);
+ clib_memset (ret, 0, nbytes);
+ return ret;
+}
+
void *
vl_msg_api_alloc_or_null (int nbytes)
{
return vl_msg_api_alloc_internal (nbytes, 0, 0 /* may_return_null */ );
}
+void *
+vl_msg_api_alloc_zero_as_if_client (int nbytes)
+{
+ void *ret;
+
+ ret = vl_msg_api_alloc_as_if_client (nbytes);
+ clib_memset (ret, 0, nbytes);
+ return ret;
+}
+
void *
vl_msg_api_alloc_as_if_client_or_null (int nbytes)
{
svm_map_region_args_t _a, *a = &_a;
svm_region_t *vlib_rp, *root_rp;
api_main_t *am = &api_main;
- int i, rv;
+ int i;
struct timespec ts, tsrem;
char *vpe_api_region_suffix = "-vpe-api";
while (nanosleep (&ts, &tsrem) < 0)
ts = tsrem;
tfd = open ((char *) api_name, O_RDWR);
- if (tfd > 0)
+ if (tfd >= 0)
break;
}
vec_free (api_name);
return -2;
}
close (tfd);
- rv = svm_region_init_chroot (am->root_path);
- if (rv)
- return rv;
+ svm_region_init_chroot_uid_gid (am->root_path, getuid (), getgid ());
}
if (a->root_path != NULL)
*/
if (PREDICT_FALSE
(am->vl_clients /* vpp side */ && (q->cursize == q->maxsize)))
- clib_warning ("WARNING: client input queue at %llx is stuffed...", q);
+ {
+ if (PREDICT_FALSE (am->elog_trace_api_messages))
+ {
+ /* *INDENT-OFF* */
+ ELOG_TYPE_DECLARE (e) =
+ {
+ .format = "api-client-queue-stuffed: %x%x",
+ .format_args = "i4i4",
+ };
+ /* *INDENT-ON* */
+ struct
+ {
+ u32 hi, low;
+ } *ed;
+ ed = ELOG_DATA (am->elog_main, e);
+ ed->hi = (uword) q >> 32;
+ ed->low = (uword) q & 0xFFFFFFFF;
+ clib_warning ("WARNING: client input queue at %llx is stuffed...",
+ q);
+ }
+ }
(void) svm_queue_add (q, elem, 0 /* nowait */ );
}