From nobody Sat Oct 19 16:10:53 2024 X-Original-To: dev-commits-src-main@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 4XW64x6BcVz5bFfr; Sat, 19 Oct 2024 16:11:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4XW64w6FCfz4m8d; Sat, 19 Oct 2024 16:11:12 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 49JGAsOI058439; Sat, 19 Oct 2024 19:10:57 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 49JGAsOI058439 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 49JGArbR058438; Sat, 19 Oct 2024 19:10:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 19 Oct 2024 19:10:53 +0300 From: Konstantin Belousov To: John Baldwin Cc: Mark Johnston , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: f4e35c044c89 - main - bus: Set the current VNET in device_attach() Message-ID: References: <202410191304.49JD4JoM084001@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4XW64w6FCfz4m8d X-Spamd-Bar: ---- 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). It sounds as if bus_topo_lock() is the right place. May be some other name for it is better, like bus_topo_changes_enter().