acl: fix invalid results for rule with zero priority

Message ID 1535129226-25510-1-git-send-email-konstantin.ananyev@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series acl: fix invalid results for rule with zero priority |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ananyev, Konstantin Aug. 24, 2018, 4:47 p.m. UTC
  If user specifies priority=0 for some of ACL rules
that can cause rte_acl_classify to return wrong results.
The reason is that priority zero is used internally for no-match nodes.
See more details at: https://bugs.dpdk.org/show_bug.cgi?id=79.
The simplest way to overcome the issue is just not allow zero
to be a valid priority for the rule.

Fixes: dc276b5780c2 ("acl: new library")

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_acl/rte_acl.h |  2 +-
 test/test/test_acl.h     | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)
  

Comments

Thomas Monjalon Sept. 16, 2018, 9:56 a.m. UTC | #1
24/08/2018 18:47, Konstantin Ananyev:
> If user specifies priority=0 for some of ACL rules
> that can cause rte_acl_classify to return wrong results.
> The reason is that priority zero is used internally for no-match nodes.
> See more details at: https://bugs.dpdk.org/show_bug.cgi?id=79.
> The simplest way to overcome the issue is just not allow zero
> to be a valid priority for the rule.
> 
> Fixes: dc276b5780c2 ("acl: new library")
> 
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Cc: stable@dpdk.org

Applied with below title, thanks
	acl: forbid rule with priority zero
  
Luca Boccassi Sept. 25, 2018, 12:22 p.m. UTC | #2
On Sun, 2018-09-16 at 11:56 +0200, Thomas Monjalon wrote:
> 24/08/2018 18:47, Konstantin Ananyev:
> > If user specifies priority=0 for some of ACL rules
> > that can cause rte_acl_classify to return wrong results.
> > The reason is that priority zero is used internally for no-match
> > nodes.
> > See more details at: https://bugs.dpdk.org/show_bug.cgi?id=79.
> > The simplest way to overcome the issue is just not allow zero
> > to be a valid priority for the rule.
> > 
> > Fixes: dc276b5780c2 ("acl: new library")
> > 
> > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> Cc: stable@dpdk.org
> 
> Applied with below title, thanks
> 	acl: forbid rule with priority zero

Hi,

This patch is marked for stable, but it changes an enum in a public
header so it looks like an ABI breakage? Have I got it wrong?
  
Thomas Monjalon Sept. 25, 2018, 12:57 p.m. UTC | #3
25/09/2018 14:22, Luca Boccassi:
> On Sun, 2018-09-16 at 11:56 +0200, Thomas Monjalon wrote:
> > 24/08/2018 18:47, Konstantin Ananyev:
> > > If user specifies priority=0 for some of ACL rules
> > > that can cause rte_acl_classify to return wrong results.
> > > The reason is that priority zero is used internally for no-match
> > > nodes.
> > > See more details at: https://bugs.dpdk.org/show_bug.cgi?id=79.
> > > The simplest way to overcome the issue is just not allow zero
> > > to be a valid priority for the rule.
> > > 
> > > Fixes: dc276b5780c2 ("acl: new library")
> > > 
> > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> > 
> > Cc: stable@dpdk.org
> > 
> > Applied with below title, thanks
> > 	acl: forbid rule with priority zero
> 
> Hi,
> 
> This patch is marked for stable, but it changes an enum in a public
> header so it looks like an ABI breakage? Have I got it wrong?

-	RTE_ACL_MIN_PRIORITY = 0,
+	RTE_ACL_MIN_PRIORITY = 1,

In my understanding, the change is not breaking the ABI because
the old minimal value (0) can still be used, with the same side effect.

The new value is just removing a side effect for newly compiled apps.

Konstantin, am I right?
  
Ananyev, Konstantin Sept. 25, 2018, 2:34 p.m. UTC | #4
Hi Luca,

> 
> On Sun, 2018-09-16 at 11:56 +0200, Thomas Monjalon wrote:
> > 24/08/2018 18:47, Konstantin Ananyev:
> > > If user specifies priority=0 for some of ACL rules
> > > that can cause rte_acl_classify to return wrong results.
> > > The reason is that priority zero is used internally for no-match
> > > nodes.
> > > See more details at: https://bugs.dpdk.org/show_bug.cgi?id=79.
> > > The simplest way to overcome the issue is just not allow zero
> > > to be a valid priority for the rule.
> > >
> > > Fixes: dc276b5780c2 ("acl: new library")
> > >
> > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> >
> > Cc: stable@dpdk.org
> >
> > Applied with below title, thanks
> > 	acl: forbid rule with priority zero
> 
> Hi,
> 
> This patch is marked for stable, but it changes an enum in a public header 

