From nobody Mon Dec 1 16:38:11 2025 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dKqMl3wGQz6Js7B for ; Mon, 01 Dec 2025 16:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dKqMl1xBgz3dJq for ; Mon, 01 Dec 2025 16:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764607091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KlrzMYEPkPIyo8u3A5MRjgUWhPYBrtvowo1TM5FcMp4=; b=THH9sxNIGbU8bsn59C7/Uh41C2K/CYjwb+vt3UPRHhDzvVFQt5qDJVNcsi9AHURYb1rVIh fvhdRPi5TNFzapFYBUzLCaw/b22yPdAZP5YVpRr30B7WSp1xuL/4VqCZMMOuxvWczsCzOy aIVC0643zhRTqw+7q9KcZyIMRSgwPUnFHzHbIiKxR0TFNPPgJJqmY0BER/KLb2R0R1X/st SXgUNcmSM2NBnI9Kg53AKWFGXJHOjwq1V72k2wOizaoZo8nRe6B6tMrW/XSGMCepaaQNYJ pIWPRKQNbqbCez/+SVRDuMjNsMbZ+myU2e7J5cUmLFYRsC73ywILhjSS2DM8Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764607091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KlrzMYEPkPIyo8u3A5MRjgUWhPYBrtvowo1TM5FcMp4=; b=feYE4sbSJfibJn1qSY0Ve/WQyeAI63n5/fYbLBM38R1TiJ5nrqxB9EZQyQKxW4fRembP7y vQNhD5q5/kH2PLN3Unsf9fZxTi2VFQV+j5/krbXD1+TbnyssKAskyjAAaheqWTjKbLGHPl aOE/ZOMoP+GA8V4MsuTZCLTnlcBU+sjMmltdh7gMNcuXgfeokyDsSoKYsmPXyAlDpzzuro kO1COqVFyBhJ2jESknCEVbxcMR7m4BdVBvwrDL/60etHfvFXI9+62uD3CfDmZSnbn5TaPn TICt+Y9v+x3lGC6GLGBez8aS+E2ejNI/ycra0WzQie7UlZoD8ovaOp6zQ8he/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764607091; a=rsa-sha256; cv=none; b=HW4y1H5r+MNdK37cHOCkaBlvb43FCUKlIm7gCrhZhtaZZS92XbIKdoMUpKBldsu1V81wMu JXUrC5YzMINajTLRuuGKKHoeQHfWZGMz7aq5jgdNaamskh28+rImeyId5gXpoYKSjKZcLB 0/02v7yurSBtfl3JeRiuwsMR2ZcDOl04kU1pn4A2wobSvx5GZq4Qx1EcmPKgBS2NntSrh7 VPuUHvBa/RKpEoB2tcFac7sNkehGQpqG4ckV56gXZA179zTWXLK/fCqlZBoNHKYia20Od+ Vq5nZi2Z4fAB6Y35+90G4Q1A3mGd2SJay8pACQcE1frdUS5VkQBVy73mFGsGPQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dKqMl1H2jzCpg for ; Mon, 01 Dec 2025 16:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 8103 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 01 Dec 2025 16:38:11 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Quent=?utf-8?Q?in Th=C3=A9?=bault From: Mark Johnston Subject: git: 626cf6c8fcff - stable/15 - bhyve: add support for ng_device network backend List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 626cf6c8fcff7acf10da4894d6f876026cb173db Auto-Submitted: auto-generated Date: Mon, 01 Dec 2025 16:38:11 +0000 Message-Id: <692dc473.8103.7e43c99a@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=626cf6c8fcff7acf10da4894d6f876026cb173db commit 626cf6c8fcff7acf10da4894d6f876026cb173db Author: Quentin Thébault AuthorDate: 2025-09-12 08:39:55 +0000 Commit: Mark Johnston CommitDate: 2025-12-01 16:37:57 +0000 bhyve: add support for ng_device network backend Signed-off-by: Quentin Thébault Reviewed by: markj MFC after: 1 month Sponsored by: Defenso Differential Revision: https://reviews.freebsd.org/D52542 Pull Request: https://github.com/freebsd/freebsd-src/pull/1880 (cherry picked from commit 1aad95345237424918e5f6b18464df4dbc2aa1d8) --- usr.sbin/bhyve/bhyve.8 | 19 ++++++++++++++++++- usr.sbin/bhyve/net_backends.c | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8 index 13f0d239ef40..27e067f50394 100644 --- a/usr.sbin/bhyve/bhyve.8 +++ b/usr.sbin/bhyve/bhyve.8 @@ -521,6 +521,8 @@ considered unconnected. .Op Cm \&,mtu= Ar N .Xc .It +.Cm ngd Ar N +.It .Xo .Cm netgraph,path= Ar ADDRESS Cm \&,peerhook= Ar HOOK .Op Cm \&,socket= Ar NAME @@ -545,6 +547,19 @@ The MAC address is an ASCII string in .Xr ethers 5 format. .Pp +A +.Cm ngd +device can be used to connect a guest to a +.Xr netgraph 4 +through a +.Xr ng_device 4 +node. +This can be used to run bhyve in a +.Xr VNET 9 +jail, and give it access to the host's netgraph, that cannot be reached +directly, by exposing the ng_device through +.Xr devfs 8 . +.Pp With .Cm virtio-net devices, the @@ -575,7 +590,9 @@ must comply with .Xr netgraph 4 addressing rules. .Pp -The slirp backend can be used to provide a NATed network to the guest. +The +.Cm slirp +backend can be used to provide a NATed network to the guest. This backend has poor performance but does not require any network configuration on the host system. It depends on the diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c index 2d11c45f217a..95909d1f8ea2 100644 --- a/usr.sbin/bhyve/net_backends.c +++ b/usr.sbin/bhyve/net_backends.c @@ -119,7 +119,8 @@ tap_init(struct net_backend *be, const char *devname, goto error; } - if (ioctl(be->fd, VMIO_SIOCSIFFLAGS, up)) { + if (strncmp("ngd", be->prefix, 3) && + ioctl(be->fd, VMIO_SIOCSIFFLAGS, up)) { EPRINTLN("tap device link up failed"); goto error; } @@ -273,8 +274,24 @@ static struct net_backend vmnet_backend = { .set_cap = tap_set_cap, }; +/* A clone of the tap backend, with a different prefix. */ +static struct net_backend ngd_backend = { + .prefix = "ngd", + .priv_size = sizeof(struct tap_priv), + .init = tap_init, + .cleanup = tap_cleanup, + .send = tap_send, + .peek_recvlen = tap_peek_recvlen, + .recv = tap_recv, + .recv_enable = tap_recv_enable, + .recv_disable = tap_recv_disable, + .get_cap = tap_get_cap, + .set_cap = tap_set_cap, +}; + DATA_SET(net_backend_set, tap_backend); DATA_SET(net_backend_set, vmnet_backend); +DATA_SET(net_backend_set, ngd_backend); int netbe_legacy_config(nvlist_t *nvl, const char *opts)