Skip to content

Commit 70ffe65

Browse files
pweisongovsrobot
authored andcommitted
datapath-windows: Merge split dis-continuous net-buf.
NdisGetDataBuffer() is called without providing a buffer to copy packet data in case it is not contiguous. So, it fails in some scenarios where the packet is handled by the general network stack before OVS and headers become split in multiple buffers. In the fix it will supply the stack buffer to copy packet data when call NdisGetDataBuffer(). In the conntrack Action process, it will do OvsPartialCopyNBL firstly with the size of layers l7offsets. If the header is split the header will be merged to one continuous buffer. But IPV6 traffic is not handed in this case. Reported-at: openvswitch/ovs-issues#323 Signed-off-by: Wilson Peng <pweisong@vmware.com> Signed-off-by: 0-day Robot <robot@bytheb.org>
1 parent d7e7714 commit 70ffe65

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

datapath-windows/ovsext/Actions.c

+7
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,13 @@ OvsDoExecuteActions(POVS_SWITCH_CONTEXT switchContext,
24142414
}
24152415

24162416
PNET_BUFFER_LIST oldNbl = ovsFwdCtx.curNbl;
2417+
PUINT8 bufferStart = NULL;
2418+
2419+
bufferStart = OvsGetHeaderBySize(&ovsFwdCtx, layers->l7Offset);
2420+
if (!bufferStart) {
2421+
dropReason = L"OVS-Netbuf reallocated failed";
2422+
goto dropit;
2423+
}
24172424
status = OvsExecuteConntrackAction(&ovsFwdCtx, key,
24182425
(const PNL_ATTR)a);
24192426
if (status != NDIS_STATUS_SUCCESS) {

datapath-windows/ovsext/BufferMgmt.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1110,12 +1110,14 @@ GetIpHeaderInfo(PNET_BUFFER_LIST curNbl,
11101110
IPHdr *ipHdr;
11111111
IPv6Hdr *ipv6Hdr;
11121112
PNET_BUFFER curNb;
1113+
CHAR tempBuf[MAX_IP_HEADER_LEN];
11131114

11141115
curNb = NET_BUFFER_LIST_FIRST_NB(curNbl);
11151116
ASSERT(NET_BUFFER_NEXT_NB(curNb) == NULL);
1117+
NdisZeroMemory(tempBuf, MAX_IP_HEADER_LEN);
11161118
eth = (EthHdr *)NdisGetDataBuffer(curNb,
11171119
hdrInfo->l4Offset,
1118-
NULL, 1, 0);
1120+
(PVOID)tempBuf, 1, 0);
11191121
if (eth == NULL) {
11201122
return NDIS_STATUS_INVALID_PACKET;
11211123
}

datapath-windows/ovsext/Conntrack.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ OvsGetTcpHeader(PNET_BUFFER_LIST nbl,
683683
TCPHdr *tcp;
684684
VOID *dest = storage;
685685
uint16_t ipv6ExtLength = 0;
686+
CHAR tempBuf[MAX_IP_HEADER_LEN];
686687

687688
if (layers->isIPv6) {
688689
ipv6Hdr = NdisGetDataBuffer(NET_BUFFER_LIST_FIRST_NB(nbl),
@@ -701,9 +702,10 @@ OvsGetTcpHeader(PNET_BUFFER_LIST nbl,
701702
return storage;
702703
}
703704
} else {
705+
NdisZeroMemory(tempBuf, MAX_IP_HEADER_LEN);
704706
ipHdr = NdisGetDataBuffer(NET_BUFFER_LIST_FIRST_NB(nbl),
705707
layers->l4Offset + sizeof(TCPHdr),
706-
NULL, 1 /*no align*/, 0);
708+
(PVOID)tempBuf, 1 /*no align*/, 0);
707709
if (ipHdr == NULL) {
708710
return NULL;
709711
}
@@ -1202,6 +1204,8 @@ OvsCtExecute_(OvsForwardingContext *fwdCtx,
12021204
UINT64 currentTime;
12031205
NdisGetCurrentSystemTime((LARGE_INTEGER *) &currentTime);
12041206

1207+
1208+
curNbl = fwdCtx->curNbl;
12051209
/* Retrieve the Conntrack Key related fields from packet */
12061210
OvsCtSetupLookupCtx(key, zone, &ctx, curNbl, layers->l4Offset);
12071211

datapath-windows/ovsext/IpFragment.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,14 @@ OvsIpv4Reassemble(POVS_SWITCH_CONTEXT switchContext,
153153
PNET_BUFFER_LIST newNbl = NULL;
154154
UINT16 ipHdrLen, packetHeader;
155155
UINT32 packetLen;
156+
CHAR tempBuf[MAX_IP_HEADER_LEN];
156157

157158
curNb = NET_BUFFER_LIST_FIRST_NB(*curNbl);
158159
ASSERT(NET_BUFFER_NEXT_NB(curNb) == NULL);
159160

161+
NdisZeroMemory(tempBuf, MAX_IP_HEADER_LEN);
160162
eth = (EthHdr*)NdisGetDataBuffer(curNb, layers->l4Offset,
161-
NULL, 1, 0);
163+
(PVOID)tempBuf, 1, 0);
162164
if (eth == NULL) {
163165
return NDIS_STATUS_INVALID_PACKET;
164166
}
@@ -253,12 +255,14 @@ OvsProcessIpv4Fragment(POVS_SWITCH_CONTEXT switchContext,
253255
POVS_IPFRAG_ENTRY entry;
254256
POVS_FRAGMENT_LIST fragStorage;
255257
LOCK_STATE_EX htLockState;
258+
CHAR tempBuf[MAX_IP_HEADER_LEN];
256259

257260
curNb = NET_BUFFER_LIST_FIRST_NB(*curNbl);
258261
ASSERT(NET_BUFFER_NEXT_NB(curNb) == NULL);
259262

263+
NdisZeroMemory(tempBuf, MAX_IP_HEADER_LEN);
260264
eth = (EthHdr*)NdisGetDataBuffer(curNb, layers->l4Offset,
261-
NULL, 1, 0);
265+
(PVOID)tempBuf, 1, 0);
262266
if (eth == NULL) {
263267
return NDIS_STATUS_INVALID_PACKET;
264268
}

datapath-windows/ovsext/PacketParser.h

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define __PACKET_PARSER_H_ 1
1919

2020
#define MIN_IPV4_HLEN 20
21+
#define MAX_IP_HEADER_LEN 80
2122

2223
#include "precomp.h"
2324
#include "NetProto.h"

0 commit comments

Comments
 (0)