diff mbox series

[02/10] Optimize seq_sorter function for colo-compare

Message ID 20201014072555.12515-3-chen.zhang@intel.com
State New
Headers show
Series COLO project queued patches 20-Oct | expand

Commit Message

Zhang, Chen Oct. 14, 2020, 7:25 a.m. UTC
From: "Rao, Lei" <lei.rao@intel.com>

The seq of tcp has been filled in fill_pkt_tcp_info, it
can be used directly here.

Signed-off-by: leirao <lei.rao@intel.com>
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
Reviewed-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
---
 net/colo-compare.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Philippe Mathieu-Daudé Oct. 15, 2020, 11:06 a.m. UTC | #1
On 10/14/20 9:25 AM, Zhang Chen wrote:
> From: "Rao, Lei" <lei.rao@intel.com>
> 
> The seq of tcp has been filled in fill_pkt_tcp_info, it
> can be used directly here.
> 
> Signed-off-by: leirao <lei.rao@intel.com>

"Signed-off-by: Lei Rao <lei.rao@intel.com>"?

> Signed-off-by: Zhang Chen <chen.zhang@intel.com>
> Reviewed-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> Reviewed-by: Zhang Chen <chen.zhang@intel.com>
> ---
>   net/colo-compare.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index 3a45d64175..86980cef5e 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -196,11 +196,7 @@ static void colo_compare_inconsistency_notify(CompareState *s)
>   

Maybe add a comment /* Use restricted to colo_insert_packet() */

Because if someone use it elsewhere it will now be buggy.

>   static gint seq_sorter(Packet *a, Packet *b, gpointer data)
>   {
> -    struct tcp_hdr *atcp, *btcp;
> -
> -    atcp = (struct tcp_hdr *)(a->transport_header);
> -    btcp = (struct tcp_hdr *)(b->transport_header);
> -    return ntohl(atcp->th_seq) - ntohl(btcp->th_seq);
> +    return a->tcp_seq - b->tcp_seq;
>   }
>   
>   static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
>
diff mbox series

Patch

diff --git a/net/colo-compare.c b/net/colo-compare.c
index 3a45d64175..86980cef5e 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -196,11 +196,7 @@  static void colo_compare_inconsistency_notify(CompareState *s)
 
 static gint seq_sorter(Packet *a, Packet *b, gpointer data)
 {
-    struct tcp_hdr *atcp, *btcp;
-
-    atcp = (struct tcp_hdr *)(a->transport_header);
-    btcp = (struct tcp_hdr *)(b->transport_header);
-    return ntohl(atcp->th_seq) - ntohl(btcp->th_seq);
+    return a->tcp_seq - b->tcp_seq;
 }
 
 static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)