From patchwork Thu Jun 30 00:08:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sairam Venugopal X-Patchwork-Id: 642271 X-Patchwork-Delegate: guru@ovn.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rg0KQ2Gjdz9snl for ; Thu, 30 Jun 2016 10:09:46 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 674E81070F; Wed, 29 Jun 2016 17:09:19 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id A4F97102A9 for ; Wed, 29 Jun 2016 17:09:17 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 1385F161779 for ; Wed, 29 Jun 2016 18:09:17 -0600 (MDT) X-ASG-Debug-ID: 1467245356-0b32371666944c0001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar6.cudamail.com with ESMTP id nvsMZBQfNQSMlSMV (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 29 Jun 2016 18:09:16 -0600 (MDT) X-Barracuda-Envelope-From: vsairam@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO smtp-outbound-1.vmware.com) (208.91.2.12) by mx3-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 30 Jun 2016 00:09:16 -0000 Received-SPF: error (mx3-pf2.cudamail.com: error in processing during lookup of vmware.com: DNS problem) X-Barracuda-Apparent-Source-IP: 208.91.2.12 X-Barracuda-RBL-IP: 208.91.2.12 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 771749814F for ; Wed, 29 Jun 2016 17:09:14 -0700 (PDT) Received: from localhost.localdomain (htb-1s-eng-dhcp151.eng.vmware.com [10.33.78.151]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 75C0D1855D; Wed, 29 Jun 2016 17:09:15 -0700 (PDT) X-CudaMail-Envelope-Sender: vsairam@vmware.com From: Sairam Venugopal To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V2-628063136 X-CudaMail-DTE: 062916 X-CudaMail-Originating-IP: 208.91.2.12 Date: Wed, 29 Jun 2016 17:08:44 -0700 X-ASG-Orig-Subj: [##CM-V2-628063136##][PATCH v4 02/11] datapath-windows: Add support for Netfilter netlink message Message-Id: <1467245333-8112-3-git-send-email-vsairam@vmware.com> X-Mailer: git-send-email 2.5.0.windows.1 In-Reply-To: <1467245333-8112-1-git-send-email-vsairam@vmware.com> References: <1467245333-8112-1-git-send-email-vsairam@vmware.com> X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1467245356 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-ASG-Whitelist: EmailCat (corporate) Subject: [ovs-dev] [PATCH v4 02/11] datapath-windows: Add support for Netfilter netlink message X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" 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 Acked-by: Paul-Daniel Boca Acked-by: Nithin Raju Acked-by: Nithin Raju --- datapath-windows/ovsext/Netlink/Netlink.c | 11 +++++++++++ datapath-windows/ovsext/Netlink/Netlink.h | 9 +++++++-- datapath-windows/ovsext/Netlink/NetlinkProto.h | 9 +++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c index 1eec320..ccf9ec1 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 b1b3bed..5261b9e 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 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)))