From: Xin Long <lucien.xin@gmail.com>
To: Yuehaibing <yuehaibing@huawei.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
davem <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>,
network dev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] xfrm: policy: Fix xfrm policy match
Date: Sat, 23 May 2020 17:02:38 +0800 [thread overview]
Message-ID: <CADvbK_e8ixjGGHRK9A4HcXDGKYcNykneUHzHiE8sQ4ojDz+e-g@mail.gmail.com> (raw)
In-Reply-To: <1c4c5d40-1e35-f9bb-3f17-01bb4675f3aa@huawei.com>
On Fri, May 22, 2020 at 8:39 PM Yuehaibing <yuehaibing@huawei.com> wrote:
>
> On 2020/5/22 13:49, Xin Long wrote:
> > On Fri, May 22, 2020 at 9:45 AM Yuehaibing <yuehaibing@huawei.com> wrote:
> >>
> >> On 2020/5/21 14:49, Xin Long wrote:
> >>> On Tue, May 19, 2020 at 4:53 PM Steffen Klassert
> >>> <steffen.klassert@secunet.com> wrote:
> >>>>
> >>>> On Fri, May 15, 2020 at 04:39:57PM +0800, Yuehaibing wrote:
> >>>>>
> >>>>> Friendly ping...
> >>>>>
> >>>>> Any plan for this issue?
> >>>>
> >>>> There was still no consensus between you and Xin on how
> >>>> to fix this issue. Once this happens, I consider applying
> >>>> a fix.
> >>>>
> >>> Sorry, Yuehaibing, I can't really accept to do: (A->mark.m & A->mark.v)
> >>> I'm thinking to change to:
> >>>
> >>> static bool xfrm_policy_mark_match(struct xfrm_policy *policy,
> >>> struct xfrm_policy *pol)
> >>> {
> >>> - u32 mark = policy->mark.v & policy->mark.m;
> >>> -
> >>> - if (policy->mark.v == pol->mark.v && policy->mark.m == pol->mark.m)
> >>> - return true;
> >>> -
> >>> - if ((mark & pol->mark.m) == pol->mark.v &&
> >>> - policy->priority == pol->priority)
> >>> + if (policy->mark.v == pol->mark.v &&
> >>> + (policy->mark.m == pol->mark.m ||
> >>> + policy->priority == pol->priority))
> >>> return true;
> >>>
> >>> return false;
> >>>
> >>> which means we consider (the same value and mask) or
> >>> (the same value and priority) as the same one. This will
> >>> cover both problems.
> >>
> >> policy A (mark.v = 0x1011, mark.m = 0x1011, priority = 1)
> >> policy B (mark.v = 0x1001, mark.m = 0x1001, priority = 1)
> > I'd think these are 2 different policies.
> >
> >>
> >> when fl->flowi_mark == 0x12341011, in xfrm_policy_match() do check like this:
> >>
> >> (fl->flowi_mark & pol->mark.m) != pol->mark.v
> >>
> >> 0x12341011 & 0x1011 == 0x00001011
> >> 0x12341011 & 0x1001 == 0x00001001
> >>
> >> This also match different policy depends on the order of policy inserting.
> > Yes, this may happen when a user adds 2 policies like that.
> > But I think this's a problem that the user doesn't configure it well,
> > 'priority' should be set.
> > and this can not be avoided, also such as:
> >
> > policy A (mark.v = 0xff00, mark.m = 0x1000, priority = 1)
> > policy B (mark.v = 0x00ff, mark.m = 0x0011, priority = 1)
> >
> > try with 0x12341011
> >
> > So just be it, let users decide.
>
> Ok, this make sense.
Thanks Yuehaibing, it's good we're on the same page now.
Just realized the patch I created above won't work for the case:
policy A (mark.v = 0x10, mark.m = 0, priority = 1)
policy B (mark.v = 0x1, mark.m = 0, priority = 2)
policy C (mark.v = 0x10, mark.m = 0, priority = 2)
when policy C is being added, the warning still occurs.
So I will just check value and priority:
- u32 mark = policy->mark.v & policy->mark.m;
-
- if (policy->mark.v == pol->mark.v && policy->mark.m == pol->mark.m)
- return true;
-
- if ((mark & pol->mark.m) == pol->mark.v &&
+ if (policy->mark.v == pol->mark.v &&
policy->priority == pol->priority)
return true;
This allows two policies like this exist:
policy A (mark.v = 0x10, mark.m = 0, priority = 1)
policy C (mark.v = 0x10, mark.m = 0, priority = 2)
But I don't think it's a problem.
next prev parent reply other threads:[~2020-05-23 8:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-21 14:31 [PATCH] xfrm: policy: Only use mark as policy lookup key YueHaibing
2020-04-22 9:33 ` Steffen Klassert
2020-04-22 12:18 ` Yuehaibing
2020-04-22 15:41 ` Xin Long
2020-04-22 15:54 ` Xin Long
2020-04-23 2:25 ` Yuehaibing
2020-04-23 6:37 ` Xin Long
2020-04-23 8:40 ` Yuehaibing
2020-04-23 9:43 ` Xin Long
2020-04-24 3:48 ` Yuehaibing
2020-04-30 6:30 ` Yuehaibing
2020-04-22 12:53 ` [PATCH v2] xfrm: policy: Fix xfrm policy match YueHaibing
2020-05-15 8:39 ` Yuehaibing
2020-05-19 8:53 ` Steffen Klassert
2020-05-21 6:49 ` Xin Long
2020-05-22 1:45 ` Yuehaibing
2020-05-22 5:49 ` Xin Long
2020-05-22 12:39 ` Yuehaibing
2020-05-23 9:02 ` Xin Long [this message]
2020-05-25 3:04 ` Yuehaibing
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=CADvbK_e8ixjGGHRK9A4HcXDGKYcNykneUHzHiE8sQ4ojDz+e-g@mail.gmail.com \
--to=lucien.xin@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=yuehaibing@huawei.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 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).