Skip to contentSkip to conversation

Enable zero verdicts in ACLs

PATCH Applied Michał Mirosław 3 participants 5 messages Jan 18, 2017 – Jan 30, 2017

lore
Share & tools
lore
#0 lore raw

cover Enable zero verdicts in ACLs

This set enables one to have ACL matches return 0 where the distinction from no-match case is not needed.

This is a resubmission of the patches as a series, rebased on net-next tree, no other changes vs v2.

v2: fixes to prog_guide and ACL tests

Michał Mirosław (2):
acl: remove invalid test
acl: allow zero verdict

 app/test/test_acl.c                                | 33 ----------------------
 .../prog_guide/packet_classif_access_ctrl.rst      |  3 +-
 lib/librte_acl/rte_acl.c                           |  3 +-
 lib/librte_acl/rte_acl.h                           |  2 --
 lib/librte_table/rte_table_acl.c                   |  2 +-
 5 files changed, 4 insertions(+), 39 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/2 acl: remove invalid test

rte_acl_add_rules() has no way of checking rule size.

This was hidden because the test effectively checked that adding a rule with userdata == 0 failed.

From: Michał Mirosław <[email protected]>

---
 app/test/test_acl.c | 20 --------------------
 1 file changed, 20 deletions(-)
app/test/test_acl.c +0 -20
index 28955f08a..be744ec23 100644
@@ -1515,26 +1515,6 @@ test_invalid_parameters(void)
 	/* free ACL context */
 	rte_acl_free(acx);
 
-	/* set wrong rule_size so that adding any rules would fail */
-	param.rule_size = RTE_ACL_IPV4VLAN_RULE_SZ + 4;
-	acx = rte_acl_create(&param);
-	if (acx == NULL) {
-		printf("Line %i: ACL context creation failed!\n", __LINE__);
-		return -1;
-	}
-
-	/* try adding a rule with size different from context rule_size */
-	result = rte_acl_ipv4vlan_add_rules(acx, &rule, 1);
-	if (result == 0) {
-		printf("Line %i: Adding an invalid sized rule "
-				"should have failed!\n", __LINE__);
-		rte_acl_free(acx);
-		return -1;
-	}
-
-	/* free ACL context */
-	rte_acl_free(acx);
-
 
 	/**
 	 * rte_acl_ipv4vlan_build
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/2 acl: allow zero verdict

In reply to Michał Mirosław

This enables ACL matches to return 0 where the distinction from no-match case is not needed.

From: Michał Mirosław <[email protected]>

---
 app/test/test_acl.c                                  | 13 -------------
 doc/guides/prog_guide/packet_classif_access_ctrl.rst |  3 ++-
 lib/librte_acl/rte_acl.c                             |  3 +--
 lib/librte_acl/rte_acl.h                             |  2 --
 lib/librte_table/rte_table_acl.c                     |  2 +-
 5 files changed, 4 insertions(+), 19 deletions(-)
app/test/test_acl.c +0 -13
index be744ec23..c6b511fb1 100644
@@ -1357,19 +1357,6 @@ test_invalid_rules(void)
 		goto err;
 	}
 
-	rule.dst_mask_len = 0;
-	rule.src_mask_len = 0;
-	rule.data.userdata = 0;
-
-	/* try adding this rule (it should fail because userdata is invalid) */
-	ret = rte_acl_ipv4vlan_add_rules(acx, &rule, 1);
-	if (ret == 0) {
-		printf("Line %i: Adding a rule with invalid user data "
-				"should have failed!\n", __LINE__);
-		rte_acl_free(acx);
-		return -1;
-	}
-
 	rte_acl_free(acx);
 
 	return 0;
doc/guides/prog_guide/packet_classif_access_ctrl.rst +2 -1
index 5fd3d348d..a6bee9ba2 100644
@@ -329,8 +329,9 @@ When creating a set of rules, for each rule, additional information must be supp
     Each set could be assigned its own category and by combining them into a single database,
     one lookup returns a result for each of the four sets.
 
-*   **userdata**: A user-defined field that could be any value except zero.
+*   **userdata**: A user-defined value.
     For each category, a successful match returns the userdata field of the highest priority matched rule.
+    When no rules match, returned value is zero.
 
 .. note::
 
lib/librte_acl/rte_acl.c +1 -2
index 8b7e92cec..d1f40bef0 100644
@@ -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;
 }
lib/librte_acl/rte_acl.h +0 -2
index caa91f7ea..b53179a83 100644
@@ -120,8 +120,6 @@ enum {
 	RTE_ACL_MIN_PRIORITY = 0,
 };
 
-#define	RTE_ACL_INVALID_USERDATA	0
-
 #define	RTE_ACL_MASKLEN_TO_BITMASK(v, s)	\
 ((v) == 0 ? (v) : (typeof(v))((uint64_t)-1 << ((s) * CHAR_BIT - (v))))
 
lib/librte_table/rte_table_acl.c +1 -1
index 8f1f8cebc..94b69a983 100644
@@ -792,7 +792,7 @@ rte_table_acl_lookup(
 
 		pkts_mask &= ~pkt_mask;
 
-		if (action_table_pos != RTE_ACL_INVALID_USERDATA) {
+		if (action_table_pos != 0) {
 			pkts_out_mask |= pkt_mask;
 			entries[pkt_pos] = (void *)
 				&acl->memory[action_table_pos *
Signature · 1 line
2.11.0
Acked-by on the v1 series
#3 lore raw
In reply to Michał Mirosław
Quoted 21 lines

-----Original Message-----
From: Michał Mirosław [mailto:[email protected]]
Sent: Wednesday, January 18, 2017 7:33 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Thomas Monjalon <[email protected]>
Subject: [PATCH 0/2] Enable zero verdicts in ACLs

This set enables one to have ACL matches return 0 where the distinction from no-match case is not needed.

This is a resubmission of the patches as a series, rebased on net-next tree, no other changes vs v2.

v2: fixes to prog_guide and ACL tests

Michał Mirosław (2):
acl: remove invalid test
acl: allow zero verdict

Quoted 8 lines
 app/test/test_acl.c                                | 33 ----------------------
 .../prog_guide/packet_classif_access_ctrl.rst      |  3 +-
 lib/librte_acl/rte_acl.c                           |  3 +-
 lib/librte_acl/rte_acl.h                           |  2 --
 lib/librte_table/rte_table_acl.c                   |  2 +-
 5 files changed, 4 insertions(+), 39 deletions(-)

--

Quoted 1 line

2.11.0

#4 lore raw
Quoted 6 lines
Quoted 6 lines

This set enables one to have ACL matches return 0 where the distinction from no-match case is not needed.

This is a resubmission of the patches as a series, rebased on net-next tree, no other changes vs v2.

Quoted 7 lines
Quoted 5 lines

v2: fixes to prog_guide and ACL tests

Michał Mirosław (2):
acl: remove invalid test
acl: allow zero verdict

Applied, thanks