gro : fix reordering of packets in GRO library
PATCH 1/1 gro : fix reordering of packets in GRO library
From: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets upto the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there are no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment.
This is the behaviour with linux stack as well
---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modifited to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
lib/gro/gro_tcp4.c | 35 ++++++++++++++++++++++++++++------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 37 insertions(+), 16 deletions(-)
lib/gro/gro_tcp4.c +28 -7
@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; +} + int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,
@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater
@@ -219,12 +233,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ;/* * Don't process the packet whose payload length is less than or * equal to 0.
@@ -263,12 +271,21 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--; } } +if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) { +if (find) +/* Since PSH flag is set, start time will be set to 0 so it will be flushed immediately */ + tbl->items[start_idx].start_time =0 ; +else +return -1 ; + } +/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow.
@@ -303,8 +320,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, ip_id,0 )) { +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl->items[cur_idx].firstseg);return 1 ; + } +/* * Fail to merge the two packets, as the packet * length is greater than the max value. Store
lib/gro/rte_gro.c +9 -9
@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, -0 , pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, +0 , &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {
@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro;
Signature · 1 line
2.25.1
Please find the attached pcap files for the testing done.
Thanks,
Kumara.
Quoted 183 lines · Kumara Parameshwaran
From: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets upto the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there are
no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment. This is the behaviour with linux stack as wellSigned-off-by Kumara Parameshwaran <[email protected]>---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst
mode,
P1 contains PSH flag and since it does not contain any prior packets
in the flow
we copy it tounprocess_packetsand P2(ACK) and P3(ACK) are merged
together.
In the existing case the P2,P3 would be delivered as single segment
first and the
unprocess_packetswill be copied later which will cause reordering.
With the patch
copy the unprocess packets first and then the packets from the GRO
table.Testing done
The csum test-pmd was modifited to support the following GET request of 10MB from client to server via test-pmd (static arp
entries added in client
and server). Enable GRO and TSO in test-pmd where the packets recived
from the client mac
would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering
of 25 packets
and with the patch there were no packet re-ordering observerd.lib/gro/gro_tcp4.c | 35 ++++++++++++++++++++++++++++------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 37 insertions(+), 16 deletions(-)lib/gro/gro_tcp4.c +13
-0@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; +} + int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt,struct
gro_tcp4_tbl*tbl,lib/gro/gro_tcp4.c +5
-6@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater @@ -219,12 +233,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ;/* * Don't process the packet whose payload length is less than or * equal to 0. @@ -263,12 +271,21 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--; } } +if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) { +if (find) +/* Since PSH flag is set, start time will be set to 0 so it will be flushed immediately */
lib/gro/gro_tcp4.c +10
-1+ tbl->items[start_idx].start_time =0 ; + else + return -1; + } +/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow. @@ -303,8 +320,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, ip_id, 0)) { +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl->items[cur_idx].firstseg);return 1 ; + } +/*
* Fail to merge the two packets, as the packet
* length is greater than the max value. Storelib/gro/rte_gro.c +9
-2@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, -0 , pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, + 0, &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {lib/gro/rte_gro.c +0
-8@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro; --2.25.1
PATCH v2 1/1 gro : fix reordering of packets in GRO library
In reply to Kumara ParameshwaranFrom: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets up to the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there are no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment. This is the behaviour with linux stack as well.
---
v1:
If the received packet is not a pure ACK packet, we check if
there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modifited to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
* Fix warnings in commit and comment
* Do not consider packet as candidate to merge if it contains SYN/RST flag
lib/gro/gro_tcp4.c | 43 ++++++++++++++++++++++++++++++++++++------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 45 insertions(+), 16 deletions(-)
lib/gro/gro_tcp4.c +36 -7
@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; +} + int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,
@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater
@@ -219,12 +233,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ;/* * Don't process the packet whose payload length is less than or * equal to 0.
@@ -263,12 +271,29 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--; } } +if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) { +/* +* Check and try merging the current TCP segment with the previous +* TCP segment if the TCP header does not contain RST and SYN flag +* There are cases where the last segment is sent with FIN|PSH|ACK +* which should also be considered for merging with previous segments. +*/ +if (find && !(tcp_hdr->tcp_flags & (RTE_TCP_RST_FLAG |RTE_TCP_SYN_FLAG ))) +/* +* Since PSH flag is set, start time will be set to 0 so it will be flushed immediately +*/ + tbl->items[start_idx].start_time =0 ; +else +return -1 ; + } +/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow.
@@ -303,8 +328,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, ip_id,0 )) { +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl->items[cur_idx].firstseg);return 1 ; + } +/* * Fail to merge the two packets, as the packet * length is greater than the max value. Store
lib/gro/rte_gro.c +9 -9
@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, -0 , pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, +0 , &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {
@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro;
Signature · 1 line
2.25.1
PATCH v3 1/1 gro : fix reordering of packets in GRO library
In reply to Kumara ParameshwaranFrom: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets up to the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there are no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment. This is the behaviour with linux stack as well.
---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modifited to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
lib/gro/gro_tcp4.c | 44 +++++++++++++++++++++++++++++++++++++------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 46 insertions(+), 16 deletions(-)
lib/gro/gro_tcp4.c +37 -7
@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; +} + int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,
@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater
@@ -219,12 +233,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ;/* * Don't process the packet whose payload length is less than or * equal to 0.
@@ -263,12 +271,30 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--; } } +if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) { +/* +* Check and try merging the current TCP segment with the previous +* TCP segment if the TCP header does not contain RST and SYN flag +* There are cases where the last segment is sent with FIN|PSH|ACK +* which should also be considered for merging with previous segments. +*/ +if (find && !(tcp_hdr->tcp_flags & (RTE_TCP_RST_FLAG |RTE_TCP_SYN_FLAG ))) +/* +* Since PSH flag is set, start time will be set to 0 so it will be flushed +* immediately. +*/ + tbl->items[start_idx].start_time =0 ; +else +return -1 ; + } +/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow.
@@ -303,8 +329,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, ip_id,0 )) { +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl->items[cur_idx].firstseg);return 1 ; + } +/* * Fail to merge the two packets, as the packet * length is greater than the max value. Store
lib/gro/rte_gro.c +9 -9
@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, -0 , pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, +0 , &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {
@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro;
Signature · 1 line
2.25.1
PATCH v4 1/1 gro : fix reordering of packets in GRO library
In reply to Kumara ParameshwaranFrom: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets up to the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there are no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment. This is the behaviour with linux stack as well.
---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modifited to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
lib/gro/gro_tcp4.c | 45 +++++++++++++++++++++++++++++++++++++-------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 46 insertions(+), 17 deletions(-)
lib/gro/gro_tcp4.c +37 -8
@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; +} + int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,
@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater
@@ -219,13 +233,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ; -/* trim the tail padding bytes */ ip_tlen =rte_be_to_cpu_16 (ipv4_hdr->total_length);if (pkt->pkt_len > (uint32_t )(ip_tlen + pkt->l2_len))
@@ -264,12 +271,30 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--; } } +if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) { +/* +* Check and try merging the current TCP segment with the previous +* TCP segment if the TCP header does not contain RST and SYN flag +* There are cases where the last segment is sent with FIN|PSH|ACK +* which should also be considered for merging with previous segments. +*/ +if (find && !(tcp_hdr->tcp_flags & (RTE_TCP_RST_FLAG |RTE_TCP_SYN_FLAG ))) +/* +* Since PSH flag is set, start time will be set to 0 so it will be flushed +* immediately. +*/ + tbl->items[start_idx].start_time =0 ; +else +return -1 ; + } +/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow.
@@ -304,8 +329,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, ip_id,0 )) { +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl->items[cur_idx].firstseg);return 1 ; + } +/* * Fail to merge the two packets, as the packet * length is greater than the max value. Store
lib/gro/rte_gro.c +9 -9
@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, -0 , pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, +0 , &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {
@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro;
Signature · 1 line
2.25.1
PATCH v5 1/1 gro : fix reordering of packets in GRO library
From: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets up to the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there are no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment. This is the behaviour with linux stack as well.
---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modifited to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
lib/gro/gro_tcp4.c | 45 +++++++++++++++++++++++++++++++++++++-------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 46 insertions(+), 17 deletions(-)
lib/gro/gro_tcp4.c +37 -8
@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; +} + int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,
@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater
@@ -219,13 +233,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ; -/* trim the tail padding bytes */ ip_tlen =rte_be_to_cpu_16 (ipv4_hdr->total_length);if (pkt->pkt_len > (uint32_t )(ip_tlen + pkt->l2_len))
@@ -264,12 +271,30 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--; } } +if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) { +/* +* Check and try merging the current TCP segment with the previous +* TCP segment if the TCP header does not contain RST and SYN flag +* There are cases where the last segment is sent with FIN|PSH|ACK +* which should also be considered for merging with previous segments. +*/ +if (find && !(tcp_hdr->tcp_flags & (RTE_TCP_RST_FLAG |RTE_TCP_SYN_FLAG ))) +/* +* Since PSH flag is set, start time will be set to 0 so it will be flushed +* immediately. +*/ + tbl->items[start_idx].start_time =0 ; +else +return -1 ; + } +/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow.
@@ -304,8 +329,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, ip_id,0 )) { +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl->items[cur_idx].firstseg);return 1 ; + } +/* * Fail to merge the two packets, as the packet * length is greater than the max value. Store
lib/gro/rte_gro.c +9 -9
@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, -0 , pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, +0 , &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {
@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro;
Signature · 1 line
2.25.1
01/11/2022 08:05, Kumara Parameshwaran:
Quoted 9 lines
From: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets up to the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
Quoted 8 lines
With this patch, if a packet does not contain only ACK flag and if there are no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment. This is the behaviour with linux stack as well.
Signed-off-by Kumara Parameshwaran <[email protected]>Co-authored-by Kumara Parameshwaran <[email protected]>
This is yourself, right?
Please choose one email address and use it in your git config.
Jiayu, any comment about the patch content?
Hi Kumara,
Please see replies inline.
Thanks,
Jiayu
Quoted 85 lines
-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Tuesday, November 1, 2022 3:06 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; Kumara Parameshwaran <[email protected]>
Subject: [PATCH v5] gro : fix reordering of packets in GRO libraryFrom: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to the application though there might be packets of the same flow in the GRO table. If PSH flag is set on a segment packets up to the segment should be delivered immediately. But the current implementation delivers the last arrived packet with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there are no previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment.
This is the behaviour with linux stack as well.Signed-off-by Kumara Parameshwaran <[email protected]>Co-authored-by Kumara Parameshwaran <[email protected]>---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in
burst mode,
P1 contains PSH flag and since it does not contain any prior packets in
the flow
we copy it tounprocess_packetsand P2(ACK) and P3(ACK) are
merged together.
In the existing case the P2,P3 would be delivered as single segment
first and the
unprocess_packetswill be copied later which will cause reordering.
With the patch
copy the unprocess packets first and then the packets from the GRO
table.Testing done
The csum test-pmd was modifited to support the following GET request of 10MB from client to server via test-pmd (static arp
entries added in client
and server). Enable GRO and TSO in test-pmd where the packets
recived from the client mac
would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering
of 25 packets
and with the patch there were no packet re-ordering observerd.v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST
flag.v3:
Fix warnings.v4:
Rebase with master.v5:
Adding co-author emaillib/gro/gro_tcp4.c | 45 +++++++++++++++++++++++++++++++++++++-------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 46 insertions(+), 17 deletions(-)lib/gro/gro_tcp4.c index renamed from lib/gro/gro_tcp4.c +0
-0
0014096e63..7363c5d540100644lib/gro/gro_tcp4.c +2
-0@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt)
lib/gro/gro_tcp4.c update_header(struct gro_tcp4_item *item) · line 202
Quoted 10 lines
lib/gro/gro_tcp4.c +9
-0+{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt- >l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; }
The Linux kernel updates the TCP flag via "tcp_flag_word(th2) |= flags & (TCP_FLAG_FIN | TCP_FLAG_PSH)", which only adds FIN and PSH at most to the merge packet.
Quoted 53 lines
lib/gro/gro_tcp4.c +2
-0+ int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater @@ - 219,13 +233,6 @@ gro_tcp4_reassemble(struct
rte_mbuf*pkt,lib/gro/gro_tcp4.c +5
-7tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ; -/* trim the tail padding bytes */ ip_tlen =rte_be_to_cpu_16 (ipv4_hdr->total_length); if (pkt->pkt_len > (uint32_t)(ip_tlen + pkt->l2_len)) @@ -264,12 +271,30 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, if (tbl->flows[i].start_index != INVALID_ARRAY_INDEX) { if (is_same_tcp4_flow(tbl->flows[i].key, key)) { find = 1; + start_idx = tbl->flows[i].start_index; break; } remaining_flow_num--; } } + if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) { +/* +* Check and try merging the current TCP segment with the previous
lib/gro/gro_tcp4.c +1
-0+* TCP segment if the TCP header does not contain RST and SYN flag
lib/gro/gro_tcp4.c +1
-0+* There are cases where the last segment is sent with FIN|PSH|ACK
lib/gro/gro_tcp4.c +1
-0+* which should also be considered for merging with previous segments.
lib/gro/gro_tcp4.c +2
-0+*/ + if (find && !(tcp_hdr->tcp_flags &(RTE_TCP_RST_FLAG|RTE_TCP_SYN_FLAG)))
lib/gro/gro_tcp4.c +2
-0+/* +* Since PSH flag is set, start time will be set to 0 so it will be flushed
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 296
Quoted 6 lines
lib/gro/gro_tcp4.c +6
-0+* immediately. +*/ + tbl->items[start_idx].start_time =0 ; + else + return -1; + }
The nested if-else check is not straightforward, and it's hard to read the condition-action of different combinations of flag bits. In addition, are all flag bits considered like Linux kernel?
Quoted 25 lines
lib/gro/gro_tcp4.c +6
-1+/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow. @@ -304,8 +329,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, ip_id,0 )) { +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl- >items[cur_idx].firstseg);return 1 ; + } +/* lib/gro/gro_tcp4.c +0
-0* Fail to merge the two packets, as the packet * length is greater than the max value. Store diff --git
a/lib/gro/rte_gro.cb/lib/gro/rte_gro.cindexe35399fd42..87c5502dce100644
lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts, · line 292
Quoted 10 lines
lib/gro/rte_gro.c +7
-0@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }
Why copy unprocess pkts first? This is for avoiding out-of-order?
Thanks,
Jiayu
Quoted 26 lines
lib/gro/rte_gro.c +2
-2/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, -0 , pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, +0 , &pkts[i], nb_pkts - i); }lib/gro/rte_gro.c +0
-8if (do_vxlan_udp_gro) {@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro; --2.25.1
Hi Jiayu,
Thanks for the comments. I have replied inline below. Will address the review comments, but I think this would be a good patch to have in general. Please let me know your thoughts.
Quoted 263 lines · Jiayu
Hi Kumara,
Please see replies inline.
Thanks,
JiayuQuoted 9 lines
-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Tuesday, November 1, 2022 3:06 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; Kumara Parameshwaran <[email protected]>
Subject: [PATCH v5] gro : fix reordering of packets in GRO libraryQuoted 3 lines
From: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to
the
Quoted 1 line
application though there might be packets of the same flow in the GRO
table.
Quoted 1 line
If PSH flag is set on a segment packets up to the segment should be
delivered
Quoted 1 line
immediately. But the current implementation delivers the last arrived
packet
Quoted 3 lines
with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there
are no
Quoted 5 lines
previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment.
This is the behaviour with linux stack as well.Quoted 7 lines
Signed-off-by Kumara Parameshwaran <[email protected]>Co-authored-by Kumara Parameshwaran <[email protected]>---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update theflags
Quoted 6 lines
of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in
burst mode,
P1 contains PSH flag and since it does not contain any priorpackets in
Quoted 4 lines
the flow
we copy it tounprocess_packetsand P2(ACK) and P3(ACK) are
merged together.
In the existing case the P2,P3 would be delivered as singlesegment
Quoted 6 lines
first and the
unprocess_packetswill be copied later which will cause reordering.
With the patch
copy the unprocess packets first and then the packets from the GRO
table.Quoted 8 lines
Testing done
The csum test-pmd was modifited to support the following GET request of 10MB from client to server via test-pmd (static arp
entries added in client
and server). Enable GRO and TSO in test-pmd where the packets
recived from the client mac
would be sent to server mac and vice versa.
In above testing, without the patch the client observerdre-ordering
Quoted 31 lines
of 25 packets
and with the patch there were no packet re-ordering observerd.v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST
flag.v3:
Fix warnings.v4:
Rebase with master.v5:
Adding co-author emaillib/gro/gro_tcp4.c | 45 +++++++++++++++++++++++++++++++++++++-------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 46 insertions(+), 17 deletions(-)lib/gro/gro_tcp4.c index renamed from lib/gro/gro_tcp4.c +0
-0
0014096e63..7363c5d540100644lib/gro/gro_tcp4.c +2
-0@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt)lib/gro/gro_tcp4.c update_header(struct gro_tcp4_item *item) · line 202
Quoted 10 lines
lib/gro/gro_tcp4.c +9
-0+{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt- >l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; }The Linux kernel updates the TCP flag via "
tcp_flag_word(th2)|= flags & (TCP_FLAG_FIN|TCP_FLAG_PSH)",
which only adds FIN and PSH at most to the merge packet.Quoted 43 lines
Sure, will change it to add only FIN and PSH.
lib/gro/gro_tcp4.c +2
-0+ int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater @@ - 219,13 +233,6 @@ gro_tcp4_reassemble(struct
rte_mbuf*pkt,tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len;lib/gro/gro_tcp4.c +5
-7-/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ; -/* trim the tail padding bytes */ ip_tlen =rte_be_to_cpu_16 (ipv4_hdr->total_length); if (pkt->pkt_len > (uint32_t)(ip_tlen + pkt->l2_len)) @@ -264,12 +271,30 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, if (tbl->flows[i].start_index != INVALID_ARRAY_INDEX) { if (is_same_tcp4_flow(tbl->flows[i].key, key)) { find = 1; + start_idx = tbl->flows[i].start_index; break; } remaining_flow_num--; } } + if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) { +/* +* Check and try merging the current TCP segment with the Quoted 6 lines
previous
+ * TCP segment if the TCP header does not contain RST and
SYN flag
+ * There are cases where the last segment is sent with
FIN|PSH|ACK
+ * which should also be considered for merging withprevious
lib/gro/gro_tcp4.c
Quoted 6 lines
segments.
lib/gro/gro_tcp4.c +2
-0+*/ + if (find && !(tcp_hdr->tcp_flags &(RTE_TCP_RST_FLAG|RTE_TCP_SYN_FLAG)))
lib/gro/gro_tcp4.c +2
-0+/* +* Since PSH flag is set, start time will be set to 0 so it
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 296
Quoted 7 lines
will be flushed
lib/gro/gro_tcp4.c +6
-0+* immediately. +*/ + tbl->items[start_idx].start_time =0 ; + else + return -1; + }The nested if-else check is not straightforward, and it's hard to read the condition-action of
different combinations of flag bits. In addition, are all flag bits considered like Linux kernel?Quoted 10 lines
Not all bits are considered. Will fix to make sure that all bits are considered. Will try to reorganise the code better. Let me know if you have any other suggestions here.
lib/gro/gro_tcp4.c +1
-0+/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow. lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 307
Quoted 4 lines
lib/gro/gro_tcp4.c +0
-1@@ -304,8 +329,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) { if (merge_two_tcp4_packets(&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0))
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 332
Quoted 1 line
lib/gro/gro_tcp4.c +1
-0+ pkt, cmp, sent_seq, ip_id,0))
Quoted 10 lines
lib/gro/gro_tcp4.c +4
-0{ +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl- >items[cur_idx].firstseg);return 1 ; + } +/* * Fail to merge the two packets, as the packet
* length is greater than the max value. Storediff --git
Quoted 5 lines
a/lib/gro/rte_gro.cb/lib/gro/rte_gro.cindexe35399fd42..87c5502dce100644lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts, · line 292
Quoted 10 lines
lib/gro/rte_gro.c +7
-0@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }Why copy unprocess pkts first? This is for avoiding out-of-order?
Thanks,
Jiayulib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts,
Quoted 3 lines
lib/gro/rte_gro.c +0
-1/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { - i =gro_vxlan_tcp4_tbl_timeout_flush(&vxlan_tcp_tbl,
Quoted 23 lines
lib/gro/rte_gro.c +2
-1- 0, pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush (&vxlan_tcp_tbl, +0 , &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {lib/gro/rte_gro.c +0
-8@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro; --2.25.1
Quoted 272 lines · Jiayu
Hi Kumara,
Please see replies inline.
Thanks,
JiayuQuoted 9 lines
-----Original Message-----
From: Kumara Parameshwaran <[email protected]>
Sent: Tuesday, November 1, 2022 3:06 PM
To: Hu, Jiayu <[email protected]>
Cc: [email protected]; Kumara Parameshwaran <[email protected]>; Kumara Parameshwaran <[email protected]>
Subject: [PATCH v5] gro : fix reordering of packets in GRO libraryQuoted 3 lines
From: Kumara Parameshwaran <[email protected]>
When a TCP packet contains flags like PSH it is returned immediately to
the
Quoted 1 line
application though there might be packets of the same flow in the GRO
table.
Quoted 1 line
If PSH flag is set on a segment packets up to the segment should be
delivered
Quoted 1 line
immediately. But the current implementation delivers the last arrived
packet
Quoted 3 lines
with PSH flag set causing re-ordering
With this patch, if a packet does not contain only ACK flag and if there
are no
Quoted 5 lines
previous packets for the flow the packet would be returned immediately, else will be merged with the previous segment and the flag on the last segment will be set on the entire segment.
This is the behaviour with linux stack as well.Quoted 7 lines
Signed-off-by Kumara Parameshwaran <[email protected]>Co-authored-by Kumara Parameshwaran <[email protected]>---
v1:
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update theflags
Quoted 6 lines
of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in
burst mode,
P1 contains PSH flag and since it does not contain any priorpackets in
Quoted 4 lines
the flow
we copy it tounprocess_packetsand P2(ACK) and P3(ACK) are
merged together.
In the existing case the P2,P3 would be delivered as singlesegment
Quoted 6 lines
first and the
unprocess_packetswill be copied later which will cause reordering.
With the patch
copy the unprocess packets first and then the packets from the GRO
table.Quoted 8 lines
Testing done
The csum test-pmd was modifited to support the following GET request of 10MB from client to server via test-pmd (static arp
entries added in client
and server). Enable GRO and TSO in test-pmd where the packets
recived from the client mac
would be sent to server mac and vice versa.
In above testing, without the patch the client observerdre-ordering
Quoted 31 lines
of 25 packets
and with the patch there were no packet re-ordering observerd.v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST
flag.v3:
Fix warnings.v4:
Rebase with master.v5:
Adding co-author emaillib/gro/gro_tcp4.c | 45 +++++++++++++++++++++++++++++++++++++-------- lib/gro/rte_gro.c | 18 +++++++++--------- 2 files changed, 46 insertions(+), 17 deletions(-)lib/gro/gro_tcp4.c index renamed from lib/gro/gro_tcp4.c +0
-0
0014096e63..7363c5d540100644lib/gro/gro_tcp4.c +2
-0@@ -188,6 +188,19 @@ update_header(struct gro_tcp4_item *item) pkt->l2_len); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt)lib/gro/gro_tcp4.c update_header(struct gro_tcp4_item *item) · line 202
Quoted 10 lines
lib/gro/gro_tcp4.c +9
-0+{ +struct rte_ether_hdr *eth_hdr; +struct rte_ipv4_hdr *ipv4_hdr; +struct rte_tcp_hdr *merged_tcp_hdr; + + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)eth_hdr + pkt->l2_len); + merged_tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt- >l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; }The Linux kernel updates the TCP flag via "
tcp_flag_word(th2)|= flags & (TCP_FLAG_FIN|TCP_FLAG_PSH)",
which only adds FIN and PSH at most to the merge packet.Quoted 40 lines
lib/gro/gro_tcp4.c +2
-0+ int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt, struct gro_tcp4_tbl *tbl,@@ -206,6 +219,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t i, max_flow_num, remaining_flow_num;int cmp;uint8_t find; +uint32_t start_idx;/* * Don't process the packet whose TCP header length is greater @@ - 219,13 +233,6 @@ gro_tcp4_reassemble(struct
rte_mbuf*pkt,tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len;lib/gro/gro_tcp4.c +5
-7-/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ; -/* trim the tail padding bytes */ ip_tlen =rte_be_to_cpu_16 (ipv4_hdr->total_length); if (pkt->pkt_len > (uint32_t)(ip_tlen + pkt->l2_len)) @@ -264,12 +271,30 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, if (tbl->flows[i].start_index != INVALID_ARRAY_INDEX) { if (is_same_tcp4_flow(tbl->flows[i].key, key)) { find = 1; + start_idx = tbl->flows[i].start_index; break; } remaining_flow_num--; } } + if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG) { +/* +* Check and try merging the current TCP segment with the Quoted 6 lines
previous
+ * TCP segment if the TCP header does not contain RST and
SYN flag
+ * There are cases where the last segment is sent with
FIN|PSH|ACK
+ * which should also be considered for merging withprevious
lib/gro/gro_tcp4.c
Quoted 6 lines
segments.
lib/gro/gro_tcp4.c +2
-0+*/ + if (find && !(tcp_hdr->tcp_flags &(RTE_TCP_RST_FLAG|RTE_TCP_SYN_FLAG)))
lib/gro/gro_tcp4.c +2
-0+/* +* Since PSH flag is set, start time will be set to 0 so it
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 296
Quoted 7 lines
will be flushed
lib/gro/gro_tcp4.c +6
-0+* immediately. +*/ + tbl->items[start_idx].start_time =0 ; + else + return -1; + }The nested if-else check is not straightforward, and it's hard to read the condition-action of
different combinations of flag bits. In addition, are all flag bits considered like Linux kernel?Quoted 19 lines
In case of Linux kernel the packets are flushed even if the ack numbers are different or if the tcp options are different. In DPDK case if options are different it is inserted as new item in the table. Is this intended? Should we maintain the same approach ? In case of linux kernel, additional flags like CWR, SYN, RST, URG are considered. I think we can consider them as well as well, and if one these flags we can consider flushing the entire flow. As you mentioned the flags can be updated only for FIN and PSH, but what we shoud make sure is when delivered the packet ordering should be maintained where if a packet with PSH arrives and if there are existing packets in the GRO table make sure we copy the flags and deliver the entire packet in-order. This should be trhe case for any case where a packet with one of the flag is set and there packets in the GRO table. Please let me know your thoughts.
lib/gro/gro_tcp4.c +1
-0+/* * Fail to find a matched flow. Insert a new flow and store the * packet into the flow. lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 307
Quoted 4 lines
lib/gro/gro_tcp4.c +0
-1@@ -304,8 +329,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, is_atomic);if (cmp) { if (merge_two_tcp4_packets(&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, ip_id,0))
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 332
Quoted 1 line
lib/gro/gro_tcp4.c +1
-0+ pkt, cmp, sent_seq, ip_id,0))
Quoted 10 lines
lib/gro/gro_tcp4.c +4
-0{ +if (tbl->items[cur_idx].start_time ==0 ) +update_tcp_hdr_flags (tcp_hdr, tbl- >items[cur_idx].firstseg);return 1 ; + } +/* * Fail to merge the two packets, as the packet
* length is greater than the max value. Storediff --git
Quoted 5 lines
a/lib/gro/rte_gro.cb/lib/gro/rte_gro.cindexe35399fd42..87c5502dce100644lib/gro/rte_gro.c rte_gro_reassemble_burst(struct rte_mbuf **pkts, · line 292
Quoted 10 lines
lib/gro/rte_gro.c +7
-0@@ -283,10 +283,17 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts,if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { i =0 ; +/* Copy unprocessed packets */ +if (unprocess_num >0 ) { +memcpy (&pkts[i], unprocess_pkts, +sizeof (struct rte_mbuf *) * + unprocess_num); + i = unprocess_num; + }Why copy unprocess pkts first? This is for avoiding out-of-order?
Quoted 2 lines
Yes, this it to avoid out of order.
Thanks,
JiayuQuoted 3 lines
/* Flush all packets from the tables */ if (do_vxlan_tcp_gro) {- i =
gro_vxlan_tcp4_tbl_timeout_flush(&vxlan_tcp_tbl,
Quoted 23 lines
lib/gro/rte_gro.c +1
-1- 0, pkts, nb_pkts); + i +=gro_vxlan_tcp4_tbl_timeout_flush(&vxlan_tcp_tbl,
lib/gro/rte_gro.c +1
-8+ 0, &pkts[i], nb_pkts - i); }if (do_vxlan_udp_gro) {@@ -304,13 +311,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, i +=gro_udp4_tbl_timeout_flush (&udp_tbl,0 , &pkts[i], nb_pkts - i); } -/* Copy unprocessed packets */ -if (unprocess_num >0 ) { -memcpy (&pkts[i], unprocess_pkts, -sizeof (struct rte_mbuf *) * - unprocess_num); - } - nb_after_gro = i + unprocess_num; }return nb_after_gro; --2.25.1
PATCH v6 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when packets is received with special flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table beloging to the same flow but not handled.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
lib/gro/gro_tcp.h | 10 +++++++ lib/gro/gro_tcp4.c | 65 +++++++++++++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 24 deletions(-)
lib/gro/gro_tcp.h +10 -0
@@ -187,4 +187,14 @@ is_same_common_tcp_key(struct cmn_tcp_key *k1, struct cmn_tcp_key *k2)return (!memcmp (k1, k2,sizeof (struct cmn_tcp_key ))); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_tcp_hdr *merged_tcp_hdr; + + merged_tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, pkt->l2_len + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; + +} +#endif
lib/gro/gro_tcp4.c +41 -24
94 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when packets is received with special flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table beloging to the same flow but not handled.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
lib/gro/gro_tcp.h | 11 ++++++++ lib/gro/gro_tcp4.c | 65 +++++++++++++++++++++++++++++----------------- 2 files changed, 52 insertions(+), 24 deletions(-)
lib/gro/gro_tcp.h +11 -0
@@ -187,4 +187,15 @@ is_same_common_tcp_key(struct cmn_tcp_key *k1, struct cmn_tcp_key *k2)return (!memcmp (k1, k2,sizeof (struct cmn_tcp_key ))); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_tcp_hdr *merged_tcp_hdr; + + merged_tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, pkt->l2_len + + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; + +} +#endif
lib/gro/gro_tcp4.c +41 -24
94 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v8 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when packets is received with special flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table beloging to the same flow but not handled.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
v7:
Fix warnings and errors
v8:
Fix warnings and errors
lib/gro/gro_tcp.h | 11 ++++++++ lib/gro/gro_tcp4.c | 67 +++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 24 deletions(-)
lib/gro/gro_tcp.h +11 -0
@@ -187,4 +187,15 @@ is_same_common_tcp_key(struct cmn_tcp_key *k1, struct cmn_tcp_key *k2)return (!memcmp (k1, k2,sizeof (struct cmn_tcp_key ))); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_tcp_hdr *merged_tcp_hdr; + + merged_tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, pkt->l2_len + + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; + +} +#endif
lib/gro/gro_tcp4.c +43 -24
96 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v9 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
v7:
Fix warnings and errors
v8:
Fix warnings and errors
v9:
Fix commit message
lib/gro/gro_tcp.h | 11 ++++++++ lib/gro/gro_tcp4.c | 67 +++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 24 deletions(-)
lib/gro/gro_tcp.h +11 -0
@@ -187,4 +187,15 @@ is_same_common_tcp_key(struct cmn_tcp_key *k1, struct cmn_tcp_key *k2)return (!memcmp (k1, k2,sizeof (struct cmn_tcp_key ))); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_tcp_hdr *merged_tcp_hdr; + + merged_tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, pkt->l2_len + + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; + +} +#endif
lib/gro/gro_tcp4.c +43 -24
96 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v9] gro: fix reordering of packets in GRO layer
Quoted 115 lines · Kumara Parameshwaran
In the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implementedSigned-off-by Kumara Parameshwaran<[email protected]>Co-authored-by Kumara Parameshwaran<[email protected]>---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to
unprocess_packetsand P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and theunprocess_packetswill be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.v3:
Fix warnings.v4:
Rebase with master.v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FINv7:
Fix warnings and errorsv8:
Fix warnings and errorsv9:
Fix commit messagelib/gro/gro_tcp.h | 11 ++++++++ lib/gro/gro_tcp4.c | 67 +++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 24 deletions(-)lib/gro/gro_tcp.h +11
-0@@ -187,4 +187,15 @@ is_same_common_tcp_key(struct cmn_tcp_key *k1, struct cmn_tcp_key *k2)return (!memcmp (k1, k2,sizeof (struct cmn_tcp_key ))); } +static inline void +update_tcp_hdr_flags (struct rte_tcp_hdr *tcp_hdr,struct rte_mbuf *pkt) +{ +struct rte_tcp_hdr *merged_tcp_hdr; + + merged_tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, pkt->l2_len + + pkt->l3_len); + merged_tcp_hdr->tcp_flags |= tcp_hdr->tcp_flags; + +} +#endif lib/gro/gro_tcp4.c +2
-7@@ -126,6 +126,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t item_idx;uint32_t i, max_flow_num, remaining_flow_num;uint8_t find; +uint32_t item_start_idx;/* * Don't process the packet whose TCP header length is greater @@ -139,13 +140,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) -return -1 ; -/* trim the tail padding bytes */ ip_tlen =rte_be_to_cpu_16 (ipv4_hdr->total_length);if (pkt->pkt_len > (uint32_t )(ip_tlen + pkt->l2_len))@@ -183,6 +177,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + item_start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--;
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 187
Quoted 3 lines
lib/gro/gro_tcp4.c +0
-0@@ -190,28 +185,52 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, }if (find ==0 ) {
It is more likely to find a match flow. So better to put the below logic to the else statement.
Quoted 20 lines
lib/gro/gro_tcp4.c +14
-6- sent_seq =rte_be_to_cpu_32 (tcp_hdr->sent_seq); - item_idx =insert_new_tcp_item (pkt, tbl->items, &tbl->item_num, - tbl->max_item_num, start_time, -INVALID_ARRAY_INDEX , sent_seq, ip_id, - is_atomic); -if (item_idx ==INVALID_ARRAY_INDEX ) +/* +* Add new flow to the table only if contains ACK flag with data. +* Do not add any packets with additional tcp flags to the GRO table +*/ +if (tcp_hdr->tcp_flags ==RTE_TCP_ACK_FLAG ) { + sent_seq =rte_be_to_cpu_32 (tcp_hdr->sent_seq); + item_idx =insert_new_tcp_item (pkt, tbl->items, &tbl->item_num, + tbl->max_item_num, start_time, +INVALID_ARRAY_INDEX , sent_seq, ip_id, + is_atomic); +if (item_idx ==INVALID_ARRAY_INDEX ) +return -1 ; +if (insert_new_flow (tbl, &key, item_idx) == +INVALID_ARRAY_INDEX ) {
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 211
Quoted 10 lines
lib/gro/gro_tcp4.c +10
-0+/* +* Fail to insert a new flow, so delete the +* stored packet. +*/ +delete_tcp_item (tbl->items, item_idx, &tbl->item_num, +INVALID_ARRAY_INDEX ); +return -1 ; + } +return 0 ; + }else {
"else" is not needed.
Quoted 7 lines
lib/gro/gro_tcp4.c +0
-6return -1 ; -if (insert_new_flow (tbl, &key, item_idx) == -INVALID_ARRAY_INDEX ) { -/* -* Fail to insert a new flow, so delete the -* stored packet. -*/
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 221
Quoted 10 lines
lib/gro/gro_tcp4.c +9
-1-delete_tcp_item (tbl->items, item_idx, &tbl->item_num,INVALID_ARRAY_INDEX ); + } + }else { +/* +* Any packet with additional flags like PSH,FIN should be processed +* and flushed immediately. +* Hence marking the start time to 0, so that the packets will be flushed +* immediately in timer mode. +*/ +if (tcp_hdr->tcp_flags & (RTE_TCP_ACK_FLAG |RTE_TCP_PSH_FLAG |RTE_TCP_FIN_FLAG )) {
Add a space beween RTE_TCP_ACK_FLAG and '|'.
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 228
Quoted 7 lines
lib/gro/gro_tcp4.c +7
-0+if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) + tbl->items[item_start_idx].start_time =0 ; +return process_tcp_item (pkt, tcp_hdr, tcp_dl, tbl->items, + tbl->flows[i].start_index, + &tbl->item_num, tbl->max_item_num, + ip_id, is_atomic, start_time); + }else {
It is better to check the "invalid" flags, like SYN, RST and URG, at the beginning of
gro_tcp4_reassemble(), as the packet can be returned earlier.
Thanks,
Jiayu
Quoted 12 lines
lib/gro/gro_tcp4.c +1
-4return -1 ; } -return 0 ; } -return process_tcp_item (pkt, tcp_hdr, tcp_dl, tbl->items, tbl->flows[i].start_index, - &tbl->item_num, tbl->max_item_num, - ip_id, is_atomic, start_time); +return -1 ; }/*
PATCH v10 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
v7:
Fix warnings and errors
v8:
Fix warnings and errors
v9:
Fix commit message
v10:
Update tcp header flags and address review comments
lib/gro/gro_tcp.h | 9 ++++++++ lib/gro/gro_tcp4.c | 46 ++++++++++++++++++++++++++++---------- lib/gro/gro_tcp_internal.h | 2 +- lib/gro/gro_vxlan_tcp4.c | 5 +++-- 4 files changed, 47 insertions(+), 15 deletions(-)
lib/gro/gro_tcp.h +9 -0
@@ -19,6 +19,8 @@#define INVALID_TCP_HDRLEN (len) \ (((len) < sizeof(struct rte_tcp_hdr)) || ((len) > MAX_TCP_HLEN)) +#define VALID_GRO_TCP_FLAGS (RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG | RTE_TCP_FIN_FLAG) +struct cmn_tcp_key {struct rte_ether_addr eth_saddr;struct rte_ether_addr eth_daddr;
@@ -81,11 +83,13 @@ merge_two_tcp_packets(struct gro_tcp_item *item,struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t ip_id, uint16_t l2_offset) { struct rte_mbuf *pkt_head, *pkt_tail, *lastseg;uint16_t hdr_len, l2_len; +struct rte_tcp_hdr *tcp_hdr;if (cmp >0 ) { pkt_head = item->firstseg;
@@ -128,6 +132,11 @@ merge_two_tcp_packets(struct gro_tcp_item *item,/* update MBUF metadata for the merged packet */ pkt_head->nb_segs += pkt_tail->nb_segs; pkt_head->pkt_len += pkt_tail->pkt_len; +if (tcp_flags !=RTE_TCP_ACK_FLAG ) { + tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, + l2_offset + pkt_head->l2_len + pkt_head->l3_len); + tcp_hdr->tcp_flags |= tcp_flags; + }return 1 ; }
lib/gro/gro_tcp4.c +34 -12
82 lines not on this page · raw message
lib/gro/gro_tcp_internal.h +1 -1
@@ -101,7 +101,7 @@ process_tcp_item(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp_packets (&items[cur_idx], - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, ip_id,0 ))return 1 ;/* * Fail to merge the two packets, as the packet
lib/gro/gro_vxlan_tcp4.c +3 -2
@@ -239,10 +239,11 @@ merge_two_vxlan_tcp4_packets(struct gro_vxlan_tcp4_item *item, struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t outer_ip_id, uint16_t ip_id) { - if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, + if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, tcp_flags, ip_id, pkt->outer_l2_len + pkt->outer_l3_len)) {/* Update the outer IPv4 ID to the large value. */
@@ -413,7 +414,7 @@ gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt, tcp_dl, outer_is_atomic, is_atomic);if (cmp) {if (merge_two_vxlan_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, outer_ip_id, ip_id))return 1 ;/*
Signature · 1 line
2.25.1
PATCH v11 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
v7:
Fix warnings and errors
v8:
Fix warnings and errors
v9:
Fix commit message
v10:
Update tcp header flags and address review comments
v11:
Fix warnings
lib/gro/gro_tcp.h | 9 ++++++++ lib/gro/gro_tcp4.c | 46 ++++++++++++++++++++++++++++---------- lib/gro/gro_tcp_internal.h | 2 +- lib/gro/gro_vxlan_tcp4.c | 5 +++-- 4 files changed, 47 insertions(+), 15 deletions(-)
lib/gro/gro_tcp.h +9 -0
@@ -19,6 +19,8 @@#define INVALID_TCP_HDRLEN (len) \ (((len) < sizeof(struct rte_tcp_hdr)) || ((len) > MAX_TCP_HLEN)) +#define VALID_GRO_TCP_FLAGS (RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG | RTE_TCP_FIN_FLAG) +struct cmn_tcp_key {struct rte_ether_addr eth_saddr;struct rte_ether_addr eth_daddr;
@@ -81,11 +83,13 @@ merge_two_tcp_packets(struct gro_tcp_item *item,struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t ip_id, uint16_t l2_offset) { struct rte_mbuf *pkt_head, *pkt_tail, *lastseg;uint16_t hdr_len, l2_len; +struct rte_tcp_hdr *tcp_hdr;if (cmp >0 ) { pkt_head = item->firstseg;
@@ -128,6 +132,11 @@ merge_two_tcp_packets(struct gro_tcp_item *item,/* update MBUF metadata for the merged packet */ pkt_head->nb_segs += pkt_tail->nb_segs; pkt_head->pkt_len += pkt_tail->pkt_len; +if (tcp_flags !=RTE_TCP_ACK_FLAG ) { + tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, + l2_offset + pkt_head->l2_len + pkt_head->l3_len); + tcp_hdr->tcp_flags |= tcp_flags; + }return 1 ; }
lib/gro/gro_tcp4.c +34 -12
82 lines not on this page · raw message
lib/gro/gro_tcp_internal.h +1 -1
@@ -101,7 +101,7 @@ process_tcp_item(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp_packets (&items[cur_idx], - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, ip_id,0 ))return 1 ;/* * Fail to merge the two packets, as the packet
lib/gro/gro_vxlan_tcp4.c +3 -2
@@ -239,10 +239,11 @@ merge_two_vxlan_tcp4_packets(struct gro_vxlan_tcp4_item *item, struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t outer_ip_id, uint16_t ip_id) { - if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, + if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, tcp_flags, ip_id, pkt->outer_l2_len + pkt->outer_l3_len)) {/* Update the outer IPv4 ID to the large value. */
@@ -413,7 +414,7 @@ gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt, tcp_dl, outer_is_atomic, is_atomic);if (cmp) {if (merge_two_vxlan_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, outer_ip_id, ip_id))return 1 ;/*
Signature · 1 line
2.25.1
Re: [PATCH v11] gro: fix reordering of packets in GRO layer
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 144
Quoted 2 lines · On Sun, 7 Jan 2024 16:59:20 +0530 Kumara Parameshwaran…
lib/gro/gro_tcp4.c +2
-0+/* Return early if the TCP flags are not handled in GRO layer */ +if (tcp_hdr->tcp_flags & (~(VALID_GRO_TCP_FLAGS )))
Nit, lots of extra paren here. Could be:
if (tcp_hdr->tcp_flags & ~VALID_GRO_TCP_FLAGS)
Quoted 8 lines
lib/gro/gro_tcp4.c +8
-0+if (find ==1 ) { +/* +* Any packet with additional flags like PSH,FIN should be processed +* and flushed immediately. +* Hence marking the start time to 0, so that the packets will be flushed +* immediately in timer mode. +*/ +if (tcp_hdr->tcp_flags & (RTE_TCP_ACK_FLAG |RTE_TCP_PSH_FLAG |RTE_TCP_FIN_FLAG )) {
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 208
Quoted 10 lines
lib/gro/gro_tcp4.c +10
-0+if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) + tbl->items[item_start_idx].start_time =0 ; +return process_tcp_item (pkt, tcp_hdr, tcp_dl, tbl->items, + tbl->flows[i].start_index, + &tbl->item_num, tbl->max_item_num, + ip_id, is_atomic, start_time); + }else { +return -1 ; + } + }
Reordering this conditional would keep code from being so indented.
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 229
Quoted 4 lines
lib/gro/gro_tcp4.c +2
-1-delete_tcp_item (tbl->items, item_idx, &tbl->item_num,INVALID_ARRAY_INDEX ); +delete_tcp_item (tbl->items, item_idx, &tbl->item_num, +INVALID_ARRAY_INDEX );return -1 ;
This change is unnecessary, max line length in DPDK is 100 characters for readability.
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 237
Quoted 10 lines
lib/gro/gro_tcp4.c +3
-3return 0 ; + }else { +return -1 ; } -return process_tcp_item (pkt, tcp_hdr, tcp_dl, tbl->items, tbl->flows[i].start_index, - &tbl->item_num, tbl->max_item_num, - ip_id, is_atomic, start_time); +return -1 ; }
Since end of else and end of function both return -1, the else clause is unnecessary.
Re: [PATCH v11] gro: fix reordering of packets in GRO layer
Quoted 73 lines · Stephen Hemminger
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 144
Quoted 2 lines · On Sun, 7 Jan 2024 16:59:20 +0530 Kumara Parameshwaran…
lib/gro/gro_tcp4.c +2
-0+/* Return early if the TCP flags are not handled in GRO layer */ +if (tcp_hdr->tcp_flags & (~(VALID_GRO_TCP_FLAGS )))Nit, lots of extra paren here. Could be:
if (tcp_hdr->tcp_flags & ~VALID_GRO_TCP_FLAGS)lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt,
Quoted 5 lines
Done.
lib/gro/gro_tcp4.c +3
-0+if (find ==1 ) { +/* +* Any packet with additional flags like PSH,FIN should be processed
Review
Quoted 2 lines
(quoted diff) +2
-0+ * and flushed immediately. + * Hence marking the start time to 0, so that the packetswill be flushed
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt,
Quoted 3 lines
lib/gro/gro_tcp4.c +3
-0+* immediately in timer mode. +*/ + if (tcp_hdr->tcp_flags & (RTE_TCP_ACK_FLAG |
RTE_TCP_PSH_FLAG|RTE_TCP_FIN_FLAG)) {lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt,
Quoted 3 lines
lib/gro/gro_tcp4.c +3
-0+if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) + tbl->items[item_start_idx].start_time =0 ; + return process_tcp_item(pkt, tcp_hdr, tcp_dl,
tbl->items,Review
Quoted 2 lines
(quoted diff) +2
-0+ tbl->flows[i].start_index, + &tbl->item_num,
tbl->max_item_num,Quoted 1 line
+
ip_id,is_atomic,
start_time);lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt, · line 208
Quoted 4 lines
lib/gro/gro_tcp4.c +4
-0+ }else { +return -1 ; + } + }Reordering this conditional would keep code from being so indented.
Quoted 4 lines
Doing this reordering as suggested by Jiyau since the find == 1 would be likely in most cases.
- delete_tcp_item(tbl->items,
item_idx,
&tbl->item_num,INVALID_ARRAY_INDEX);Quoted 1 line
+ delete_tcp_item(tbl->items,
item_idx,
&tbl->item_num,Quoted 2 lines
+ INVALID_ARRAY_INDEX); return -1;This change is unnecessary, max line length in DPDK is 100 characters for readability.
lib/gro/gro_tcp4.c gro_tcp4_reassemble(struct rte_mbuf *pkt,
Quoted 8 lines
Done.
return 0;lib/gro/gro_tcp4.c +2
-1+ }else { +return -1 ; } - return process_tcp_item(pkt, tcp_hdr, tcp_dl, tbl->items,tbl->flows[i].start_index,
Quoted 1 line
-
&tbl->item_num,
tbl->max_item_num,Quoted 1 line
-
ip_id,is_atomic,
start_time);Quoted 2 lines
+ return -1;
}Since end of else and end of function both return -1, the else clause is unnecessary.
Quoted 2 lines
Done.
PATCH v12 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
v7:
Fix warnings and errors
v8:
Fix warnings and errors
v9:
Fix commit message
v10:
Update tcp header flags and address review comments
v11:
Fix warnings
v12:
Fix nit review comments
lib/gro/gro_tcp.h | 9 +++++++ lib/gro/gro_tcp4.c | 48 ++++++++++++++++++++++++-------------- lib/gro/gro_tcp_internal.h | 2 +- lib/gro/gro_vxlan_tcp4.c | 5 ++-- 4 files changed, 44 insertions(+), 20 deletions(-)
lib/gro/gro_tcp.h +9 -0
@@ -19,6 +19,8 @@#define INVALID_TCP_HDRLEN (len) \ (((len) < sizeof(struct rte_tcp_hdr)) || ((len) > MAX_TCP_HLEN)) +#define VALID_GRO_TCP_FLAGS (RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG | RTE_TCP_FIN_FLAG) +struct cmn_tcp_key {struct rte_ether_addr eth_saddr;struct rte_ether_addr eth_daddr;
@@ -81,11 +83,13 @@ merge_two_tcp_packets(struct gro_tcp_item *item,struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t ip_id, uint16_t l2_offset) { struct rte_mbuf *pkt_head, *pkt_tail, *lastseg;uint16_t hdr_len, l2_len; +struct rte_tcp_hdr *tcp_hdr;if (cmp >0 ) { pkt_head = item->firstseg;
@@ -128,6 +132,11 @@ merge_two_tcp_packets(struct gro_tcp_item *item,/* update MBUF metadata for the merged packet */ pkt_head->nb_segs += pkt_tail->nb_segs; pkt_head->pkt_len += pkt_tail->pkt_len; +if (tcp_flags !=RTE_TCP_ACK_FLAG ) { + tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, + l2_offset + pkt_head->l2_len + pkt_head->l3_len); + tcp_hdr->tcp_flags |= tcp_flags; + }return 1 ; }
lib/gro/gro_tcp4.c +31 -17
82 lines not on this page · raw message
lib/gro/gro_tcp_internal.h +1 -1
@@ -101,7 +101,7 @@ process_tcp_item(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp_packets (&items[cur_idx], - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, ip_id,0 ))return 1 ;/* * Fail to merge the two packets, as the packet
lib/gro/gro_vxlan_tcp4.c +3 -2
@@ -239,10 +239,11 @@ merge_two_vxlan_tcp4_packets(struct gro_vxlan_tcp4_item *item, struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t outer_ip_id, uint16_t ip_id) { - if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, + if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, tcp_flags, ip_id, pkt->outer_l2_len + pkt->outer_l3_len)) {/* Update the outer IPv4 ID to the large value. */
@@ -413,7 +414,7 @@ gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt, tcp_dl, outer_is_atomic, is_atomic);if (cmp) {if (merge_two_vxlan_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, outer_ip_id, ip_id))return 1 ;/*
Signature · 1 line
2.25.1
PATCH v13 1/1 gro: fix reordering of packets in GRO layer
In reply to Kumara ParameshwaranIn the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.
Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to unprocess_packets and P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and the unprocess_packets will be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.
Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.
v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.
v3:
Fix warnings.
v4:
Rebase with master.
v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FIN
v7:
Fix warnings and errors
v8:
Fix warnings and errors
v9:
Fix commit message
v10:
Update tcp header flags and address review comments
v11:
Fix warnings
v12:
Fix nit review comments
v13:
Fix warnings
lib/gro/gro_tcp.h | 9 +++++++++ lib/gro/gro_tcp4.c | 36 +++++++++++++++++++++++++++--------- lib/gro/gro_tcp_internal.h | 2 +- lib/gro/gro_vxlan_tcp4.c | 5 +++-- 4 files changed, 40 insertions(+), 12 deletions(-)
lib/gro/gro_tcp.h +9 -0
@@ -19,6 +19,8 @@#define INVALID_TCP_HDRLEN (len) \ (((len) < sizeof(struct rte_tcp_hdr)) || ((len) > MAX_TCP_HLEN)) +#define VALID_GRO_TCP_FLAGS (RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG | RTE_TCP_FIN_FLAG) +struct cmn_tcp_key {struct rte_ether_addr eth_saddr;struct rte_ether_addr eth_daddr;
@@ -81,11 +83,13 @@ merge_two_tcp_packets(struct gro_tcp_item *item,struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t ip_id, uint16_t l2_offset) { struct rte_mbuf *pkt_head, *pkt_tail, *lastseg;uint16_t hdr_len, l2_len; +struct rte_tcp_hdr *tcp_hdr;if (cmp >0 ) { pkt_head = item->firstseg;
@@ -128,6 +132,11 @@ merge_two_tcp_packets(struct gro_tcp_item *item,/* update MBUF metadata for the merged packet */ pkt_head->nb_segs += pkt_tail->nb_segs; pkt_head->pkt_len += pkt_tail->pkt_len; +if (tcp_flags !=RTE_TCP_ACK_FLAG ) { + tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *, + l2_offset + pkt_head->l2_len + pkt_head->l3_len); + tcp_hdr->tcp_flags |= tcp_flags; + }return 1 ; }
lib/gro/gro_tcp4.c +27 -9
@@ -126,6 +126,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,uint32_t item_idx;uint32_t i, max_flow_num, remaining_flow_num;uint8_t find; +uint32_t item_start_idx;/* * Don't process the packet whose TCP header length is greater
@@ -139,11 +140,8 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len); hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len; -/* -* Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE -* or CWR set. -*/ -if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) +/* Return early if the TCP flags are not handled in GRO layer */ +if (tcp_hdr->tcp_flags & ~VALID_GRO_TCP_FLAGS )return -1 ;/* trim the tail padding bytes */
@@ -183,13 +181,35 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,if (tbl->flows[i].start_index !=INVALID_ARRAY_INDEX ) {if (is_same_tcp4_flow (tbl->flows[i].key, key)) { find =1 ; + item_start_idx = tbl->flows[i].start_index;break ; } remaining_flow_num--; } } -if (find ==0 ) { +if (find ==1 ) { +/* +* Any packet with additional flags like PSH,FIN should be processed +* and flushed immediately. +* Hence marking the start time to 0, so that the packets will be flushed +* immediately in timer mode. +*/ +if (tcp_hdr->tcp_flags & (RTE_TCP_ACK_FLAG |RTE_TCP_PSH_FLAG |RTE_TCP_FIN_FLAG )) { +if (tcp_hdr->tcp_flags !=RTE_TCP_ACK_FLAG ) + tbl->items[item_start_idx].start_time =0 ; +return process_tcp_item (pkt, tcp_hdr, tcp_dl, tbl->items, + tbl->flows[i].start_index, &tbl->item_num, + tbl->max_item_num, ip_id, is_atomic, start_time); + }else { +return -1 ; + } + } +/* +* Add new flow to the table only if contains ACK flag with data. +* Do not add any packets with additional tcp flags to the GRO table +*/ +if (tcp_hdr->tcp_flags ==RTE_TCP_ACK_FLAG ) { sent_seq =rte_be_to_cpu_32 (tcp_hdr->sent_seq); item_idx = insert_new_tcp_item(pkt, tbl->items, &tbl->item_num, tbl->max_item_num, start_time,
@@ -209,9 +229,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,return 0 ; } -return process_tcp_item (pkt, tcp_hdr, tcp_dl, tbl->items, tbl->flows[i].start_index, - &tbl->item_num, tbl->max_item_num, - ip_id, is_atomic, start_time); +return -1 ; }/*
lib/gro/gro_tcp_internal.h +1 -1
@@ -101,7 +101,7 @@ process_tcp_item(struct rte_mbuf *pkt, is_atomic);if (cmp) {if (merge_two_tcp_packets (&items[cur_idx], - pkt, cmp, sent_seq, ip_id,0 )) + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, ip_id,0 ))return 1 ;/* * Fail to merge the two packets, as the packet
lib/gro/gro_vxlan_tcp4.c +3 -2
@@ -239,10 +239,11 @@ merge_two_vxlan_tcp4_packets(struct gro_vxlan_tcp4_item *item, struct rte_mbuf *pkt, int cmp, uint32_t sent_seq, + uint8_t tcp_flags, uint16_t outer_ip_id, uint16_t ip_id) { - if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, + if (merge_two_tcp_packets(&item->inner_item, pkt, cmp, sent_seq, tcp_flags, ip_id, pkt->outer_l2_len + pkt->outer_l3_len)) {/* Update the outer IPv4 ID to the large value. */
@@ -413,7 +414,7 @@ gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt, tcp_dl, outer_is_atomic, is_atomic);if (cmp) {if (merge_two_vxlan_tcp4_packets (&(tbl->items[cur_idx]), - pkt, cmp, sent_seq, + pkt, cmp, sent_seq, tcp_hdr->tcp_flags, outer_ip_id, ip_id))return 1 ;/*
Signature · 1 line
2.25.1
Re: [PATCH v13] gro: fix reordering of packets in GRO layer
Quoted 64 lines · Kumara Parameshwaran
In the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implementedSigned-off-by Kumara Parameshwaran <[email protected]>---
If the received packet is not a pure ACK packet, we check if there are any previous packets in the flow, if present we indulge the received packet also in the coalescing logic and update the flags of the last recived packet to the entire segment which would avoid re-ordering.Lets say a case where P1(PSH), P2(ACK), P3(ACK) are received in burst mode, P1 contains PSH flag and since it does not contain any prior packets in the flow we copy it to
unprocess_packetsand P2(ACK) and P3(ACK) are merged together. In the existing case the P2,P3 would be delivered as single segment first and theunprocess_packetswill be copied later which will cause reordering. With the patch copy the unprocess packets first and then the packets from the GRO table.Testing done
The csum test-pmd was modified to support the following
GET request of 10MB from client to server via test-pmd (static arp entries added in client and server). Enable GRO and TSO in test-pmd where the packets recived from the client mac would be sent to server mac and vice versa.
In above testing, without the patch the client observerd re-ordering of 25 packets and with the patch there were no packet re-ordering observerd.v2:
Fix warnings in commit and comment.
Do not consider packet as candidate to merge if it contains SYN/RST flag.v3:
Fix warnings.v4:
Rebase with master.v5:
Adding co-author email
v6:
Address review comments from the maintainer to restructure the code and handle only special flags PSH,FINv7:
Fix warnings and errorsv8:
Fix warnings and errorsv9:
Fix commit messagev10:
Update tcp header flags and address review commentsv11:
Fix warningsv12:
Fix nit review comments
Quoted 9 lines
v13:
Fix warningslib/gro/gro_tcp.h | 9 +++++++++ lib/gro/gro_tcp4.c | 36 +++++++++++++++++++++++++++--------- lib/gro/gro_tcp_internal.h | 2 +- lib/gro/gro_vxlan_tcp4.c | 5 +++-- 4 files changed, 40 insertions(+), 12 deletions(-)
Thanks,
Jiayu
Re: [PATCH v13] gro: fix reordering of packets in GRO layer
16/01/2024 15:28, 胡嘉瑜:
Quoted 9 lines · Kumara Parameshwaran
Quoted 7 lines
In the current implementation when a packet is received with special TCP flag(s) set, only that packet is delivered out of order. There could be already coalesced packets in the GRO table belonging to the same flow but not delivered.
This fix makes sure that the entire segment is delivered with the special flag(s) set which is how the Linux GRO is also implemented
Quoted 3 lines
Quoted 1 line
Signed-off-by Kumara Parameshwaran <[email protected]>Reviewed-by Jiayu Hu <[email protected]>
Applied with Cc stable, thanks.