From nobody Mon Oct 21 14:03:03 2024 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 4XXH886L8zz5ZKHl; Mon, 21 Oct 2024 14:03:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XXH885qKKz4WG2; Mon, 21 Oct 2024 14:03:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729519384; 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: in-reply-to:in-reply-to:references:references; bh=aiSGXcX54+0JjgIHM66pk28jveXuU6QamXkxlxlaouU=; b=qToG6nyARRqcbg9+yjqsdPAVR7H/nZKXEdG0Pay/Za0Z+JnKgKibv/UtFpMwBZ1/OfeAW5 SaWYXr0udCyKZm9Dpv3mkELoV4ZzIFfbWRzCnx6u4dX0711IQrqUvsN/9sbucuDiHvfQJf 9iCZL5/kj4Lxu5hZ6+pqG1Wp7gSR1QVDU4v2/XoOJjM3cn2ceDzPqZBfoOiTFXjavTYkCZ y8hiW0I888Xy3Cv3m8OcBv+85J0bLXN7yLMwVLFq7A+Xz15dX3v/vghVMPYPIVnCYy2VBr 0xq/SPfiCQ4zm7ZA63Ei2R2Xua6uB7wW2OAxlzXnEA0oI0bIYt0RH0ozRsoHDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729519384; 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: in-reply-to:in-reply-to:references:references; bh=aiSGXcX54+0JjgIHM66pk28jveXuU6QamXkxlxlaouU=; b=h6+h8HRv8mhkkkcRRbEr9crQoXrcDxnvJxDz58ngp5eS3PFsMwd+ItT0ea7yZSVygm5bHg vXAWCPqHr2r4msfwNCj4MNPl0aD7ZXQ6Cby15GTdfIcuKk0f59emB4M7cLE7hPkn/TQFax beFxUbNCYcOacjR0GuqX+eAP51EEzxYZ9nNeL3yQOOejPz0xjjioK1kXuqA2fnuPyOMhJY ZSdQImyWbDRnkVI8QexZJkoaxqdy15SWw7wewRKy0QfKdCaXN9Cn1YO3FFVsv3twJP7Jgg t8EackQYF1Ag91UJCP3aoSoYVwOqt93AZ/iItTS876TbjREZXcI55pFSH6tUYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729519384; a=rsa-sha256; cv=none; b=MGVMC7BsmVQBjulmNYMUq+lEEn+VclWKTkb3mx6uIYi9DdyFZz7Mu+zbPGZ8Pu5xpD4wGn 2JHFfnl03VXz59Covg2Db2AG51YO3/8fDP2R2PjLjc5G4QEFHh5GgjNfE+UibpkDFxsL38 QD89uIqaClHLqh6T6kFVMHJg6TtHwVZuB/rK+LNFt8oAADlrIq2crxX+2iPp7CcsbxSplG cWovtXh/0FbmNMuz5bQm/TqdE7vF44tJ+1WwNiHHGH7Emqr8kdB90fZwsDxhzktDcCRh31 hrPXl9XKaG4fweveILpJ4BH7D2lQQ02l9ZS6r2bSSYhCXxGgi4+d+8FdTCY2nQ== Received: from [IPV6:2601:5c0:4200:b830:f8e2:d9f1:55af:c410] (unknown [IPv6:2601:5c0:4200:b830:f8e2:d9f1:55af:c410]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4XXH883wbWz10XF; Mon, 21 Oct 2024 14:03:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <1e519577-35cb-499e-8e41-57d93f78f8ee@FreeBSD.org> Date: Mon, 21 Oct 2024 10:03:03 -0400 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: f4e35c044c89 - main - bus: Set the current VNET in device_attach() To: Konstantin Belousov Cc: Mark Johnston , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202410191304.49JD4JoM084001@gitrepo.freebsd.org> Content-Language: en-US From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/19/24 12:10, Konstantin Belousov wrote: > On Sat, Oct 19, 2024 at 11:36:32AM -0400, John Baldwin wrote: >> On 10/19/24 09:04, Mark Johnston wrote: >>> The branch main has been updated by markj: >>> >>> URL: https://cgit.FreeBSD.org/src/commit/?id=f4e35c044c8988b7452cefbdcc417f5fd723e021 >>> >>> commit f4e35c044c8988b7452cefbdcc417f5fd723e021 >>> Author: Mark Johnston >>> AuthorDate: 2024-10-19 13:03:56 +0000 >>> Commit: Mark Johnston >>> CommitDate: 2024-10-19 13:03:56 +0000 >>> >>> bus: Set the current VNET in device_attach() >>> Some drivers, in particular anything which creates an ifnet during >>> attach, need to have the current VNET set, as if_attach_internal() and >>> its callees access VNET-global variables. >>> device_probe_and_attach() handles this, but this is not the only way to >>> arrive in DEVICE_ATTACH. In particular, bus drivers may invoke >>> device_attach() directly, as does devctl2's DEV_ENABLE ioctl handler. >>> So, set the current VNET in device_attach() instead. >>> I believe it is always safe to use vnet0, as devctl2 ioctls are not >>> permitted within a jail. >>> PR: 282168 >>> Reviewed by: zlei, kevans, bz, imp, glebius >>> MFC after: 1 week >>> Differential Revision: https://reviews.freebsd.org/D47174 >> >> Hmm, there was some other review I thought that had a completely different change. >> That change removed all the vnet stuff from new-bus and instead handled it in >> if.c. Specifically, that if_attach would set a default vnet to vnet0 if there >> wasn't an active vnet at the time. See all the discussion in >> https://reviews.freebsd.org/D42678 which has a patch that I think is correct >> in the comments. >> > In fact, I think that bus level is better. At least, I know that detach > also might need something by vnet (e.g. mce(4) needs to clear the IPSEC > offload database on detach, although it still does not do). During detach your ifnet has if_vnet and it needs to use that (and only that, not vnet0). new-bus can't know about if_vnet so can't set curvnet correctly. -- John Baldwin