Skip to contentSkip to conversation

gro: fix gro for UDP fragmented packets

PATCH Superseded Kumara Parameshwaran 3 participants 13 messages Mar 19, 2022 – Jul 5, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gro: fix gro for UDP fragmented packets

From: Kumara Parameshwaran <[email protected]>

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")

---
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(-)
lib/gro/rte_gro.c +41 -2
index 6f7dd4d709..2f0e6d7088 100644
@@ -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)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 gro: fix gro for UDP fragmented packets

From: Kumara Parameshwaran <[email protected]>

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")

---
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(-)
lib/gro/rte_gro.c +41 -2
index 6f7dd4d709..2f0e6d7088 100644
@@ -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)
Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 1/1 gro: bug fix in identifying fragmented packets

From: Kumara Parameshwaran <[email protected]>

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")

---
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(-)
lib/gro/rte_gro.c +41 -2
index 6f7dd4d709..7512553183 100644
@@ -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)
Signature · 1 line
2.25.1
#3 lore raw

PATCH v4 1/1 gro: bug fix in identifying fragmented packets

In reply to Kumara Parameshwaran

From: Kumara Parameshwaran <[email protected]>

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")

---
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,v4:
* Fix extra whitespace and column limit warnings

 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
lib/gro/rte_gro.c +41 -2
index 6f7dd4d709..83d6e21dbb 100644
@@ -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)
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH v4] gro: bug fix in identifying fragmented packets

Jiayu, please could you review this patch?

08/06/2022 11:57, Kumara Parameshwaran:

Quoted 97 lines

From: Kumara Parameshwaran <[email protected]>

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")

---
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,v4:
* Fix extra whitespace and column limit warnings

 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
lib/gro/rte_gro.c +41 -2
index 6f7dd4d709..83d6e21dbb 100644
@@ -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)
#5 lore raw

RE: [PATCH v4] gro: bug fix in identifying fragmented packets

Sure. Will review soon.

Thanks,
Jiayu

Quoted 129 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, June 9, 2022 4:14 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; [email protected]
Subject: Re: [PATCH v4] gro: bug fix in identifying fragmented packets

Jiayu, please could you review this patch?

08/06/2022 11:57, Kumara Parameshwaran:

Quoted 3 lines

From: Kumara Parameshwaran <[email protected]>

A packet with RTE_PTYPE_L4_FRAG(0x300) contains both

RTE_PTYPE_L4_TCP

lib/gro/rte_gro.c static gro_tbl_pkt_count_fn

Quoted 30 lines

(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")

---
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,v4:
* Fix extra whitespace and column limit warnings

 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)  lib/gro/rte_gro.c |
43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
lib/gro/rte_gro.c index renamed from lib/gro/rte_gro.c +0 -0

6f7dd4d709..83d6e21dbb 100644

lib/gro/rte_gro.c +0 -0
@@ -38,6 +38,9 @@ static gro_tbl_pkt_count_fn

tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {

lib/gro/rte_gro.c static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {

Quoted 7 lines
lib/gro/rte_gro.c +3 -0
 		((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)

&& \

lib/gro/rte_gro.c static gro_tbl_pkt_count_fn · line 46

Quoted 2 lines
lib/gro/rte_gro.c +0 -0
 		((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \
 		((ptype & RTE_PTYPE_TUNNEL_VXLAN) == \ @@ -240,7

+243,28 @@

lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts,

Quoted 8 lines

rte_gro_reassemble_burst(struct rte_mbuf **pkts,

lib/gro/rte_gro.c +3 -1
 		 * 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,

Quoted 1 line

+

					sizeof(*ip4h), &ip4h_copy);

lib/gro/rte_gro.c

Quoted 1 line
lib/gro/rte_gro.c +1 -0
+			if (ip4h->next_proto_id == IPPROTO_UDP &&

do_udp4_gro) {

lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts,

Quoted 6 lines
lib/gro/rte_gro.c +6 -0
+				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];

lib/gro/rte_gro.c

Quoted 1 line
lib/gro/rte_gro.c +1 -0
+			} else if (ip4h->next_proto_id == IPPROTO_TCP &&

do_tcp4_gro) {

lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts,

Quoted 6 lines
lib/gro/rte_gro.c +6 -0
+				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];

Quoted 8 lines
lib/gro/rte_gro.c +4 -0
+			} 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);

lib/gro/rte_gro.c rte_gro_reassemble(struct rte_mbuf **pkts, · line 378

Quoted 7 lines
lib/gro/rte_gro.c +3 -1
@@ -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,

lib/gro/rte_gro.c static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = { · line 43

Quoted 1 line
lib/gro/rte_gro.c +1 -0
+
					sizeof(*ip4h), &ip4h_copy);

lib/gro/rte_gro.c rte_gro_reassemble(struct rte_mbuf **pkts, · line 380

Quoted 1 line
lib/gro/rte_gro.c +1 -0
+			if (ip4h->next_proto_id == IPPROTO_UDP &&

do_udp4_gro) {

lib/gro/rte_gro.c rte_gro_reassemble(struct rte_mbuf **pkts,

Quoted 3 lines
lib/gro/rte_gro.c +3 -0
+				if (gro_udp4_reassemble(pkts[i], udp_tbl,
+						current_time) < 0)
+					unprocess_pkts[unprocess_num++] =

pkts[i];

lib/gro/rte_gro.c rte_gro_reassemble(struct rte_mbuf **pkts, · line 384

Quoted 1 line
lib/gro/rte_gro.c +1 -0
+			} else if (ip4h->next_proto_id == IPPROTO_TCP &&

do_tcp4_gro) {

lib/gro/rte_gro.c rte_gro_reassemble(struct rte_mbuf **pkts,

Quoted 3 lines
lib/gro/rte_gro.c +3 -0
+				if (gro_tcp4_reassemble(pkts[i], tcp_tbl,
+						current_time) < 0)
+					unprocess_pkts[unprocess_num++] =

pkts[i];

Quoted 8 lines
lib/gro/rte_gro.c +4 -0
+			} 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)
#6 lore raw

RE: [PATCH v4] gro: bug fix in identifying fragmented packets

In reply to Kumara Parameshwaran

Hi Kumara,

Quoted 8 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Wednesday, June 8, 2022 5:57 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; [email protected]
Subject: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 7 lines

From: Kumara Parameshwaran <[email protected]>

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

A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))" in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments in TCP based GRO functions. For example:

#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
	((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

Thanks,
Jiayu

Quoted 105 lines

header should be parsed to recognize the appropriate IP type and invoke the respective gro handler.

Fixes 1ca5e6740852 ("gro: support UDP/IPv4")

---
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,v4:
* Fix extra whitespace and column limit warnings

 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)  lib/gro/rte_gro.c | 43
+++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
lib/gro/rte_gro.c index renamed from lib/gro/rte_gro.c +0 -0

6f7dd4d709..83d6e21dbb 100644

lib/gro/rte_gro.c +3 -0
@@ -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)
 && \
lib/gro/rte_gro.c +4 -1
 		((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);
lib/gro/rte_gro.c +1 -0
+			if (ip4h->next_proto_id == IPPROTO_UDP &&

do_udp4_gro) {

lib/gro/rte_gro.c +6 -0
+				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];

lib/gro/rte_gro.c +1 -0
+			} else if (ip4h->next_proto_id == IPPROTO_TCP &&

do_tcp4_gro) {

lib/gro/rte_gro.c +6 -0
+				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];

lib/gro/rte_gro.c +12 -1
+			} 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];

lib/gro/rte_gro.c +1 -0
+			} else if (ip4h->next_proto_id == IPPROTO_TCP &&

do_tcp4_gro) {

lib/gro/rte_gro.c +3 -0
+				if (gro_tcp4_reassemble(pkts[i], tcp_tbl,
+						current_time) < 0)
+					unprocess_pkts[unprocess_num++] =

pkts[i];

lib/gro/rte_gro.c +4 -1
+			} 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

#7 lore raw

Re: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 8 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Wednesday, June 8, 2022 5:57 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; [email protected]
Subject: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 7 lines

From: Kumara Parameshwaran <[email protected]>

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

A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) !=

Quoted 8 lines

RTE_PTYPE_L4_FRAG))"
in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments
in TCP based GRO functions. For example:

