From owner-freebsd-ipfw@freebsd.org Tue Jan 9 23:00:16 2018 Return-Path: Delivered-To: freebsd-ipfw@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1304EE78730; Tue, 9 Jan 2018 23:00:16 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D374B75CF5; Tue, 9 Jan 2018 23:00:15 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w09N0BnV028969; Tue, 9 Jan 2018 15:00:11 -0800 (PST) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w09N0AAo028968; Tue, 9 Jan 2018 15:00:10 -0800 (PST) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201801092300.w09N0AAo028968@pdx.rh.CN85.dnsmgr.net> Subject: Re: ipfw: manpage: semantics of "receive" and "xmit" interfaces In-Reply-To: <5e6811ff-70c6-ee74-bf04-1319e9002b29@yandex.ru> To: "Andrey V. Elsukov" Date: Tue, 9 Jan 2018 15:00:10 -0800 (PST) CC: "O. Hartmann" , freebsd-current , freebsd-ipfw@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jan 2018 23:00:16 -0000 > On 09.01.2018 12:28, O. Hartmann wrote: > > In section RULE OPTIONS, there is recv|xmit|via explained (a bit). There is > > also an example: > > > > ipfw add deny ip from any to any out recv ed0 xmit ed1 > > > > Can someone explain a bit more what the semantics of these is? I get especially > > confused by the subsequent blocks of text following the line I mentioned above. > > Since not everybody using FreeBSD is capable of studying the kernel sources, I > > have difficulties to put those statements in line with a visualization of the > > packet flow. A local host receiving a packets destined for the local host can > > not have xmit interface? If I imagine, that the recv interface might be the > > interface adjacent directly to the in/out port depicted in section PACKET FLOW > > it doesn't give me any idea why there is no xmit interface. > > When your system has two interfaces ed0 and ed1, and it acts as router, > a forwarded packet can be checked by firewall two times: > > 1. When a packet is received on ed0 interface, mbuf associated with this > packet gets a property "receiving interface". This packet is checked for > inbound direction and can be matched by "in" and "recv ed0" opcodes. in, recv and via options > If it was not dropped by rules, it will go through IP stack and can be > forwarded according to routing table via interface ed1. > > 2. When the routing decision was made (i.e. outbound interface is > determined) a packet checked by firewall again, now for outbound > direction. And it can be matched by "out" and "xmit ed1" opcodes. The in, recv and via options > opcode "recv ed0" still can be matched too, but "in" opcode will not > matched. > > A packet destined for local host is consumed by local IP stack and will > not forwarded. It is checked by firewall only one time (usually). Thus > it can not have xmit interface. And a packet generated localy would not have a recv interface. > -- > WBR, Andrey V. Elsukov > -- Rod Grimes rgrimes@freebsd.org