Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Dec 2025 16:38:11 +0000
From:      Mark Johnston <markj@FreeBSD.org>
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 <quentin.thebault@defenso.fr>
Subject:   git: 626cf6c8fcff - stable/15 - bhyve: add support for ng_device network backend
Message-ID:  <692dc473.8103.7e43c99a@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=626cf6c8fcff7acf10da4894d6f876026cb173db

commit 626cf6c8fcff7acf10da4894d6f876026cb173db
Author:     Quentin Thébault <quentin.thebault@defenso.fr>
AuthorDate: 2025-09-12 08:39:55 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-12-01 16:37:57 +0000

    bhyve: add support for ng_device network backend
    
    Signed-off-by: Quentin Thébault <quentin.thebault@defenso.fr>
    
    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)


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?692dc473.8103.7e43c99a>