Skip to contentSkip to conversation

net/colo-compare.c: Fix ACK track reverse issue

PATCH Applied Zhang Chen 2 participants 4 messages Nov 18, 2021 – Nov 19, 2021 Networking

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

PATCH 1/2 net/colo-compare.c: Fix ACK track reverse issue

The TCP protocol ACK maybe bigger than uint32_t MAX. At this time, the ACK will reverse to 0. This patch fix the max_ack and min_ack track issue.

---
 net/colo-compare.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/colo-compare.c +4 -2
index b8876d7fd9..1225f40e41 100644
@@ -209,7 +209,8 @@ static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
 
     pkt->tcp_seq = ntohl(tcphd->th_seq);
     pkt->tcp_ack = ntohl(tcphd->th_ack);
-    *max_ack = *max_ack > pkt->tcp_ack ? *max_ack : pkt->tcp_ack;
+    /* Need to consider ACK will bigger than uint32_t MAX */
+    *max_ack = pkt->tcp_ack - *max_ack > 0 ? pkt->tcp_ack : *max_ack;
     pkt->header_size = pkt->transport_header - (uint8_t *)pkt->data
                        + (tcphd->th_off << 2);
     pkt->payload_size = pkt->size - pkt->header_size;
@@ -413,7 +414,8 @@ static void colo_compare_tcp(CompareState *s, Connection *conn)
      * can ensure that the packet's payload is acknowledged by
      * primary and secondary.
     */
-    uint32_t min_ack = conn->pack > conn->sack ? conn->sack : conn->pack;
+    uint32_t min_ack = conn->pack - conn->sack > 0 ?
+                       conn->sack : conn->pack;
 
 pri:
     if (g_queue_is_empty(&conn->primary_list)) {
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 net/colo-compare.c: Fix incorrect return when input wrong size

---
 net/colo-compare.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +1 -1
index 1225f40e41..b966e7e514 100644
@@ -807,7 +807,7 @@ static int compare_chr_send(CompareState *s,
     }
 
     if (!size) {
-        return 0;
+        return -1;
     }
 
     entry = g_slice_new(SendEntry);
Signature · 1 line
2.25.1
Applied
#2 lore raw

Re: [PATCH 2/2] net/colo-compare.c: Fix incorrect return when input wrong size

Quoted 2 lines · Zhang Chen

---

Applied.

Thanks

Quoted 16 lines
  net/colo-compare.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +1 -1
index 1225f40e41..b966e7e514 100644
@@ -807,7 +807,7 @@ static int compare_chr_send(CompareState *s,
      }
 
      if (!size) {
-        return 0;
+        return -1;
      }
 
      entry = g_slice_new(SendEntry);
Applied
#3 lore raw
In reply to Zhang Chen
Quoted 6 lines · Zhang Chen

The TCP protocol ACK maybe bigger than uint32_t MAX. At this time, the ACK will reverse to 0. This patch fix the max_ack and min_ack track issue.

---

Applied.

Thanks

Quoted 27 lines
  net/colo-compare.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
net/colo-compare.c +4 -2
index b8876d7fd9..1225f40e41 100644
@@ -209,7 +209,8 @@ static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
 
      pkt->tcp_seq = ntohl(tcphd->th_seq);
      pkt->tcp_ack = ntohl(tcphd->th_ack);
-    *max_ack = *max_ack > pkt->tcp_ack ? *max_ack : pkt->tcp_ack;
+    /* Need to consider ACK will bigger than uint32_t MAX */
+    *max_ack = pkt->tcp_ack - *max_ack > 0 ? pkt->tcp_ack : *max_ack;
      pkt->header_size = pkt->transport_header - (uint8_t *)pkt->data
                         + (tcphd->th_off << 2);
      pkt->payload_size = pkt->size - pkt->header_size;
@@ -413,7 +414,8 @@ static void colo_compare_tcp(CompareState *s, Connection *conn)
       * can ensure that the packet's payload is acknowledged by
       * primary and secondary.
      */
-    uint32_t min_ack = conn->pack > conn->sack ? conn->sack : conn->pack;
+    uint32_t min_ack = conn->pack - conn->sack > 0 ?
+                       conn->sack : conn->pack;
 
  pri:
      if (g_queue_is_empty(&conn->primary_list)) {