diff options
author | Sairam Venugopal <vsairam@vmware.com> | 2016-07-25 17:04:40 -0700 |
---|---|---|
committer | Gurucharan Shetty <guru@ovn.org> | 2016-07-29 08:38:10 -0700 |
commit | 9afd6746b1afb40c8b8e04dc7d34636abe37573f (patch) | |
tree | 31dc9433aaaa8e06d7f4ed45fd9b6fa87896cb1a | |
parent | 1f3dd67f336da4a1335de2bebf1b1df2d62a508a (diff) | |
download | openvswitch-9afd6746b1afb40c8b8e04dc7d34636abe37573f.tar.gz |
datapath-windows: Modify OvsCreateNlMsgFromCtEntry to make it reusable
Tweak the OvsCreateNlMsgFromCtEntry() method to reuse it for creating
netlink messages from other files. Also define the function in Conntrack.h
to make it accessible.
Signed-off-by: Sairam Venugopal <vsairam@vmware.com>
Acked-By: Yin Lin <linyi@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-By: Yin Lin <linyi@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
-rw-r--r-- | datapath-windows/ovsext/Conntrack.c | 32 | ||||
-rw-r--r-- | datapath-windows/ovsext/Conntrack.h | 9 |
2 files changed, 31 insertions, 10 deletions
diff --git a/datapath-windows/ovsext/Conntrack.c b/datapath-windows/ovsext/Conntrack.c index 90b59ceee..382c13dde 100644 --- a/datapath-windows/ovsext/Conntrack.c +++ b/datapath-windows/ovsext/Conntrack.c @@ -934,12 +934,15 @@ WindowsTickToUnixSeconds(long long windowsTicks) - SEC_TO_UNIX_EPOCH)); } -static NTSTATUS +NTSTATUS OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry, - POVS_MESSAGE msgIn, PVOID outBuffer, UINT32 outBufLen, - int dpIfIndex) + UINT8 eventType, + UINT32 nlmsgSeq, + UINT32 nlmsgPid, + UINT8 nfGenVersion, + UINT32 dpIfIndex) { NL_BUFFER nlBuf; BOOLEAN ok; @@ -947,6 +950,7 @@ OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry, UINT32 timeout; NDIS_STATUS status; UINT64 currentTime, expiration; + UINT16 nlmsgType; NdisGetCurrentSystemTime((LARGE_INTEGER *)¤tTime); UINT8 nfgenFamily = 0; if (entry->key.dl_type == htons(ETH_TYPE_IPV4)) { @@ -957,13 +961,17 @@ OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry, NlBufInit(&nlBuf, outBuffer, outBufLen); /* Mimic netfilter */ - UINT16 nlmsgType = (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_NEW); + if (eventType == OVS_EVENT_CT_NEW) { + nlmsgType = (UINT16) (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_NEW); + } else if (eventType == OVS_EVENT_CT_DELETE) { + nlmsgType = (UINT16) (NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_DELETE); + } else { + return STATUS_INVALID_PARAMETER; + } + ok = NlFillOvsMsgForNfGenMsg(&nlBuf, nlmsgType, NLM_F_CREATE, - msgIn->nlMsg.nlmsgSeq, - msgIn->nlMsg.nlmsgPid, - nfgenFamily, - msgIn->nfGenMsg.version, - dpIfIndex); + nlmsgSeq, nlmsgPid, nfgenFamily, + nfGenVersion, dpIfIndex); if (!ok) { return STATUS_INVALID_BUFFER_SIZE; } @@ -1130,9 +1138,13 @@ OvsCtDumpCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx, if (outIndex >= inIndex) { entry = CONTAINING_RECORD(link, OVS_CT_ENTRY, link); - rc = OvsCreateNlMsgFromCtEntry(entry, msgIn, + rc = OvsCreateNlMsgFromCtEntry(entry, usrParamsCtx->outputBuffer, usrParamsCtx->outputLength, + OVS_EVENT_CT_NEW, + msgIn->nlMsg.nlmsgSeq, + msgIn->nlMsg.nlmsgPid, + msgIn->nfGenMsg.version, 0); if (rc != NDIS_STATUS_SUCCESS) { diff --git a/datapath-windows/ovsext/Conntrack.h b/datapath-windows/ovsext/Conntrack.h index 6d573c88a..4995ff412 100644 --- a/datapath-windows/ovsext/Conntrack.h +++ b/datapath-windows/ovsext/Conntrack.h @@ -116,4 +116,13 @@ enum CT_UPDATE_RES OvsConntrackUpdateTcpEntry(OVS_CT_ENTRY* conn_, enum ct_update_res OvsConntrackUpdateOtherEntry(OVS_CT_ENTRY *conn_, BOOLEAN reply, UINT64 now); +NTSTATUS +OvsCreateNlMsgFromCtEntry(POVS_CT_ENTRY entry, + PVOID outBuffer, + UINT32 outBufLen, + UINT8 eventType, + UINT32 nlmsgSeq, + UINT32 nlmsgPid, + UINT8 nfGenVersion, + UINT32 dpIfIndex); #endif /* __OVS_CONNTRACK_H_ */ |