Make assertions actually useful
There are some places in passt/pasta which #include <assert.h> and make various assertions. If we hit these something has already gone wrong, but they're there so that we a useful message instead of cryptic misbehaviour if assumptions we thought were correct turn out not to be. Except.. the glibc implementation of assert() uses syscalls that aren't in our seccomp filter, so we'll get a SIGSYS before it actually prints the message. Work around this by adding our own ASSERT() implementation using our existing err() function to log the message, and an abort(). The abort() probably also won't work exactly right with seccomp, but once we've printed the message, dying with a SIGSYS works just as well as dying with a SIGABRT. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:

committed by
Stefano Brivio

parent
cc6d8286d1
commit
7a8ed9459d
@@ -46,7 +46,6 @@
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "passt.h"
|
||||
@@ -519,7 +518,7 @@ bool tcp_splice_conn_from_sock(struct ctx *c, union epoll_ref ref,
|
||||
union inany_addr aany;
|
||||
in_port_t port;
|
||||
|
||||
assert(c->mode == MODE_PASTA);
|
||||
ASSERT(c->mode == MODE_PASTA);
|
||||
|
||||
inany_from_sockaddr(&aany, &port, sa);
|
||||
a4 = inany_v4(&aany);
|
||||
|
Reference in New Issue
Block a user