[ovs-dev] [PATCH v9 06/10] Add incremental proessing to lflow_run

2016-03-11 Thread Ryan Moats
From: RYAN D. MOATS 

This code changes lflow_run to do incremental process of the
logical flow table rather than processing the full table each run.

Signed-off-by: RYAN D. MOATS 
---
 ovn/controller/binding.c|3 ++
 ovn/controller/lflow.c  |   53 +--
 ovn/controller/lflow.h  |4 +-
 ovn/controller/ofctrl.c |4 +-
 ovn/controller/ofctrl.h |2 +
 ovn/controller/ovn-controller.c |5 +++-
 6 files changed, 58 insertions(+), 13 deletions(-)

diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index 602a8fe..87cae99 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -15,6 +15,7 @@
 
 #include 
 #include "binding.h"
+#include "lflow.h"
 
 #include "lib/bitmap.h"
 #include "lib/hmap.h"
@@ -139,6 +140,7 @@ remove_local_datapath(struct hmap *local_datapaths, 
unsigned int ins_seqno)
 if (ld) {
 hmap_remove(local_datapaths, &ld->hmap_node);
 hmap_remove(&local_datapaths_by_seqno, &ld->seqno_hmap_node);
+reset_flow_processing();
 }
 }
 
@@ -156,6 +158,7 @@ add_local_datapath(struct hmap *local_datapaths,
 hmap_insert(local_datapaths, &ld->hmap_node,
 binding_rec->datapath->tunnel_key);
 hmap_insert(&local_datapaths_by_seqno, &ld->seqno_hmap_node, ins_seqno);
+reset_flow_processing();
 }
 
 static void
diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
index 4856362..6d0d417 100644
--- a/ovn/controller/lflow.c
+++ b/ovn/controller/lflow.c
@@ -176,6 +176,20 @@ struct logical_datapath {
 enum ldp_type type; /* Type of logical datapath */
 };
 
+void reset_flow_processing(void);
+void ldp_port_create(uint32_t ins_seqno, char *name,
+ struct logical_datapath *ldp);
+void ldp_port_update(uint32_t ins_seqno, char *name,
+ struct logical_datapath *ldp);
+
+bool restart_flow_processing = false;
+
+void
+reset_flow_processing(void)
+{
+restart_flow_processing = true;
+}
+
 /* Contains "struct logical_datapath"s. */
 static struct hmap logical_datapaths = HMAP_INITIALIZER(&logical_datapaths);
 
@@ -208,6 +222,7 @@ ldp_create(const struct sbrec_datapath_binding *binding)
 const char *ls = smap_get(&binding->external_ids, "logical-switch");
 ldp->type = ls ? LDP_TYPE_SWITCH : LDP_TYPE_ROUTER;
 simap_init(&ldp->ports);
+reset_flow_processing();
 return ldp;
 }
 
@@ -224,6 +239,7 @@ ldp_free(struct logical_datapath *ldp)
 simap_destroy(&ldp->ports);
 hmap_remove(&logical_datapaths, &ldp->hmap_node);
 free(ldp);
+reset_flow_processing();
 }
 
 /* Whether a particular port has been seen or not
@@ -319,6 +335,7 @@ ldp_run(struct controller_ctx *ctx)
 binding->logical_port);
 if (!old || old->data != binding->tunnel_key) {
 simap_put(&ldp->ports, binding->logical_port, binding->tunnel_key);
+reset_flow_processing();
 }

 ldp_port_update(ins_seqno, binding->logical_port, ldp);
@@ -380,13 +397,21 @@ lflow_init(void)
 
 /* Translates logical flows in the Logical_Flow table in the OVN_SB database
  * into OpenFlow flows.  See ovn-architecture(7) for more information. */
