1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-20 13:55:35 +02:00

packet: Upgrade severity of most packet errors

All errors from packet_range_check(), packet_add() and packet_get() are
trace level.  However, these are for the most part actual error conditions.
They're states that should not happen, in many cases indicating a bug
in the caller or elswhere.

We don't promote these to err() or ASSERT() level, for fear of a localised
bug on very specific input crashing the entire program, or flooding the
logs, but we can at least upgrade them to debug level.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2025-03-17 20:24:24 +11:00 committed by Stefano Brivio
parent 0857515c94
commit cf4d3f05c9

View file

@ -36,7 +36,7 @@ static int packet_check_range(const struct pool *p, const char *ptr, size_t len,
const char *func, int line) const char *func, int line)
{ {
if (len > PACKET_MAX_LEN) { if (len > PACKET_MAX_LEN) {
trace("packet range length %zu (max %zu), %s:%i", debug("packet range length %zu (max %zu), %s:%i",
len, PACKET_MAX_LEN, func, line); len, PACKET_MAX_LEN, func, line);
return -1; return -1;
} }
@ -47,25 +47,25 @@ static int packet_check_range(const struct pool *p, const char *ptr, size_t len,
ret = vu_packet_check_range((void *)p->buf, ptr, len); ret = vu_packet_check_range((void *)p->buf, ptr, len);
if (ret == -1) if (ret == -1)
trace("cannot find region, %s:%i", func, line); debug("cannot find region, %s:%i", func, line);
return ret; return ret;
} }
if (ptr < p->buf) { if (ptr < p->buf) {
trace("packet range start %p before buffer start %p, %s:%i", debug("packet range start %p before buffer start %p, %s:%i",
(void *)ptr, (void *)p->buf, func, line); (void *)ptr, (void *)p->buf, func, line);
return -1; return -1;
} }
if (len > p->buf_size) { if (len > p->buf_size) {
trace("packet range length %zu larger than buffer %zu, %s:%i", debug("packet range length %zu larger than buffer %zu, %s:%i",
len, p->buf_size, func, line); len, p->buf_size, func, line);
return -1; return -1;
} }
if ((size_t)(ptr - p->buf) > p->buf_size - len) { if ((size_t)(ptr - p->buf) > p->buf_size - len) {
trace("packet range %p, len %zu after buffer end %p, %s:%i", debug("packet range %p, len %zu after buffer end %p, %s:%i",
(void *)ptr, len, (void *)(p->buf + p->buf_size), (void *)ptr, len, (void *)(p->buf + p->buf_size),
func, line); func, line);
return -1; return -1;
@ -98,7 +98,7 @@ void packet_add_do(struct pool *p, size_t len, const char *start,
size_t idx = p->count; size_t idx = p->count;
if (pool_full(p)) { if (pool_full(p)) {
trace("add packet index %zu to pool with size %zu, %s:%i", debug("add packet index %zu to pool with size %zu, %s:%i",
idx, p->size, func, line); idx, p->size, func, line);
return; return;
} }
@ -134,7 +134,7 @@ void *packet_get_try_do(const struct pool *p, size_t idx, size_t offset,
p->count, p->size, func, line); p->count, p->size, func, line);
if (idx >= p->count) { if (idx >= p->count) {
trace("packet %zu from pool count: %zu, %s:%i", debug("packet %zu from pool count: %zu, %s:%i",
idx, p->count, func, line); idx, p->count, func, line);
return NULL; return NULL;
} }