Skip to content

Commit

Permalink
datapath-windows: Fixed tcp flags byte order in conntrack
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Alin Gabriel Serdean <[email protected]>
Acked-by: Sairam Venugopal <[email protected]>
Signed-off-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
Paul Boca authored and shettyg committed Sep 8, 2016
1 parent 75e82c1 commit c40dcaa
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions datapath-windows/ovsext/Conntrack-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c40dcaa

Please sign in to comment.