Skip to content

Commit

Permalink
datapath-windows: Added the API for getting unused space in nlbuf.
Browse files Browse the repository at this point in the history
Also, the boundary check in NlBufAt was a little weird.
Fixed the same.

Signed-off-by: Ankur Sharma <[email protected]>
Acked-by: Nithin Raju <[email protected]>
Acked-by: Alin Gabriel Serdean <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
ankursh authored and blp committed Oct 6, 2014
1 parent e6ac5e9 commit ffa0808
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 1 addition & 2 deletions datapath-windows/ovsext/Datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,7 @@ OvsDpFillInfo(POVS_SWITCH_CONTEXT ovsSwitchContext,
OVS_DATAPATH *datapath = &ovsSwitchContext->datapath;
PNL_MSG_HDR nlMsg;

/* XXX: Add API for nlBuf->bufRemLen. */
ASSERT(NlBufAt(nlBuf, 0, 0) != 0 && nlBuf->bufRemLen >= sizeof *msgIn);
ASSERT(NlBufAt(nlBuf, 0, 0) != 0 && NlBufRemLen(nlBuf) >= sizeof *msgIn);

msgOutTmp.nlMsg.nlmsgType = OVS_WIN_NL_DATAPATH_FAMILY_ID;
msgOutTmp.nlMsg.nlmsgFlags = 0; /* XXX: ? */
Expand Down
4 changes: 3 additions & 1 deletion datapath-windows/ovsext/Netlink/NetlinkBuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ NlBufCopyAtOffsetUninit(PNL_BUFFER nlBuf, UINT32 len, UINT32 offset)
*
* Returns pointer to buffer at input offset.
* bufLen is used to verify that expected data length
* is within valid boundaries.
* is within valid boundaries. Here by boundaries we mean
* within head and tail.
* --------------------------------------------------------------------------
*/
PCHAR
Expand All @@ -291,6 +292,7 @@ NlBufAt(PNL_BUFFER nlBuf, UINT32 offset, UINT32 bufLen)
goto done;
}

/* Check if requested buffer is within head and tail */
if ((offset + bufLen) > NL_BUF_USED_SPACE(nlBuf)) {
goto done;
}
Expand Down
14 changes: 14 additions & 0 deletions datapath-windows/ovsext/Netlink/NetlinkBuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,18 @@ NlBufSize(PNL_BUFFER nlBuf)
return (nlBuf->bufLen - nlBuf->bufRemLen);
}

/*
* --------------------------------------------------------------------------
* NlBufRemLen --
*
* Returns the unused size of buffer.
* --------------------------------------------------------------------------
*/
static __inline UINT32
NlBufRemLen(PNL_BUFFER nlBuf)
{
ASSERT(nlBuf);
return (nlBuf->bufRemLen);
}

#endif /* __NETLINK_BUF_H_ */

0 comments on commit ffa0808

Please sign in to comment.