From patchwork Sun Mar 20 10:12:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumara Parameshwaran X-Patchwork-Id: 108782 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 01C03A04FD; Sun, 20 Mar 2022 11:12:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5D9A410EE; Sun, 20 Mar 2022 11:12:43 +0100 (CET) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id BC1A5410D4; Sun, 20 Mar 2022 11:12:42 +0100 (CET) Received: by mail-pf1-f170.google.com with SMTP id g19so13152465pfc.9; Sun, 20 Mar 2022 03:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HsmkWkqPaZTRHCkpRUtI+eKg+esDVsT38FcIzpjRikg=; b=cVMFz4abFBvpCdg7xyTWANyfZMqRxwFW/2/ss3TEhTCHlPwzlH2gm6POBPF4jDrsWq HWoh6oRtTSa1UfWimS2hZe2cXBfcoY9s9cQDQGQnTsqZ9jhdUYIqFw5/bbGxXyKl/8T2 m1gBgllQ3zSTkUOgcsJTv0V1I9Pfsl+v6Xfnzanmq5KdwbxLe9nwGHFFUvpxWmcbRP2V 8bo3Q7x5OsPtXOW+8wr6WDlUtAIeq1WQ/eMCIJrFbWRAldrHB3rsCnyO5oq8+ILvji6e pHfAdytO7oaFXdc72fA2mUOpkQDqsGICuc08RJjoRe59fNsWP+bj55TfMaNc8rijTPyq RhqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HsmkWkqPaZTRHCkpRUtI+eKg+esDVsT38FcIzpjRikg=; b=1WbJyeDLayiYaU19BCj0LkU3UqzcYVhlr6Oqp6G9mRO6Ig1QsUyinQ8DDDeCFEgHNX L9uq56uFvpfN9iZ7asXosrSA3ioeKh+t9oQneUM2G/Me/vqv4O34HAksXbnqXWF7uO8s zkYax4allwr5FCsGQYCIYJMJyDqQjkaJGQfanmAWcMEGwOSPJzKtXH5CocxcmJM8sgvh ub1nCghx3nl2sCxDkws3017vT+w5aUsh/+8C09t3n0xef/dhfBY+SgBFP6o7eeuM0xC0 /qloBIWvOXc/1phGucoDsmtqzXbFY3az7mkyqaEZ+kGK2y7xC5NT/1RLjg+wy4/1jQBs i0LA== X-Gm-Message-State: AOAM532vS+rGvwqgT/qi9ODRnbR6ZSHZZ0PD+oGX915GOOTxhJbeDtJ5 1aDoddDOv03gIYlM703Lg0GhZrfST4SJvYAo X-Google-Smtp-Source: ABdhPJzcVWGFXvrqvpswlVm+h2MNZ/ZAlp46KNGPBA3RWAz3l01s4MO2y38HouWfUcWDD/whIP0trg== X-Received: by 2002:a05:6a00:2284:b0:4f7:86a3:6f6 with SMTP id f4-20020a056a00228400b004f786a306f6mr18598284pfe.20.1647771161532; Sun, 20 Mar 2022 03:12:41 -0700 (PDT) Received: from kparameshwa-a01.vmware.com.com ([49.206.14.100]) by smtp.gmail.com with ESMTPSA id o7-20020aa79787000000b004f8e44a02e2sm16580579pfp.45.2022.03.20.03.12.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Mar 2022 03:12:40 -0700 (PDT) From: Kumara Parameshwaran To: dev@dpdk.org Cc: jiayu.hu@intel.com, ferruh.yigit@intel.com, stephen@networkplumber.org, olivier.matz@6wind.com, Kumara Parameshwaran , stable@dpdk.org Subject: [PATCH v2] gro: fix gro for UDP fragmented packets Date: Sun, 20 Mar 2022 15:42:32 +0530 Message-Id: <20220320101232.34438-1-kumaraparamesh92@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220319111829.71676-1-kumaraparamesh92@gmail.com> References: <20220319111829.71676-1-kumaraparamesh92@gmail.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Kumara Parameshwaran A packet with RTE_PTYPE_L4_FRAG(0x300) contains both RTE_PTYPE_L4_TCP (0x100) & RTE_PTYPE_L4_UDP (0x200). A fragmented packet as defined in rte_mbuf_ptype.h cannot be recognized as other L4 types and hence the GRO layer should not use IS_IPV4_TCP_PKT or IS_IPV4_UDP_PKT for RTE_PTYPE_L4_FRAG. Hence, if the packet type is RTE_PTYPE_L4_FRAG the ip header should be parsed to recognize the appropriate IP type and invoke the respective gro handler. Fixes: 1ca5e6740852 ("gro: support UDP/IPv4") Cc: stable@dpdk.org Signed-off-by: Kumara Parameshwaran --- v1: * Introduce IS_IPV4_FRAGMENT macro to check if fragmented packet and if true extract the IP header to identify the protocol type and invoke the appropriate gro handler. This is done for both rte_gro_reassemble and rte_gro_reassemble_burst APIs. v2: * Fix extra whitespace and column limit warnings lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index 6f7dd4d709..2f0e6d7088 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -38,6 +38,9 @@ static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = { ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \ (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0)) +#define IS_IPV4_FRAGMENT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \ + ((ptype & RTE_PTYPE_L4_FRAG) == RTE_PTYPE_L4_FRAG)) + #define IS_IPV4_VXLAN_TCP4_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \ ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \ ((ptype & RTE_PTYPE_TUNNEL_VXLAN) == \ @@ -240,7 +243,28 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, * The timestamp is ignored, since all packets * will be flushed from the tables. */ - if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) && + if (IS_IPV4_FRAGMENT(pkts[i]->packet_type)) { + struct rte_ipv4_hdr ip4h_copy; + const struct rte_ipv4_hdr *ip4h = rte_pktmbuf_read(pkts[i], pkts[i]->l2_len, sizeof(*ip4h), + &ip4h_copy); + if (ip4h->next_proto_id == IPPROTO_UDP && do_udp4_gro) { + ret = gro_udp4_reassemble(pkts[i], + &udp_tbl, 0); + if (ret > 0) + nb_after_gro--; + else if (ret < 0) + unprocess_pkts[unprocess_num++] = pkts[i]; + } else if (ip4h->next_proto_id == IPPROTO_TCP && do_tcp4_gro) { + ret = gro_tcp4_reassemble(pkts[i], + &tcp_tbl, 0); + if (ret > 0) + nb_after_gro--; + else if (ret < 0) + unprocess_pkts[unprocess_num++] = pkts[i]; + } else { + unprocess_pkts[unprocess_num++] = pkts[i]; + } + } else if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) && do_vxlan_tcp_gro) { ret = gro_vxlan_tcp4_reassemble(pkts[i], &vxlan_tcp_tbl, 0); @@ -349,7 +373,22 @@ rte_gro_reassemble(struct rte_mbuf **pkts, current_time = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) { - if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) && + if (IS_IPV4_FRAGMENT(pkts[i]->packet_type)) { + struct rte_ipv4_hdr ip4h_copy; + const struct rte_ipv4_hdr *ip4h = rte_pktmbuf_read(pkts[i], pkts[i]->l2_len, sizeof(*ip4h), + &ip4h_copy); + if (ip4h->next_proto_id == IPPROTO_UDP && do_udp4_gro) { + if (gro_udp4_reassemble(pkts[i], udp_tbl, + current_time) < 0) + unprocess_pkts[unprocess_num++] = pkts[i]; + } else if (ip4h->next_proto_id == IPPROTO_TCP && do_tcp4_gro) { + if (gro_tcp4_reassemble(pkts[i], tcp_tbl, + current_time) < 0) + unprocess_pkts[unprocess_num++] = pkts[i]; + } else { + unprocess_pkts[unprocess_num++] = pkts[i]; + } + } else if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) && do_vxlan_tcp_gro) { if (gro_vxlan_tcp4_reassemble(pkts[i], vxlan_tcp_tbl, current_time) < 0)