mirror of
https://passt.top/passt
synced 2024-12-22 21:55:22 +00:00
vhost-user: compare mode MODE_PASTA and not MODE_PASST
As we are going to introduce the MODE_VU that will act like the mode MODE_PASST, compare to MODE_PASTA rather than to add a comparison to MODE_VU when we check for MODE_PASST. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
377b666dc9
commit
0c335d751a
14
conf.c
14
conf.c
@ -147,7 +147,7 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
|
|||||||
if (fwd->mode)
|
if (fwd->mode)
|
||||||
goto mode_conflict;
|
goto mode_conflict;
|
||||||
|
|
||||||
if (c->mode != MODE_PASST)
|
if (c->mode == MODE_PASTA)
|
||||||
die("'all' port forwarding is only allowed for passt");
|
die("'all' port forwarding is only allowed for passt");
|
||||||
|
|
||||||
fwd->mode = FWD_ALL;
|
fwd->mode = FWD_ALL;
|
||||||
@ -1118,7 +1118,7 @@ static void conf_ugid(char *runas, uid_t *uid, gid_t *gid)
|
|||||||
*/
|
*/
|
||||||
static void conf_open_files(struct ctx *c)
|
static void conf_open_files(struct ctx *c)
|
||||||
{
|
{
|
||||||
if (c->mode == MODE_PASST && c->fd_tap == -1)
|
if (c->mode != MODE_PASTA && c->fd_tap == -1)
|
||||||
c->fd_tap_listen = tap_sock_unix_open(c->sock_path);
|
c->fd_tap_listen = tap_sock_unix_open(c->sock_path);
|
||||||
|
|
||||||
c->pidfile_fd = pidfile_open(c->pidfile);
|
c->pidfile_fd = pidfile_open(c->pidfile);
|
||||||
@ -1285,7 +1285,7 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||||||
c->no_dhcp_dns = 0;
|
c->no_dhcp_dns = 0;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (c->mode != MODE_PASST)
|
if (c->mode == MODE_PASTA)
|
||||||
die("--no-dhcp-dns is for passt mode only");
|
die("--no-dhcp-dns is for passt mode only");
|
||||||
|
|
||||||
c->no_dhcp_dns = 1;
|
c->no_dhcp_dns = 1;
|
||||||
@ -1297,7 +1297,7 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||||||
c->no_dhcp_dns_search = 0;
|
c->no_dhcp_dns_search = 0;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
if (c->mode != MODE_PASST)
|
if (c->mode == MODE_PASTA)
|
||||||
die("--no-dhcp-search is for passt mode only");
|
die("--no-dhcp-search is for passt mode only");
|
||||||
|
|
||||||
c->no_dhcp_dns_search = 1;
|
c->no_dhcp_dns_search = 1;
|
||||||
@ -1352,7 +1352,7 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
c->mode == MODE_PASST ? "passt " : "pasta ");
|
c->mode == MODE_PASTA ? "pasta " : "passt ");
|
||||||
fprintf(stdout, VERSION_BLOB);
|
fprintf(stdout, VERSION_BLOB);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
case 15:
|
case 15:
|
||||||
@ -1648,7 +1648,7 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||||||
v6_only = true;
|
v6_only = true;
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
if (c->mode != MODE_PASST)
|
if (c->mode == MODE_PASTA)
|
||||||
die("--one-off is for passt mode only");
|
die("--one-off is for passt mode only");
|
||||||
|
|
||||||
if (c->one_off)
|
if (c->one_off)
|
||||||
@ -1694,7 +1694,7 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||||||
conf_ugid(runas, &uid, &gid);
|
conf_ugid(runas, &uid, &gid);
|
||||||
|
|
||||||
if (logfile) {
|
if (logfile) {
|
||||||
logfile_init(c->mode == MODE_PASST ? "passt" : "pasta",
|
logfile_init(c->mode == MODE_PASTA ? "pasta" : "passt",
|
||||||
logfile, logsize);
|
logfile, logsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
isolation.c
10
isolation.c
@ -312,7 +312,7 @@ int isolate_prefork(const struct ctx *c)
|
|||||||
* PID namespace. For passt, use CLONE_NEWPID anyway, in case somebody
|
* PID namespace. For passt, use CLONE_NEWPID anyway, in case somebody
|
||||||
* ever gets around seccomp profiles -- there's no harm in passing it.
|
* ever gets around seccomp profiles -- there's no harm in passing it.
|
||||||
*/
|
*/
|
||||||
if (!c->foreground || c->mode == MODE_PASST)
|
if (!c->foreground || c->mode != MODE_PASTA)
|
||||||
flags |= CLONE_NEWPID;
|
flags |= CLONE_NEWPID;
|
||||||
|
|
||||||
if (unshare(flags)) {
|
if (unshare(flags)) {
|
||||||
@ -379,12 +379,12 @@ void isolate_postfork(const struct ctx *c)
|
|||||||
|
|
||||||
prctl(PR_SET_DUMPABLE, 0);
|
prctl(PR_SET_DUMPABLE, 0);
|
||||||
|
|
||||||
if (c->mode == MODE_PASST) {
|
if (c->mode == MODE_PASTA) {
|
||||||
prog.len = (unsigned short)ARRAY_SIZE(filter_passt);
|
|
||||||
prog.filter = filter_passt;
|
|
||||||
} else {
|
|
||||||
prog.len = (unsigned short)ARRAY_SIZE(filter_pasta);
|
prog.len = (unsigned short)ARRAY_SIZE(filter_pasta);
|
||||||
prog.filter = filter_pasta;
|
prog.filter = filter_pasta;
|
||||||
|
} else {
|
||||||
|
prog.len = (unsigned short)ARRAY_SIZE(filter_passt);
|
||||||
|
prog.filter = filter_passt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) ||
|
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) ||
|
||||||
|
2
passt.c
2
passt.c
@ -333,7 +333,7 @@ loop:
|
|||||||
uint32_t eventmask = events[i].events;
|
uint32_t eventmask = events[i].events;
|
||||||
|
|
||||||
trace("%s: epoll event on %s %i (events: 0x%08x)",
|
trace("%s: epoll event on %s %i (events: 0x%08x)",
|
||||||
c.mode == MODE_PASST ? "passt" : "pasta",
|
c.mode == MODE_PASTA ? "pasta" : "passt",
|
||||||
EPOLL_TYPE_STR(ref.type), ref.fd, eventmask);
|
EPOLL_TYPE_STR(ref.type), ref.fd, eventmask);
|
||||||
|
|
||||||
switch (ref.type) {
|
switch (ref.type) {
|
||||||
|
12
tap.c
12
tap.c
@ -416,10 +416,10 @@ size_t tap_send_frames(const struct ctx *c, const struct iovec *iov,
|
|||||||
if (!nframes)
|
if (!nframes)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (c->mode == MODE_PASST)
|
if (c->mode == MODE_PASTA)
|
||||||
m = tap_send_frames_passt(c, iov, bufs_per_frame, nframes);
|
|
||||||
else
|
|
||||||
m = tap_send_frames_pasta(c, iov, bufs_per_frame, nframes);
|
m = tap_send_frames_pasta(c, iov, bufs_per_frame, nframes);
|
||||||
|
else
|
||||||
|
m = tap_send_frames_passt(c, iov, bufs_per_frame, nframes);
|
||||||
|
|
||||||
if (m < nframes)
|
if (m < nframes)
|
||||||
debug("tap: failed to send %zu frames of %zu",
|
debug("tap: failed to send %zu frames of %zu",
|
||||||
@ -1330,7 +1330,9 @@ void tap_sock_init(struct ctx *c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->mode == MODE_PASST) {
|
if (c->mode == MODE_PASTA) {
|
||||||
|
tap_sock_tun_init(c);
|
||||||
|
} else {
|
||||||
tap_sock_unix_init(c);
|
tap_sock_unix_init(c);
|
||||||
|
|
||||||
/* In passt mode, we don't know the guest's MAC address until it
|
/* In passt mode, we don't know the guest's MAC address until it
|
||||||
@ -1338,7 +1340,5 @@ void tap_sock_init(struct ctx *c)
|
|||||||
* first packets will reach it.
|
* first packets will reach it.
|
||||||
*/
|
*/
|
||||||
memset(&c->mac_guest, 0xff, sizeof(c->mac_guest));
|
memset(&c->mac_guest, 0xff, sizeof(c->mac_guest));
|
||||||
} else {
|
|
||||||
tap_sock_tun_init(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#define TCP_FRAMES_MEM 128
|
#define TCP_FRAMES_MEM 128
|
||||||
#define TCP_FRAMES \
|
#define TCP_FRAMES \
|
||||||
(c->mode == MODE_PASST ? TCP_FRAMES_MEM : 1)
|
(c->mode == MODE_PASTA ? 1 : TCP_FRAMES_MEM)
|
||||||
|
|
||||||
/* Static buffers */
|
/* Static buffers */
|
||||||
/**
|
/**
|
||||||
|
2
udp.c
2
udp.c
@ -747,7 +747,7 @@ void udp_buf_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t eve
|
|||||||
* whether we'll use tap or splice, always go one at a time
|
* whether we'll use tap or splice, always go one at a time
|
||||||
* for pasta mode.
|
* for pasta mode.
|
||||||
*/
|
*/
|
||||||
ssize_t n = (c->mode == MODE_PASST ? UDP_MAX_FRAMES : 1);
|
ssize_t n = (c->mode == MODE_PASTA ? 1 : UDP_MAX_FRAMES);
|
||||||
in_port_t dstport = ref.udp.port;
|
in_port_t dstport = ref.udp.port;
|
||||||
bool v6 = ref.udp.v6;
|
bool v6 = ref.udp.v6;
|
||||||
struct mmsghdr *mmh_recv;
|
struct mmsghdr *mmh_recv;
|
||||||
|
Loading…
Reference in New Issue
Block a user