From owner-freebsd-pf@freebsd.org Sun Jun 24 19:28:25 2018 Return-Path: Delivered-To: freebsd-pf@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 749B5100A545 for ; Sun, 24 Jun 2018 19:28:25 +0000 (UTC) (envelope-from srs0=3krg=jk=sigsegv.be=kristof@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9724E73C79 for ; Sun, 24 Jun 2018 19:28:24 +0000 (UTC) (envelope-from srs0=3krg=jk=sigsegv.be=kristof@codepro.be) Received: from [172.28.128.1] (ptr-8rgnodtexwcxco6sd6i.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:240b:b802:12f:460a:85e4:57ba]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 0AFC0421F5; Sun, 24 Jun 2018 21:28:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sigsegv.be; s=mail; t=1529868502; bh=ANekh/ijx5V7zSrdQ6MbAuviclIi4a9qcBZqHrW2Reg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eIx96kGjBovvjA/5l47Zwdfuta/dQ7tgIuDMr2+N+TF5m+FPX0C6B5MYuPksnYH5B ols5bdAXvgu5Md0I1XFJScVwIQAU8n3Q26MN28+4IZdUP81O+VKmYVEKWMKhz9i7uE 5uoyL7/dY/pun81Oa6CFzso2J65/kVySmfBEy/FQ= From: "Kristof Provost" To: "Marek Zarychta" Cc: freebsd-pf@freebsd.org Subject: Re: pfr_update_stats: assertion failed. Date: Sun, 24 Jun 2018 21:28:19 +0200 X-Mailer: MailMate (2.0BETAr6113) Message-ID: <5D8E4DA7-3984-47DE-89E7-2B731525573C@sigsegv.be> In-Reply-To: <20180624190726.GA6807@plan-b.pwste.edu.pl> References: <20161016181713.GA95110@plan-b.pwste.edu.pl> <20180623152729.GA81271@plan-b.pwste.edu.pl> <20180623164616.GA82672@plan-b.pwste.edu.pl> <322F58D6-B7CA-4F78-A860-D43E4F07E402@sigsegv.be> <20180624190726.GA6807@plan-b.pwste.edu.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.26 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: Sun, 24 Jun 2018 19:28:25 -0000 On 24 Jun 2018, at 21:07, Marek Zarychta wrote: > On Sun, Jun 24, 2018 at 01:56:07PM +0200, Kristof Provost wrote: >> On 23 Jun 2018, at 18:46, Marek Zarychta wrote: >>> On Sat, Jun 23, 2018 at 05:27:29PM +0200, Marek Zarychta wrote: >>>> On Sun, Oct 16, 2016 at 08:17:13PM +0200, Marek Zarychta wrote: >>>>> The issue occurred first two years ago, after upgrade from 8 to 9 >>>>> branch. Now this i386 machine is running 11.0-STABLE and despite >>>>> it >>>>> was >>>>> compiled with "WITHOUT_ASSERT_DEBUG=yes", still from time to time >>>>> message buffer is fed with: >>>>> pfr_update_stats: assertion failed. >>>>> pfr_update_stats: assertion failed. >>>>> pfr_update_stats: assertion failed. >>>>> pfr_update_stats: assertion failed. >>>>> pfr_update_stats: assertion failed. >>>>> pfr_update_stats: assertion failed. >>>>> pfr_update_stats: assertion failed. >>>> >>>> These messages are still filling system message buffer. According >>>> to >>>> pfctl (8) there is nothing wrong with incrementing "XPass" counters >>>> instead of the "Pass" counters. The message "pfr_update_stats: >>>> assertion >>>> failed" is printed for debugging purposes only. One could also >>>> compare >>>> the counters with the command "pfctl -sT -vv". >>>> >>>> OpenBSD converted printf()'s to DPFDEBUG() macro in their sources >>>> almost >>>> 8 years ago. Only this printf() in pf_table.c has been converted to >>>> the >>>> level of LOG_DEBUG [1]. >>>> >>>> Perhaps this line of code could be removed from FreeBSD PF sources? >>>> >>> >>> The previous patch was hastily prepared. It should rather look like >>> this: >>> >>> --- sys/netpfil/pf/pf_table.orig.c 2018-06-23 16:40:14.876882000 >>> +0200 >>> +++ sys/netpfil/pf/pf_table.c 2018-06-23 18:17:49.353490000 +0200 >>> @@ -1984,9 +1984,7 @@ >>> panic("%s: unknown address family %u", __func__, af); >>> } >>> - if ((ke == NULL || ke->pfrke_not) != notrule) { >>> - if (op_pass != PFR_OP_PASS) >>> - printf("pfr_update_stats: assertion failed.\n"); >>> + if ((ke == NULL || ke->pfrke_not) != notrule) >>> op_pass = PFR_OP_XPASS; >>> - } >>> kt->pfrkt_packets[dir_out][op_pass]++; >>> kt->pfrkt_bytes[dir_out][op_pass] += len; >>> >> We could delete those lines and that’d get rid of the dmesg noise, >> but >> I’m a bit worried that this demonstrates an actual problem. >> It’s not at all clear to me what’s going on in this bit of the >> code, >> and the OpenBSD repo doesn’t have any information about it either. >> > > This machine acts as a NAT/firewall gateway for about a hundred users. > A few hundred of PF rules + 20 tables are used. The error appeared > suddenly after upgrade from 8-STABLE to 10-STABLE 3 years ago. It > never > occurred when the firewall run PF on 8-STABLE. I don't remember > whether > firewall rules were changed at that time. If it is true then changes > concerned only the compatibility with the newer version of PF. > > If it demonstrates an actual problem, then, please give me a clue how > to > debug it. On the other hand, ~6 years ago PF was significantly > reworked. > Is this piece of code still relevant there? > I honestly don’t know. I’d be good to actually investigate this before simply removing the warning. Unfortunately I just don’t have the time to dig into this right now. The only thing I can suggest is to look at the code and work out where the op_pass value comes from (and perhaps also what it’s used for. Why is PRF_OP_XPASS better than !PFR_OP_PASS? It’s still present (though perhaps not logged) in OpenBSD too. Regards, Kristof