-void
+unsigned int
 lflow_run(struct controller_ctx *ctx,
   const struct simap *ct_zones,
-  struct hmap *local_datapaths)
+  struct hmap *local_datapaths,
+  unsigned int seqno)
 {
 struct hmap flows = HMAP_INITIALIZER(&flows);
 uint32_t conj_id_ofs = 1;
+unsigned int processed_seqno = seqno;
+
+if (restart_flow_processing) {
+seqno = 0;
+ovn_flow_table_clear();
+restart_flow_processing = false;
+}
 
 ldp_run(ctx);
 
@@ -398,17 +423,29 @@ lflow_run(struct controller_ctx *ctx,
 OVSDB_IDL_CHANGE_MODIFY);
 unsigned int ins_seqno = sbrec_logical_flow_row_get_seqno(lflow,
 OVSDB_IDL_CHANGE_INSERT);
-// this offset is to protect the hard coded rules in physical.c
-ins_seqno += 4;
-
+if (del_seqno <= seqno && mod_seqno <= seqno && ins_seqno <= seqno) {
+continue;
+}
 /* if the row has a del_seqno > 0, then trying to process the
  * row isn't going to work (as it has already been freed).
- * Therefore all we can do is to pass the ins_seqno to 
+ * Therefore all we can do is to pass the offset ins_seqno to 
  * ofctrl_remove_flow() to remove the flow */
 if (del_seqno > 0) {
-ofctrl_remove_flow(ins_seqno);
+ofctrl_remove_flow(ins_seqno+4);
+if (del_seqno > processed_seqno) {
+processed_seqno = del_seqno;
+}
 continue;
 }
+if (mod_seqno > processed_seqno) {
+processed_seqno = mod_seqno;
+}
+if (ins_seqno > processed_seqno) {
+processed_seqno = ins_seqno;
+}
+
+  

Re: [ovs-dev] [PATCH v9 06/10] Add incremental proessing to lflow_run

2016-03-22 Thread Han Zhou
On Fri, Mar 11, 2016 at 1:06 PM, Ryan Moats  wrote:
>
> From: RYAN D. MOATS 
>
> This code changes lflow_run to do incremental process of the
> logical flow table rather than processing the full table each run.
>
> Signed-off-by: RYAN D. MOATS 
> ---
>  ovn/controller/binding.c|3 ++
>  ovn/controller/lflow.c  |   53
+--
>  ovn/controller/lflow.h  |4 +-
>  ovn/controller/ofctrl.c |4 +-
>  ovn/controller/ofctrl.h |2 +
>  ovn/controller/ovn-controller.c |5 +++-
>  6 files changed, 58 insertions(+), 13 deletions(-)
>
> diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
> index 602a8fe..87cae99 100644
> --- a/ovn/controller/binding.c
> +++ b/ovn/controller/binding.c
> @@ -15,6 +15,7 @@
>
>  #include 
>  #include "binding.h"
> +#include "lflow.h"
>
>  #include "lib/bitmap.h"
>  #include "lib/hmap.h"
> @@ -139,6 +140,7 @@ remove_local_datapath(struct hmap *local_datapaths,
unsigned int ins_seqno)
>  if (ld) {
>  hmap_remove(local_datapaths, &ld->hmap_node);
>  hmap_remove(&local_datapaths_by_seqno, &ld->seqno_hmap_node);
> +reset_flow_processing();
>  }
>  }
>
> @@ -156,6 +158,7 @@ add_local_datapath(struct hmap *local_datapaths,
>  hmap_insert(local_datapaths, &ld->hmap_node,
>  binding_rec->datapath->tunnel_key);
>  hmap_insert(&local_datapaths_by_seqno, &ld->seqno_hmap_node,
ins_seqno);
> +reset_flow_processing();
>  }
>
>  static void
> diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
> index 4856362..6d0d417 100644
> --- a/ovn/controller/lflow.c
> +++ b/ovn/controller/lflow.c
> @@ -176,6 +176,20 @@ struct logical_datapath {
>  enum ldp_type type; /* Type of logical datapath */
>  };
>
> +void reset_flow_processing(void);
> +void ldp_port_create(uint32_t ins_seqno, char *name,
> + struct logical_datapath *ldp);
> +void ldp_port_update(uint32_t ins_seqno, char *name,
> + struct logical_datapath *ldp);
> +
> +bool restart_flow_processing = false;
> +
> +void
> +reset_flow_processing(void)
> +{
> +restart_flow_processing = true;
> +}
> +
>  /* Contains "struct logical_datapath"s. */
>  static struct hmap logical_datapaths =
HMAP_INITIALIZER(&logical_datapaths);
>
> @@ -208,6 +222,7 @@ ldp_create(const struct sbrec_datapath_binding
*binding)
>  const char *ls = smap_get(&binding->external_ids, "logical-switch");
>  ldp->type = ls ? LDP_TYPE_SWITCH : LDP_TYPE_ROUTER;
>  simap_init(&ldp->ports);
> +reset_flow_processing();
>  return ldp;
>  }
>
> @@ -224,6 +239,7 @@ ldp_free(struct logical_datapath *ldp)
>  simap_destroy(&ldp->ports);
>  hmap_remove(&logical_datapaths, &ldp->hmap_node);
>  free(ldp);
> +reset_flow_processing();
>  }
>
>  /* Whether a particular port has been seen or not
> @@ -319,6 +335,7 @@ ldp_run(struct controller_ctx *ctx)
>  binding->logical_port);
>  if (!old || old->data != binding->tunnel_key) {
>  simap_put(&ldp->ports, binding->logical_port,
binding->tunnel_key);
> +reset_flow_processing();
>  }
>
>  ldp_port_update(ins_seqno, binding->logical_port, ldp);
> @@ -380,13 +397,21 @@ lflow_init(void)
>
>  /* Translates logical flows in the Logical_Flow table in the OVN_SB
database
>   * into OpenFlow flows.  See ovn-architecture(7) for more information. */
> -void
> +unsigned int
>  lflow_run(struct controller_ctx *ctx,
>const struct simap *ct_zones,
> -  struct hmap *local_datapaths)
> +  struct hmap *local_datapaths,
> +  unsigned int seqno)
>  {
>  struct hmap flows = HMAP_INITIALIZER(&flows);
>  uint32_t conj_id_ofs = 1;
> +unsigned int processed_seqno = seqno;
> +
> +if (restart_flow_processing) {
> +seqno = 0;
> +ovn_flow_table_clear();
> +restart_flow_processing = false;
> +}
>
>  ldp_run(ctx);
>
> @@ -398,17 +423,29 @@ lflow_run(struct controller_ctx *ctx,
>  OVSDB_IDL_CHANGE_MODIFY);
>  unsigned int ins_seqno = sbrec_logical_flow_row_get_seqno(lflow,
>  OVSDB_IDL_CHANGE_INSERT);
> -// this offset is to protect the hard coded rules in physical.c
> -ins_seqno += 4;
> -
> +if (del_seqno <= seqno && mod_seqno <= seqno && ins_seqno <=
seqno) {
> +continue;
> +}
>  /* if the row has a del_seqno > 0, then trying to process the
>   * row isn't going to work (as it has already been freed).
> - * Therefore all we can do is to pass the ins_seqno to
> + * Therefore all we can do is to pass the offset ins_seqno to
>   * ofctrl_remove_flow() to remove the flow */
>  if (del_seqno > 0) {
> -ofctrl_remove_flow(ins_seqno);
> +ofctrl_remove_flow(ins_seqno+4);
> +if (del_seqno > processed_seqno) {
> +

Re: [ovs-dev] [PATCH v9 06/10] Add incremental proessing to lflow_run

2016-03-23 Thread Han Zhou
On Tue, Mar 22, 2016 at 6:17 PM, Han Zhou  wrote:
>
>
>
> On Fri, Mar 11, 2016 at 1:06 PM, Ryan Moats  wrote:
> >
> > From: RYAN D. MOATS 
> >
> > This code changes lflow_run to do incremental process of the
> > logical flow table rather than processing the full table each run.
> >
> > Signed-off-by: RYAN D. MOATS 
> > ---
> >  ovn/controller/binding.c|3 ++
> >  ovn/controller/lflow.c  |   53
+--
> >  ovn/controller/lflow.h  |4 +-
> >  ovn/controller/ofctrl.c |4 +-
> >  ovn/controller/ofctrl.h |2 +
> >  ovn/controller/ovn-controller.c |5 +++-
> >  6 files changed, 58 insertions(+), 13 deletions(-)
> >
> > diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
> > index 602a8fe..87cae99 100644
> > --- a/ovn/controller/binding.c
> > +++ b/ovn/controller/binding.c
> > @@ -15,6 +15,7 @@
> >
> >  #include 
> >  #include "binding.h"
> > +#include "lflow.h"
> >
> >  #include "lib/bitmap.h"
> >  #include "lib/hmap.h"
> > @@ -139,6 +140,7 @@ remove_local_datapath(struct hmap *local_datapaths,
unsigned int ins_seqno)
> >  if (ld) {
> >  hmap_remove(local_datapaths, &ld->hmap_node);
> >  hmap_remove(&local_datapaths_by_seqno, &ld->seqno_hmap_node);
> > +reset_flow_processing();
> >  }
> >  }
> >
> > @@ -156,6 +158,7 @@ add_local_datapath(struct hmap *local_datapaths,
> >  hmap_insert(local_datapaths, &ld->hmap_node,
> >  binding_rec->datapath->tunnel_key);
> >  hmap_insert(&local_datapaths_by_seqno, &ld->seqno_hmap_node,
ins_seqno);
> > +reset_flow_processing();
> >  }
> >
> >  static void
> > diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
> > index 4856362..6d0d417 100644
> > --- a/ovn/controller/lflow.c
> > +++ b/ovn/controller/lflow.c
> > @@ -176,6 +176,20 @@ struct logical_datapath {
> >  enum ldp_type type; /* Type of logical datapath */
> >  };
> >
> > +void reset_flow_processing(void);
> > +void ldp_port_create(uint32_t ins_seqno, char *name,
> > + struct logical_datapath *ldp);
> > +void ldp_port_update(uint32_t ins_seqno, char *name,
> > + struct logical_datapath *ldp);
> > +
> > +bool restart_flow_processing = false;
> > +
> > +void
> > +reset_flow_processing(void)
> > +{
> > +restart_flow_processing = true;
> > +}
> > +
> >  /* Contains "struct logical_datapath"s. */
> >  static struct hmap logical_datapaths =
HMAP_INITIALIZER(&logical_datapaths);
> >
> > @@ -208,6 +222,7 @@ ldp_create(const struct sbrec_datapath_binding
*binding)
> >  const char *ls = smap_get(&binding->external_ids,
"logical-switch");
> >  ldp->type = ls ? LDP_TYPE_SWITCH : LDP_TYPE_ROUTER;
> >  simap_init(&ldp->ports);
> > +reset_flow_processing();
> >  return ldp;
> >  }
> >
> > @@ -224,6 +239,7 @@ ldp_free(struct logical_datapath *ldp)
> >  simap_destroy(&ldp->ports);
> >  hmap_remove(&logical_datapaths, &ldp->hmap_node);
> >  free(ldp);
> > +reset_flow_processing();
> >  }
> >
> >  /* Whether a particular port has been seen or not
> > @@ -319,6 +335,7 @@ ldp_run(struct controller_ctx *ctx)
> >  binding->logical_port);
> >  if (!old || old->data != binding->tunnel_key) {
> >  simap_put(&ldp->ports, binding->logical_port,
binding->tunnel_key);
> > +reset_flow_processing();
> >  }
> >
> >  ldp_port_update(ins_seqno, binding->logical_port, ldp);
> > @@ -380,13 +397,21 @@ lflow_init(void)
> >
> >  /* Translates logical flows in the Logical_Flow table in the OVN_SB
database
> >   * into OpenFlow flows.  See ovn-architecture(7) for more information.
*/
> > -void
> > +unsigned int
> >  lflow_run(struct controller_ctx *ctx,
> >const struct simap *ct_zones,
> > -  struct hmap *local_datapaths)
> > +  struct hmap *local_datapaths,
> > +  unsigned int seqno)
> >  {
> >  struct hmap flows = HMAP_INITIALIZER(&flows);
> >  uint32_t conj_id_ofs = 1;
> > +unsigned int processed_seqno = seqno;
> > +
> > +if (restart_flow_processing) {
> > +seqno = 0;
> > +ovn_flow_table_clear();
> > +restart_flow_processing = false;
> > +}
> >
> >  ldp_run(ctx);
> >
> > @@ -398,17 +423,29 @@ lflow_run(struct controller_ctx *ctx,
> >  OVSDB_IDL_CHANGE_MODIFY);
> >  unsigned int ins_seqno =
sbrec_logical_flow_row_get_seqno(lflow,
> >  OVSDB_IDL_CHANGE_INSERT);
> > -// this offset is to protect the hard coded rules in physical.c
> > -ins_seqno += 4;
> > -
> > +if (del_seqno <= seqno && mod_seqno <= seqno && ins_seqno <=
seqno) {
> > +continue;
> > +}
> >  /* if the row has a del_seqno > 0, then trying to process the
> >   * row isn't going to work (as it has already been freed).
> > - * Therefore all we can do is to pass the ins_seqn

Re: [ovs-dev] [PATCH v9 06/10] Add incremental proessing to lflow_run

2016-03-23 Thread Ryan Moats

Han Zhou  wrote on 03/23/2016 01:39:04 PM:

> From: Han Zhou 
> To: Ryan Moats/Omaha/IBM@IBMUS
> Cc: "dev@openvswitch.org" , Russell Bryant
> 
> Date: 03/23/2016 01:39 PM
> Subject: Re: [ovs-dev] [PATCH v9 06/10] Add incremental proessing
tolflow_run
>
>
>
> On Tue, Mar 22, 2016 at 6:17 PM, Han Zhou  wrote:
> >
> >
> >
> > On Fri, Mar 11, 2016 at 1:06 PM, Ryan Moats  wrote:
> > >
> > > From: RYAN D. MOATS 
> > >
> > > This code changes lflow_run to do incremental process of the
> > > logical flow table rather than processing the full table each run.
> > >
> > > Signed-off-by: RYAN D. MOATS 
> > > ---
> > >  ovn/controller/binding.c        |    3 ++
> > >  ovn/controller/lflow.c          |   53 
> +--
> > >  ovn/controller/lflow.h          |    4 +-
> > >  ovn/controller/ofctrl.c         |    4 +-
> > >  ovn/controller/ofctrl.h         |    2 +
> > >  ovn/controller/ovn-controller.c |    5 +++-
> > >  6 files changed, 58 insertions(+), 13 deletions(-)
> > >
> > > diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
> > > index 602a8fe..87cae99 100644
> > > --- a/ovn/controller/binding.c
> > > +++ b/ovn/controller/binding.c
> > > @@ -15,6 +15,7 @@
> > >
> > >  #include 
> > >  #include "binding.h"
> > > +#include "lflow.h"
> > >
> > >  #include "lib/bitmap.h"
> > >  #include "lib/hmap.h"
> > > @@ -139,6 +140,7 @@ remove_local_datapath(struct hmap
> *local_datapaths, unsigned int ins_seqno)
> > >      if (ld) {
> > >          hmap_remove(local_datapaths, &ld->hmap_node);
> > >          hmap_remove(&local_datapaths_by_seqno, &ld->
seqno_hmap_node);
> > > +        reset_flow_processing();
> > >      }
> > >  }
> > >
> > > @@ -156,6 +158,7 @@ add_local_datapath(struct hmap *local_datapaths,
> > >      hmap_insert(local_datapaths, &ld->hmap_node,
> > >                  binding_rec->datapath->tunnel_key);
> > >      hmap_insert(&local_datapaths_by_seqno,
> &ld->seqno_hmap_node, ins_seqno);
> > > +    reset_flow_processing();
> > >  }
> > >
> > >  static void
> > > diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
> > > index 4856362..6d0d417 100644
> > > --- a/ovn/controller/lflow.c
> > > +++ b/ovn/controller/lflow.c
> > > @@ -176,6 +176,20 @@ struct logical_datapath {
> > >      enum ldp_type type;         /* Type of logical datapath */
> > >  };
> > >
> > > +void reset_flow_processing(void);
> > > +void ldp_port_create(uint32_t ins_seqno, char *name,
> > > +                     struct logical_datapath *ldp);
> > > +void ldp_port_update(uint32_t ins_seqno, char *name,
> > > +                     struct logical_datapath *ldp);
> > > +
> > > +bool restart_flow_processing = false;
> > > +
> > > +void
> > > +reset_flow_processing(void)
> > > +{
> > > +    restart_flow_processing = true;
> > > +}
> > > +
> > >  /* Contains "struct logical_datapath"s. */
> > >  static struct hmap logical_datapaths = HMAP_INITIALIZER
> (&logical_datapaths);
> > >
> > > @@ -208,6 +222,7 @@ ldp_create(const struct
> sbrec_datapath_binding *binding)
> > >      const char *ls = smap_get(&binding->external_ids,
"logical-switch");
> > >      ldp->type = ls ? LDP_TYPE_SWITCH : LDP_TYPE_ROUTER;
> > >      simap_init(&ldp->ports);
> > > +    reset_flow_processing();
> > >      return ldp;
> > >  }
> > >
> > > @@ -224,6 +239,7 @@ ldp_free(struct logical_datapath *ldp)
> > >      simap_destroy(&ldp->ports);
> > >      hmap_remove(&logical_datapaths, &ldp->hmap_node);
> > >      free(ldp);
> > > +    reset_flow_processing();
> > >  }
> > >
> > >  /* Whether a particular port has been seen or not
> > > @@ -319,6 +335,7 @@ ldp_run(struct controller_ctx *ctx)
> > >                                              binding->logical_port);
> > >          if (!old || old->data != binding->tunnel_key) {
> > >              simap_put(&ldp->ports, binding->logical_port,
> binding->tunnel_key);
> > > +            reset_flow_processing();
> > >          }
> > >
> > >          ldp_port_update(ins_seqno, binding->logical_port, ldp);
> > > @@ -380,13 +397,21 @@ lflow_init(void)
> > >
> > >  /* Translates logical flows in the Logical_Flow table in the
> OVN_SB database
> > >   * into OpenFlow flows.  See ovn-architecture(7) for more
information. */
> > > -void
> > > +unsigned int
> > >  lflow_run(struct controller_ctx *ctx,
> > >            const struct simap *ct_zones,
> > > -          struct hmap *local_datapaths)
> > > +          struct hmap *local_datapaths,
> > > +          unsigned int seqno)
> > >  {
> > >      struct hmap flows = HMAP_INITIALIZER(&flows);
> > >      uint32_t conj_id_ofs = 1;
> > > +    unsigned int processed_seqno = seqno;
> > > +
> > > +    if (restart_flow_processing) {
> > > +        seqno = 0;
> > > +        ovn_flow_table_clear();
> > > +        restart_flow_processing = false;
> > > +    }
> > >
> > >      ldp_run(ctx);
> > >
> > > @@ -398,17 +423,29 @@ lflow_run(struct controller_ctx *ctx,
> > >              OVSDB_IDL_CHANGE_MODIFY);
> > >          unsigned int ins_seqno = sbrec

Re: [ovs-dev] [PATCH v9 06/10] Add incremental proessing to lflow_run

2016-03-23 Thread Han Zhou
On Wed, Mar 23, 2016 at 12:28 PM, Ryan Moats  wrote:
>
> Han Zhou  wrote on 03/23/2016 01:39:04 PM:
>
> > From: Han Zhou 
> > To: Ryan Moats/Omaha/IBM@IBMUS
> > Cc: "dev@openvswitch.org" , Russell Bryant
> > 
> > Date: 03/23/2016 01:39 PM
> > Subject: Re: [ovs-dev] [PATCH v9 06/10] Add incremental proessing
tolflow_run
>
>
> >
> >
> >
> > On Tue, Mar 22, 2016 at 6:17 PM, Han Zhou  wrote:
> > >
> > >
> > >
> > > On Fri, Mar 11, 2016 at 1:06 PM, Ryan Moats  wrote:
> > > >
> > > > From: RYAN D. MOATS 
> > > >
> > > > This code changes lflow_run to do incremental process of the
> > > > logical flow table rather than processing the full table each run.
> > > >
> > > > Signed-off-by: RYAN D. MOATS 
> > > > ---
> > > >  ovn/controller/binding.c|3 ++
> > > >  ovn/controller/lflow.c  |   53 
> > +--
> > > >  ovn/controller/lflow.h  |4 +-
> > > >  ovn/controller/ofctrl.c |4 +-
> > > >  ovn/controller/ofctrl.h |2 +
> > > >  ovn/controller/ovn-controller.c |5 +++-
> > > >  6 files changed, 58 insertions(+), 13 deletions(-)
> > > >
> > > > diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
> > > > index 602a8fe..87cae99 100644
> > > > --- a/ovn/controller/binding.c
> > > > +++ b/ovn/controller/binding.c
> > > > @@ -15,6 +15,7 @@
> > > >
> > > >  #include 
> > > >  #include "binding.h"
> > > > +#include "lflow.h"
> > > >
> > > >  #include "lib/bitmap.h"
> > > >  #include "lib/hmap.h"
> > > > @@ -139,6 +140,7 @@ remove_local_datapath(struct hmap
> > *local_datapaths, unsigned int ins_seqno)
> > > >  if (ld) {
> > > >  hmap_remove(local_datapaths, &ld->hmap_node);
> > > >  hmap_remove(&local_datapaths_by_seqno,
&ld->seqno_hmap_node);
> > > > +reset_flow_processing();
> > > >  }
> > > >  }
> > > >
> > > > @@ -156,6 +158,7 @@ add_local_datapath(struct hmap *local_datapaths,
> > > >  hmap_insert(local_datapaths, &ld->hmap_node,
> > > >  binding_rec->datapath->tunnel_key);
> > > >  hmap_insert(&local_datapaths_by_seqno,
> > &ld->seqno_hmap_node, ins_seqno);
> > > > +reset_flow_processing();
> > > >  }
> > > >
> > > >  static void
> > > > diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
> > > > index 4856362..6d0d417 100644
> > > > --- a/ovn/controller/lflow.c
> > > > +++ b/ovn/controller/lflow.c
> > > > @@ -176,6 +176,20 @@ struct logical_datapath {
> > > >  enum ldp_type type; /* Type of logical datapath */
> > > >  };
> > > >
> > > > +void reset_flow_processing(void);
> > > > +void ldp_port_create(uint32_t ins_seqno, char *name,
> > > > + struct logical_datapath *ldp);
> > > > +void ldp_port_update(uint32_t ins_seqno, char *name,
> > > > + struct logical_datapath *ldp);
> > > > +
> > > > +bool restart_flow_processing = false;
> > > > +
> > > > +void
> > > > +reset_flow_processing(void)
> > > > +{
> > > > +restart_flow_processing = true;
> > > > +}
> > > > +
> > > >  /* Contains "struct logical_datapath"s. */
> > > >  static struct hmap logical_datapaths = HMAP_INITIALIZER
> > (&logical_datapaths);
> > > >
> > > > @@ -208,6 +222,7 @@ ldp_create(const struct
> > sbrec_datapath_binding *binding)
> > > >  const char *ls = smap_get(&binding->external_ids,
"logical-switch");
> > > >  ldp->type = ls ? LDP_TYPE_SWITCH : LDP_TYPE_ROUTER;
> > > >  simap_init(&ldp->ports);
> > > > +reset_flow_processing();
> > > >  return ldp;
> > > >  }
> > > >
> > > > @@ -224,6 +239,7 @@ ldp_free(struct logical_datapath *ldp)
> > > >  simap_destroy(&ldp->ports);
> > > >  hmap_remove(&logical_datapaths, &ldp->hmap_node);
> > > >  free(ldp);
> > > > +reset_flow_processing();
> > > >  }
> > > >
> > > >  /* Whether a particular port has been seen or not
> > > > @@ -319,6 +335,7 @@ ldp_run(struct controller_ctx *ctx)
> > > >  binding->logical_port);
> > > >  if (!old || old->data != binding->tunnel_key) {
> > > >  simap_put(&ldp->ports, binding->logical_port,
> > binding->tunnel_key);
> > > > +reset_flow_processing();
> > > >  }
> > > >
> > > >  ldp_port_update(ins_seqno, binding->logical_port, ldp);
> > > > @@ -380,13 +397,21 @@ lflow_init(void)
> > > >
> > > >  /* Translates logical flows in the Logical_Flow table in the
> > OVN_SB database
> > > >   * into OpenFlow flows.  See ovn-architecture(7) for more
information. */
> > > > -void
> > > > +unsigned int
> > > >  lflow_run(struct controller_ctx *ctx,
> > > >const struct simap *ct_zones,
> > > > -  struct hmap *local_datapaths)
> > > > +  struct hmap *local_datapaths,
> > > > +  unsigned int seqno)
> > > >  {
> > > >  struct hmap flows = HMAP_INITIALIZER(&flows);
> > > >  uint32_t conj_id_ofs = 1;
> > > > +unsigned int processed_seqno = seqno;
> > > > +
> > > > +if (restart_flow_processing)