From owner-freebsd-current@freebsd.org Fri Jan 12 10:57:03 2018 Return-Path: Delivered-To: freebsd-current@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 B54E5EA5818; Fri, 12 Jan 2018 10:57:03 +0000 (UTC) (envelope-from o.hartmann@walstatt.org) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 33AE0833BB; Fri, 12 Jan 2018 10:57:02 +0000 (UTC) (envelope-from o.hartmann@walstatt.org) Received: from freyja.zeit4.iv.bundesimmobilien.de ([87.138.105.249]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MDi9C-1edp9c37c6-00H7VO; Fri, 12 Jan 2018 11:56:54 +0100 Date: Fri, 12 Jan 2018 11:56:47 +0100 From: "O. Hartmann" To: "Andrey V. Elsukov" Cc: "O. Hartmann" , freebsd-current , freebsd-ipfw@freebsd.org Subject: Re: ipfw: manpage: semantics of "receive" and "xmit" interfaces Message-ID: <20180112115639.3b31073f@freyja.zeit4.iv.bundesimmobilien.de> In-Reply-To: <5e6811ff-70c6-ee74-bf04-1319e9002b29@yandex.ru> References: <20180109102813.63c32899@freyja.zeit4.iv.bundesimmobilien.de> <5e6811ff-70c6-ee74-bf04-1319e9002b29@yandex.ru> Organization: Walstatt MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:W8zl6w7tYnxY56sOD8F03wCMIVIARrj/haujKWZ1epwEaiV/SWI dN3aM9zgg/EFHmxyBBfSfu2HukF/zOueMHL0iyuX/9IaUoGKcXedqqojfQ9FzKVu8Pkevma YwUaV4+UDS+NdFFyx53fovZp0t2UFsP3dksykar2ZPM6pT4eE5FqfjodEI+oFT7CsYvALiK gGzj8Bb8cGPJZXh+Yj8Lg== X-UI-Out-Filterresults: notjunk:1;V01:K0:yONudj0npJU=:C3bMwQNqWvJRlDZmhCl+hy C2Gum8egytHHsRp1oHPUrMGT/TmqW8gHjoRbTaIgv/D7xjj9cnu3dWPHEhjTLbTO2Rvmkz8jx j3PzMQr3BXGlvormlDnWkrvK8ZppT+O3HSnjCUVnZDEhtYUeI4MF4UUGvnqK4MyvEAUyQJx10 eDZS5/jXWA8ZuBQ3f0lql7nNxkucFgTeByLB5Rcomz2M5YHWYGnUhXhwbBXxoxs/8BhOfoIrZ wpDFB4EAWyjm8poFmYHk/OrhebGtoQoa/6YQl9cKwZJeqo3CYaGmbFw+neKfXNPv8oXYrrbpq vp7Fg0tSldwpIy24q+Mx8d600i3aDPg4Unp7OZSI5r2ROd13oZuNvVVzl8lwjsbAtR5wfsicd 166PqIIsvSQ4moDXHgmrhfOiH61DX3Vsp0JxCTQlfMBRCMzqtZdiDM5cvgdy0+gKtIiuRrue8 4nQNYZeKsJr3njyoyrvu5wyx7+NRI8y2Hg6IcLke890puf9bH53HLwdJwe2+nKUYBOtUH/25f 48ozZWnVWlITGpnTI6PE/5780/K0KsWKJ1vge8Cdmclq2zcD40CfOZgLaOGdNE9K1kWWHQAne yPakTauVX0r5i1eO60G51Y/A4YzJqDeB6Uzya/w0cmxFOyELcjuefkfqlm8+JPqJ75hO3D41+ 3O3KfT/K74YTSTKdrySu8tzAFcf3nf9gP/Ysn3H+xtVeYPT1MzU2XqsYQ3sXERLAJgJJm7qMA DwBNZkOVu8ahUDTv8kSNqNFGSkjYu3U5GBxKP7gMS14rieT5p5+jJ2cBtwyPdnWm6rkw+MxXq TyxEv3N9qqc2Jh6g2wqmNmZls9mh/nIoWDagefw+9Y4nNbeGBY= X-Mailman-Approved-At: Fri, 12 Jan 2018 12:02:28 +0000 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jan 2018 10:57:03 -0000 On Tue, 9 Jan 2018 21:23:54 +0300 "Andrey V. Elsukov" wrote: > 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. > 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 > 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. > Thanks very much for the explanation.