From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: passt.top; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=fSbGxAnu; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by passt.top (Postfix) with ESMTPS id EB6E55A0619 for ; Sun, 02 Aug 2026 15:23:40 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-493f6de72faso8098235e9.0 for ; Sun, 02 Aug 2026 06:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785677020; x=1786281820; darn=passt.top; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cLrFMbe8wMF4ns7kwHpvz+Lm0/0eVPUlbNqcNN+nAh8=; b=fSbGxAnuOUaIOLr4aKjMJZ5gY3BOIHjFYmoZDMyIxaIPN/sIxEy4a4GsFV2lCW8A6i ezEK3oWBW9RUWqbdH5w7d+lc2SNMBqjuvQdMttEcvqAKxESP9gZKZVsXMW4b/2rb8qHv P5bUiWTcf+sZicvDnUPOgrmPjgJZ+TdppZT5oDvowhlRQp5QjkrJMf+G9mK2T7b29ufL NOs+TJXK44hjXwbHZVA166WNU6hXc2czOJgkmnfpylp3OmreD31fKrBonZEBxd1FzeKI RIz/oxSx2as8r/LRhVFs9D/3NumkJtrXw4XegGsBHWkIQXB9SbulFNPhY1SXMgghveTE IOBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785677020; x=1786281820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=cLr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Uz98xES1XhDRRN3pyIqDLwZ3jfqf X-Received: by 2002:a05:600c:1f8f:b0:493:f478:4c71 with SMTP id 5b1f17b1804b1-4980eba0817mr112723145e9.7.1785677020244; Sun, 02 Aug 2026 06:23:40 -0700 (PDT) Received: from localhost.localdomain ([196.137.15.128]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4980869106csm180745155e9.9.2026.08.02.06.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 06:23:39 -0700 (PDT) From: Ammar Yasser To: passt-dev@passt.top Subject: [RFC v3 3/8] conf: Add context fields, epoll types and the --vhost flag to pasta Date: Sun, 2 Aug 2026 13:21:50 +0000 Message-Id: <20260802132155.870796-4-aerosound161@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260802132155.870796-1-aerosound161@gmail.com> References: <20260802132155.870796-1-aerosound161@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LSTR6URTEWERLWY5EW337XG7XAXO6FYR X-Message-ID-Hash: LSTR6URTEWERLWY5EW337XG7XAXO6FYR X-MailFrom: aerosound161@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: eperezma@redhat.com, Ammar Yasser X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The --vhost controls whether or no to use vhost acceleration for pasta. The EPOLL_TYPE_VHOST_CALL means that kernel wants to notify us about data it has written. EPOLL_TYPE_VHOST_ERROR means the kernel encountered an internal error on vhost and wants to notify us that something went wrong. Add the fd_vhost field on the context which will carry the file descriptor of the device and will indicate that the setup was successful. The vq field contains the kick, call and err file descriptors for both queues. Also add vhost (mark if vhost acceleration was requested) and virtio_features field. Signed-off-by: Ammar Yasser --- conf.c | 6 ++++++ epoll_type.h | 4 ++++ passt.c | 3 +++ passt.h | 15 +++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/conf.c b/conf.c index faf2681..c31546e 100644 --- a/conf.c +++ b/conf.c @@ -736,6 +736,7 @@ pasta_opts: " default: auto\n" " --host-lo-to-ns-lo Translate host-loopback forwards to\n" " namespace loopback\n" + " --vhost\t\tUse vhost-kernel acceleration\n" " --userns NSPATH Target user namespace to join\n" " --netns PATH|NAME Target network namespace to join\n" " --netns-only Don't join existing user namespace\n" @@ -766,6 +767,7 @@ enum passt_modes conf_mode(int argc, char *argv[]) int vhost_user = 0; const struct option optvu[] = { {"vhost-user", no_argument, &vhost_user, 1 }, + {"vhost", no_argument, NULL, 0 }, { 0 }, }; char argv0[PATH_MAX], *basearg0; @@ -1309,6 +1311,7 @@ void conf(struct ctx *c, int argc, char **argv) {"ipv4-only", no_argument, NULL, '4' }, {"ipv6-only", no_argument, NULL, '6' }, {"one-off", no_argument, NULL, '1' }, + {"vhost", no_argument, &c->vhost, 1 }, {"tcp-ports", required_argument, NULL, 't' }, {"udp-ports", required_argument, NULL, 'u' }, {"tcp-ns", required_argument, NULL, 'T' }, @@ -1838,6 +1841,9 @@ void conf(struct ctx *c, int argc, char **argv) die("--no-copy-addrs needs --config-net"); } + if (c->vhost && c->mode != MODE_PASTA) + die("--vhost is only available in pasta mode"); + if (c->mode == MODE_PASTA && c->splice_only) { if (c->no_splice) die("--splice-only is incompatible with --no-splice"); diff --git a/epoll_type.h b/epoll_type.h index 061325a..e3206d1 100644 --- a/epoll_type.h +++ b/epoll_type.h @@ -50,6 +50,10 @@ enum epoll_type { EPOLL_TYPE_CONF_LISTEN, /* Configuration socket */ EPOLL_TYPE_CONF, + /* vhost-kernel call socket */ + EPOLL_TYPE_VHOST_CALL, + /* vhost-kernel error socket */ + EPOLL_TYPE_VHOST_ERROR, EPOLL_NUM_TYPES, }; diff --git a/passt.c b/passt.c index 5054551..865b331 100644 --- a/passt.c +++ b/passt.c @@ -65,6 +65,7 @@ char pkt_buf[PKT_BUF_BYTES] __attribute__ ((aligned(PAGE_SIZE))); struct ctx passt_ctx = { .pidfile_fd = -1, .fd_tap = -1, + .fd_vhost = -1, .fd_tap_listen = -1, .fd_control_listen = -1, .fd_repair_listen = -1, @@ -92,6 +93,8 @@ char *epoll_type_str[] = { [EPOLL_TYPE_NL_NEIGH] = "netlink neighbour notifier socket", [EPOLL_TYPE_CONF_LISTEN] = "configuration listening socket", [EPOLL_TYPE_CONF] = "configuration socket", + [EPOLL_TYPE_VHOST_CALL] = "vhost-kernel call socket", + [EPOLL_TYPE_VHOST_ERROR] = "vhost-kernel error socket", }; static_assert(ARRAY_SIZE(epoll_type_str) == EPOLL_NUM_TYPES, "epoll_type_str[] doesn't match enum epoll_type"); diff --git a/passt.h b/passt.h index 51ccd4f..c729316 100644 --- a/passt.h +++ b/passt.h @@ -183,8 +183,11 @@ struct ip6_ctx { * @fd_repair_listen: File descriptor for listening TCP_REPAIR socket, if any * @fd_repair: Connected AF_UNIX socket for TCP_REPAIR helper * @our_tap_mac: Pasta/passt's MAC on the tap link + * @fd_vhost: File descriptor for /dev/vhost-net, set on vhost setup * @guest_mac: MAC address of guest or namespace, seen or configured * @hash_secret: 128-bit secret for siphash functions + * @virtio_features: Negotiated virtio feature bits + * @vhost: Enable vhost-kernel acceleration for pasta * @ifi4: Template interface for IPv4, -1: none, 0: IPv4 disabled * @ip4: IPv4 configuration * @dns_search: DNS search list @@ -202,6 +205,8 @@ struct ip6_ctx { * @no_udp: Disable UDP operation * @udp: Context for UDP protocol handler * @no_icmp: Disable ICMP operation + * @vq: Per-virtqueue eventfd descriptors for vhost-kernel + * ([0] is RX, [1] is TX; each holds kick_fd, call_fd, err_fd) * @mtu: MTU passed via DHCP/NDP * @no_dns: Do not source/use DNS servers for any purpose * @no_dns_search: Do not source/use domain search lists for any purpose @@ -258,11 +263,14 @@ struct ctx { int fd_control; int fd_repair_listen; int fd_repair; + + int fd_vhost; unsigned char our_tap_mac[ETH_ALEN]; unsigned char guest_mac[ETH_ALEN]; uint16_t mtu; uint64_t hash_secret[2]; + uint64_t virtio_features; int ifi4; struct ip4_ctx ip4; @@ -288,6 +296,12 @@ struct ctx { struct udp_ctx udp; int no_icmp; + struct { + int kick_fd; + int call_fd; + int err_fd; + } vq[2]; + int no_dns; int no_dns_search; int no_dhcp_dns; @@ -300,6 +314,7 @@ struct ctx { int splice_only; int host_lo_to_ns_lo; int freebind; + int vhost; bool chroot_fallback; int low_wmem; -- 2.34.1