[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e730e848-22e7-cd01-e6d5-b428acb434f6@mojatatu.com>
Date: Fri, 21 Apr 2023 13:10:09 -0300
From: Pedro Tammela <pctammela@...atatu.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, jhs@...atatu.com, xiyou.wangcong@...il.com,
jiri@...nulli.us, davem@...emloft.net, edumazet@...gle.com,
pabeni@...hat.com, simon.horman@...igine.com
Subject: Re: [PATCH net-next v4 3/5] net/sched: act_pedit: check static
offsets a priori
On 21/04/2023 12:15, Jakub Kicinski wrote:
> On Fri, 21 Apr 2023 12:12:54 -0300 Pedro Tammela wrote:
>> On 20/04/2023 23:41, Jakub Kicinski wrote:
>>> On Tue, 18 Apr 2023 20:43:52 -0300 Pedro Tammela wrote:
>>>> @@ -414,12 +420,12 @@ TC_INDIRECT_SCOPE int tcf_pedit_act(struct sk_buff *skb,
>>>> sizeof(_d), &_d);
>>>> if (!d)
>>>> goto bad;
>>>> - offset += (*d & tkey->offmask) >> tkey->shift;
>>>> - }
>>>>
>>>> - if (offset % 4) {
>>>> - pr_info("tc action pedit offset must be on 32 bit boundaries\n");
>>>> - goto bad;
>>>> + offset += (*d & tkey->offmask) >> tkey->shift;
>>>
>>> this line loads part of the offset from packet data, so it's not
>>> exactly equivalent to the init time check.
>>
>> The code uses 'tkey->offmask' as a check for static offsets vs packet
>> derived offsets, which have different handling.
>> By checking the static offsets at init we can move the datapath
>> 'offset % 4' check for the packet derived offsets only.
>>
>> Note that this change only affects the offsets defined in 'tkey->off',
>> the 'at' offset logic stays the same.
>> My intention was to keep the code semantically the same.
>> Did I miss anything?
>
> You are now erroring out if the static offset is not divisible by 4,
> and technically it was possible to construct a case where that'd work
> previously - if static offset was 2 and we load another 2 from the
> packet, no?
>
True!
It seems though that the iproute2 packing broke this feature:
tc action add action pedit ex munge offset 2 u16 at 128 ff 0 clear
offset will be rounded down to 0 in iproute2, so if in the datapath at
128 sums 2, it will fail the offset check since 2 % 4 != 0.
Let me check with Jamal what he thinks about this change since netlink
could do it still.
This slipped under our radar, thanks for catching it!
> If so it needs to be mentioned in the commit msg.
Powered by blists - more mailing lists