From: Florian Westphal <fw@strlen.de>
To: Harry <simonsharry@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: Why aren't INPUT and FORWARD chains available to a locally-generated packet?
Date: Wed, 11 Aug 2021 23:09:19 +0200 [thread overview]
Message-ID: <20210811210919.GX607@breakpoint.cc> (raw)
In-Reply-To: <CACj4R39Whos6mVwo1CsvR7me61raq2udnxevjBYgMru3V__JGQ@mail.gmail.com>
Harry <simonsharry@gmail.com> wrote:
Please keep the ML in CC, thnaks.
> On Wed, Aug 11, 2021 at 7:59 PM Florian Westphal <fw@strlen.de> wrote:
> > Harry S <simonsharry@gmail.com> wrote:
> > [..]
> > > Let's say a process on a router host generates a packet. This packet
> > > goes to the OUTPUT chain, following which a routing decision is made.
> >
> > No, for output, routing decision happens before output.
>
> I perhaps had this documentation source in mind; see the ASCII diagram
> and also the explanation below it for what it says when the routing
> happens:
> https://netfilter.org/documentation/HOWTO//netfilter-hacking-HOWTO-3.html
"[..] in fact, the routing code is called first (to figure out the source IP
address and some IP options): if you want to alter the routing, you must alter
the `skb->dst' field yourself, as is done in the NAT code."
> But in this diagram,
> https://upload.wikimedia.org/wikipedia/commons/3/37/Netfilter-packet-flow.svg
> as well as in Table 6-2 in the iptables-tutorial here,
> https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html#TRAVERSINGOFTABLES
> routing happens before OUTPUT -- just like you say.
Yes.
> I guess, my confusion is: Even if routing happens before OUTPUT, why
> in the Netfilter Packet Flow diagram above there is no arrow going to
> mangle:INPUT *also* apart from the raw:OUTPUT arrow already shown in
> the diagram?
Because packets never move directly from OUTPUT to INPUT.
> Could you or someone confirm if the Netfilter Packet Flow Diagram is
> fully accurate *and* complete, as far as the Network and higher layers
> are concerned? (That is, ignoring the ebtables stuff.)
Its accurate.
> > There is a rerouting check/reroute enforcement in mangle:output
> > to handle a change in the packet mark.
>
> I'm not sure if I'm following. It's shown neither in the diagram nor
> in Table 6-2. This means the diagram and the table are incomplete
> and/or inaccurate?
It says "reroute check", after filter. Its technically incorrect since
there are several reroute checks but I guess it would get too entangled
otherwise.
> > > Now, this packet could be destined either for the loopback interface,
> > > or for one of the host's many ethernet interfaces. If so, why
> > > shouldn't Netfilter bring the packet to the same INPUT / FORWARD
> > > decision-fork in the path that exists for an incoming packet soon
> > > after it has crossed PREROUTING?
> >
> > If its loopback, packet ends up using:
> >
> > OUTPUT -> POSTROUTING -> PREROUTING -> INPUT (or FORWARD).
>
> Hmm, after POSTROUTING, all texts that I've looked at say that the
> packet is out on the wire!
It is. Loopback driver maps each xmit to a packet receive.
Packet thus moves from postrouting to prerouting.
next prev parent reply other threads:[~2021-08-11 21:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 14:12 Why aren't INPUT and FORWARD chains available to a locally-generated packet? Harry S
2021-08-11 14:29 ` Florian Westphal
[not found] ` <CACj4R39Whos6mVwo1CsvR7me61raq2udnxevjBYgMru3V__JGQ@mail.gmail.com>
2021-08-11 21:09 ` Florian Westphal [this message]
2021-08-12 1:37 ` Harry
2021-08-12 7:58 ` Reindl Harald
2021-08-11 14:31 ` Reindl Harald
2021-08-11 23:37 ` Harry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210811210919.GX607@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter@vger.kernel.org \
--cc=simonsharry@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.