From patchwork Fri Feb 19 10:35:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sourabh.bansal@wipro.com X-Patchwork-Id: 585132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 0536C1401DA for ; Fri, 19 Feb 2016 21:36:18 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id D137A10BA3; Fri, 19 Feb 2016 02:36:17 -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 3BBA110B9B for ; Fri, 19 Feb 2016 02:36:16 -0800 (PST) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id B7F781633AC for ; Fri, 19 Feb 2016 03:36:15 -0700 (MST) X-ASG-Debug-ID: 1455878174-0b3237555044ef0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar6.cudamail.com with ESMTP id 2PBa5UjcGF47Tt4m (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 19 Feb 2016 03:36:14 -0700 (MST) X-Barracuda-Envelope-From: sourabh.bansal@wipro.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO wipro-chn-out01.wipro.com) (203.91.208.14) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 19 Feb 2016 10:36:13 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at wipro.com designates 203.91.208.14 as permitted sender) X-Barracuda-Apparent-Source-IP: 203.91.208.14 X-Barracuda-RBL-IP: 203.91.208.14 X-AuditID: cb5bdd88-f79ee6d000001534-b7-56c6f0194895 X-Invalid-Recipients: Received: from BLR-OUT-EDG03.wipro.com ( [203.91.201.88]) by wipro-chn-out01.wipro.com (Symantec Mail Security) with SMTP id 58.2A.05428.910F6C65; Fri, 19 Feb 2016 16:06:09 +0530 (IST) Received: from BLR-EC-MBX7.wipro.com (10.208.51.117) by BLR-OUT-EDG03.wipro.com (203.91.193.33) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 19 Feb 2016 16:06:00 +0530 Received: from wipro-blr-tls01.wipro.com (203.91.193.39) by BLR-EC-MBX7.wipro.com (10.208.51.117) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 19 Feb 2016 16:06:00 +0530 Received: from APC01-SG2-obe.outbound.protection.outlook.com (65.55.88.240) by wipro-blr-tls01.wipro.com (203.91.193.39) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 19 Feb 2016 16:05:57 +0530 Received: from HKXPR03MB0725.apcprd03.prod.outlook.com (10.161.181.139) by SG2PR0301MB1334.apcprd03.prod.outlook.com (10.162.203.26) with Microsoft SMTP Server (TLS) id 15.1.409.15; Fri, 19 Feb 2016 10:35:57 +0000 Received: from HKXPR03MB0725.apcprd03.prod.outlook.com ([10.161.181.139]) by HKXPR03MB0725.apcprd03.prod.outlook.com ([10.161.181.139]) with mapi id 15.01.0409.017; Fri, 19 Feb 2016 10:35:57 +0000 X-CudaMail-Envelope-Sender: sourabh.bansal@wipro.com From: To: X-CudaMail-MID: CM-E1-218005197 X-CudaMail-DTE: 021916 X-CudaMail-Originating-IP: 203.91.208.14 Thread-Topic: [ovs-dev] : ovs-appctl dump and flush command for userspace conntrack X-ASG-Orig-Subj: [##CM-E1-218005197##]RE: [ovs-dev] : ovs-appctl dump and flush command for userspace conntrack Thread-Index: AdFpgYLIxVQzKQqpRc+LYimoYzr8QwBEy5aAABsOqWA= Date: Fri, 19 Feb 2016 10:35:57 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: ovn.org; dkim=none (message not signed) header.d=none; ovn.org; dmarc=none action=none header.from=wipro.com; x-originating-ip: [203.145.180.8] x-microsoft-exchange-diagnostics: 1; SG2PR0301MB1334; 5:eSEEYdyZEu3ICmmEe2No56BXk4pg8mUkutGfdi/uy4mwLcsaRei5ktMIW99XhjLOktaaPQPSfc4i3vYojCThpWAnHWu+78I24Eviw4IAY7ppSvZI7nyKBnd+fOJAlpmXFXbvBh8Z2TJDK/V/3Ljisg==; 24:fTRNVo+6+CevJC40vEElOjeHwObGP9Q9S3FEnwx/7ynZ5PyVuNq1IDhn1Tb47eMmSxMvTA0QxoFugNU9QGu432YQUIkgJj2cjWGRqKNsxkM= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR0301MB1334; x-ms-office365-filtering-correlation-id: a493ca78-7725-4b9d-53da-08d3391873d0 x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(62627912741753); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(61426038)(61427038); SRVR:SG2PR0301MB1334; BCL:0; PCL:0; RULEID:; SRVR:SG2PR0301MB1334; x-forefront-prvs: 08572BD77F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(52604005)(50944005)(24454002)(377454003)(377424004)(13464003)(4326007)(77096005)(74316001)(5003600100002)(122556002)(2950100001)(5890100001)(5008740100001)(189998001)(1096002)(66066001)(107886002)(76176999)(76576001)(5002640100001)(54356999)(10400500002)(5001960100002)(110136002)(92566002)(1220700001)(2906002)(50986999)(33656002)(3280700002)(40100003)(3846002)(6116002)(87936001)(4001430100002)(102836003)(15975445007)(586003)(3660700001)(15974865002)(11100500001)(19580395003)(5004730100002)(19580405001)(4001150100001)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:SG2PR0301MB1334; H:HKXPR03MB0725.apcprd03.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Feb 2016 10:35:57.2996 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 258ac4e4-146a-411e-9dc8-79a9e12fd6da X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR0301MB1334 X-OrganizationHeadersPreserved: SG2PR0301MB1334.apcprd03.prod.outlook.com X-CrossPremisesHeadersPromoted: BLR-HES-EDG02.wipro.com X-CrossPremisesHeadersFiltered: BLR-HES-EDG02.wipro.com X-CFilter-Loop: Reflected X-GBUdb-Analysis: 0, 203.91.208.14, Ugly c=0.372106 p=-0.351351 Source Normal X-MessageSniffer-Rules: 0-0-0-14804-c X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1455878174 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC0_MISMATCH_TO, BSF_SC5_MJ1963, NO_REAL_NAME, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.27156 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: dev@openvswitch.org Subject: Re: [ovs-dev] : ovs-appctl dump and flush command for userspace conntrack 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: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" Hi Joe, Thanks for pointing out my mistake. Please find below updated one. m 69e63a45e2773c124deb885bbc3d5deb3e032126 Mon Sep 17 00:00:00 2001 From: soumyadeep chowdhury Date: Fri, 19 Feb 2016 07:39:34 -0500 Subject: [PATCH 4/4] Write the functions for dump-conntrack and flush-conntrack Signed-off-by: Sourabh Bansal --- ovs-userconntrack_20151115/lib/dpif-netdev.c | 82 ++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) dpif_netdev_init(void) @@ -728,6 +806,10 @@ dpif_netdev_init(void) unixctl_command_register("dpif-netdev/pmd-stats-clear", "[dp]", 0, 1, dpif_netdev_pmd_info, (void *)&clear_aux); + unixctl_command_register("dump-conntrack", "Dump the entire conntrack table", + 0, 0, dpif_netdev_dump_conntrack, NULL); + unixctl_command_register("flush-conntrack", "Flush the entire conntrack table", + 0, 0, dpif_netdev_flush_conntrack, NULL); return 0; } Regards, Sourabh Bansal -----Original Message----- From: Joe Stringer [mailto:joe@ovn.org] Sent: Friday, February 19, 2016 3:08 AM To: Sourabh Bansal (NEP) Cc: Daniele Di Proietto ; ovs dev Subject: Re: [ovs-dev] : ovs-appctl dump and flush command for userspace conntrack On 17 February 2016 at 04:50, wrote: > Hi Daniele, > > Like to contribute the following changes to your userconntrack branch. > Please review and provide your comments > > Change Description: > > This implementation is based on top of this branch (By Daniele Di Proietto): > https://github.com/ddiproietto/ovs/tree/userconntrack_20151115 > > and this provides following two commands to ovs-appctl command - > > > 1. Ovs-appctl dump-conntrack - To dump the conntrack table entries > > 2. Ovs-appctl flush-conntrack - To flush the conntrack table entries > > Corresponding function implementations are - > dpif_netdev_dump_conntrack() > dpif_netdev_flush_conntrack() > > and these functions are registered with unixctl_command_register() so > that it can be accessed via ovs-appctl command > > List of change files: > > 1. /lib/dpif-netdev.c This functionality is already available here, in the same codebase: https://github.com/ddiproietto/ovs/blob/userconntrack_20151115/lib/dpctl.c#L1246 > Change Diff: > > *** /home/bansal/submission_code/ovs-userconntrack_20151115/lib/dpif-netdev.c 2016-02-17 10:00:12.114559489 -0500 > --- /home/bansal/orig/ovs-userconntrack_20151115/lib/dpif-netdev.c 2015-11-16 01:07:25.000000000 -0500 > *************** > *** 715,797 **** The usual way to prepare and send patches for projects like this is using "git format-patch" or "git send-email". > unixctl_command_reply(conn, ds_cstr(&reply)); > ds_destroy(&reply); > } > - > - /*This function will dump the entries prestent in conntrack table*/ > - static void > - dpif_netdev_dump_conntrack(struct unixctl_conn *conn, int argc, const char *argv[], > - void *aux OVS_UNUSED) > - { > - struct dp_netdev *dp = NULL; > - struct ct_dpif_dump_state *dump; > - struct ct_dpif_entry cte; > - uint16_t *pzone = NULL; > - struct dpif *dpif; > - > - ovs_mutex_lock(&dp_netdev_mutex); > - > - if (argc == 2) { > - dp = shash_find_data(&dp_netdevs, argv[1]); > - } else if (shash_count(&dp_netdevs) == 1) { > - /* There's only one datapath */ > - dp = shash_first(&dp_netdevs)->data; > - } > - > - if (!dp) { > - ovs_mutex_unlock(&dp_netdev_mutex); > - unixctl_command_reply_error(conn, > - "please specify an existing datapath"); > - return; > - } > - ovs_mutex_unlock(&dp_netdev_mutex); > - dpif = dp->dpif; > - > - int verbosity = 1; > - int print_statistics = 0; > - > - struct ds s = DS_EMPTY_INITIALIZER; > - > - ct_dpif_dump_start(dpif, &dump, pzone); > - while (!ct_dpif_dump_next(dump, &cte)) { > - > - ct_dpif_format_entry(&cte, &s, verbosity, > - print_statistics); > - ct_dpif_entry_uninit(&cte); > - } > - > - unixctl_command_reply(conn, ds_cstr(&s)); > - ds_destroy(&s); > - > - ct_dpif_dump_done(dump); > - return; > - } > - > - /*This function will flush the entries prestent in conntrack table*/ > - static void > - dpif_netdev_flush_conntrack(struct unixctl_conn *conn, int argc, const char *argv[], > - void *aux OVS_UNUSED) > - { > - struct dp_netdev *dp = NULL; > - struct dpif *dpif; > - uint16_t *pzone = NULL; > - > - ovs_mutex_lock(&dp_netdev_mutex); > - if (argc == 2) { > - dp = shash_find_data(&dp_netdevs, argv[1]); > - } else if (shash_count(&dp_netdevs) == 1) { > - dp = shash_first(&dp_netdevs)->data; > - } > - > - ovs_mutex_unlock(&dp_netdev_mutex); > - > - struct ds s = DS_EMPTY_INITIALIZER; > - > - dpif = dp->dpif; > - ct_dpif_flush(dpif,pzone); > - > - unixctl_command_reply(conn, ds_cstr(&s)); > - ds_destroy(&s); > - > - } > > static int > dpif_netdev_init(void) > --- 715,720 ---- > *************** > *** 805,814 **** > unixctl_command_register("dpif-netdev/pmd-stats-clear", "[dp]", > 0, 1, dpif_netdev_pmd_info, > (void *)&clear_aux); > - unixctl_command_register("dump-conntrack", "Dump the entire conntrack table", > - 0, 0, dpif_netdev_dump_conntrack, NULL); > - unixctl_command_register("flush-conntrack", "Flush the entire conntrack table", > - 0, 0, dpif_netdev_flush_conntrack, NULL); > return 0; > } It looks like your diff is in the reverse order of what you intended. > Regards, > Sourabh Bansal > The information contained in this electronic message and any > attachments to this message are intended for the exclusive use of the > addressee(s) and may contain proprietary, confidential or privileged > information. If you are not the intended recipient, you should not > disseminate, distribute or copy this e-mail. Please notify the sender > immediately and destroy all copies of this message and any > attachments. WARNING: Computer viruses can be transmitted via email. > The recipient should check this email and any attachments for the > presence of viruses. The company accepts no liability for any damage > caused by any virus transmitted by this email. www.wipro.com This disclaimer makes entirely *no* sense on a public mailing list, please refrain from using it. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com diff --git a/ovs-userconntrack_20151115/lib/dpif-netdev.c b/ovs-userconntrack_20151115/lib/dpif-netdev.c index 340e37c..f950780 100644 --- a/ovs-userconntrack_20151115/lib/dpif-netdev.c +++ b/ovs-userconntrack_20151115/lib/dpif-netdev.c @@ -715,6 +715,84 @@ dpif_netdev_pmd_info(struct unixctl_conn *conn, int argc, const char *argv[], unixctl_command_reply(conn, ds_cstr(&reply)); ds_destroy(&reply); } + +/*This function will dump the entries present in conntrack table*/ +static void +dpif_netdev_dump_conntrack(struct unixctl_conn *conn, int argc, const char *argv[], + void *aux OVS_UNUSED) +{ + struct dp_netdev *dp = NULL; + struct ct_dpif_dump_state *dump; + struct ct_dpif_entry cte; + uint16_t *pzone = NULL; + struct dpif *dpif; + + ovs_mutex_lock(&dp_netdev_mutex); + + if (argc == 2) { + dp = shash_find_data(&dp_netdevs, argv[1]); + } else if (shash_count(&dp_netdevs) == 1) { + /* There's only one datapath */ + dp = shash_first(&dp_netdevs)->data; + } + + if (!dp) { + ovs_mutex_unlock(&dp_netdev_mutex); + unixctl_command_reply_error(conn, + "please specify an existing datapath"); + return; + } + ovs_mutex_unlock(&dp_netdev_mutex); + dpif = dp->dpif; + + int verbosity = 1; + int print_statistics = 0; + + struct ds s = DS_EMPTY_INITIALIZER; + + ct_dpif_dump_start(dpif, &dump, pzone); + while (!ct_dpif_dump_next(dump, &cte)) { + + ct_dpif_format_entry(&cte, &s, verbosity, + print_statistics); + ct_dpif_entry_uninit(&cte); + } + + unixctl_command_reply(conn, ds_cstr(&s)); + ds_destroy(&s); + + ct_dpif_dump_done(dump); + return; +} + +/*This function will flush the entries present in conntrack table*/ +static void +dpif_netdev_flush_conntrack(struct unixctl_conn *conn, int argc, const char *argv[], + void *aux OVS_UNUSED) +{ + struct dp_netdev *dp = NULL; + struct dpif *dpif; + uint16_t *pzone = NULL; + + ovs_mutex_lock(&dp_netdev_mutex); + if (argc == 2) { + dp = shash_find_data(&dp_netdevs, argv[1]); + } else if (shash_count(&dp_netdevs) == 1) { + dp = shash_first(&dp_netdevs)->data; + } + + ovs_mutex_unlock(&dp_netdev_mutex); + + struct ds s = DS_EMPTY_INITIALIZER; + + dpif = dp->dpif; + ct_dpif_flush(dpif,pzone); + + unixctl_command_reply(conn, ds_cstr(&s)); + ds_destroy(&s); + +} + static int