[v2,10/20] net/bnxt: allow only unicast MAC address filter creation
diff mbox series

Message ID 20191002232601.22715-11-ajit.khaparde@broadcom.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • bnxt patchset to improve rte flow support
Related show

Checks

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

Commit Message

Ajit Khaparde Oct. 2, 2019, 11:25 p.m. UTC
Check if the application is trying to create filters using
broadcast and multicast MAC address and reject it.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gupta@broadcom.com>
Reviewed-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
---
 drivers/net/bnxt/bnxt_flow.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index aedbd6d13b..cdfbb6c22f 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -219,6 +219,14 @@  bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			if (rte_is_broadcast_ether_addr(&eth_mask->dst)) {
+				if (!rte_is_unicast_ether_addr(&eth_spec->dst)) {
+					rte_flow_error_set(error,
+							   EINVAL,
+							   RTE_FLOW_ERROR_TYPE_ITEM,
+							   item,
+							   "DMAC is invalid");
+					return -rte_errno;
+				}
 				rte_memcpy(filter->dst_macaddr,
 					   &eth_spec->dst, RTE_ETHER_ADDR_LEN);
 				en |= use_ntuple ?
@@ -233,6 +241,14 @@  bnxt_validate_and_parse_flow_type(struct bnxt *bp,
 			}
 
 			if (rte_is_broadcast_ether_addr(&eth_mask->src)) {
+				if (!rte_is_unicast_ether_addr(&eth_spec->src)) {
+					rte_flow_error_set(error,
+							   EINVAL,
+							   RTE_FLOW_ERROR_TYPE_ITEM,
+							   item,
+							   "SMAC is invalid");
+					return -rte_errno;
+				}
 				rte_memcpy(filter->src_macaddr,
 					   &eth_spec->src, RTE_ETHER_ADDR_LEN);
 				en |= use_ntuple ?