archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <>
To: Florian Westphal <>
	Pablo Neira Ayuso <>,
	Alexei Starovoitov <>
Subject: Re: [PATCH net-next] netfilter: revert introduction of egress hook
Date: Wed, 18 Mar 2020 15:22:28 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 3/18/20 1:33 PM, Florian Westphal wrote:
> Daniel Borkmann <> wrote:
>> On 3/18/20 11:02 AM, Florian Westphal wrote:
>>> Daniel Borkmann <> wrote:
>>>> This reverts the following commits:
>>>>     8537f78647c0 ("netfilter: Introduce egress hook")
>>>>     5418d3881e1f ("netfilter: Generalize ingress hook")
>>>>     b030f194aed2 ("netfilter: Rename ingress hook include file")
>>>>   From the discussion in [0], the author's main motivation to add a hook
>>>> in fast path is for an out of tree kernel module, which is a red flag
>>>> to begin with.
>>> The author did post patches for nftables, i.e. you can hook up rulesets to
>>> this new hook point.
>>>> is on future extensions w/o concrete code in the tree yet. Revert as
>>>> suggested [1] given the weak justification to add more hooks to critical
>>>> fast-path.
>>> Do you have an alternative suggestion on how to expose this?
>> Yeah, I think we should not plaster the stack with same/similar hooks that
>> achieve the same functionality next to each other over and over at the cost
>> of performance for users .. ideally there should just be a single entry point
>> that is very lightweight/efficient when not used and can otherwise patch to
>> a direct call when in use. Recent work from KP Singh goes into this direction
>> with the fmodify_return work [0], so we would have a single static key which
>> wraps an empty function call entry which can then be patched by the kernel at
>> runtime. Inside that trampoline we can still keep the ordering intact, but
>> imho this would overall better reduce overhead when functionality is not used
>> compared to the practice of duplication today.
> Thanks for explaining.  If I understand this correctly then:
> 1. sch_handle_egress() becomes a non-inlined function that isn't called
>     from __dev_queue_xmit or any other location
> 2. __dev_queue_xmit calls a dummy do-nothing function wrapped in
>     existing egress-static-key
> 3. kernels sched/tc code can patch the dummy function so it calls
>     sch_handle_egress, without userspace changes/awareness
> 4. netfilter could reuse this even when tc is already patched in, so
>     the dummy function does two direct calls.

Yes, pretty much and we could do the same for the ingress side as well.

> How does that differ from current code?  One could also re-arrange
> things like this (diff below, just for illustration).
> The only difference I see vs. my understanding of your proposal is:
> 1. no additional static key, nf_hook_egress_active() doesn't exist
> 2. nf_hook_egress exists, but isn't called anywhere, patched-in at runtime
> 3. sch_handle_egress isn't called anywhere either, patched-in too
> Did I get that right? The idea/plan looks good to me, it just looks
> like a very marginal difference to me, thats why I'm asking.

Aside from that, we could take that approach potentially even further in that
it would allow for converting more indirect calls into direct ones, e.g. the
tp->classify() ones from sch_handle_egress() or potentially the entry->hook()
from nf_hook_slow() side, or BPF directly as well, so I think it would be worth
a try to see how far we could simplify both and get rid of indirect calls for
their users with this approach. Happy to help out here as well.


  reply	other threads:[~2020-03-18 14:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18  9:33 [PATCH net-next] netfilter: revert introduction of egress hook Daniel Borkmann
2020-03-18  9:36 ` Pablo Neira Ayuso
2020-03-18  9:41   ` Daniel Borkmann
2020-03-18  9:51     ` Pablo Neira Ayuso
2020-03-18 10:02 ` Florian Westphal
2020-03-18 10:50   ` Daniel Borkmann
2020-03-18 12:33     ` Florian Westphal
2020-03-18 14:22       ` Daniel Borkmann [this message]
2020-03-19  1:45 ` David Miller

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \

* 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).