From nobody Tue Oct 24 13:38:30 2023 X-Original-To: dev-commits-src-all@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 4SFCnM0xPhz4y3l4; Tue, 24 Oct 2023 13:38:31 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SFCnL5rPFz4ZMn; Tue, 24 Oct 2023 13:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698154710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ByLI8411T3gwIscWOhF7GLsQ93TNZUp5d7eBxDYThPU=; b=P6nymk2UuZfasOrQyvBGDpfud4N03Eopgm2ZjU80h7+O9jXb9/5vehUz4HaVH9pFuk+cBo /1pSTsimZJviEJSPssFCRHXhRsP1MLKdKiOOc2jhWrK7pCM0NF30ZuinJAVFyy4LW6m2IN Zd6EmQ3P3ZqQqBev5wuRp22qumdaS/jlFHCRl+XnaC8i5vZg008A/84jtUZLNeaeMzX+Wd +e3z4y763VqKDmjYiPpw7N2j7xOc454dHoXihPnb139i90PR2YLRjrKfqgn91wVD/pbrmx LGVQUd8mrVlVlPwapdaPb++7R+/KA6JENER+eXiyqd/Hlp6ztNzpb0KET3g8Eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698154710; a=rsa-sha256; cv=none; b=k2FIRL87MHGqehQIX9MEw++bgqIK8vHmcnojsTPjG4VKeCfjhzH87GrhUbwhg7sc/yqJRt XJ/GANKAl8bH6W/arOkVkPdtSLitJHY+Ct4TrP+Fis4SwzT+ga8vQcIBXKk7Ci/+2Nb2PQ GByiGPcDLNYZQg6qTNf5Lsq5iHjnUkugxT+efKSJ0GzbrAuzHXqFo6s/pbX68gnzCBuKPY 1i+AzasLmceJzd5VAR0Rifxt7WIE4JoDgjDoGqYUuKAtRR5gt241CFPGracMmCB8aYRCyB 6pDKU0utgC9Vzkrrp8urpwn0ZIEO9tTX+4hsLKbPDMANbuNeW12RcLZ3DdshBg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698154710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ByLI8411T3gwIscWOhF7GLsQ93TNZUp5d7eBxDYThPU=; b=jtG/RZB47ssws9dxhpVJXpBIsc1ALKSC7A1RNHARjzWJ2/eZ9kPTa2N5ZQDJKQhGroa8C6 H0x4pbnAc2YvkyksrMQydt3sxehIpjCRHKcwjGVhP6j0h42L6w244QJIWdoscD9Hnu+0PJ +z+0xoaKfEg6oiLd+oYyfMvRIDvxdl9AlsbJk2wJ0aV70HwhQhxCWJec9eKWIGNi7/tsNX vQ/I8pmlFOh8k97s3o20PhKWdgqd6JOj+OLlWPjeZP3geFKOr1mUkleQCj77wXgQfgCIVf jIpWEsg/CoTPZXPWbhF3STEUx0ifFzb6SJOBImUFiM4z3Nvokcs7CEK8ySVUdA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SFCnL4y05z9Zd; Tue, 24 Oct 2023 13:38:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39ODcU6k089625; Tue, 24 Oct 2023 13:38:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39ODcUE5089622; Tue, 24 Oct 2023 13:38:30 GMT (envelope-from git) Date: Tue, 24 Oct 2023 13:38:30 GMT Message-Id: <202310241338.39ODcUE5089622@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 700689bc2aba - stable/14 - bhyve: Use VMIO_SIOCSIFFLAGS instead of SIOCGIFFLAGS List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/14 X-Git-Reftype: branch X-Git-Commit: 700689bc2abaf860801b3896ceae86b0072f406c Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=700689bc2abaf860801b3896ceae86b0072f406c commit 700689bc2abaf860801b3896ceae86b0072f406c Author: Jan Bramkamp AuthorDate: 2023-09-04 08:38:25 +0000 Commit: Mark Johnston CommitDate: 2023-10-24 13:21:17 +0000 bhyve: Use VMIO_SIOCSIFFLAGS instead of SIOCGIFFLAGS Creating an IP socket to invoke the SIOCGIFFLAGS ioctl on is the only thing preventing bhyve from working inside a bhyve jail with IPv4 and IPv6 disabled restricting the jailed bhyve process to only access the host network via a tap/vmnet device node. PR: 273557 Fixes: 56be282bc999 ("bhyve: net_backends, automatically IFF_UP tap devices") Reviewed by: markj MFC after: 1 week (cherry picked from commit fd8b9c73a5a63a7aa438a73951d7a535b4f25d9a) --- usr.sbin/bhyve/net_backends.c | 52 ++++--------------------------------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c index fa7cd9c81f46..99781cfdcbb6 100644 --- a/usr.sbin/bhyve/net_backends.c +++ b/usr.sbin/bhyve/net_backends.c @@ -42,9 +42,7 @@ #include #include -#if defined(INET6) || defined(INET) #include -#endif #include #include #define NETMAP_WITH_LIBS @@ -180,17 +178,6 @@ SET_DECLARE(net_backend_set, struct net_backend); * The tap backend */ -#if defined(INET6) || defined(INET) -static const int pf_list[] = { -#if defined(INET6) - PF_INET6, -#endif -#if defined(INET) - PF_INET, -#endif -}; -#endif - struct tap_priv { struct mevent *mevp; /* @@ -222,11 +209,8 @@ tap_init(struct net_backend *be, const char *devname, { struct tap_priv *priv = NET_BE_PRIV(be); char tbuf[80]; - int opt = 1; -#if defined(INET6) || defined(INET) - struct ifreq ifrq; - int s; -#endif + int opt = 1, up = IFF_UP; + #ifndef WITHOUT_CAPSICUM cap_rights_t rights; #endif @@ -254,39 +238,11 @@ tap_init(struct net_backend *be, const char *devname, goto error; } -#if defined(INET6) || defined(INET) - /* - * Try to UP the interface rather than relying on - * net.link.tap.up_on_open. - */ - bzero(&ifrq, sizeof(ifrq)); - if (ioctl(be->fd, TAPGIFNAME, &ifrq) < 0) { - WPRINTF(("Could not get interface name")); - goto error; - } - - s = -1; - for (size_t i = 0; s == -1 && i < nitems(pf_list); i++) - s = socket(pf_list[i], SOCK_DGRAM, 0); - if (s == -1) { - WPRINTF(("Could open socket")); + if (ioctl(be->fd, VMIO_SIOCSIFFLAGS, &up)) { + WPRINTF(("tap device link up failed")); goto error; } - if (ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { - (void)close(s); - WPRINTF(("Could not get interface flags")); - goto error; - } - ifrq.ifr_flags |= IFF_UP; - if (ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) { - (void)close(s); - WPRINTF(("Could not set interface flags")); - goto error; - } - (void)close(s); -#endif - #ifndef WITHOUT_CAPSICUM cap_rights_init(&rights, CAP_EVENT, CAP_READ, CAP_WRITE); if (caph_rights_limit(be->fd, &rights) == -1)