#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

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?

Quoted 140 lines · Jiayu

Hi Kumara,

Quoted 8 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Wednesday, June 8, 2022 5:57 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; [email protected]
Subject: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 7 lines

From: Kumara Parameshwaran <[email protected]>

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

A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))"
in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments
in TCP based GRO functions. For example:

#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

Thanks,
Jiayu

Quoted 1 line

header should be parsed to recognize the appropriate IP type and invoke

the

Quoted 95 lines

respective gro handler.

Fixes 1ca5e6740852 ("gro: support UDP/IPv4")

---
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,v4:
* Fix extra whitespace and column limit warnings

 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)  lib/gro/rte_gro.c | 43
+++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
lib/gro/rte_gro.c index renamed from lib/gro/rte_gro.c +0 -0

6f7dd4d709..83d6e21dbb 100644

lib/gro/rte_gro.c +3 -0
@@ -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. */

lib/gro/rte_gro.c +3 -1
-             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,

lib/gro/rte_gro.c +2 -0
+
                                      sizeof(*ip4h), &ip4h_copy);
+                     if (ip4h->next_proto_id == IPPROTO_UDP &&

do_udp4_gro) {

lib/gro/rte_gro.c +6 -0
+                             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) {

lib/gro/rte_gro.c +6 -0
+                             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];

lib/gro/rte_gro.c +12 -1
+                     } 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) {

lib/gro/rte_gro.c +3 -0
+                             if (gro_tcp4_reassemble(pkts[i], tcp_tbl,
+                                             current_time) < 0)
+                                     unprocess_pkts[unprocess_num++] =

pkts[i];

lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts,

Quoted 6 lines
lib/gro/rte_gro.c +4 -0
+                     } 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,

Quoted 3 lines
                                              current_time) < 0)

--
2.25.1

#8 lore raw

RE: [PATCH v4] gro: bug fix in identifying fragmented packets

Hi Kumara,

IMO, TCP GSO will not use the flag. UDP GSO is the same as IP fragmentation, and UDP fragments are treated as IP fragments. Except the first fragment, the following fragments don’t have L4 header. RTE_PTYPE_L4_FRAG is set to recognize them as IP fragments fast.

TCP GSO is different with IP fragmentation. All TCP segments have complete l2/l3/l4 headers. TCP GSO doesn’t use MF flag and offset field in IP header but use sequence number to reassemble.

The case you mentioned below is IP fragmentation, not UDP GSO or TCP GSO.

Thanks,
Jiayu
From: kumaraparameshwaran rathinavel <[email protected]>
Sent: Friday, June 17, 2022 7:34 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 8 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]<mailto:[email protected]>>
Sent: Wednesday, June 8, 2022 5:57 PM
To: Hu, Jiayu <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; Kumara Parameshwaran <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Subject: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 7 lines

From: Kumara Parameshwaran <[email protected]<mailto:[email protected]>>

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

A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))" in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments in TCP based GRO functions. For example:

#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

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?

On Sun, Jun 12, 2022 at 10:50 AM Hu, Jiayu <[email protected]<mailto:[email protected]>> wrote:
Hi Kumara,

Quoted 8 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]<mailto:[email protected]>>
Sent: Wednesday, June 8, 2022 5:57 PM
To: Hu, Jiayu <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]>; Kumara Parameshwaran <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Subject: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 7 lines

From: Kumara Parameshwaran <[email protected]<mailto:[email protected]>>

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

A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))" in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments in TCP based GRO functions. For example:

#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

Thanks,
Jiayu

Quoted 105 lines

header should be parsed to recognize the appropriate IP type and invoke the respective gro handler.

