From: Ajit Khaparde Date: Thu, 9 Nov 2017 17:46:27 +0000 (-0600) Subject: net/bnxt: fix duplicate creation of ntuple filter X-Git-Tag: spdx-start~857 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1ccdd771d6a00b681d346033ad274d68a2af7a4c;p=dpdk.git net/bnxt: fix duplicate creation of ntuple filter Prevent the creation of duplicate 5tuple filters. Fixes: b7435d660a8c ("net/bnxt: add ntuple filtering support") Signed-off-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index e8c7d0e7c3..dc437b480d 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1956,25 +1956,29 @@ parse_ntuple_filter(struct bnxt *bp, } static struct bnxt_filter_info* -bnxt_match_ntuple_filter(struct bnxt_vnic_info *vnic, +bnxt_match_ntuple_filter(struct bnxt *bp, struct bnxt_filter_info *bfilter) { struct bnxt_filter_info *mfilter = NULL; + int i; - STAILQ_FOREACH(mfilter, &vnic->filter, next) { - if (bfilter->src_ipaddr[0] == mfilter->src_ipaddr[0] && - bfilter->src_ipaddr_mask[0] == - mfilter->src_ipaddr_mask[0] && - bfilter->src_port == mfilter->src_port && - bfilter->src_port_mask == mfilter->src_port_mask && - bfilter->dst_ipaddr[0] == mfilter->dst_ipaddr[0] && - bfilter->dst_ipaddr_mask[0] == - mfilter->dst_ipaddr_mask[0] && - bfilter->dst_port == mfilter->dst_port && - bfilter->dst_port_mask == mfilter->dst_port_mask && - bfilter->flags == mfilter->flags && - bfilter->enables == mfilter->enables) - return mfilter; + for (i = bp->nr_vnics - 1; i >= 0; i--) { + struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; + STAILQ_FOREACH(mfilter, &vnic->filter, next) { + if (bfilter->src_ipaddr[0] == mfilter->src_ipaddr[0] && + bfilter->src_ipaddr_mask[0] == + mfilter->src_ipaddr_mask[0] && + bfilter->src_port == mfilter->src_port && + bfilter->src_port_mask == mfilter->src_port_mask && + bfilter->dst_ipaddr[0] == mfilter->dst_ipaddr[0] && + bfilter->dst_ipaddr_mask[0] == + mfilter->dst_ipaddr_mask[0] && + bfilter->dst_port == mfilter->dst_port && + bfilter->dst_port_mask == mfilter->dst_port_mask && + bfilter->flags == mfilter->flags && + bfilter->enables == mfilter->enables) + return mfilter; + } } return NULL; } @@ -2023,7 +2027,7 @@ bnxt_cfg_ntuple_filter(struct bnxt *bp, bfilter->ethertype = 0x800; bfilter->enables |= NTUPLE_FLTR_ALLOC_INPUT_EN_ETHERTYPE; - mfilter = bnxt_match_ntuple_filter(vnic, bfilter); + mfilter = bnxt_match_ntuple_filter(bp, bfilter); if (mfilter != NULL && filter_op == RTE_ETH_FILTER_ADD) { RTE_LOG(ERR, PMD, "filter exists.");