[03/25] net/bnxt: reject offload flows with invalid MAC address
diff mbox series

Message ID 20200911015603.88359-4-ajit.khaparde@broadcom.com
State Superseded, archived
Delegated to: Ajit Khaparde
Headers show
Series
  • patchset for bnxt
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Ajit Khaparde Sept. 11, 2020, 1:55 a.m. UTC
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

Reject offload flows that have broadcast or multicast
ethernet addresses.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index fcb7c4430..ed95cf60f 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -603,6 +603,19 @@  ulp_rte_l2_proto_type_update(struct ulp_rte_parser_params *param,
 	}
 }
 
+/* Internal Function to indentify broadcast or multicast packets */
+static int32_t
+ulp_rte_parser_is_bcmc_addr(const struct rte_ether_addr *eth_addr)
+{
+	if (rte_is_multicast_ether_addr(eth_addr) ||
+	    rte_is_broadcast_ether_addr(eth_addr)) {
+		BNXT_TF_DBG(DEBUG,
+			    "No support for bcast or mcast addr offload\n");
+		return 1;
+	}
+	return 0;
+}
+
 /* Function to handle the parsing of RTE Flow item Ethernet Header. */
 int32_t
 ulp_rte_eth_hdr_handler(const struct rte_flow_item *item,
@@ -625,10 +638,18 @@  ulp_rte_eth_hdr_handler(const struct rte_flow_item *item,
 		field = ulp_rte_parser_fld_copy(&params->hdr_field[idx],
 						eth_spec->dst.addr_bytes,
 						size);
+		/* Todo: work around to avoid multicast and broadcast addr */
+		if (ulp_rte_parser_is_bcmc_addr(&eth_spec->dst))
+			return BNXT_TF_RC_PARSE_ERR;
+
 		size = sizeof(eth_spec->src.addr_bytes);
 		field = ulp_rte_parser_fld_copy(field,
 						eth_spec->src.addr_bytes,
 						size);
+		/* Todo: work around to avoid multicast and broadcast addr */
+		if (ulp_rte_parser_is_bcmc_addr(&eth_spec->src))
+			return BNXT_TF_RC_PARSE_ERR;
+
 		field = ulp_rte_parser_fld_copy(field,
 						&eth_spec->type,
 						sizeof(eth_spec->type));