Fixes 1ca5e6740852 ("gro: support UDP/IPv4")

---
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,v4:
* Fix extra whitespace and column limit warnings

 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)  lib/gro/rte_gro.c | 43
+++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
lib/gro/rte_gro.c index renamed from lib/gro/rte_gro.c +0 -0

6f7dd4d709..83d6e21dbb 100644

lib/gro/rte_gro.c +3 -0
@@ -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. */

lib/gro/rte_gro.c +3 -1
-             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,

lib/gro/rte_gro.c +2 -0
+
                                      sizeof(*ip4h), &ip4h_copy);
+                     if (ip4h->next_proto_id == IPPROTO_UDP &&

do_udp4_gro) {

lib/gro/rte_gro.c +6 -0
+                             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) {

lib/gro/rte_gro.c +6 -0
+                             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];

lib/gro/rte_gro.c +12 -1
+                     } 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) {

lib/gro/rte_gro.c +3 -0
+                             if (gro_tcp4_reassemble(pkts[i], tcp_tbl,
+                                             current_time) < 0)
+                                     unprocess_pkts[unprocess_num++] =

pkts[i];

lib/gro/rte_gro.c +4 -1
+                     } 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

#9 lore raw

Re: [PATCH v4] gro: bug fix in identifying fragmented packets

Thanks Jiyau for the detailed explanation. I will make the changes as per your comments.

Thanks,
Kumara

Quoted 220 lines · Jiayu

Hi Kumara,

IMO, TCP GSO will not use the flag. UDP GSO is the same as IP fragmentation,

and UDP fragments are treated as IP fragments. Except the first fragment, the

following fragments don’t have L4 header. RTE_PTYPE_L4_FRAG is set to

recognize them as IP fragments fast.

TCP GSO is different with IP fragmentation. All TCP segments have complete

l2/l3/l4 headers. TCP GSO doesn’t use MF flag and offset field in IP header but use

sequence number to reassemble.

The case you mentioned below is IP fragmentation, not UDP GSO or TCP GSO.

Thanks,

Jiayu

*From:* kumaraparameshwaran rathinavel <[email protected]> *Sent:* Friday, June 17, 2022 7:34 PM
*To:* Hu, Jiayu <[email protected]>
*Cc:* [email protected]; [email protected]
*Subject:* Re: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 8 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Wednesday, June 8, 2022 5:57 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; [email protected]
Subject: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 7 lines

From: Kumara Parameshwaran <[email protected]>

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

A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))"
in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments
in TCP based GRO functions. For example:

#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

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?

On Sun, Jun 12, 2022 at 10:50 AM Hu, Jiayu <[email protected]> wrote:

Hi Kumara,

Quoted 8 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Wednesday, June 8, 2022 5:57 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; [email protected]
Subject: [PATCH v4] gro: bug fix in identifying fragmented packets

Quoted 7 lines

From: Kumara Parameshwaran <[email protected]>

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

A simpler way is to add a "((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG))"
in IS_IPV4_VXLAN_TCP4_PKT and IS_IPV4_TCP_PKT to avoid processing IP fragments
in TCP based GRO functions. For example:

#define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
                ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
        ((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
                (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

Thanks,
Jiayu

Quoted 1 line

header should be parsed to recognize the appropriate IP type and invoke

the

Quoted 95 lines

respective gro handler.

Fixes 1ca5e6740852 ("gro: support UDP/IPv4")

---
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,v4:
* Fix extra whitespace and column limit warnings

 lib/gro/rte_gro.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)  lib/gro/rte_gro.c | 43
+++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
lib/gro/rte_gro.c index renamed from lib/gro/rte_gro.c +0 -0

6f7dd4d709..83d6e21dbb 100644

lib/gro/rte_gro.c +3 -0
@@ -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. */

lib/gro/rte_gro.c +3 -1
-             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,

lib/gro/rte_gro.c +2 -0
+
                                      sizeof(*ip4h), &ip4h_copy);
+                     if (ip4h->next_proto_id == IPPROTO_UDP &&

do_udp4_gro) {

lib/gro/rte_gro.c +6 -0
+                             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) {

lib/gro/rte_gro.c +6 -0
+                             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];

lib/gro/rte_gro.c +12 -1
+                     } 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) {

lib/gro/rte_gro.c +3 -0
+                             if (gro_tcp4_reassemble(pkts[i], tcp_tbl,
+                                             current_time) < 0)
+                                     unprocess_pkts[unprocess_num++] =

pkts[i];

lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts,

Quoted 6 lines
lib/gro/rte_gro.c +4 -0
+                     } 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,

