Skip to content

Commit

Permalink
datapath-windows: Conntrack move null checks to functions
Browse files Browse the repository at this point in the history
Add null checks inside OvsConntrackValidateIcmpPacket,
OvsConntrackValidateTcpPacket to make the functions self-contained.

Signed-off-by: Alin Gabriel Serdean <[email protected]>
Suggested-by: Yin Lin <[email protected]>
Acked-by: Sairam Venugopal <[email protected]>
Signed-off-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
Alin Serdean authored and shettyg committed Dec 13, 2016
1 parent bf71b09 commit 50b0a16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions datapath-windows/ovsext/Conntrack-icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ OvsConntrackUpdateIcmpEntry(OVS_CT_ENTRY* conn_,
BOOLEAN
OvsConntrackValidateIcmpPacket(const ICMPHdr *icmp)
{
if (!icmp) {
return FALSE;
}

return icmp->type == ICMP4_ECHO_REQUEST
|| icmp->type == ICMP4_INFO_REQUEST
|| icmp->type == ICMP4_TIMESTAMP_REQUEST;
Expand Down
6 changes: 5 additions & 1 deletion datapath-windows/ovsext/Conntrack-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,13 @@ OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_,
BOOLEAN
OvsConntrackValidateTcpPacket(const TCPHdr *tcp)
{
if (!tcp) {
return FALSE;
}

UINT16 tcp_flags = ntohs(tcp->flags);

if (tcp == NULL || OvsCtInvalidTcpFlags(tcp_flags)) {
if (OvsCtInvalidTcpFlags(tcp_flags)) {
return FALSE;
}

Expand Down
4 changes: 2 additions & 2 deletions datapath-windows/ovsext/Conntrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ OvsCtEntryCreate(PNET_BUFFER_LIST curNbl,
TCPHdr tcpStorage;
const TCPHdr *tcp;
tcp = OvsGetTcp(curNbl, l4Offset, &tcpStorage);
if (!tcp || !OvsConntrackValidateTcpPacket(tcp)) {
if (!OvsConntrackValidateTcpPacket(tcp)) {
goto invalid;
}

Expand All @@ -220,7 +220,7 @@ OvsCtEntryCreate(PNET_BUFFER_LIST curNbl,
ICMPHdr storage;
const ICMPHdr *icmp;
icmp = OvsGetIcmp(curNbl, l4Offset, &storage);
if (!icmp || !OvsConntrackValidateIcmpPacket(icmp)) {
if (!OvsConntrackValidateIcmpPacket(icmp)) {
goto invalid;
}

Expand Down

0 comments on commit 50b0a16

Please sign in to comment.