diff mbox series

[ovs-dev] lib/tc: fix parse act pedit for tos rewrite

Message ID 1606186869-25209-1-git-send-email-wenxu@ucloud.cn
State Accepted
Headers show
Series [ovs-dev] lib/tc: fix parse act pedit for tos rewrite | expand

Commit Message

wenxu Nov. 24, 2020, 3:01 a.m. UTC
From: wenxu <wenxu@ucloud.cn>

Check overlap between current pedit key, which is always 4 bytes
(range [off, off + 3]), and a map entry in flower_pedit_map
sf = ROUND_DOWN(mf, 4) (range [sf|mf, (mf + sz - 1)|ef]).

So for the tos the rewite the off + 3(3) is greater than mf,
and should less than ef(4) but not mf+sz(2).

Signed-off-by: wenxu <wenxu@ucloud.cn>
---
 lib/tc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Simon Horman Nov. 26, 2020, 10:44 a.m. UTC | #1
On Tue, Nov 24, 2020 at 11:01:09AM +0800, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.cn>
> 
> Check overlap between current pedit key, which is always 4 bytes
> (range [off, off + 3]), and a map entry in flower_pedit_map
> sf = ROUND_DOWN(mf, 4) (range [sf|mf, (mf + sz - 1)|ef]).
> 
> So for the tos the rewite the off + 3(3) is greater than mf,
> and should less than ef(4) but not mf+sz(2).
> 
> Signed-off-by: wenxu <wenxu@ucloud.cn>

Thanks Wenxu,

this looks good to me. And applies cleanly back to branch-2.13 (LTS).

I will try running it through Travis-CI, as a matter of course.

https://travis-ci.org/github/horms2/ovs/builds/746053729
https://travis-ci.org/github/horms2/ovs/builds/746053793
https://travis-ci.org/github/horms2/ovs/builds/746053864

However, Travis-CI.org is very slow these days so I may have to to abandon
that idea.

https://mail.openvswitch.org/pipermail/ovs-dev/2020-November/377773.html
https://mail.openvswitch.org/pipermail/ovs-dev/2020-November/377877.html
wenxu Dec. 4, 2020, 2:18 a.m. UTC | #2
Hi Simon,




How about this patch?


BR
wenxu



From: Simon Horman <simon.horman@netronome.com>
Date: 2020-11-26 18:44:25
To:  wenxu@ucloud.cn
Cc:  dev@openvswitch.org
Subject: Re: [PATCH] lib/tc: fix parse act pedit for tos rewrite>On Tue, Nov 24, 2020 at 11:01:09AM +0800, wenxu@ucloud.cn wrote:
>> From: wenxu <wenxu@ucloud.cn>
>> 
>> Check overlap between current pedit key, which is always 4 bytes
>> (range [off, off + 3]), and a map entry in flower_pedit_map
>> sf = ROUND_DOWN(mf, 4) (range [sf|mf, (mf + sz - 1)|ef]).
>> 
>> So for the tos the rewite the off + 3(3) is greater than mf,
>> and should less than ef(4) but not mf+sz(2).
>> 
>> Signed-off-by: wenxu <wenxu@ucloud.cn>
>
>Thanks Wenxu,
>
>this looks good to me. And applies cleanly back to branch-2.13 (LTS).
>
>I will try running it through Travis-CI, as a matter of course.
>
>https://travis-ci.org/github/horms2/ovs/builds/746053729
>https://travis-ci.org/github/horms2/ovs/builds/746053793
>https://travis-ci.org/github/horms2/ovs/builds/746053864
>
>However, Travis-CI.org is very slow these days so I may have to to abandon
>that idea.
>
>https://mail.openvswitch.org/pipermail/ovs-dev/2020-November/377773.html
>https://mail.openvswitch.org/pipermail/ovs-dev/2020-November/377877.html
Simon Horman Dec. 4, 2020, 6:37 a.m. UTC | #3
On Fri, Dec 04, 2020 at 10:18:56AM +0800, wenxu wrote:
> 
> Hi Simon,
> 
> 
> 
> 
> How about this patch?

Sorry for the delay, pushed to master, branch-2.14 and branch-2.13.
diff mbox series

Patch

diff --git a/lib/tc.c b/lib/tc.c
index 8761304..c2de78b 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -1003,6 +1003,7 @@  nl_parse_act_pedit(struct nlattr *options, struct tc_flower *flower)
             int flower_off = m->flower_offset;
             int sz = m->size;
             int mf = m->offset;
+            int ef = ROUND_UP(mf, 4);
 
             if (m->htype != type) {
                continue;
@@ -1010,9 +1011,10 @@  nl_parse_act_pedit(struct nlattr *options, struct tc_flower *flower)
 
             /* check overlap between current pedit key, which is always
              * 4 bytes (range [off, off + 3]), and a map entry in
-             * flower_pedit_map (range [mf, mf + sz - 1]) */
+             * flower_pedit_map sf = ROUND_DOWN(mf, 4)
+             * (range [sf|mf, (mf + sz - 1)|ef]) */
             if ((keys->off >= mf && keys->off < mf + sz)
-                || (keys->off + 3 >= mf && keys->off + 3 < mf + sz)) {
+                || (keys->off + 3 >= mf && keys->off + 3 < ef)) {
                 int diff = flower_off + (keys->off - mf);
                 ovs_be32 *dst = (void *) (rewrite_key + diff);
                 ovs_be32 *dst_m = (void *) (rewrite_mask + diff);