[ovs-dev] <conntrack><dpif-netdev>: ovs-appctl dump and flush command for userspace conntrack

Joe Stringer joe at ovn.org
Thu Feb 18 21:38:23 UTC 2016


On 17 February 2016 at 04:50,  <sourabh.bansal at wipro.com> 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.



More information about the dev mailing list