<div dir="ltr"><span class="gmail-im">> -----Original Message-----<br>
> From: Kumara Parameshwaran <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>><br>
> Sent: Wednesday, June 8, 2022 5:57 PM<br>
> To: Hu, Jiayu <<a href="mailto:jiayu.hu@intel.com" target="_blank">jiayu.hu@intel.com</a>><br>
> Cc: <a href="mailto:dev@dpdk.org" target="_blank">dev@dpdk.org</a>; Kumara Parameshwaran<br>
> <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>>; <a href="mailto:stable@dpdk.org" target="_blank">stable@dpdk.org</a><br>
> Subject: [PATCH v4] <span class="gmail-il">gro</span>: bug fix in identifying fragmented packets<br>
> <br>
> From: Kumara Parameshwaran <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>><br>
> <br>
> A packet with RTE_PTYPE_L4_FRAG(0x300) contains both RTE_PTYPE_L4_TCP<br>
> (0x100) & RTE_PTYPE_L4_UDP (0x200). A fragmented packet as defined in<br>
> rte_mbuf_ptype.h cannot be recognized as other L4 types and hence the<br>
> <span class="gmail-il">GRO</span> layer should not use IS_IPV4_TCP_PKT or IS_IPV4_UDP_PKT for<br>
> RTE_PTYPE_L4_FRAG. Hence, if the packet type is RTE_PTYPE_L4_FRAG the ip<br>
<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))"<br>
in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments<br>
in TCP based <span class="gmail-il">GRO</span> functions. For example:<br>
#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \<br>
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \<br>
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \<br>
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))</blockquote><div><br></div><div>This would be handling only the UDP fragmentation case. What if there is fragmentation of TCP packets?  What happens if the packet is RTE_PTYPE_L4_FRAG and in the  struct rte_ipv4_hdr the proto type is IPPROTO_TCP ? What happens to that case? <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 12, 2022 at 10:50 AM Hu, Jiayu <<a href="mailto:jiayu.hu@intel.com">jiayu.hu@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Kumara,<br>
<br>
> -----Original Message-----<br>
> From: Kumara Parameshwaran <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>><br>
> Sent: Wednesday, June 8, 2022 5:57 PM<br>
> To: Hu, Jiayu <<a href="mailto:jiayu.hu@intel.com" target="_blank">jiayu.hu@intel.com</a>><br>
> Cc: <a href="mailto:dev@dpdk.org" target="_blank">dev@dpdk.org</a>; Kumara Parameshwaran<br>
> <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>>; <a href="mailto:stable@dpdk.org" target="_blank">stable@dpdk.org</a><br>
> Subject: [PATCH v4] gro: bug fix in identifying fragmented packets<br>
> <br>
> From: Kumara Parameshwaran <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>><br>
> <br>
> A packet with RTE_PTYPE_L4_FRAG(0x300) contains both RTE_PTYPE_L4_TCP<br>
> (0x100) & RTE_PTYPE_L4_UDP (0x200). A fragmented packet as defined in<br>
> rte_mbuf_ptype.h cannot be recognized as other L4 types and hence the<br>
> GRO layer should not use IS_IPV4_TCP_PKT or IS_IPV4_UDP_PKT for<br>
> RTE_PTYPE_L4_FRAG. Hence, if the packet type is RTE_PTYPE_L4_FRAG the ip<br>
<br>
A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))"<br>
in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments<br>
in TCP based GRO functions. For example:<br>
#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \<br>
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \<br>
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \<br>
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))<br>
<br>
Thanks,<br>
Jiayu<br>
<br>
> header should be parsed to recognize the appropriate IP type and invoke the<br>
> respective gro handler.<br>
> <br>
> Fixes: 1ca5e6740852 ("gro: support UDP/IPv4")<br>
> Cc: <a href="mailto:stable@dpdk.org" target="_blank">stable@dpdk.org</a><br>
> <br>
> Signed-off-by: Kumara Parameshwaran <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>><br>
> ---<br>
> v1:<br>
> * Introduce IS_IPV4_FRAGMENT macro to check if fragmented packet and<br>
>   if true extract the IP header to identify the protocol type and<br>
>   invoke the appropriate gro handler. This is done for both<br>
>   rte_gro_reassemble and rte_gro_reassemble_burst APIs.<br>
> v2,v3,v4:<br>
> * Fix extra whitespace and column limit warnings<br>
> <br>
>  lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--<br>
>  1 file changed, 41 insertions(+), 2 deletions(-)  lib/gro/rte_gro.c | 43<br>
> +++++++++++++++++++++++++++++++++++++++++--<br>
>  1 file changed, 41 insertions(+), 2 deletions(-)<br>
> <br>
> diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index<br>
> 6f7dd4d709..83d6e21dbb 100644<br>
> --- a/lib/gro/rte_gro.c<br>
> +++ b/lib/gro/rte_gro.c<br>
> @@ -38,6 +38,9 @@ static gro_tbl_pkt_count_fn<br>
> tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {<br>
>               ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \<br>
>               (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))<br>
> <br>
> +#define IS_IPV4_FRAGMENT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \<br>
> +             ((ptype & RTE_PTYPE_L4_FRAG) == RTE_PTYPE_L4_FRAG))<br>
> +<br>
>  #define IS_IPV4_VXLAN_TCP4_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype)<br>
> && \<br>
>               ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \<br>
>               ((ptype & RTE_PTYPE_TUNNEL_VXLAN) == \ @@ -240,7<br>
> +243,28 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,<br>
>                * The timestamp is ignored, since all packets<br>
>                * will be flushed from the tables.<br>
>                */<br>
> -             if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) &&<br>
> +             if (IS_IPV4_FRAGMENT(pkts[i]->packet_type)) {<br>
> +                     struct rte_ipv4_hdr ip4h_copy;<br>
> +                     const struct rte_ipv4_hdr *ip4h =<br>
> rte_pktmbuf_read(pkts[i], pkts[i]->l2_len,<br>
> +<br>
>                                       sizeof(*ip4h), &ip4h_copy);<br>
> +                     if (ip4h->next_proto_id == IPPROTO_UDP &&<br>
> do_udp4_gro) {<br>
> +                             ret = gro_udp4_reassemble(pkts[i],<br>
> +                                                     &udp_tbl, 0);<br>
> +                             if (ret > 0)<br>
> +                                     nb_after_gro--;<br>
> +                             else if (ret < 0)<br>
> +                                     unprocess_pkts[unprocess_num++] =<br>
> pkts[i];<br>
> +                     } else if (ip4h->next_proto_id == IPPROTO_TCP &&<br>
> do_tcp4_gro) {<br>
> +                             ret = gro_tcp4_reassemble(pkts[i],<br>
> +                                             &tcp_tbl, 0);<br>
> +                             if (ret > 0)<br>
> +                                     nb_after_gro--;<br>
> +                             else if (ret < 0)<br>
> +                                     unprocess_pkts[unprocess_num++] =<br>
> pkts[i];<br>
> +                     } else {<br>
> +                             unprocess_pkts[unprocess_num++] = pkts[i];<br>
> +                     }<br>
> +             } else if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) &&<br>
>                               do_vxlan_tcp_gro) {<br>
>                       ret = gro_vxlan_tcp4_reassemble(pkts[i],<br>
>                                                       &vxlan_tcp_tbl, 0);<br>
> @@ -349,7 +373,22 @@ rte_gro_reassemble(struct rte_mbuf **pkts,<br>
>       current_time = rte_rdtsc();<br>
> <br>
>       for (i = 0; i < nb_pkts; i++) {<br>
> -             if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) &&<br>
> +             if (IS_IPV4_FRAGMENT(pkts[i]->packet_type)) {<br>
> +                     struct rte_ipv4_hdr ip4h_copy;<br>
> +                     const struct rte_ipv4_hdr *ip4h =<br>
> rte_pktmbuf_read(pkts[i], pkts[i]->l2_len,<br>
> +<br>
>                                       sizeof(*ip4h), &ip4h_copy);<br>
> +                     if (ip4h->next_proto_id == IPPROTO_UDP &&<br>
> do_udp4_gro) {<br>
> +                             if (gro_udp4_reassemble(pkts[i], udp_tbl,<br>
> +                                             current_time) < 0)<br>
> +                                     unprocess_pkts[unprocess_num++] =<br>
> pkts[i];<br>
> +                     } else if (ip4h->next_proto_id == IPPROTO_TCP &&<br>
> do_tcp4_gro) {<br>
> +                             if (gro_tcp4_reassemble(pkts[i], tcp_tbl,<br>
> +                                             current_time) < 0)<br>
> +                                     unprocess_pkts[unprocess_num++] =<br>
> pkts[i];<br>
> +                     } else {<br>
> +                             unprocess_pkts[unprocess_num++] = pkts[i];<br>
> +                     }<br>
> +             } else if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) &&<br>
>                               do_vxlan_tcp_gro) {<br>
>                       if (gro_vxlan_tcp4_reassemble(pkts[i], vxlan_tcp_tbl,<br>
>                                               current_time) < 0)<br>
> --<br>
> 2.25.1<br>
<br>
</blockquote></div>