aboutgitcodebugslistschat
path: root/passt.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-05-01 06:36:34 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-05-01 07:19:05 +0200
commit3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf (patch)
treeb6f895672d7a4db2d64c5faa3cea39245f0326f9 /passt.c
parentdf69be379e6d8b8b1aab2d00b858b89acfde7ab8 (diff)
downloadpasst-3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf.tar
passt-3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf.tar.gz
passt-3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf.tar.bz2
passt-3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf.tar.lz
passt-3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf.tar.xz
passt-3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf.tar.zst
passt-3c6ae625101aee6ddf94e0fd85ce3a9c9067c3bf.zip
conf, tcp, udp: Allow address specification for forwarded ports
This feature is available in slirp4netns but was missing in passt and pasta. Given that we don't do dynamic memory allocation, we need to bind sockets while parsing port configuration. This means we need to process all other options first, as they might affect addressing and IP version support. It also implies a minor rework of how TCP and UDP implementations bind sockets. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.c')
-rw-r--r--passt.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/passt.c b/passt.c
index 8781a7f..e5064f8 100644
--- a/passt.c
+++ b/passt.c
@@ -370,20 +370,13 @@ int main(int argc, char **argv)
__setlogmask(LOG_MASK(LOG_EMERG));
- conf(&c, argc, argv);
- trace_init(c.trace);
-
- if (!c.debug && (c.stderr || isatty(fileno(stdout))))
- __openlog(log_name, LOG_PERROR, LOG_DAEMON);
-
- c.epollfd = epoll_create1(c.foreground ? O_CLOEXEC : 0);
+ /* NOLINTNEXTLINE(android-cloexec-epoll-create1): forking in a moment */
+ c.epollfd = epoll_create1(0);
if (c.epollfd == -1) {
perror("epoll_create1");
exit(EXIT_FAILURE);
}
- quit_fd = pasta_netns_quit_init(&c);
-
if (getrlimit(RLIMIT_NOFILE, &limit)) {
perror("getrlimit");
exit(EXIT_FAILURE);
@@ -395,13 +388,20 @@ int main(int argc, char **argv)
}
sock_probe_mem(&c);
+ conf(&c, argc, argv);
+ trace_init(c.trace);
+
+ if (!c.debug && (c.stderr || isatty(fileno(stdout))))
+ __openlog(log_name, LOG_PERROR, LOG_DAEMON);
+
+ quit_fd = pasta_netns_quit_init(&c);
+
c.fd_tap = c.fd_tap_listen = -1;
tap_sock_init(&c);
clock_gettime(CLOCK_MONOTONIC, &now);
- if ((!c.no_udp && udp_sock_init(&c)) ||
- (!c.no_tcp && tcp_sock_init(&c)))
+ if ((!c.no_udp && udp_init(&c)) || (!c.no_tcp && tcp_init(&c)))
exit(EXIT_FAILURE);
proto_update_l2_buf(c.mac_guest, c.mac, &c.addr4);