[ovs-dev] [PATCH v1 02/10] datapath-windows/Netlink: Add NlFillOvsMsg API for creating Netlink message headers.

Ankur Sharma ankursharma at vmware.com
Thu Sep 25 01:22:25 UTC 2014


Hi Alin,

Yes i'll remove NLMSG_ALIGN.
My bad i missed out removing NL_FILL_ARGS. I'll spin up a v2 with the review comments.

Thanks.

Regards,
Ankur
________________________________
From: Alin Serdean <aserdean at cloudbasesolutions.com>
Sent: Wednesday, September 24, 2014 6:14 PM
To: Ankur Sharma; dev at openvswitch.org
Subject: RE: [ovs-dev] [PATCH v1 02/10] datapath-windows/Netlink: Add NlFillOvsMsg API for creating Netlink message headers.


Hi Ankur,



As Eitan was mentioning drop:

nlMsg->nlmsgLen = NLMSG_ALIGN(NlBufSize(nlBuf));



I see you declaring the following structure but never used:
/* Structure to hold arguments needed by NlFillOvsMsg */
typedef struct _NL_FILL_ARGS {
    UINT16 nlmsgType;
    UINT8 genlCmd;
    UINT8 version;
    UINT32 dpNo;

} NL_FILL_ARGS, *PNL_FILL_ARGS;





Also NlFillOvsMsg has too many parameters in my opionion.



A suggestion for the prototype can be the following:
NlFillOvsMsg(POVS_MESSAGE msgOut, PNL_BUFFER nlBuf,
PNL_MSG_HDR nlHdr, PGENL_MSG_HDR genlHdr,

UINT32 dpNo);



Alin.





-----Mesaj original-----
De la: dev [mailto:dev-bounces at openvswitch.org] În numele Ankur Sharma
Trimis: Wednesday, September 24, 2014 10:16 AM
Către: dev at openvswitch.org
Subiect: [ovs-dev] [PATCH v1 02/10] datapath-windows/Netlink: Add NlFillOvsMsg API for creating Netlink message headers.



Added NlFillOvsMsg API in Netlink.c This API will be used to populate netlink message headers.

---

datapath-windows/ovsext/Netlink/Netlink.c | 38 +++++++++++++++++++++++++++++++  datapath-windows/ovsext/Netlink/Netlink.h | 14 ++++++++++++

2 files changed, 52 insertions(+)



diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c

index c286c2f..efaba90 100644

--- a/datapath-windows/ovsext/Netlink/Netlink.c

+++ b/datapath-windows/ovsext/Netlink/Netlink.c

@@ -34,6 +34,44 @@

 /*

  * ---------------------------------------------------------------------------

+ * Prepare netlink message headers. Attributes should be added by caller.

+ *

+-----------------------------------------------------------------------

+----

+ */

+NTSTATUS

+NlFillOvsMsg(POVS_MESSAGE msgOut, PNL_BUFFER nlBuf,

+             UINT16 nlmsgType, UINT16 nlmsgFlags,

+             UINT32 nlmsgSeq, UINT32 nlmsgPid,

+             UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo) {

+    BOOLEAN writeOk;

+    PNL_MSG_HDR nlMsg;

+

+    /* XXX: Add API for nlBuf->bufRemLen. */

+    ASSERT(NlBufAt(nlBuf, 0, 0) != 0 &&

+           nlBuf->bufRemLen >= sizeof (struct _OVS_MESSAGE));

+

+    msgOut->nlMsg.nlmsgType = nlmsgType;

+    msgOut->nlMsg.nlmsgFlags = nlmsgFlags;

+    msgOut->nlMsg.nlmsgSeq = nlmsgSeq;

+    msgOut->nlMsg.nlmsgPid = nlmsgPid;

+

+    msgOut->genlMsg.cmd = genlCmd;

+    msgOut->genlMsg.version = genlVer;

+    msgOut->genlMsg.reserved = 0;

+

+    msgOut->ovsHdr.dp_ifindex = dpNo;

+

+    writeOk = NlMsgPutHead(nlBuf, (PCHAR)msgOut,

+                           sizeof (struct _OVS_MESSAGE));

+

+    nlMsg = (PNL_MSG_HDR)NlBufAt(nlBuf, 0, 0);

+    nlMsg->nlmsgLen = NLMSG_ALIGN(NlBufSize(nlBuf));

+

+    return writeOk ? STATUS_SUCCESS : STATUS_INVALID_BUFFER_SIZE; }

+

+/*

+ *

+-----------------------------------------------------------------------

+----

  * Adds Netlink Header to the NL_BUF.

  * ---------------------------------------------------------------------------

  */

diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h

index b036723..8f30800 100644

--- a/datapath-windows/ovsext/Netlink/Netlink.h

+++ b/datapath-windows/ovsext/Netlink/Netlink.h

@@ -61,6 +61,14 @@ typedef struct _NL_POLICY

     BOOLEAN optional;

} NL_POLICY, *PNL_POLICY;

+/* Structure to hold arguments needed by NlFillOvsMsg */ typedef struct

+_NL_FILL_ARGS {

+    UINT16 nlmsgType;

+    UINT8 genlCmd;

+    UINT8 version;

+    UINT32 dpNo;

+} NL_FILL_ARGS, *PNL_FILL_ARGS;

+

/* This macro is careful to check for attributes with bad lengths. */

#define NL_ATTR_FOR_EACH(ITER, LEFT, ATTRS, ATTRS_LEN)                  \

     for ((ITER) = (ATTRS), (LEFT) = (ATTRS_LEN);                        \

@@ -78,6 +86,12 @@ typedef struct _NL_POLICY  #define NL_ATTR_GET_AS(NLA, TYPE) \

         (*(TYPE*) NlAttrGetUnspec(nla, sizeof(TYPE)))

+NTSTATUS

+NlFillOvsMsg(POVS_MESSAGE msgOut, PNL_BUFFER nlBuf,

+             UINT16 nlmsgType, UINT16 nlmsgFlags,

+             UINT32 nlmsgSeq, UINT32 nlmsgPid,

+             UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo);

+

/* Netlink message accessing the payload */  PVOID NlMsgAt(const PNL_MSG_HDR nlh, UINT32 offset);

UINT32 NlMsgSize(const PNL_MSG_HDR nlh);

--

1.9.1



_______________________________________________

dev mailing list

dev at openvswitch.org<mailto:dev at openvswitch.org>

http://openvswitch.org/mailman/listinfo/dev<https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=f6EhnZ0ORGZNt5QbYmRaOxfWfx%2Bqd3KEiPf3%2FYaollU%3D%0A&m=I4rC2OOcyrAnmt0iYVCsgyRyQ5Gy6pHS7QhephdEXac%3D%0A&s=0bfb14dcbb663d264ead189a698bf1d6896d23a48830844515dd80d63b65a342>



More information about the dev mailing list