Yes it does.

> so it looks like an ABI breakage? Have I got it wrong?

Strictly speaking - yes, but priority=0 is invalid value with current implementation.
I don't think someone uses it - as in that case acl library simply wouldn't work
correctly.
Konstantin
  
Luca Boccassi Oct. 3, 2018, 4:18 p.m. UTC | #5
On Tue, 2018-09-25 at 14:34 +0000, Ananyev, Konstantin wrote:
> Hi Luca,
> 
> > 
> > On Sun, 2018-09-16 at 11:56 +0200, Thomas Monjalon wrote:
> > > 24/08/2018 18:47, Konstantin Ananyev:
> > > > If user specifies priority=0 for some of ACL rules
> > > > that can cause rte_acl_classify to return wrong results.
> > > > The reason is that priority zero is used internally for no-
> > > > match
> > > > nodes.
> > > > See more details at: https://bugs.dpdk.org/show_bug.cgi?id=79.
> > > > The simplest way to overcome the issue is just not allow zero
> > > > to be a valid priority for the rule.
> > > > 
> > > > Fixes: dc276b5780c2 ("acl: new library")
> > > > 
> > > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com
> > > > >
> > > 
> > > Cc: stable@dpdk.org
> > > 
> > > Applied with below title, thanks
> > > 	acl: forbid rule with priority zero
> > 
> > Hi,
> > 
> > This patch is marked for stable, but it changes an enum in a public
> > header 
> 
> Yes it does.
> 
> > so it looks like an ABI breakage? Have I got it wrong?
> 
> Strictly speaking - yes, but priority=0 is invalid value with current
> implementation.
> I don't think someone uses it - as in that case acl library simply
> wouldn't work
> correctly.
> Konstantin

Ok, I'll include this patch in 16.11.9 then, thanks for clarifying.
  

Patch

diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index 34c3b9c6a..aa22e70c6 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -88,7 +88,7 @@  enum {
 	RTE_ACL_TYPE_SHIFT = 29,
 	RTE_ACL_MAX_INDEX = RTE_LEN2MASK(RTE_ACL_TYPE_SHIFT, uint32_t),
 	RTE_ACL_MAX_PRIORITY = RTE_ACL_MAX_INDEX,
-	RTE_ACL_MIN_PRIORITY = 0,
+	RTE_ACL_MIN_PRIORITY = 1,
 };
 
 #define	RTE_ACL_MASKLEN_TO_BITMASK(v, s)	\
diff --git a/test/test/test_acl.h b/test/test/test_acl.h
index c4811c8f5..bbb0447a8 100644
--- a/test/test/test_acl.h
+++ b/test/test/test_acl.h
@@ -80,34 +80,40 @@  enum {
 struct rte_acl_ipv4vlan_rule invalid_layout_rules[] = {
 		/* test src and dst address */
 		{
-				.data = {.userdata = 1, .category_mask = 1},
+				.data = {.userdata = 1, .category_mask = 1,
+					.priority = 1},
 				.src_addr = IPv4(10,0,0,0),
 				.src_mask_len = 24,
 		},
 		{
-				.data = {.userdata = 2, .category_mask = 1},
+				.data = {.userdata = 2, .category_mask = 1,
+					.priority = 1},
 				.dst_addr = IPv4(10,0,0,0),
 				.dst_mask_len = 24,
 		},
 		/* test src and dst ports */
 		{
-				.data = {.userdata = 3, .category_mask = 1},
+				.data = {.userdata = 3, .category_mask = 1,
+					.priority = 1},
 				.dst_port_low = 100,
 				.dst_port_high = 100,
 		},
 		{
-				.data = {.userdata = 4, .category_mask = 1},
+				.data = {.userdata = 4, .category_mask = 1,
+					.priority = 1},
 				.src_port_low = 100,
 				.src_port_high = 100,
 		},
 		/* test proto */
 		{
-				.data = {.userdata = 5, .category_mask = 1},
+				.data = {.userdata = 5, .category_mask = 1,
+					.priority = 1},
 				.proto = 0xf,
 				.proto_mask = 0xf
 		},
 		{
-				.data = {.userdata = 6, .category_mask = 1},
+				.data = {.userdata = 6, .category_mask = 1,
+					.priority = 1},
 				.dst_port_low = 0xf,
 				.dst_port_high = 0xf,
 		}