From owner-freebsd-pf@freebsd.org Sat Dec 28 13:59:15 2019 Return-Path: Delivered-To: freebsd-pf@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B1AE1E90F8 for ; Sat, 28 Dec 2019 13:59:15 +0000 (UTC) (envelope-from SRS0=QYpd=2S=sigsegv.be=kristof@codepro.be) Received: from mercury.codepro.be (mercury.codepro.be [IPv6:2001:4b98:dc0:41:216:3eff:fe31:eda8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "monitoring.codepro.be", Issuer "Let's Encrypt Authority X3" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 47lQKZ155qz4Ntk for ; Sat, 28 Dec 2019 13:59:13 +0000 (UTC) (envelope-from SRS0=QYpd=2S=sigsegv.be=kristof@codepro.be) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) by mercury.codepro.be (Postfix) with ESMTPS id F40079048C; Sat, 28 Dec 2019 13:58:17 +0000 (UTC) Received: from [100.117.154.237] (unknown [188.189.26.237]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 49F6AFB4F; Sat, 28 Dec 2019 14:59:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sigsegv.be; s=mail; t=1577541550; bh=RXdKa4OvIqphgQ79Oz0xE9tC4sYKrAvnDSdqYsFiGy0=; h=From:Subject:Date:References:Cc:In-Reply-To:To; b=MqjqgKcKQkkwoeSmehD9pRJoRgGWIaLabRKj8NHnSe+4urNR7+pCvBBagb9ylVO+M Q4w9w66TKOvBo9fXZRQ4sLkKQyPGWJo11pvwhNRIpfM1Rk5l7QX9OjzsW4e9bbzecM nTlZhvOo643RZS6pHGxnXc+UIjs9wjl9Ah47a1Jg= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Kristof Provost Mime-Version: 1.0 (1.0) Subject: Re: Flow of broadcast/multicast packets in pf when a bridge is present Date: Sat, 28 Dec 2019 14:59:08 +0100 Message-Id: References: <5E074209.2070801@incore.de> Cc: freebsd-pf@freebsd.org In-Reply-To: <5E074209.2070801@incore.de> To: Andreas Longwitz X-Mailer: iPhone Mail (17C54) X-Rspamd-Queue-Id: 47lQKZ155qz4Ntk X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sigsegv.be header.s=mail header.b=MqjqgKcK; dmarc=pass (policy=none) header.from=sigsegv.be; spf=pass (mx1.freebsd.org: domain of SRS0=QYpd=2S=sigsegv.be=kristof@codepro.be designates 2001:4b98:dc0:41:216:3eff:fe31:eda8 as permitted sender) smtp.mailfrom=SRS0=QYpd=2S=sigsegv.be=kristof@codepro.be X-Spamd-Result: default: False [-5.25 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[sigsegv.be:s=mail]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2001:4b98:dc0:41:216:3eff:fe31:eda8]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[8.a.d.e.1.3.e.f.f.f.e.3.6.1.2.0.1.4.0.0.0.c.d.0.8.9.b.4.1.0.0.2.list.dnswl.org : 127.0.9.2]; DKIM_TRACE(0.00)[sigsegv.be:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[sigsegv.be,none]; FORGED_SENDER(0.30)[kristof@sigsegv.be,SRS0=QYpd=2S=sigsegv.be=kristof@codepro.be]; MIME_TRACE(0.00)[0:+]; IP_SCORE(-2.35)[ip: (-7.01), ipnet: 2001:4b98::/32(-3.50), asn: 29169(-1.24), country: FR(0.00)]; ASN(0.00)[asn:29169, ipnet:2001:4b98::/32, country:FR]; FROM_NEQ_ENVFROM(0.00)[kristof@sigsegv.be,SRS0=QYpd=2S=sigsegv.be=kristof@codepro.be]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Dec 2019 13:59:15 -0000 > On 28 Dec 2019, at 12:52, Andreas Longwitz wrote: >=20 > =EF=BB=BFIn the meantime I have understand I was wrong about the code snip= pet >=20 >> mc2 =3D m_dup(m, M_NOWAIT); >> if (mc2 !=3D NULL) { >> /* Keep the layer3 header aligned */ >> int i =3D min(mc2->m_pkthdr.len, max_protohdr); >> mc2 =3D m_copyup(mc2, i, ETHER_ALIGN); >> } >> if (mc2 !=3D NULL) { >> mc2->m_pkthdr.rcvif =3D bifp; >> (*bifp->if_input)(bifp, mc2); >> } >=20 > My mistake concerned the function call m_copyup(): The mbuf chain is > copied correct and not shortened, I was confused because of the field > m_len in mc2. So reinjecting the packet in the bridge is ok. >=20 > Another aspect is what is done next with the broadcast/multicast packet > handled by this code: >=20 >> /* Return the original packet for local processing. */ >> return (m); >=20 > Therefore local processing on the member interface is done for > broadcast/multicast packets without checking the pfil_local_phys > variable. That was confusing me because these packets are counting twice > in the pf rules. I think this is needless and pfil_local_phys should > respect all packets not only unicast. >=20 > After introducing the patch >=20 > --- if_bridge.c.iorig 2019-05-14 09:43:33.000000000 +0200 > +++ if_bridge.c 2019-12-28 11:54:52.000000000 +0100 > @@ -2386,6 +2386,10 @@ > (*bifp->if_input)(bifp, mc2); > } >=20 > + if (!pfil_local_phys ) { > + m_freem(m); > + return (NULL); > + } > /* Return the original packet for local processing. */ > return (m); > } >=20 > everything works fine and all the counters in pf have values as expected >=20 Can you put that in Phabricator and cc me and kevans@? (I seem to remember h= im touching related code a few months ago). Thanks, Kristof=