[ovs-dev] [PATCH v1 03/10] datapath-windows/Netlink: Added NlAttrLen API

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


Hi Alin,

Yes Eitan also pointed it out.
I am panning to send a seperate series which will make a lot of NETLINK APIS inline.
I did not do it in this patch as i would have complicated it further.

let me know if it sounds fine that i send out a seperate patch handling all the netlink APIs that need to be marked inline.

Thanks.

Regards,
Ankur
________________________________________
From: Alin Serdean <aserdean at cloudbasesolutions.com>
Sent: Wednesday, September 24, 2014 6:18 PM
To: Ankur Sharma; dev at openvswitch.org
Subject: RE: [ovs-dev] [PATCH v1 03/10] datapath-windows/Netlink: Added NlAttrLen API

Think it would be a good idea to inline the functions.

Also maybe add asserts to nla.

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 03/10] datapath-windows/Netlink: Added NlAttrLen API

Added an API to retrieve the attribute length.
Added 2 more API for BE16 and BE8 attribute parsing.
Fixed a trailing whitespace issue.
---
 datapath-windows/ovsext/Netlink/Netlink.c | 28 +++++++++++++++++++++++++++-  datapath-windows/ovsext/Netlink/Netlink.h | 13 ++++++++++++-
 datapath-windows/ovsext/Types.h           |  1 +
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index efaba90..5f07451 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -585,7 +585,7 @@ NlMsgAttrs(const PNL_MSG_HDR nlh)
  * Returns size of to nlmsg attributes.
  * ---------------------------------------------------------------------------
  */
-INT
+UINT32
 NlMsgAttrLen(const PNL_MSG_HDR nlh)
 {
     return NlMsgPayloadLen(nlh) - GENL_HDRLEN - OVS_HDRLEN; @@ -788,6 +788,32 @@ NlAttrGetBe32(const PNL_ATTR nla)

 /*
  * ---------------------------------------------------------------------------
+ * Returns the 16-bit network byte order value in 'nla''s payload.
+ *
+ * Asserts that 'nla''s payload is at least 2 bytes long.
+ *
+-----------------------------------------------------------------------
+----
+ */
+BE16
+NlAttrGetBe16(const PNL_ATTR nla)
+{
+    return NL_ATTR_GET_AS(nla, BE16);
+}
+
+/*
+ *
+-----------------------------------------------------------------------
+----
+ * Returns the 8-bit network byte order value in 'nla''s payload.
+ *
+ * Asserts that 'nla''s payload is at least 1 byte long.
+ *
+-----------------------------------------------------------------------
+----
+ */
+BE8
+NlAttrGetBe8(const PNL_ATTR nla)
+{
+    return NL_ATTR_GET_AS(nla, BE8);
+}
+
+/*
+ *
+-----------------------------------------------------------------------
+----
  * Returns the 8-bit value in 'nla''s payload.
  * ---------------------------------------------------------------------------
  */
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h
index 8f30800..80f98dd 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -98,7 +98,7 @@ UINT32 NlMsgSize(const PNL_MSG_HDR nlh);  PCHAR NlMsgPayload(const PNL_MSG_HDR nlh);
 UINT32 NlMsgPayloadLen(const PNL_MSG_HDR nlh);  PNL_ATTR NlMsgAttrs(const PNL_MSG_HDR nlh); -INT NlMsgAttrLen(const PNL_MSG_HDR nlh);
+UINT32 NlMsgAttrLen(const PNL_MSG_HDR nlh);

 /* Netlink message parse */
 PNL_MSG_HDR NlMsgNext(const PNL_MSG_HDR nlh); @@ -130,6 +130,17 @@ BOOLEAN NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,  BOOLEAN NlParseNested(const PNL_ATTR, const NL_POLICY policy[],
                       PNL_ATTR attrs[], UINT32 n_attrs);

+/*
+ *
+-----------------------------------------------------------------------
+---
+ * Returns the length of attribute.
+ *
+-----------------------------------------------------------------------
+---
+ */
+static __inline UINT16
+NlAttrLen(const PNL_ATTR nla)
+{
+    return nla->nlaLen;
+}
+
 /* Netlink attribute validation */
 BOOLEAN NlAttrValidate(const PNL_ATTR, const PNL_POLICY);

diff --git a/datapath-windows/ovsext/Types.h b/datapath-windows/ovsext/Types.h index b2ef48c..5d2744b 100644
--- a/datapath-windows/ovsext/Types.h
+++ b/datapath-windows/ovsext/Types.h
@@ -31,6 +31,7 @@ typedef uint8 __u8;

 /* Defines the  userspace specific data types for file
  * included within kernel only. */
+typedef UINT8 BE8;
 typedef UINT16 BE16;
 typedef UINT32 BE32;
 typedef UINT64 BE64;
--
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=f6EhnZ0ORGZNt5QbYmRaOxfWfx%2Bqd3KEiPf3%2FYaollU%3D%0A&m=YTLjIrV5b7Up%2BwxCwaGwtB8FpUmOE3cxwFo3AIUf3SE%3D%0A&s=91bdf8b1a9a1ac15a3b4a14e8e3c3e34f2a988e5feb5f8a7eaa3a520c322629f



More information about the dev mailing list