DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 04/13] acl: allow zero verdict
Date: Wed, 14 Dec 2016 03:11:12 +0100	[thread overview]
Message-ID: <20161214021111.2l4h4gsbjxmbffca@rere.qmqm.pl> (raw)
In-Reply-To: <2601191342CEEE43887BDE71AB9772583F0EA71F@irsmsx105.ger.corp.intel.com>

On Tue, Dec 13, 2016 at 09:55:12PM +0000, Ananyev, Konstantin wrote:
> 
> 
> > -----Original Message-----
> > From: Michal Miroslaw [mailto:mirq-linux@rere.qmqm.pl]
> > Sent: Tuesday, December 13, 2016 6:03 PM
> > To: Ananyev, Konstantin <konstantin.ananyev@intel.com>
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH 04/13] acl: allow zero verdict
> > 
> > On Tue, Dec 13, 2016 at 05:27:31PM +0000, Ananyev, Konstantin wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Michal Miroslaw [mailto:mirq-linux@rere.qmqm.pl]
> > > > Sent: Tuesday, December 13, 2016 4:14 PM
> > > > To: Ananyev, Konstantin <konstantin.ananyev@intel.com>
> > > > Cc: dev@dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH 04/13] acl: allow zero verdict
> > > >
> > > > On Tue, Dec 13, 2016 at 03:13:42PM +0000, Ananyev, Konstantin wrote:
> > > > [...]
> > > > > > > > > > Subject: [dpdk-dev] [PATCH 04/13] acl: allow zero verdict
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Michał Mirosław <michal.miroslaw@atendesoftware.pl>
> > > > > > > > > > ---
> > > > > > > > > >  lib/librte_acl/rte_acl.c         | 3 +--
> > > > > > > > > >  lib/librte_acl/rte_acl.h         | 2 --
> > > > > > > > > >  lib/librte_table/rte_table_acl.c | 2 +-
> > > > > > > > > >  3 files changed, 2 insertions(+), 5 deletions(-)
> > > > > > > > > >
> > > > > > > > > > diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
> > > > > > > > > > index 8b7e92c..d1f40be 100644
> > > > > > > > > > --- a/lib/librte_acl/rte_acl.c
> > > > > > > > > > +++ b/lib/librte_acl/rte_acl.c
> > > > > > > > > > @@ -313,8 +313,7 @@ acl_check_rule(const struct rte_acl_rule_data *rd)
> > > > > > > > > >  	if ((RTE_LEN2MASK(RTE_ACL_MAX_CATEGORIES, typeof(rd->category_mask)) &
> > > > > > > > > >  			rd->category_mask) == 0 ||
> > > > > > > > > >  			rd->priority > RTE_ACL_MAX_PRIORITY ||
> > > > > > > > > > -			rd->priority < RTE_ACL_MIN_PRIORITY ||
> > > > > > > > > > -			rd->userdata == RTE_ACL_INVALID_USERDATA)
> > > > > > > > > > +			rd->priority < RTE_ACL_MIN_PRIORITY)
> > > > > > > > > >  		return -EINVAL;
> > > > > > > > > >  	return 0;
> > > > > > > > > >  }
> > > > > > > > >
> > > > > > > > > I am not sure, how it supposed to work properly?
> > > > > > > > > Zero value is reserved and ifnicates that no match were found for that input.
> > > > > > > >
> > > > > > > > This is actually in use by us. In our use we don't need to differentiate
> > > > > > > > matching a rule with zero verdict vs not matching a rule at all. I also
> > > > > > > > have a patch that changes the value returned in non-matching case, but
> > > > > > > > it's in "dirty hack" state, as of yet.
> > > > > > >
> > > > > > > With that chane rte_acl_classify() might produce invalid results.
> > > > > > > Even if you don't need it (I still don't understand how) , it doesn't mean other people
> > > > > > > don't  need it either and it is ok to change it.
> > > > > > >
> > > > > > > >
> > > > > > > > The ACL code does not treat zero userdata specially, so this is only
> > > > > > > > a policy choice and as such would be better to be made by the user.
> > > > > > >
> > > > > > > I believe it does.
> > > > > > > userdata==0 is a reserved value.
> > > > > > > When rte_acl_clasify() returns 0 for that particular input, it means 'no matches were found'.
> > > > > >
> > > > > > Dear Konstantin,
> > > > > >
> > > > > > Can you describe how the ACL code treats zero specially? I could not find
> > > > > > anything, really. The only thing I found is that iff I use zero userdata
> > > > > > in a rule I won't be able to differentiate a case where it matched from
> > > > > > a case where no rule matched.
> > > > >
> > > > > Yes, that's what I am talking about.
> > > > >
> > > > > > If I all my rules have non-zero userdata,
> > > > > > then this patch changes nothing.
> > > > >
> > > > > Ok, then why do you remove a code that does checking for invalid userdata==0?
> > > > > That supposed to prevent user to setup invalid value by mistake.
> > > > >
> > > > >  But if I have a table where 0 means drop
> > > > > > (default-drop policy) then being able to use zero userdata in DROP rules
> > > > > > makes the ACLs just that more useful.
> > > > >
> > > > > Ok, and what prevents you from do +1 to your policy values before
> > > > > you insert it into the ACL table and -1 after you retrieved it via rte_acl_classify()?
> > > >
> > > > The check is enforcing an assumption that all users want to distinguish
> > > > the cases whether any rule matched and whether no rules matched. Not all
> > > > users do, hence the assumption is invalid and this patch removes it.
> > >
> > > The check is based on the assumption that users might need to distinguish
> > > the situation when no rules were matched.
> > > To support that we need a reserved userdata value, which would mean
> > > NO_MATCH.
> > > From what I heard, most users do need this ability, those who don't
> > > can easily overcome it.
> > 
> > That's actually my point. Some users need the distinction, so they don't use
> > zero userdata in their rules and have their work done. Some users don't need
> > it and would prefer to just use the convenience of zero being no-match signal
> > to insert "non-matching" rules (now they have to check two values for the
> > same signal).
> > 
> > > > Yes, people can work around it by loosing 1 of 2^32 useful values and
> > > > convoluting their code.
> > > Yes, one of 2^32 values is reserved.
> > > Any reason why (2^32 - 1) values might not be enough?
> > 
> > Sure. We're using userdata as a bitmask of actions to take on the packet,
> > and because of this restriction we're loosing half of the userdata field.
> > If we would add this "decrement if non-zero" workaround this would keep
> > biting us on every occasion where we touch the ACL verdict code.
> > 
> > > > You seem to argue that 0 is somehow an invalid value, but I can't find
> > > > anything in the ACL that would require it to be so. Could you point me
> > > > to the code in DPDK where this actually matters?
> > >
> > > It was a while, when I looked into ACL code in details, but as remember
> > > that's the only reason: we need some value to be reserved as NO_MATCH.
> > > Let say in build_trie() we set results to zero for rules with unused categories:
> > > for (m = context->cfg.num_categories; 0 != m--; ) {
> > >                         if (rule->f->data.category_mask & (1 << m)) {
> > >                                 end->mrt->results[m] = rule->f->data.userdata;
> > >                                 end->mrt->priority[m] = rule->f->data.priority;
> > >                         } else {
> > >                                 end->mrt->results[m] = 0;
> > >                                 end->mrt->priority[m] = 0;
> > >                         }
> > >                 }
> > 
> > So, if I understand correctly, 0 is a default value for category result.
> > Any matching rule with priority >= 0 will override it (leaving last highest
> > priority rule's userdata). This will just work the same for anyone needing
> > the distinction (when he doesn't use userdata == 0) and also for those who
> > don't -- when the restriction is removed.
> > 
> > I think that it comes to documenting the behaviour and let users choose
> > their way. At the beginning I haven't found any mention of the restriction
> > in the docs, so I had to spend a fair amount of time to find out why the
> > zero is so special (it wasn't).
> 
> Ok, so you suggest the following:
> 1. Zero value for both userdata and results still has a special meaning: NO_MATCH.
> 2. Allow user to create a rule(s) that would on hit return NO_MATCH for it,
> as if no rule was matched by that input (i.e. rule's userdata==0).
> Is my understanding correct?

That is exactly it.

Best Regards,
Michał Mirosław

  reply	other threads:[~2016-12-14  2:11 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-13  1:08 [dpdk-dev] [PATCH 00/13] Fixes and tweaks Michał Mirosław
2016-12-13  1:08 ` [dpdk-dev] [PATCH 02/13] mbuf: rte_pktmbuf_free_bulk() Michał Mirosław
2016-12-13 21:41   ` Stephen Hemminger
2016-12-14  2:09     ` Michał Mirosław
2016-12-13  1:08 ` [dpdk-dev] [PATCH 01/13] EAL: count nr_overcommit_hugepages as available Michał Mirosław
     [not found]   ` <20161213010852.862C4376C@dpdk.org>
2016-12-13  1:28     ` [dpdk-dev] [PATCH v2 " Michał Mirosław
2017-04-30 15:53       ` Thomas Monjalon
2017-05-04 18:43         ` Michał Mirosław
2019-01-17 17:18           ` Ferruh Yigit
2016-12-13  1:08 ` [dpdk-dev] [PATCH 05/13] acl: fix acl_flow_data comments Michał Mirosław
2016-12-13 10:43   ` Ananyev, Konstantin
2017-01-30 10:15     ` Thomas Monjalon
2016-12-13  1:08 ` [dpdk-dev] [PATCH 03/13] rte_ether: set PKT_RX_VLAN_STRIPPED in rte_vlan_strip() Michał Mirosław
2017-01-30  9:54   ` Thomas Monjalon
2017-02-09 15:56     ` Olivier MATZ
2017-04-30 15:58       ` Thomas Monjalon
2017-05-04  7:30         ` Olivier MATZ
2017-05-04 22:36           ` [dpdk-dev] [PATCH v2] net: fix stripped VLAN flag for offload emulation Thomas Monjalon
2017-05-05 10:02             ` Olivier Matz
2017-05-05 14:00               ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2016-12-13  1:08 ` [dpdk-dev] [PATCH 06/13] null: fake PMD capabilities Michał Mirosław
     [not found]   ` <20161213010913.34C8B5597@dpdk.org>
2016-12-13  1:28     ` [dpdk-dev] [PATCH v2 " Michał Mirosław
2016-12-13  1:35   ` [dpdk-dev] [-- " Michał Mirosław
2016-12-13 10:48   ` [dpdk-dev] [PATCH " Ananyev, Konstantin
2016-12-13 14:26     ` Michal Miroslaw
2016-12-13 14:37       ` Ananyev, Konstantin
2016-12-13 14:57         ` Michal Miroslaw
2016-12-13 17:12           ` Ananyev, Konstantin
2016-12-13 17:31             ` Ferruh Yigit
2016-12-14 19:16   ` [dpdk-dev] [PATCH v4] " Michał Mirosław
2017-01-09 12:07     ` Ferruh Yigit
2017-01-11 10:14       ` Michał Mirosław
2017-01-11 12:23         ` Ferruh Yigit
2016-12-13  1:08 ` [dpdk-dev] [PATCH 04/13] acl: allow zero verdict Michał Mirosław
2016-12-13 10:36   ` Ananyev, Konstantin
2016-12-13 13:54     ` Michal Miroslaw
2016-12-13 14:14       ` Ananyev, Konstantin
2016-12-13 14:53         ` Michal Miroslaw
2016-12-13 15:13           ` Ananyev, Konstantin
2016-12-13 16:14             ` Michal Miroslaw
2016-12-13 16:43               ` Michal Miroslaw
2016-12-13 17:27               ` Ananyev, Konstantin
2016-12-13 18:02                 ` Michal Miroslaw
2016-12-13 21:55                   ` Ananyev, Konstantin
2016-12-14  2:11                     ` Michal Miroslaw [this message]
2016-12-14 12:16                       ` Ananyev, Konstantin
2016-12-13  1:08 ` [dpdk-dev] [PATCH 08/13] PMD/af_packet: guard against buffer overruns in RX path Michał Mirosław
     [not found]   ` <20161213010918.F1B095684@dpdk.org>
2016-12-13  1:28     ` [dpdk-dev] [PATCH v2 " Michał Mirosław
2016-12-13 16:05       ` John W. Linville
2016-12-16 10:32         ` Ferruh Yigit
2017-01-18 11:48   ` [dpdk-dev] [PATCH " Ferruh Yigit
2017-01-18 19:22     ` Michał Mirosław
2016-12-13  1:08 ` [dpdk-dev] [PATCH 07/13] pcap: fix timestamps in output pcap file Michał Mirosław
2016-12-14 17:45   ` Ferruh Yigit
2016-12-16 10:06     ` Ferruh Yigit
2016-12-13  1:08 ` [dpdk-dev] [PATCH 09/13] PMD/af_packet: guard against buffer overruns in TX path Michał Mirosław
     [not found]   ` <20161213010927.9B12CFA30@dpdk.org>
2016-12-13  1:28     ` [dpdk-dev] [PATCH v2 " Michał Mirosław
2016-12-13 16:06       ` John W. Linville
2016-12-16 10:32         ` Ferruh Yigit
2016-12-13  1:08 ` [dpdk-dev] [PATCH 10/13] KNI: provided netif name's source is user-space Michał Mirosław
2016-12-14 17:06   ` Ferruh Yigit
2016-12-14 17:19     ` Michał Mirosław
2016-12-14 17:35       ` Ferruh Yigit
2016-12-14 17:35         ` Ferruh Yigit
2017-01-29 21:50           ` Thomas Monjalon
2016-12-13  1:08 ` [dpdk-dev] [PATCH 13/13] i40e: improve message grepability Michał Mirosław
2016-12-28  3:51   ` Wu, Jingjing
2017-01-09 12:02     ` Bruce Richardson
2017-01-09 13:18       ` Thomas Monjalon
2017-01-09 17:25         ` Stephen Hemminger
2017-01-09 14:11   ` Ferruh Yigit
2017-01-11  9:49   ` [dpdk-dev] [PATCH] " Michał Mirosław
2017-01-11 16:05     ` Ferruh Yigit
2017-01-11 17:13   ` [dpdk-dev] [PATCH v3 1/1] " Michał Mirosław
2017-01-11 17:50     ` Ferruh Yigit
2017-01-11 17:52       ` Ferruh Yigit
2016-12-13  1:08 ` [dpdk-dev] [PATCH 12/13] i40e: return -errno when intr setup fails Michał Mirosław
2016-12-22 15:45   ` Ferruh Yigit
2016-12-23  1:55     ` Michał Mirosław
2016-12-28  3:47   ` Wu, Jingjing
2017-01-11 16:09     ` Ferruh Yigit
2016-12-13  1:08 ` [dpdk-dev] [PATCH 11/13] KNI: guard against unterminated dev_info.name leading to BUG in alloc_netdev() Michał Mirosław
2016-12-14 17:33   ` Ferruh Yigit
2016-12-14 17:37     ` Michał Mirosław
2016-12-14 17:48       ` Ferruh Yigit
2017-01-29 21:53     ` Thomas Monjalon
2016-12-14 17:23 ` [dpdk-dev] [PATCH] acl: remove invalid test Michał Mirosław
2016-12-19 18:48   ` Ananyev, Konstantin
2016-12-23  1:47     ` Michal Miroslaw
2016-12-23  9:36       ` Ananyev, Konstantin
2017-01-17 15:24         ` Thomas Monjalon
2017-01-18  9:51           ` Ananyev, Konstantin
2017-01-18 19:21             ` Michal Miroslaw
2016-12-14 17:23 ` [dpdk-dev] [PATCH v2] acl: allow zero verdict Michał Mirosław
2016-12-19 18:54   ` Ananyev, Konstantin

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=20161214021111.2l4h4gsbjxmbffca@rere.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.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).