From nobody Wed Apr 19 02:31:42 2023 X-Original-To: freebsd-current@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 4Q1Ptw1Gw7z44p9S for ; Wed, 19 Apr 2023 02:31:52 +0000 (UTC) (envelope-from zlei@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q1Ptw0rb5z47x2; Wed, 19 Apr 2023 02:31:52 +0000 (UTC) (envelope-from zlei@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681871512; 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: in-reply-to:in-reply-to:references:references; bh=0g5dyRpVZYEBPED/JFrHltyQ2AcxdhJai3Qluxar0HM=; b=aOdzIBxxf74laM8VTlnDObp1+E9yL+vGgBjG6hj1gIxT1PCHOPLIcjLyng/6z/dIwc4KBP H9MedA5hP/rnuX763tjXoi/sFoPjOWd+/G6VXapvHF2wPNqWxsilZ3wqHdIBCg67gAOxN9 xbSa4QlwismaD8wF/+H1ftwD088ElXO6T9gpn1Mfi/eGW59WOIpnW7VHJHhb1B8LRDkatw jVLixLPjUbzfzhrU6b76ByEgMgQiw/ob5gEkrTcfgB5wK20lISVcOxMUMPqRwT0LFDhOE2 33lxrm4jyptOmV7xRmSiIfOTjBXG9Di/qzt24LFM9HKESngpDxOIfpAJCfgIEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681871512; 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: in-reply-to:in-reply-to:references:references; bh=0g5dyRpVZYEBPED/JFrHltyQ2AcxdhJai3Qluxar0HM=; b=pPJYViJTDpLLiJ5AznCMhIr0NWc18e5TSFe35sq43eqJAbSUv7Ed8a4vC1eAilWSKPZjjS QJ2XsVGI/k334nIVNZfvy+dmIgqBT1Uqp/jsdlDBfXiZ25Ma/usiK074KulH7ijGL7YMFf j24kb12rYE292dxnFXVi1ucmqvAXjZ6RZ4sfQPTn/TbgCVLEZa307N6odmfggyUjF3S8aK zXBt16x5ljWbJEmqIfnULAdMUkcVBIYVPlmuwFkimMiQnrTaHynMTYj14JMoBOr+5yK9Ce YCx56To/Y5NM+KrYktw+iIl0femdIUXlPZSy+DlboNYktWEQHMVHLn7KTM4dQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681871512; a=rsa-sha256; cv=none; b=uaNAllyiBBYr6V37H5yHvS0qGBWfS4853IQRJW11L1q2TYeZKa09YTlTolOFX/QhAKIUey +1p3weHk/SrX9tkYfAU+qw1uREsez3oY+m9t+XMNMxrEKu9FD6ub2a3R4OjfiRALlTBBzl pNpM6YJxpZOTKIRBKDGYeFWyCTT/CzVr3lqlRyku4ASXVJDBf+I8Z52ST0nB63XScehEE1 dhP4Y957518EZJhiPHch3Hw0GAqzxgOjnXPW9yfjuBL63x02YNmYnNOJsf67ThZCLSWxUo sUAOzDbXu7x12mBlOaw53vQiwn/jgfqN9b1rs6fMLrLfXmllwFkysrTl1E5MXg== Received: from smtpclient.apple (unknown [IPv6:2001:19f0:6001:9db:98f0:9fe0:3545:10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: zlei/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Q1Ptt57QHz1KMk; Wed, 19 Apr 2023 02:31:50 +0000 (UTC) (envelope-from zlei@FreeBSD.org) From: Zhenlei Huang Message-Id: <2CFA5EBD-ABEB-4D22-9D9A-50725168112E@FreeBSD.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_B7DDE398-2F32-4F00-BCD5-DEB9D957E844" List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: Is it valid to combine CTLFLAG_TUN with CTLFLAG_VNET ? Date: Wed, 19 Apr 2023 10:31:42 +0800 In-Reply-To: <263045d4-409a-8a2d-87e1-50b1afcb7338@selasky.org> Cc: freebsd-current@freebsd.org To: Hans Petter Selasky , Gleb Smirnoff References: <94C1B333-9C0F-4874-BBB1-3E72F3DF3F6A@FreeBSD.org> <9dc65578-9312-1139-932f-396bc42e66b2@selasky.org> <263045d4-409a-8a2d-87e1-50b1afcb7338@selasky.org> X-Mailer: Apple Mail (2.3696.120.41.1.2) X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_B7DDE398-2F32-4F00-BCD5-DEB9D957E844 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Apr 6, 2023, at 3:56 AM, Hans Petter Selasky = wrote: >=20 > On 4/5/23 21:44, Hans Petter Selasky wrote: >> On 4/5/23 20:23, Gleb Smirnoff wrote: >>> What if we remove the CTLFLAG_VNET check from the code you posted = above? >>> I don't see anything going wrong, rather going right =F0=9F=98=84 >>>=20 >>> CTLFLAG_VNET will not mask away CTLFLAG_TUN. >> Hi Gleb, >> It's possible to bypass that check, but some work needs to be done = first. Then all jails created, will also start from those sysctl tunable = values. >> The problem is, where does the VNET base pointer come from? >> Especially those static sysctl's. You would need to make some design = there I guess and look at the SYSINIT() order. When are SYSINIT's filled = with tunable data's. And when is the default VNET created. >> Because the data pointer passed to the register sysctl function is = simply an offset pointer into a malloc'ed structure. >> --HPS >=20 > Hi Zhenlei, >=20 > Feel free to work on this, and add me as a reviewer and complete phase = two of: >=20 >> commit 3da1cf1e88f8448bb10c5f778ab56ff65c7a6938 >> Author: Hans Petter Selasky >> Date: Fri Jun 27 16:33:43 2014 +0000 >> Extend the meaning of the CTLFLAG_TUN flag to automatically check = if >> there is an environment variable which shall initialize the SYSCTL >> during early boot. This works for all SYSCTL types both statically = and >> dynamically created ones, except for the SYSCTL NODE type and = SYSCTLs >> which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added = to >=20 > --HPS Posted to https://reviews.freebsd.org/D39638 = =20 CC freebsd-current if some people are interested in the fix. Best regards, Zhenlei --Apple-Mail=_B7DDE398-2F32-4F00-BCD5-DEB9D957E844 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Apr 6, 2023, at 3:56 AM, Hans Petter Selasky <hps@selasky.org> = wrote:

On 4/5/23 21:44, Hans Petter Selasky wrote:
On 4/5/23 20:23, Gleb = Smirnoff wrote:
What = if we remove the CTLFLAG_VNET check from the code you posted above?
I don't see anything going wrong, rather going right =F0=9F=98=84=

CTLFLAG_VNET will not mask away = CTLFLAG_TUN.
Hi Gleb,
It's = possible to bypass that check, but some work needs to be done first. = Then all jails created, will also start from those sysctl tunable = values.
The problem is, where does the VNET base pointer = come from?
Especially those static sysctl's. You would = need to make some design there I guess and look at the SYSINIT() order. = When are SYSINIT's filled with tunable data's. And when is the default = VNET created.
Because the data pointer passed to the = register sysctl function is simply an offset pointer into a malloc'ed = structure.
--HPS

Hi Zhenlei,

Feel free to work on = this, and add me as a reviewer and complete phase two of:

commit = 3da1cf1e88f8448bb10c5f778ab56ff65c7a6938
Author: Hans = Petter Selasky <hselasky@FreeBSD.org>
Date: =   Fri Jun 27 16:33:43 2014 +0000
=    Extend the meaning of the CTLFLAG_TUN flag to = automatically check if
   there is an = environment variable which shall initialize the SYSCTL
=    during early boot. This works for all SYSCTL types = both statically and
   dynamically created = ones, except for the SYSCTL NODE type and SYSCTLs
=    which belong to VNETs. A new flag, CTLFLAG_NOFETCH, = has been added to

--HPS

Posted = to https://reviews.freebsd.org/D39638 
CC freebsd-current if = some people are interested in the fix.

Best regards,
Zhenlei

= --Apple-Mail=_B7DDE398-2F32-4F00-BCD5-DEB9D957E844--