From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7BA5A0544 for ; Wed, 8 Jun 2022 11:46:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF297427EC; Wed, 8 Jun 2022 11:46:37 +0200 (CEST) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id E81F34021D; Wed, 8 Jun 2022 11:46:34 +0200 (CEST) Received: by mail-pj1-f49.google.com with SMTP id 3-20020a17090a174300b001e426a02ac5so20128145pjm.2; Wed, 08 Jun 2022 02:46:34 -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=PGeb2dYpwpFdJAyynEqpt4VEzpeRVBZiPFBS2V7AcOM=; b=anc3BLgtU1iCGY+i201UVIn6AjmSe3umTNQX4V2RA1sJgMXJWTBAT/pm/FAzJ5QHIE AWKtvjMKDfMUVDquGvYTicuvFkN5CJbq9NZGn4j0jKDkza5i0NEpo+Zd6T4xW8uE8uaB XcPzduOXW1mK0KzJ893uPkN54OHFuP/UZfBqEGS9yOMm3Qd1XKNmCzt0tI3APOBxoidN Nrj9XKCwjV9lndjLL/1PiX/t6/irhI3Xg29B6u4K/TLAr8yk1UYMhRB/sXYvV4Lt+f8c pfPPLFJfr+nzjt1F/s4/UzakyGePn6vsv8h+QDrsB/hMAL5Cdi70XIJwPJyb2efkSU2t fkhA== 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=PGeb2dYpwpFdJAyynEqpt4VEzpeRVBZiPFBS2V7AcOM=; b=GaJxo1EtHEVKhh0VuoEEFD11BfEO1kTUMzE6i0BMZIUy6lDNtzl+pOqIpeV7aNLrSa 2VHTRUNMq6/r3dOHZPpUWvlp7EYN7Ok/bSLXyj8MKWH8iw5Eus/j1OMtUBDdBgToU8Ac nfVgh79EDYxFh99Uo3c6DjM1nwpgLWT7JuZ+6uvrnQFfUO6egqNTD9FH94S3Hxlj8jCZ brAOrz3jzsOk3OSwoVsYIfwllel0/NNv8U22kHCD/26ABRo8M19mVQHKBJSR3VeAEpSx kiXxQh7044Wv1wwJfCma1soASOuFbiNf83npWGUnbrkGDrg4Y3caTz2x4qQO0YxZ+HO3 XAOw== X-Gm-Message-State: AOAM533kBZczFNRsyKbnlys1GEzud8sfD3dEA1sVPxuYECQEKIr+9ZhJ ljhwBousF9sBd2mWUJcbWP8eiLGVBgdSkCId X-Google-Smtp-Source: ABdhPJyoB/KyhlQI/UyD91PO4x8gdMN/Y+tpx7OQaoNRuX9qou+F7Qf05k5ILxsEOpXlVbE+hb1BwA== X-Received: by 2002:a17:90a:7846:b0:1e3:3025:6717 with SMTP id y6-20020a17090a784600b001e330256717mr47298796pjl.29.1654681594040; Wed, 08 Jun 2022 02:46:34 -0700 (PDT) Received: from kparameshwa-a02.vmware.com.com ([49.206.13.91]) by smtp.gmail.com with ESMTPSA id c28-20020aa7953c000000b0051c01aa7d31sm7470229pfp.46.2022.06.08.02.46.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Jun 2022 02:46:33 -0700 (PDT) From: Kumara Parameshwaran X-Google-Original-From: Kumara Parameshwaran To: jiayu.hu@intel.com Cc: dev@dpdk.org, Kumara Parameshwaran , stable@dpdk.org Subject: [PATCH v3] gro: bug fix in identifying fragmented packets Date: Wed, 8 Jun 2022 15:16:16 +0530 Message-Id: <20220608094616.40663-1-kumaraparmesh92@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220320101232.34438-1-kumaraparamesh92@gmail.com> References: <20220320101232.34438-1-kumaraparamesh92@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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,v3: * 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..7512553183 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) -- 2.25.1