From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-2.cisco.com (rcdn-iport-2.cisco.com [173.37.86.73]) by dpdk.org (Postfix) with ESMTP id A6FC337B4; Sat, 2 Mar 2019 11:43:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2848; q=dns/txt; s=iport; t=1551523421; x=1552733021; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=EoulLgFiP2sV34OOop8XhEHNXfSmjvz9TpR+cs1WmcA=; b=fmW8SNVpQLiJFa5ZKnNytYM+bG8fJ4GODpaWychXvLwgWSyH9Wfb38Iv IHT2VJRPRG36zKCBxpPLLZtUE1CXyzzIvGeeKaewdg7AsiiCLuFep/QKc FEqtm5cPbkVe99PqPEDrQQMw0CoX8v6y58DXag7rAkLQpLYg8I5uaP80R Q=; X-IronPort-AV: E=Sophos;i="5.58,431,1544486400"; d="scan'208";a="530643051" Received: from alln-core-9.cisco.com ([173.36.13.129]) by rcdn-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2019 10:43:40 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-9.cisco.com (8.15.2/8.15.2) with ESMTP id x22AheJh012122; Sat, 2 Mar 2019 10:43:40 GMT Received: by cisco.com (Postfix, from userid 508933) id 6F4F620F2001; Sat, 2 Mar 2019 02:43:40 -0800 (PST) From: Hyong Youb Kim To: Ferruh Yigit Cc: dev@dpdk.org, John Daley , Hyong Youb Kim , stable@dpdk.org Date: Sat, 2 Mar 2019 02:42:41 -0800 Message-Id: <20190302104251.32565-4-hyonkim@cisco.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20190302104251.32565-1-hyonkim@cisco.com> References: <20190302104251.32565-1-hyonkim@cisco.com> X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: alln-core-9.cisco.com Subject: [dpdk-dev] [PATCH v2 03/13] net/enic: fix SCTP match for flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Mar 2019 10:43:42 -0000 The driver needs to explicitly set the protocol number (132) in the IP header pattern, as the current firmware filter API lacks "match SCTP packet" flag. Otherwise, the resulting NIC filter may lead to false positives (i.e. NIC reporting non-SCTP packets as SCTP packets). The flow director handler does the same (enic_clsf.c). Fixes: 6ced137607d0 ("net/enic: flow API for NICs with advanced filters enabled") Cc: stable@dpdk.org Signed-off-by: Hyong Youb Kim Reviewed-by: John Daley --- drivers/net/enic/enic_flow.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index bb9ed037a..55d8d50a1 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -70,7 +70,6 @@ static enic_copy_item_fn enic_copy_item_ipv6_v2; static enic_copy_item_fn enic_copy_item_udp_v2; static enic_copy_item_fn enic_copy_item_tcp_v2; static enic_copy_item_fn enic_copy_item_sctp_v2; -static enic_copy_item_fn enic_copy_item_sctp_v2; static enic_copy_item_fn enic_copy_item_vxlan_v2; static copy_action_fn enic_copy_action_v1; static copy_action_fn enic_copy_action_v2; @@ -237,7 +236,7 @@ static const struct enic_items enic_items_v3[] = { }, [RTE_FLOW_ITEM_TYPE_SCTP] = { .copy_item = enic_copy_item_sctp_v2, - .valid_start_item = 1, + .valid_start_item = 0, .prev_items = (const enum rte_flow_item_type[]) { RTE_FLOW_ITEM_TYPE_IPV4, RTE_FLOW_ITEM_TYPE_IPV6, @@ -819,12 +818,37 @@ enic_copy_item_sctp_v2(const struct rte_flow_item *item, const struct rte_flow_item_sctp *spec = item->spec; const struct rte_flow_item_sctp *mask = item->mask; struct filter_generic_1 *gp = &enic_filter->u.generic_1; + uint8_t *ip_proto_mask = NULL; + uint8_t *ip_proto = NULL; FLOW_TRACE(); if (*inner_ofst) return ENOTSUP; + /* + * The NIC filter API has no flags for "match sctp", so explicitly set + * the protocol number in the IP pattern. + */ + if (gp->val_flags & FILTER_GENERIC_1_IPV4) { + struct ipv4_hdr *ip; + ip = (struct ipv4_hdr *)gp->layer[FILTER_GENERIC_1_L3].mask; + ip_proto_mask = &ip->next_proto_id; + ip = (struct ipv4_hdr *)gp->layer[FILTER_GENERIC_1_L3].val; + ip_proto = &ip->next_proto_id; + } else if (gp->val_flags & FILTER_GENERIC_1_IPV6) { + struct ipv6_hdr *ip; + ip = (struct ipv6_hdr *)gp->layer[FILTER_GENERIC_1_L3].mask; + ip_proto_mask = &ip->proto; + ip = (struct ipv6_hdr *)gp->layer[FILTER_GENERIC_1_L3].val; + ip_proto = &ip->proto; + } else { + /* Need IPv4/IPv6 pattern first */ + return EINVAL; + } + *ip_proto = IPPROTO_SCTP; + *ip_proto_mask = 0xff; + /* Match all if no spec */ if (!spec) return 0; -- 2.16.2