From nobody Sat Oct 19 23:22:08 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 4XWHfG0DMzz5ZRXk; Sat, 19 Oct 2024 23:22:14 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) (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-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XWHfF5WlVz4Stj; Sat, 19 Oct 2024 23:22:13 +0000 (UTC) (envelope-from markjdb@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-qv1-xf35.google.com with SMTP id 6a1803df08f44-6cbd550b648so24500816d6.0; Sat, 19 Oct 2024 16:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729380132; x=1729984932; darn=freebsd.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=u4uajAl6ubo0bXx5pO4jC1Yqf6X70C7bbyINRz1uSL0=; b=lq3nD1OGLcWgLF+gOFDig1cw6mBCvsnMLhsP/ose5mZPu4qCUv+ZswIGyimKsaaQwT NVyWmCMkiD0WxZOBlnYoiTfhQ+k+PCxzqXTJvgXgMGoqtcjSIq9iFFtfSX7ysnw+W7lU fPcoJyKbC10nVgOPo5tzOOHK9IstyjUvvnOvfrKQ3fcBAxWkZs9wcexuDthk7vlsAZa3 iKm/jUorV3jrZ7+xxs5MBg1vkDJLfkAkdrU/XUodc30X5cuEwP20hjX8DdVsuDiCIKUE fIZANmRosAAJD3RTZ2W67HM8Kexa72Bo/KiEotrgV+JvQ0rKdnfawpoRn8/mcyeYHklP lRcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729380132; x=1729984932; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u4uajAl6ubo0bXx5pO4jC1Yqf6X70C7bbyINRz1uSL0=; b=SVIkOBAuwf/yN3LLp7AQuIexD8A2o8G0pqlUulzCt92d7MVGutn2kCRiCVw9DJUnL4 06AoFEHKX6KQyh8N3Ej+IYdOc+OcE+NjZHgw7UGLJ1UYc82Ori048+/BKydqQbod0wiR StohgEkOvosTihCTcGmD4l2zV9nYCv4MjxILG3QNaYXjPbY0oehUmFal1ZGncvOvJXSE LuCOIWXjPQHxTTdM1wUJ8vhAjXLayDBc/+Y1IEEFK6fKG4XhiRvvo9cEJB2LUM54cvD5 ZNK1RV9cu6h6EII8uCNrt6qVB6Oeqae6+GR9QocAf10mcy35wVjLSyeCsPKUGqTmCu+F e7vA== X-Forwarded-Encrypted: i=1; AJvYcCUK5ZOUYFTr/HdxUBMH9KLbO01j4L9q6OP8yqG4DT+nzZl8r2i4rn1uBJvJb5MynbInrA6BfGbsDq/Mu7KGr6FwWKggJUU=@freebsd.org, AJvYcCW4IJxWG1HoZ0IlElGH8GD1vnsAAcrZNCJgGBXHRtL0cYNviyKoewANDZJjC2IJ6sQ/NJNXUFTXb9WUSVWBnfA=@freebsd.org, AJvYcCX1AHbdLs0CwvI6fijqOCqNDcIl1Xp2dO2hi7clrVSLsOzEXmW+rCJIbRHAqsrLEEODs9noy08wUEp1ItX30pQP7NLt@freebsd.org X-Gm-Message-State: AOJu0YyI/WujBh802Ugr79eKlRTlVQg6+F24D7LbfNjiLjxI6LSQ6L2A IfFEnLt66swlQi7vHERJYDR9/I1nObw96a1H6sVwb6gr6ZVsPugpft22PA== X-Google-Smtp-Source: AGHT+IEQWWLu0BlniKcOF0oYMY3hX1IzpqFPCMLb8kB+StYoTAOEVuVD+qDYaVwkpMDWm7q7uAud2A== X-Received: by 2002:a05:6214:5d0a:b0:6cb:9bc9:e24b with SMTP id 6a1803df08f44-6cde160bcc4mr90782156d6.43.1729380132368; Sat, 19 Oct 2024 16:22:12 -0700 (PDT) Received: from nuc (192-0-220-237.cpe.teksavvy.com. [192.0.220.237]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-460d3c3aff7sm2447071cf.12.2024.10.19.16.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 16:22:11 -0700 (PDT) Date: Sat, 19 Oct 2024 19:22:08 -0400 From: Mark Johnston To: Konstantin Belousov Cc: John Baldwin , 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 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4XWHfF5WlVz4Stj X-Spamd-Bar: ---- On Sat, Oct 19, 2024 at 07:10:53PM +0300, 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. Gleb's proposal, described a bit in D47147, is to require device-based ifnet drivers to fully detach themselves from the parent bus in order to change VNETs. The intent is to eliminate the need for if_vmove() and all the complexity it entails. This would also eliminate the need for a "home" VNET, referenced in the patch that you reference here. > 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). Shouldn't something like this be handled by if_detach()/ether_ifdetach()? Posed another way, why does device detach itself need to care about the VNET? I tend to agree that having VNET knowledge in subr_bus.c is a hack. My aim was just to fix the panic without making the hack worse. > 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().