From patchwork Wed Dec 2 19:46:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Di Proietto X-Patchwork-Id: 551689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 371D41402D5 for ; Thu, 3 Dec 2015 06:47:09 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7323510AB4; Wed, 2 Dec 2015 11:46:53 -0800 (PST) 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 133A510AA9 for ; Wed, 2 Dec 2015 11:46:52 -0800 (PST) Received: from bar3.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 966B9162081 for ; Wed, 2 Dec 2015 12:46:51 -0700 (MST) X-ASG-Debug-ID: 1449085611-03dd7b0fba6f9b20001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar3.cudamail.com with ESMTP id dPKxhtQKaMHNjwEG (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 02 Dec 2015 12:46:51 -0700 (MST) X-Barracuda-Envelope-From: diproiettod@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO smtp-outbound-2.vmware.com) (208.91.2.13) by mx3-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 2 Dec 2015 19:46:51 -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.13 X-Barracuda-RBL-IP: 208.91.2.13 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id AB86D28770 for ; Wed, 2 Dec 2015 11:46:49 -0800 (PST) Received: from sc9-mailhost2.vmware.com (unknown [10.33.74.48]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 84F2F183EC; Wed, 2 Dec 2015 11:46:50 -0800 (PST) X-CudaMail-Envelope-Sender: diproiettod@vmware.com From: Daniele Di Proietto To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V2-1201047536 X-CudaMail-DTE: 120215 X-CudaMail-Originating-IP: 208.91.2.13 Date: Wed, 2 Dec 2015 11:46:19 -0800 X-ASG-Orig-Subj: [##CM-V2-1201047536##][PATCH v3 05/12] dpif-netlink: Implement ct_dump_{start, next, done}. Message-Id: <1449085586-13342-6-git-send-email-diproiettod@vmware.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449085586-13342-1-git-send-email-diproiettod@vmware.com> References: <1449085586-13342-1-git-send-email-diproiettod@vmware.com> X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1449085611 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 v3 05/12] dpif-netlink: Implement ct_dump_{start, next, done}. 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" These member functions are used by the ct-dpif module to provide its services. They're implemented using the netlink-conntrack module. N.B. The Linux kernel datapaths share the connection tracker among them and with the rest of the system. Therefore the operations are not really dpif specific. Signed-off-by: Daniele Di Proietto --- lib/dpif-netlink.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index fa995c1..189506c 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -40,6 +40,7 @@ #include "netdev.h" #include "netdev-linux.h" #include "netdev-vport.h" +#include "netlink-conntrack.h" #include "netlink-notifier.h" #include "netlink-socket.h" #include "netlink.h" @@ -2279,6 +2280,57 @@ dpif_netlink_get_datapath_version(void) return version_str; } +struct dpif_netlink_ct_dump_state { + struct ct_dpif_dump_state up; + struct nl_ct_dump_state *nl_ct_dump; +}; + +static int +dpif_netlink_ct_dump_start(struct dpif *dpif OVS_UNUSED, + struct ct_dpif_dump_state **dump_, + const uint16_t *zone) +{ + struct dpif_netlink_ct_dump_state *dump; + int err; + + dump = xzalloc(sizeof *dump); + err = nl_ct_dump_start(&dump->nl_ct_dump, zone); + if (err) { + free(dump); + return err; + } + + *dump_ = &dump->up; + + return 0; +} + +static int +dpif_netlink_ct_dump_next(struct dpif *dpif OVS_UNUSED, + struct ct_dpif_dump_state *dump_, + struct ct_dpif_entry *entry) +{ + struct dpif_netlink_ct_dump_state *dump; + + INIT_CONTAINER(dump, dump_, up); + + return nl_ct_dump_next(dump->nl_ct_dump, entry); +} + +static int +dpif_netlink_ct_dump_done(struct dpif *dpif OVS_UNUSED, + struct ct_dpif_dump_state *dump_) +{ + struct dpif_netlink_ct_dump_state *dump; + int err; + + INIT_CONTAINER(dump, dump_, up); + + err = nl_ct_dump_done(dump->nl_ct_dump); + free(dump); + return err; +} + const struct dpif_class dpif_netlink_class = { "system", NULL, /* init */ @@ -2319,9 +2371,9 @@ const struct dpif_class dpif_netlink_class = { NULL, /* enable_upcall */ NULL, /* disable_upcall */ dpif_netlink_get_datapath_version, /* get_datapath_version */ - NULL, /* ct_dump_start */ - NULL, /* ct_dump_next */ - NULL, /* ct_dump_done */ + dpif_netlink_ct_dump_start, + dpif_netlink_ct_dump_next, + dpif_netlink_ct_dump_done, NULL, /* ct_flush */ };