summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Netlink
diff options
context:
space:
mode:
authorSairam Venugopal <vsairam@vmware.com>2016-07-01 13:49:26 -0700
committerGurucharan Shetty <guru@ovn.org>2016-07-01 20:51:57 -0700
commit9f8407b9027df9614909bfdee49ab43f0612f39b (patch)
treeab0a91f730ea4c7577bf726c92ed125fd970b79f /datapath-windows/ovsext/Netlink
parent3c1c21190dbeff8845ee276ea1f4bf3c789cb76b (diff)
downloadopenvswitch-9f8407b9027df9614909bfdee49ab43f0612f39b.tar.gz
datapath-windows: Add support for Netfilter netlink message
Introduce NF_GEN_MSG_HDR similar to GENL_MSG_HDR that will be used for communicating via netfilter-netlink channel. This will be used by userspace to retrieve and modify Conntrack data in Windows. Signed-off-by: Sairam Venugopal <vsairam@vmware.com> Acked-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Nithin Raju <nithin@vmware.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
Diffstat (limited to 'datapath-windows/ovsext/Netlink')
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.c11
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.h9
-rw-r--r--datapath-windows/ovsext/Netlink/NetlinkProto.h9
3 files changed, 27 insertions, 2 deletions
diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index 1eec320e2..ccf9ec1f0 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -672,6 +672,17 @@ NlMsgAttrsLen(const PNL_MSG_HDR nlh)
return NlHdrPayloadLen(nlh) - GENL_HDRLEN - OVS_HDRLEN;
}
+/*
+ * ---------------------------------------------------------------------------
+ * Returns size of to nfnlmsg attributes.
+ * ---------------------------------------------------------------------------
+ */
+UINT32
+NlNfMsgAttrsLen(const PNL_MSG_HDR nlh)
+{
+ return NlHdrPayloadLen(nlh) - NF_GEN_MSG_HDRLEN - OVS_HDRLEN;
+}
+
/* Netlink message parse. */
/*
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h
index b1b3bed51..5261b9ece 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -27,10 +27,14 @@
*/
typedef struct _OVS_MESSAGE {
NL_MSG_HDR nlMsg;
- GENL_MSG_HDR genlMsg;
+ union {
+ GENL_MSG_HDR genlMsg;
+ NF_GEN_MSG_HDR nfGenMsg;
+ };
OVS_HDR ovsHdr;
/* Variable length nl_attrs follow. */
} OVS_MESSAGE, *POVS_MESSAGE;
+BUILD_ASSERT_DECL(sizeof(GENL_MSG_HDR) == sizeof(NF_GEN_MSG_HDR));
/*
* Structure of an error message sent as a reply from kernel.
@@ -107,6 +111,7 @@ PCHAR NlHdrPayload(const PNL_MSG_HDR nlh);
UINT32 NlHdrPayloadLen(const PNL_MSG_HDR nlh);
PNL_ATTR NlMsgAttrs(const PNL_MSG_HDR nlh);
UINT32 NlMsgAttrsLen(const PNL_MSG_HDR nlh);
+UINT32 NlNfMsgAttrsLen(const PNL_MSG_HDR nlh);
/* Netlink message parse */
PNL_MSG_HDR NlMsgNext(const PNL_MSG_HDR nlh);
@@ -135,7 +140,7 @@ const PNL_ATTR NlAttrFindNested(const PNL_ATTR nla,
UINT16 type);
BOOLEAN NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen, const NL_POLICY policy[],
- const UINT32 numPolicy, PNL_ATTR attrs[],
+ const UINT32 numPolicy, PNL_ATTR attrs[],
UINT32 numAttrs);
BOOLEAN NlAttrParseNested(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
UINT32 totalAttrLen, const NL_POLICY policy[],
diff --git a/datapath-windows/ovsext/Netlink/NetlinkProto.h b/datapath-windows/ovsext/Netlink/NetlinkProto.h
index f2e9aee47..beb14d552 100644
--- a/datapath-windows/ovsext/Netlink/NetlinkProto.h
+++ b/datapath-windows/ovsext/Netlink/NetlinkProto.h
@@ -98,6 +98,14 @@ typedef struct _GENL_MSG_HDR {
} GENL_MSG_HDR, *PGENL_MSG_HDR;
BUILD_ASSERT_DECL(sizeof(GENL_MSG_HDR) == 4);
+/* Netfilter Generic Message */
+typedef struct _NF_GEN_MSG_HDR {
+ UINT8 nfgenFamily; /* AF_xxx */
+ UINT8 version; /* nfnetlink version */
+ UINT16 resId; /* resource id */
+} NF_GEN_MSG_HDR, *PNF_GEN_MSG_HDR;
+BUILD_ASSERT_DECL(sizeof(NF_GEN_MSG_HDR) == 4);
+
/* Netlink attributes */
typedef struct _NL_ATTR {
UINT16 nlaLen;
@@ -113,6 +121,7 @@ BUILD_ASSERT_DECL(sizeof(NL_ATTR) == 4);
#define NLMSG_HDRLEN ((INT) NLMSG_ALIGN(sizeof(NL_MSG_HDR)))
#define GENL_HDRLEN NLMSG_ALIGN(sizeof(GENL_MSG_HDR))
+#define NF_GEN_MSG_HDRLEN NLMSG_ALIGN(sizeof(NF_GEN_MSG_HDR))
#define OVS_HDRLEN NLMSG_ALIGN(sizeof(OVS_HDR))
#define NLA_HDRLEN ((INT) NLA_ALIGN(sizeof(NL_ATTR)))