diff mbox

[V6,08/10] net/colo-compare.c: Add vnet packet's tcp/udp/icmp compare

Message ID 1496829322-17099-9-git-send-email-zhangchen.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Zhang Chen June 7, 2017, 9:55 a.m. UTC
COLO-Proxy just focus on packet payload, So we skip vnet header.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
---
 net/colo-compare.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Jason Wang June 9, 2017, 6:17 a.m. UTC | #1
On 2017年06月07日 17:55, Zhang Chen wrote:
> COLO-Proxy just focus on packet payload, So we skip vnet header.

s/So/so/

>
> Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
> ---
>   net/colo-compare.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index e33cf7e..ad1c3d5 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -201,8 +201,11 @@ static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
>                                      sec_ip_src, sec_ip_dst);
>       }
>   
> +    offset = ppkt->vnet_hdr_len + offset;
> +
>       if (ppkt->size == spkt->size) {
> -        return memcmp(ppkt->data + offset, spkt->data + offset,
> +        return memcmp(ppkt->data + offset,
> +                      spkt->data + offset,
>                         spkt->size - offset);
>       } else {
>           trace_colo_compare_main("Net packet size are not the same");
> @@ -261,8 +264,9 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
>        */
>       if (ptcp->th_off > 5) {
>           ptrdiff_t tcp_offset;
> +
>           tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
> -                     + (ptcp->th_off * 4);
> +                     + (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
>           res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
>       } else if (ptcp->th_sum == stcp->th_sum) {
>           res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
diff mbox

Patch

diff --git a/net/colo-compare.c b/net/colo-compare.c
index e33cf7e..ad1c3d5 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -201,8 +201,11 @@  static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
                                    sec_ip_src, sec_ip_dst);
     }
 
+    offset = ppkt->vnet_hdr_len + offset;
+
     if (ppkt->size == spkt->size) {
-        return memcmp(ppkt->data + offset, spkt->data + offset,
+        return memcmp(ppkt->data + offset,
+                      spkt->data + offset,
                       spkt->size - offset);
     } else {
         trace_colo_compare_main("Net packet size are not the same");
@@ -261,8 +264,9 @@  static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
      */
     if (ptcp->th_off > 5) {
         ptrdiff_t tcp_offset;
+
         tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
-                     + (ptcp->th_off * 4);
+                     + (ptcp->th_off * 4) - ppkt->vnet_hdr_len;
         res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
     } else if (ptcp->th_sum == stcp->th_sum) {
         res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);