mirror of
https://passt.top/passt
synced 2025-06-12 10:35:34 +02:00
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>
This commit is contained in:
parent
df69be379e
commit
3c6ae62510
10 changed files with 274 additions and 156 deletions
22
passt.c
22
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue