[ovs-dev] [PATCH v2 4/7] datapath-windows: Modify OvsCreateNlMsgFromCtEntry to make it reusable

Yin Lin yinlin10 at gmail.com
Tue Jul 26 03:05:18 UTC 2016


Acked-By: Yin Lin <linyi at vmware.com>

On Mon, Jul 25, 2016 at 5:04 PM, Sairam Venugopal <vsairam at vmware.com>
wrote:

> 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.
>
> v2: Added Acked-By
>
> Signed-off-by: Sairam Venugopal <vsairam at vmware.com>
> Acked-By: Yin Lin <linyi at vmware.com>
> Acked-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
> ---
>  datapath-windows/ovsext/Conntrack.c | 32 ++++++++++++++++++++++----------
>  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 90b59ce..382c13d 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 *)&currentTime);
>      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 6d573c8..4995ff4 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_ */
> --
> 2.9.0.windows.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list