Re: [ovs-dev] [PATCH v4 6/9] ofproto-dpif: Consume CT_Zone, and CT_Timeout_Policy tables

2019-08-19 Thread Darrell Ball
On Mon, Aug 19, 2019 at 11:12 AM Yi-Hung Wei  wrote:

> On Fri, Aug 16, 2019 at 5:10 PM Darrell Ball  wrote:
> >
> > Thanks for the patch
> >
> > Pls let me know if the following incremental works for you.
> >
> > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> > index 244155a..cb8b51e 100644
> > --- a/ofproto/ofproto-dpif.c
> > +++ b/ofproto/ofproto-dpif.c
> > @@ -168,6 +168,12 @@ struct ct_timeout_policy {
> >   * "ct_tp_kill_list" list. */
> >  };
> >
> > +/* Periodically try to purge deleted timeout policies from the
> datapath. Retry
> > + * may be necessary if the kernel datapath has a non-zero datapath flow
> > + * reference count for the timeout policy. */
> > +#define TIMEOUT_POLICY_CLEANUP_INTERVAL (30) /* 5 minutes. */
> > +static long long int timeout_policy_cleanup_timer;
>
> Thanks for adding the clean up debounce and makes the comment clearer.
>
> I will fold in your diff and the following minor change in the next
> version.
>
> #define TIMEOUT_POLICY_CLEANUP_INTERVAL (2) /* 20 seconds. */
> static long long int timeout_policy_cleanup_timer = LLONG_MIN;
>

looks fine


>
> I changed the interval to be two times of the revlidataion cycle
> because we should be able to remove the unused timeout policies in the
> kernel datapath after the next flow revalidation cycle.


> Thanks,
>
> -Yi-Hung
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v4 6/9] ofproto-dpif: Consume CT_Zone, and CT_Timeout_Policy tables

2019-08-19 Thread Yi-Hung Wei
On Fri, Aug 16, 2019 at 5:10 PM Darrell Ball  wrote:
>
> Thanks for the patch
>
> Pls let me know if the following incremental works for you.
>
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index 244155a..cb8b51e 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -168,6 +168,12 @@ struct ct_timeout_policy {
>   * "ct_tp_kill_list" list. */
>  };
>
> +/* Periodically try to purge deleted timeout policies from the datapath. 
> Retry
> + * may be necessary if the kernel datapath has a non-zero datapath flow
> + * reference count for the timeout policy. */
> +#define TIMEOUT_POLICY_CLEANUP_INTERVAL (30) /* 5 minutes. */
> +static long long int timeout_policy_cleanup_timer;

Thanks for adding the clean up debounce and makes the comment clearer.

I will fold in your diff and the following minor change in the next version.

#define TIMEOUT_POLICY_CLEANUP_INTERVAL (2) /* 20 seconds. */
static long long int timeout_policy_cleanup_timer = LLONG_MIN;

I changed the interval to be two times of the revlidataion cycle
because we should be able to remove the unused timeout policies in the
kernel datapath after the next flow revalidation cycle.

Thanks,

-Yi-Hung
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v4 6/9] ofproto-dpif: Consume CT_Zone, and CT_Timeout_Policy tables

2019-08-16 Thread Darrell Ball
Thanks for the patch

Pls let me know if the following incremental works for you.

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 244155a..cb8b51e 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -168,6 +168,12 @@ struct ct_timeout_policy {
  * "ct_tp_kill_list" list. */
 };

