<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.gmail-im
        {mso-style-name:gmail-im;}
span.gmail-il
        {mso-style-name:gmail-il;}
span.EmailStyle21
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Kumara,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">IMO, TCP GSO will not use the flag. UDP GSO is the same as IP fragmentation,<o:p></o:p></p>
<p class="MsoNormal">and UDP fragments are treated as IP fragments. Except the first fragment, the<o:p></o:p></p>
<p class="MsoNormal">following fragments don’t have L4 header. RTE_PTYPE_L4_FRAG is set to<o:p></o:p></p>
<p class="MsoNormal">recognize them as IP fragments fast.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">TCP GSO is different with IP fragmentation. All TCP segments have complete<o:p></o:p></p>
<p class="MsoNormal">l2/l3/l4 headers. TCP GSO doesn’t use MF flag and offset field in IP header but use<o:p></o:p></p>
<p class="MsoNormal">sequence number to reassemble.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The case you mentioned below is IP fragmentation, not UDP GSO or TCP GSO.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Jiayu<o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> kumaraparameshwaran rathinavel <kumaraparamesh92@gmail.com>
<br>
<b>Sent:</b> Friday, June 17, 2022 7:34 PM<br>
<b>To:</b> Hu, Jiayu <jiayu.hu@intel.com><br>
<b>Cc:</b> dev@dpdk.org; stable@dpdk.org<br>
<b>Subject:</b> Re: [PATCH v4] gro: bug fix in identifying fragmented packets<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span class="gmail-im">> -----Original Message-----</span><br>
<span class="gmail-im">> From: Kumara Parameshwaran <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>></span><br>
<span class="gmail-im">> Sent: Wednesday, June 8, 2022 5:57 PM</span><br>
<span class="gmail-im">> To: Hu, Jiayu <<a href="mailto:jiayu.hu@intel.com" target="_blank">jiayu.hu@intel.com</a>></span><br>
<span class="gmail-im">> Cc: <a href="mailto:dev@dpdk.org" target="_blank">dev@dpdk.org</a>; Kumara Parameshwaran</span><br>
<span class="gmail-im">> <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>>;
<a href="mailto:stable@dpdk.org" target="_blank">stable@dpdk.org</a></span><br>
<span class="gmail-im">> Subject: [PATCH v4] </span><span class="gmail-il">gro</span><span class="gmail-im">: bug fix in identifying fragmented packets</span><br>
<span class="gmail-im">> </span><br>
<span class="gmail-im">> From: Kumara Parameshwaran <<a href="mailto:kumaraparamesh92@gmail.com" target="_blank">kumaraparamesh92@gmail.com</a>></span><br>
<span class="gmail-im">> </span><br>
<span class="gmail-im">> A packet with RTE_PTYPE_L4_FRAG(0x300) contains both RTE_PTYPE_L4_TCP</span><br>
<span class="gmail-im">> (0x100) & RTE_PTYPE_L4_UDP (0x200). A fragmented packet as defined in</span><br>
<span class="gmail-im">> rte_mbuf_ptype.h cannot be recognized as other L4 types and hence the</span><br>
<span class="gmail-im">> </span><span class="gmail-il">GRO</span><span class="gmail-im"> layer should not use IS_IPV4_TCP_PKT or IS_IPV4_UDP_PKT for</span><br>
<span class="gmail-im">> RTE_PTYPE_L4_FRAG. Hence, if the packet type is RTE_PTYPE_L4_FRAG the ip</span><o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">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))<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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? <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Sun, Jun 12, 2022 at 10:50 AM Hu, Jiayu <<a href="mailto:jiayu.hu@intel.com">jiayu.hu@intel.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal" style="margin-bottom:12.0pt">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<o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>