[ovs-dev] [PATCH v1 02/10] datapath-windows/Netlink: Add NlFillOvsMsg API for creating Netlink message headers.
Eitan Eliahu
eliahue at vmware.com
Wed Sep 24 20:55:17 UTC 2014
Hi Ankur, do we really need to align the size of the NL message to 4 bytes? In this case we don't add any attributes after the OVS header?
Otherwise, looks good.
Thanks,
Eitan
-----Original Message-----
From: dev [mailto:dev-bounces at openvswitch.org] On Behalf Of Ankur Sharma
Sent: Wednesday, September 24, 2014 12:16 AM
To: dev at openvswitch.org
Subject: [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
https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yTvML8OxA42Jb6ViHe7fUXbvPVOYDPVq87w43doxtlY%3D%0A&m=PlwQyoi4uGQk%2F46mB8rAsIW1K7aJijOQglddVQ8JBww%3D%0A&s=9f436d47bba141c08205e20e45e660efa55fa06e204565c2f70fcf232dfaa701
More information about the dev
mailing list