+/* Periodically try to purge deleted timeout policies from the datapath.
Retry
+ * may be necessary if the kernel datapath has a non-zero datapath flow
+ * reference count for the timeout policy. */
+#define TIMEOUT_POLICY_CLEANUP_INTERVAL (30) /* 5 minutes. */
+static long long int timeout_policy_cleanup_timer;
+
 struct ct_zone {
 uint16_t zone_id;
 struct ct_timeout_policy *ct_tp;
@@ -5294,19 +5300,20 @@ ct_zone_config_uninit(struct dpif_backer *backer)
 static void
 ct_zone_timeout_policy_sweep(struct dpif_backer *backer)
 {
-if (!ovs_list_is_empty(>ct_tp_kill_list)) {
+if (!ovs_list_is_empty(>ct_tp_kill_list)
+&& time_msec() >= timeout_policy_cleanup_timer) {
 struct ct_timeout_policy *ct_tp, *next;

 LIST_FOR_EACH_SAFE (ct_tp, next, list_node,
>ct_tp_kill_list) {
-int err = ct_dpif_del_timeout_policy(backer->dpif,
ct_tp->tp_id);
-if (!err) {
+if (!ct_dpif_del_timeout_policy(backer->dpif, ct_tp->tp_id)) {
 ovs_list_remove(_tp->list_node);
 ct_timeout_policy_destroy(ct_tp, backer->tp_ids);
 } else {
-VLOG_INFO_RL(, "failed to delete timeout policy id = "
- "%"PRIu32" %s", ct_tp->tp_id,
ovs_strerror(err));
+/* INFO log raised by 'dpif' layer. */
 }
 }
+timeout_policy_cleanup_timer = time_msec() +
+TIMEOUT_POLICY_CLEANUP_INTERVAL;
 }
 }

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 72c9297..56f42c0 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -158,22 +158,23 @@ struct ct_zone {
 uint16_t zone;
 struct simap tp;/* A map from timeout policy attribute to
  * timeout value. */
-unsigned int last_used; /* The last idl_seqno that this struct is
used
+unsigned int last_used; /* The last idl_seqno that this 'ct_zone'
used
  * in OVSDB. This number is used for
garbage
  * collection. */
-struct hmap_node node;  /* Element in struct datapath_cfgs's
- * "ct_zone_timeout_policies" hmap. */
+struct hmap_node node;  /* Node in 'struct datapath' 'ct_zones'
+ * hmap. */
 };

 /* Internal representation of datapath configuration table in OVSDB. */
 struct datapath {
 char *type; /* Datapath type. */
-struct hmap ct_zones;   /* "struct ct_zone"s indexed by zone id. */
-struct hmap_node node;  /* In 'all_datapath_cfgs'. */
+struct hmap ct_zones;   /* Map of 'struct ct_zone' elements,
indexed
+ * by 'zone'. */
+struct hmap_node node;  /* Node in 'all_datapaths' hmap. */
 const struct ovsrec_datapath *dp_cfg;
-unsigned int last_used; /* The last idl_seqno that this struct is
used
- * in OVSDB. This number is used for
garbage
- * collection. */
+unsigned int last_used; /* The last idl_seqno that this 'datapath'
+ * used in OVSDB. This number is used for
+ * garbage collection. */
 };

 /* All bridges, indexed by name. */
@@ -712,10 +713,9 @@ static void
 update_datapath_cfgs(const struct ovsrec_open_vswitch *cfg)
 {
 struct datapath *dp, *next;
-size_t i;

-/* Add new datapath configs. */
-for (i = 0; i < cfg->n_datapaths; i++) {
+/* Add new 'datapath's or update existing ones. */
+for (size_t i = 0; i < cfg->n_datapaths; i++) {
 const struct ovsrec_datapath *dp_cfg = cfg->value_datapaths[i];
 char *dp_name = cfg->key_datapaths[i];

@@ -726,7 +726,7 @@ update_datapath_cfgs(const struct ovsrec_open_vswitch
*cfg)
 dp->last_used = idl_seqno;
 }

-/* Get rid of deleted datapath configs. */
+/* Purge deleted 'datapath's. */
 HMAP_FOR_EACH_SAFE (dp, next, node, _datapaths) {
 if (dp->last_used != idl_seqno) {
 datapath_destroy(dp);
@@ -740,7 +740,8 @@ reconfigure_ct_zones(struct datapath *dp)
 const struct ovsrec_datapath *dp_cfg = dp->dp_cfg;
 struct ct_zone *ct_zone, *next;

-/* Loop through all zones. Add or update configs. */
+/* Add new 'ct_zone's or update existing 'ct_zone's based on the
database
+ * state. */
 for (size_t i = 0; i < dp_cfg->n_ct_zones; i++) {
 uint16_t zone = dp_cfg->key_ct_zones[i];
 struct ovsrec_ct_zone *zone_cfg = dp_cfg->value_ct_zones[i];
@@ -763,7