From owner-freebsd-bugs@FreeBSD.ORG Sat Jul 24 03:20:05 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32F571065745 for ; Sat, 24 Jul 2010 03:20:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CA5798FC13 for ; Sat, 24 Jul 2010 03:20:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o6O3K4ik096727 for ; Sat, 24 Jul 2010 03:20:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o6O3K42x096726; Sat, 24 Jul 2010 03:20:04 GMT (envelope-from gnats) Resent-Date: Sat, 24 Jul 2010 03:20:04 GMT Resent-Message-Id: <201007240320.o6O3K42x096726@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nickolay Dudorov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38DB01065676 for ; Sat, 24 Jul 2010 03:14:42 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 0F3208FC08 for ; Sat, 24 Jul 2010 03:14:42 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o6O3EfiT019305 for ; Sat, 24 Jul 2010 03:14:41 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o6O3EfDA019304; Sat, 24 Jul 2010 03:14:41 GMT (envelope-from nobody) Message-Id: <201007240314.o6O3EfDA019304@www.freebsd.org> Date: Sat, 24 Jul 2010 03:14:41 GMT From: Nickolay Dudorov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/148885: ipfw netgraph ignores net.inet.ip.fw.one_pass X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Jul 2010 03:20:05 -0000 >Number: 148885 >Category: kern >Synopsis: ipfw netgraph ignores net.inet.ip.fw.one_pass >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jul 24 03:20:04 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Nickolay Dudorov >Release: 8.1-RELEASE >Organization: STE Infoteka >Environment: FreeBSD nnd.itfs.nsk.su 8.1-RELEASE FreeBSD 8.1-RELEASE #5: Thu Jul 22 20:51:35 NOVST 2010 root@nnd.itfs.nsk.su:/usr/obj/usr/src/sys/FINER8 amd64 >Description: man ipfw says: .. netgraph cookie Divert packet into netgraph with given cookie. The search termi- nates. If packet is later returned from netgraph it is either accepted or continues with the next rule, depending on net.inet.ip.fw.one_pass sysctl variable. .. but after last massive changes in ipfw realisation (Mart 23 2010) packets continues with the next rule independently of the net.inet.ip.fw.one_pass value. The same holds for 'netgraph ngtee' rules. Included patch correct the problem. The problem stands in CURRENT, RELENG_8 and 8.1-RELEASE. >How-To-Repeat: On plain CURRENT or 8.1-RELEASE system with (say) em0 interface do: ================================================================ kldload netgraph kldload ng_ipfw kldload ng_ip_input ngctl << EOF mkpeer ipfw: ip_input 100 in EOF ipfw add 100 netgraph 100 all from any to any in recv em0 ipfw add 200 count log all from any to any in recv em0 ================================================================ and you can see that all packets go through 100 and 200 rules independently of the net.inet.ip.fw.one_pass value. >Fix: Applay the patch included. Patch attached with submission follows: --- sys/netinet/ipfw/ip_fw2.c.orig 2010-07-24 09:25:28.000000000 +0700 +++ sys/netinet/ipfw/ip_fw2.c 2010-07-24 09:27:35.000000000 +0700 @@ -2084,6 +2084,8 @@ set_match(args, f_pos, chain); args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) ? tablearg : cmd->arg1; + if (V_fw_one_pass) + args->rule.info |= IPFW_ONEPASS; retval = (cmd->opcode == O_NETGRAPH) ? IP_FW_NETGRAPH : IP_FW_NGTEE; l = 0; /* exit inner loop */ --- sys/netgraph/ng_ipfw.c.orig 2010-07-24 09:24:51.000000000 +0700 +++ sys/netgraph/ng_ipfw.c 2010-07-24 09:23:54.000000000 +0700 @@ -287,7 +287,8 @@ } r = (struct ipfw_rule_ref *)(tag + 1); *r = fwa->rule; - r->info = dir ? IPFW_INFO_IN : IPFW_INFO_OUT; + r->info &= IPFW_ONEPASS; /* keep this info */ + r->info |= dir ? IPFW_INFO_IN : IPFW_INFO_OUT; m_tag_prepend(m, tag); } else >Release-Note: >Audit-Trail: >Unformatted: