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 C67FCA0093 for ; Sat, 19 Mar 2022 12:18:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA15C41144; Sat, 19 Mar 2022 12:18:42 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 0DA3440683; Sat, 19 Mar 2022 12:18:41 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id s8so11620784pfk.12; Sat, 19 Mar 2022 04:18:40 -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:mime-version :content-transfer-encoding; bh=BCqmRgd5lNS8ijzvLIMLJYyebOjnHsSyIIeGU+SQRps=; b=hTwo/n7Suh8l6dKuDejg/klcs2SYy5JkbHR48yNU0cxl5QahggpN63uC4xZw9pDmND hB+ZMCOuF4pR7MhaAQZAhOgK02Woyc2Xe8PwjjRPxsqT+rdD3MgdNgCGzJTvA8Q/4kaZ /DDi3RnEmk+G2+VR+4jv6OJQO5jMxsUzWMF34yc+eFnB/NjCY3ndkknzO1MJO6qpS32l VC87VgslhpgbmUFRu8q7pfY2wcdowohdigUG08LGndNDMwjOOYmRjFW5f4tWeERlK39I ixPT5M1HeKx+lZ/tfPdRF1WaE3mb9NZEj7Yi/SrmU5DrpKMg66XAbkyWkyHMBLT486F0 tjIQ== 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:mime-version :content-transfer-encoding; bh=BCqmRgd5lNS8ijzvLIMLJYyebOjnHsSyIIeGU+SQRps=; b=21J/BT1VQiBqOXNtHZzqOqMotQ/nmwlbQnFY27KkOY6bHZWSi3QFkKJ+oUL2SFfeZT vN+CHOOO3FXOg8MK42k4ZHh91YeN5YilAh4w/MOkyFRjBl1/16DnK06/XpiFuB8E8wPa Zd9CyJaB11RbEW7gktDgjBvlRrXeTor2/lQlN9LkHZ4ZIlpkf5YgLtHzF7x35+OqoSNf lq1XdwWGXQzTVV/Y0kWS1Sthkw8d55P76LEHm3SNGEj3CLX450e/bE9EfEFyXlsM17pi WGhzhEPl59txvKCYPIgkF7XNW16w4lAu2GjQGuPyRHY84GYcFOOCEqimY5gX7+UKScv6 lGhw== X-Gm-Message-State: AOAM532YaQQW9PeXefwMySxM1vF7PA6yh2yjqlfolyKFPKu9/+v67wS7 0BW31xUPdx4QDMxvTH5lrWdoLJ6Arp/fkrN7 X-Google-Smtp-Source: ABdhPJzqXU3e6AhmJ4JdX2cfAVXZUFZdVYAWfA3B1cXSVdpaS5m1JZP8XAPptEo4rIpwfpEiizHYEQ== X-Received: by 2002:a63:fc0e:0:b0:365:39dd:2cd0 with SMTP id j14-20020a63fc0e000000b0036539dd2cd0mr11464226pgi.173.1647688719726; Sat, 19 Mar 2022 04:18:39 -0700 (PDT) Received: from kparameshwa-a01.vmware.com.com ([49.206.14.100]) by smtp.gmail.com with ESMTPSA id lb1-20020a17090b4a4100b001bfb76e56d1sm15310231pjb.36.2022.03.19.04.18.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Mar 2022 04:18:39 -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 v1] gro: fix gro for UDP fragmented packets Date: Sat, 19 Mar 2022 16:48:29 +0530 Message-Id: <20220319111829.71676-1-kumaraparamesh92@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) 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. 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) -- 2.17.1