[ovs-dev] [PATCH 2/9] datapath-windows: Add support for Netfilter netlink message
Paul Boca
pboca at cloudbasesolutions.com
Thu Jun 23 19:49:01 UTC 2016
Acked-by: Paul-Daniel Boca <pboca at cloudbasesolutions.com>
> -----Original Message-----
> From: dev [mailto:dev-bounces at openvswitch.org] On Behalf Of Sairam
> Venugopal
> Sent: Tuesday, June 21, 2016 4:23 AM
> To: dev at openvswitch.org
> Subject: [ovs-dev] [PATCH 2/9] 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 at vmware.com>
> ---
> datapath-windows/ovsext/Netlink/Netlink.c | 11 +++++++++++
> datapath-windows/ovsext/Netlink/Netlink.h | 8 ++++++--
> datapath-windows/ovsext/Netlink/NetlinkProto.h | 9 +++++++++
> 3 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-
> windows/ovsext/Netlink/Netlink.c
> index 1eec320..a25a22a 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
> +NfNlMsgAttrsLen(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 b1b3bed..cce7ec3 100644
> --- a/datapath-windows/ovsext/Netlink/Netlink.h
> +++ b/datapath-windows/ovsext/Netlink/Netlink.h
> @@ -27,7 +27,10 @@
> */
> 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;
> @@ -107,6 +110,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 NfNlMsgAttrsLen(const PNL_MSG_HDR nlh);
>
> /* Netlink message parse */
> PNL_MSG_HDR NlMsgNext(const PNL_MSG_HDR nlh);
> @@ -135,7 +139,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 f2e9aee..beb14d5 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)))
>
> --
> 2.5.0.windows.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list