From nobody Thu Jul 31 12:55:50 2025 X-Original-To: net@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 4bt8G94wNRz63qtb for ; Thu, 31 Jul 2025 12:56:01 +0000 (UTC) (envelope-from vadimnuclight@gmail.com) Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) (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 4bt8G91nQKz4JGq for ; Thu, 31 Jul 2025 12:56:01 +0000 (UTC) (envelope-from vadimnuclight@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-32f1df5b089so3941521fa.3 for ; Thu, 31 Jul 2025 05:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753966554; x=1754571354; darn=freebsd.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=iAZaVPsSgVWxIgUp4+uzt8q+0yXPx8F7sL45087PDqU=; b=e1n2FasbuHNHrrxlUHOnhWXp+RJB79MhaNPtsCBB8awhN5O13cjsLc3b7ch35m3Z19 g9n0uQSJZ19xPNptQ3y9qGzrAhboRVTiO005J7IxF/MXkuhI3Pp0ss9l4rfXTv9VS6Sk /BGysZmQHicvSFkTCGlunYPxOlyEVNXZH1XEVuPTAxuuugyEzXhMMqntn2w9vMW8JQYq G1OudMHbunCHD/BxJ07ZyQKIaoH/O13VuDGVT6jGfEA8bPc7Ezqc+p7gSzPICJfPz7r3 wrQCN4aG4NnAuDT861hn5PhTe8Xd+uJIcLLznoyNruUWkBNkqoFb2zOTcehBCnUiGKI7 86sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753966554; x=1754571354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iAZaVPsSgVWxIgUp4+uzt8q+0yXPx8F7sL45087PDqU=; b=qBdjYPXv3cMUqIGG4Ja9stUXpMlZ5sn64JNLSpcvrgY1CldMdExYfDTJjZZXQEEoAl 6gDUEYcHC1vCKf5j9Vuv6nVnQ++xgupwQEncgR6wQPrXSQXkR3F8P5a62A6KDsLpH9oX BWLcn/VPoj1E+P/yns9QN5toR5mr3YIZzivnzET5ELhAeRc67C1JTOO2GleuhlJ7JWnL D5S+HL7cWUPxww51qGlwG45oP9Q4L5MDDCW0MYyRsVcd1NCXuzqCBHkMWreCT1r/cWJs YFlFHV1r/Xgim5/vY6rxswUq6SeWaMI7/5WEkP8IfWA6eWlPvVzcGXRp9p80eYlJD9tj jAwg== X-Gm-Message-State: AOJu0YzQyhKGw482B8O7uvZsPEWxs4yruGsc6IYJJ64OStAEmFRq/f20 QEGpemiYKlLch85lUfcPMEsexT3yFKotf/A8f8vW5sEyzC079aSU9yQHRDgE/A== X-Gm-Gg: ASbGnctmHYL4k1/o1SUi2Lq9363o2tj7fIUnRUK7flJvZvHJ999fpm7wDZxmOrPDStT EX+RwtTKjuaKtCS3ubRgk1Ia+Irai07by+ar3wA8j24Uaxzv+J87MGdpT6/DngfL+NTNnitvqLV i31KcNULUQPfkC2sUxN2MojgbtfFeRQdsY4W3oZ6Fj6ArSmdRyMrfUvAynepA7/qIhslqt8NHXp BWsHgjkaU7OMWmphZVCJGK50/Fk1nDMBP1BfmHzbRqwQyWxqozPPcEXrd+JrHBpMxpism8U+AzX 7prfcNvcid9x9cSnbe3nEBpi7k274SkndDOfCL5wXncquureD7lnA6nwItrvHvxWnAxwMg7n9Ny efkn2o31ia/k8+twkWmnoE+pXjk+schOBmyOXMp7uTQvc+riWau0H4Rm4NL5dydjl+g== X-Google-Smtp-Source: AGHT+IEbRUj0d+yaj8QTd5xp4pKxX36T66Zvd8jKwJ1pTkWjguLtYyofQM3vSsm7tYDkrcFGp1jTqw== X-Received: by 2002:a05:651c:f1a:b0:332:1766:f734 with SMTP id 38308e7fff4ca-33224a56254mr19510481fa.7.1753966553375; Thu, 31 Jul 2025 05:55:53 -0700 (PDT) Received: from nuclight.lan (broadband-77-37-180-76.ip.moscow.rt.ru. [77.37.180.76]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-332388d87c3sm2316761fa.43.2025.07.31.05.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Jul 2025 05:55:53 -0700 (PDT) Date: Thu, 31 Jul 2025 15:55:50 +0300 From: Vadim Goncharov To: Kajetan Staszkiewicz Cc: net@FreeBSD.org Subject: Re: adding fields to struct mbuf Message-ID: <20250731155550.529ce1fb@nuclight.lan> In-Reply-To: References: X-Mailer: Claws Mail 3.21.0 (GTK+ 2.24.33; amd64-portbld-freebsd13.4) List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4bt8G91nQKz4JGq X-Spamd-Bar: ---- 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:2a00:1450::/32, country:US] On Thu, 31 Jul 2025 13:03:22 +0200 Kajetan Staszkiewicz wrote: > Hello group, > > I'm researching loop prevention in pfil. There are cases where packets > are reinjected into the network stack and would be handled by the same > hooks again, i.e. pf + dummynet where currently pf itself handles loop > prevention on its own. My current experiment's approach to making loop > prevention a general, non-pf-specific thing is to create a new mtag with > pointer to the last hook and update it in pfil.c/pfil_mbuf_common(). > That works good so far, but it means memory allocation when pfil hooks > are involved. I'm unsure what the impact on performance would be. > Another approach would be to extend struct mbuf, or probably rather > struct m_pkthdr, to contain the aforementioned pointer. But is changing > that struct something that can be easily done and approved and merged? First, you certainly don't need it in every mbuf - just first in chain with struct pkthdr (where mtags also start). Second. The "last hook ptr" does not look like general solution for all cases and occupies 8 bytes. What about idea from network itself - TTL ? It occupies less bytes, the main problem is to decide where to decrement (e.g. each netgraph hook, etc.) Third. What about redoing mtag allocator so that it reuses m_pktdat[] when M_EXT is set? This could optimize performance for many tags, not just yours. > For those curious the experiment will be uploaded to Phabricator soon-ish. -- WBR, @nuclight