Quoted 3 lines
                                              current_time) < 0)

--
2.25.1

#10 lore raw

PATCH v5 1/1 gro: bug fix in identifying fragmented packets

In reply to Kumara Parameshwaran

From: Kumara Parameshwaran <[email protected]>

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")

---
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,v4:
* Fix extra whitespace and column limit warnings
v5
* Use RTE_PTYPE_L4_FRAG to identify the fragmented packets in IS_IPV4_TCP_PKT and IS_IPV4_VXLAN_TCP4_PKT

 lib/gro/rte_gro.c | 2 ++
 1 file changed, 2 insertions(+)
lib/gro/rte_gro.c +2 -0
index 6f7dd4d709..e35399fd42 100644
@@ -32,6 +32,7 @@ static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
 
 #define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
 		((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
+		((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
 		(RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))
 
 #define IS_IPV4_UDP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
@@ -40,6 +41,7 @@ static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
 
 #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_L4_FRAG) != RTE_PTYPE_L4_FRAG) && \
 		((ptype & RTE_PTYPE_TUNNEL_VXLAN) == \
 		 RTE_PTYPE_TUNNEL_VXLAN) && \
 		((ptype & RTE_PTYPE_INNER_L4_TCP) == \
Signature · 1 line
2.25.1
Reviewed-by on v5 1/1
#11 lore raw

RE: [PATCH v5] gro: bug fix in identifying fragmented packets

Thanks,
Jiayu

Quoted 63 lines

-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Monday, June 27, 2022 6:31 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; [email protected]
Subject: [PATCH v5] gro: bug fix in identifying fragmented packets

From: Kumara Parameshwaran <[email protected]>

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")

---
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,v4:
* Fix extra whitespace and column limit warnings
v5
* Use RTE_PTYPE_L4_FRAG to identify the fragmented packets in IS_IPV4_TCP_PKT and IS_IPV4_VXLAN_TCP4_PKT

 lib/gro/rte_gro.c | 2 ++
 1 file changed, 2 insertions(+)
lib/gro/rte_gro.c index renamed from lib/gro/rte_gro.c +0 -0

6f7dd4d709..e35399fd42 100644

lib/gro/rte_gro.c +1 -0
@@ -32,6 +32,7 @@ static gro_tbl_pkt_count_fn
 tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
 
 #define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
 		((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP) && \
+		((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) &&
 \
 		(RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))

#define IS_IPV4_UDP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \ @@ -
40,6 +41,7 @@ static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {

#define IS_IPV4_VXLAN_TCP4_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype)
&& \

lib/gro/rte_gro.c +1 -0
 		((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP) && \
+		((ptype & RTE_PTYPE_L4_FRAG) != RTE_PTYPE_L4_FRAG) &&

\

lib/gro/rte_gro.c +0 -1
 		((ptype & RTE_PTYPE_TUNNEL_VXLAN) == \
 		 RTE_PTYPE_TUNNEL_VXLAN) && \
 		((ptype & RTE_PTYPE_INNER_L4_TCP) == \
--

2.25.1

#12 lore raw

Re: [PATCH v5] gro: bug fix in identifying fragmented packets

Quoted 10 lines
Quoted 10 lines

From: Kumara Parameshwaran <[email protected]>

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.

Quoted 5 lines
Quoted 3 lines
Fixes 1ca5e6740852 ("gro: support UDP/IPv4")

Applied, thanks.