]> git.proxmox.com Git - mirror_ovs.git/commitdiff
datapath-windows: Fixed tcp flags byte order in conntrack
authorPaul Boca <pboca@cloudbasesolutions.com>
Mon, 29 Aug 2016 19:11:06 +0000 (19:11 +0000)
committerGurucharan Shetty <guru@ovn.org>
Thu, 8 Sep 2016 19:33:34 +0000 (12:33 -0700)
In user mode the flags are interpreted as little endian.
This fix makes the kernel mode compatible with user mode.

Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
datapath-windows/ovsext/Conntrack-tcp.c

index 1820705eadcca719ff25d345a3475c8b413316a1..6adf490f796ea8ff5d2ca2ef1f38d9979ccf68fa 100644 (file)
@@ -226,13 +226,13 @@ OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_,
     /* The peer that should receive 'pkt' */
     struct tcp_peer *dst = &conn->peer[reply ? 0 : 1];
     uint8_t sws = 0, dws = 0;
-    UINT16 tcp_flags = tcp->flags;
+    UINT16 tcp_flags = ntohs(tcp->flags);
     uint16_t win = ntohs(tcp->window);
     uint32_t ack, end, seq, orig_seq;
     uint32_t p_len = OvsGetTcpPayloadLength(nbl);
     int ackskew;
 
-    if (OvsCtInvalidTcpFlags(tcp->flags)) {
+    if (OvsCtInvalidTcpFlags(tcp_flags)) {
         return CT_UPDATE_INVALID;
     }
 
@@ -268,7 +268,7 @@ OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_,
     if (src->state < CT_DPIF_TCPS_SYN_SENT) {
         /* First packet from this end. Set its state */
 
-        ack = ntohl(tcp->ack);
+        ack = ntohl(tcp->ack_seq);
 
         end = seq + p_len;
         if (tcp_flags & TCP_SYN) {
@@ -308,7 +308,7 @@ OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_,
         }
 
     } else {
-        ack = ntohl(tcp->ack);
+        ack = ntohl(tcp->ack_seq);
         end = seq + p_len;
         if (tcp_flags & TCP_SYN) {
             end++;
@@ -460,14 +460,16 @@ OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_,
 BOOLEAN
 OvsConntrackValidateTcpPacket(const TCPHdr *tcp)
 {
-    if (tcp == NULL || OvsCtInvalidTcpFlags(tcp->flags)) {
+    UINT16 tcp_flags = ntohs(tcp->flags);
+
+    if (tcp == NULL || OvsCtInvalidTcpFlags(tcp_flags)) {
         return FALSE;
     }
 
     /* A syn+ack is not allowed to create a connection.  We want to allow
      * totally new connections (syn) or already established, not partially
      * open (syn+ack). */
-    if ((tcp->flags & TCP_SYN) && (tcp->flags & TCP_ACK)) {
+    if ((tcp_flags & TCP_SYN) && (tcp_flags & TCP_ACK)) {
         return FALSE;
     }