[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <be6eee6b-9d58-f0f7-571b-7e473612e2b3@solarflare.com>
Date: Fri, 6 Sep 2019 16:13:17 +0100
From: Edward Cree <ecree@...arflare.com>
To: Pablo Neira Ayuso <pablo@...filter.org>
CC: <netfilter-devel@...r.kernel.org>, <davem@...emloft.net>,
<netdev@...r.kernel.org>, <jakub.kicinski@...ronome.com>,
<jiri@...nulli.us>, <saeedm@...lanox.com>, <vishal@...lsio.com>,
<vladbu@...lanox.com>
Subject: Re: [PATCH net-next,v3 0/4] flow_offload: update mangle action
representation
On 06/09/2019 15:50, Pablo Neira Ayuso wrote:
> On Fri, Sep 06, 2019 at 02:37:16PM +0100, Edward Cree wrote:
>> On 06/09/2019 14:14, Pablo Neira Ayuso wrote:
>>> OK, I can document this semantics, I need just _time_ to write that
>>> documentation. I was expecting this patch description is enough by now
>>> until I can get to finish that documentation.
>> I think for two structs with apparently the same contents but different
>> semantics (one has the mask bitwise complemented) it's best to hold up
>> the code change until the comment is ready to come with it, because
>> until then it's a dangerously confusing situation.
> The idea is that flow rule API != tc front-end anymore. So the flow
> rule API can evolve regardless the front-end requirements. Before this
> update there was no other choice than using the tc pedit layout since
> it was exposed to the drivers, this is not the case anymore.
I'm not saying that they have to be the same.
I'm saying that they're _almost_ the same, and having things that are
_almost_ the same but subtly different is a recipe for misunderstandings
and bugs, and so must must must have very visible comments in the code.
>> So an IPv6 address mangle only comes as a single action if it's from
>> netfilter, not if it's coming from TC pedit.
> Driver gets one single action from tc/netfilter (and potentially
> ethtool if it would support for this), it comes as a single action
> from both subsystems:
>
> front-end -----> flow_rule API -----> drivers
>
> Front-end need to translate their representation to this
> FLOW_ACTION_MANGLE layout.
>
> By front-end, I refer to ethtool/netfilter/tc.
In your patch, flow_action_mangle() looks only at the offset and type
(add vs. set) of each pedit, coalesces them if compatible (so, unless
I'm misreading the code, it _will_ coalesce adjacent pedits to
contiguous fields like UDP sport & dport, unlike what you said),
because it doesn't know whether two contiguous pedits are part of the
same field or not (it doesn't have any knowledge of 'fields' at all).
And for you to change that, while still coalescing IPv6 pedits, you
would need flow_action_mangle() to know what fields each pedit is in.
It is not possible for code that doesn't know about fields to both:
(a) not coalesce edits of contiguous fields, and
(b) coalesce edits of larger-than-u32 fields
>> Yes, but we don't add code/features to the kernel based on what we
>> *could* use it for later
> This is already useful: Look at the cxgb driver in particular, it's
> way easier to read.
Have you tested it? Again, I might be misreading, but it looks like
your flow_action_mangle() *will* coalesce sport & dport, which it
appears will break that cxgb code.
> Other existing drivers do not need to do things like:
>
> case round_down(offsetof(struct iphdr, tos), 4):
>
> and the play with masks to infer if the user wants to mangle the TOS
> field, they can just do:
>
> case offsetof(struct iphdr, tos):
>
> which is way more natural representation.
Proper thing to do is have helper functions available to drivers to test
the pedit, and not just switch on the offset. Why do I say that?
Well, consider a pedit on UDP dport, with mask 0x00ff (network endian).
Now as a u32 pedit that's 0x000000ff offset 0, so field-blind offset
calculation (ffs in flow_action_mangle_entry()) will turn that into
offset 3 mask 0xff. Now driver does
switch(offset) { /* 3 */
case offsetof(struct udphdr, dest): /* 2 */
/* Whoops, we never get here! */
}
Do you see the problem?
-Ed
Powered by blists - more mailing lists