Re: [ovs-dev] [ovn-controller-vtep V7 1/3] ovn-controller-vtep: Add vtep module.

2015-08-20 Thread Russell Bryant
acked this earlier, but just came across something while reviewing the
next patch ... let me know if I'm missing something.

On 08/18/2015 05:58 PM, Alex Wang wrote:
 This commit adds the vtep module to ovn-controller-vtep.  The
 module will scan through the Port_Binding table in OVN-SB database,
 and update the vtep logcial switches tunnel keys.
 
 Signed-off-by: Alex Wang al...@nicira.com
 ---
 V6-V7:
 - change the assertion to VLOG_ERR in vtep_lswitch_run().
 - refine the vtep_lswitch_run() as suggested by Russell.
 - refine vtep_lswitch_cleanup() as suggested by Russell.
 
 V5-V6:
 - rebase.
 
 V5: new patch.
 ---
  ovn/controller-vtep/automake.mk   |4 +-
  ovn/controller-vtep/binding.c |3 +-
  ovn/controller-vtep/gateway.c |3 +-
  ovn/controller-vtep/ovn-controller-vtep.c |3 +
  ovn/controller-vtep/vtep.c|  149 
 +
  ovn/controller-vtep/vtep.h|   27 ++
  tests/ovn-controller-vtep.at  |   32 +++
  7 files changed, 218 insertions(+), 3 deletions(-)
  create mode 100644 ovn/controller-vtep/vtep.c
  create mode 100644 ovn/controller-vtep/vtep.h
 
 diff --git a/ovn/controller-vtep/automake.mk b/ovn/controller-vtep/automake.mk
 index 33f063f..cacfae6 100644
 --- a/ovn/controller-vtep/automake.mk
 +++ b/ovn/controller-vtep/automake.mk
 @@ -5,7 +5,9 @@ ovn_controller_vtep_ovn_controller_vtep_SOURCES = \
   ovn/controller-vtep/gateway.c \
   ovn/controller-vtep/gateway.h \
   ovn/controller-vtep/ovn-controller-vtep.c \
 - ovn/controller-vtep/ovn-controller-vtep.h
 + ovn/controller-vtep/ovn-controller-vtep.h \
 + ovn/controller-vtep/vtep.c \
 + ovn/controller-vtep/vtep.h
  ovn_controller_vtep_ovn_controller_vtep_LDADD = ovn/lib/libovn.la 
 lib/libopenvswitch.la vtep/libvtep.la
  man_MANS += ovn/controller-vtep/ovn-controller-vtep.8
  EXTRA_DIST += ovn/controller-vtep/ovn-controller-vtep.8.xml
 diff --git a/ovn/controller-vtep/binding.c b/ovn/controller-vtep/binding.c
 index 652852d..d65f43c 100644
 --- a/ovn/controller-vtep/binding.c
 +++ b/ovn/controller-vtep/binding.c
 @@ -226,7 +226,8 @@ binding_run(struct controller_vtep_ctx *ctx)
  }
  
  /* Removes all port binding association with vtep gateway chassis.
 - * Returns true when all done. */
 + * Returns true when done (i.e. there is no change made to 'ovnsb_idl'),
 + * otherwise returns false. */
  bool
  binding_cleanup(struct controller_vtep_ctx *ctx)
  {
 diff --git a/ovn/controller-vtep/gateway.c b/ovn/controller-vtep/gateway.c
 index 025aff8..963d419 100644
 --- a/ovn/controller-vtep/gateway.c
 +++ b/ovn/controller-vtep/gateway.c
 @@ -189,7 +189,8 @@ gateway_run(struct controller_vtep_ctx *ctx)
  }
  
  /* Destroys the chassis table entries for vtep physical switches.
 - * Returns true when all done. */
 + * Returns true when done (i.e. there is no change made to 'ovnsb_idl'),
 + * otherwise returns false. */
  bool
  gateway_cleanup(struct controller_vtep_ctx *ctx)
  {
 diff --git a/ovn/controller-vtep/ovn-controller-vtep.c 
 b/ovn/controller-vtep/ovn-controller-vtep.c
 index 7e98f69..429ac23 100644
 --- a/ovn/controller-vtep/ovn-controller-vtep.c
 +++ b/ovn/controller-vtep/ovn-controller-vtep.c
 @@ -39,6 +39,7 @@
  
  #include binding.h
  #include gateway.h
 +#include vtep.h
  #include ovn-controller-vtep.h
  
  static unixctl_cb_func ovn_controller_vtep_exit;
 @@ -99,6 +100,7 @@ main(int argc, char *argv[])
  
  gateway_run(ctx);
  binding_run(ctx);
 +vtep_run(ctx);
  unixctl_server_run(unixctl);
  
  unixctl_server_wait(unixctl);
 @@ -127,6 +129,7 @@ main(int argc, char *argv[])
   * We're done if all of them return true. */
  done = binding_cleanup(ctx);
  done = gateway_cleanup(ctx)  done;
 +done = vtep_cleanup(ctx)  done;
  if (done) {
  poll_immediate_wake();
  }
 diff --git a/ovn/controller-vtep/vtep.c b/ovn/controller-vtep/vtep.c
 new file mode 100644
 index 000..9870296
 --- /dev/null
 +++ b/ovn/controller-vtep/vtep.c
 @@ -0,0 +1,149 @@
 +/* Copyright (c) 2015 Nicira, Inc.
 + *
 + * Licensed under the Apache License, Version 2.0 (the License);
 + * you may not use this file except in compliance with the License.
 + * You may obtain a copy of the License at:
 + *
 + * http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an AS IS BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +#include config.h
 +
 +#include vtep.h
 +
 +#include lib/hash.h
 +#include lib/hmap.h
 +#include lib/smap.h
 +#include lib/util.h
 +#include ovn-controller-vtep.h
 +#include openvswitch/vlog.h
 +#include ovn/lib/ovn-sb-idl.h
 +#include 

Re: [ovs-dev] [ovn-controller-vtep V7 1/3] ovn-controller-vtep: Add vtep module.

2015-08-20 Thread Alex Wang
On Thu, Aug 20, 2015 at 8:24 AM, Russell Bryant rbry...@redhat.com wrote:

 acked this earlier, but just came across something while reviewing the
 next patch ... let me know if I'm missing something.

 On 08/18/2015 05:58 PM, Alex Wang wrote:
  This commit adds the vtep module to ovn-controller-vtep.  The
  module will scan through the Port_Binding table in OVN-SB database,
  and update the vtep logcial switches tunnel keys.
 
  Signed-off-by: Alex Wang al...@nicira.com
  ---
  V6-V7:
  - change the assertion to VLOG_ERR in vtep_lswitch_run().
  - refine the vtep_lswitch_run() as suggested by Russell.
  - refine vtep_lswitch_cleanup() as suggested by Russell.
 
  V5-V6:
  - rebase.
 
  V5: new patch.
  ---
   ovn/controller-vtep/automake.mk   |4 +-
   ovn/controller-vtep/binding.c |3 +-
   ovn/controller-vtep/gateway.c |3 +-
   ovn/controller-vtep/ovn-controller-vtep.c |3 +
   ovn/controller-vtep/vtep.c|  149
 +
   ovn/controller-vtep/vtep.h|   27 ++
   tests/ovn-controller-vtep.at  |   32 +++
   7 files changed, 218 insertions(+), 3 deletions(-)
   create mode 100644 ovn/controller-vtep/vtep.c
   create mode 100644 ovn/controller-vtep/vtep.h
 
  diff --git a/ovn/controller-vtep/automake.mk b/ovn/controller-vtep/
 automake.mk
  index 33f063f..cacfae6 100644
  --- a/ovn/controller-vtep/automake.mk
  +++ b/ovn/controller-vtep/automake.mk
  @@ -5,7 +5,9 @@ ovn_controller_vtep_ovn_controller_vtep_SOURCES = \
ovn/controller-vtep/gateway.c \
ovn/controller-vtep/gateway.h \
ovn/controller-vtep/ovn-controller-vtep.c \
  - ovn/controller-vtep/ovn-controller-vtep.h
  + ovn/controller-vtep/ovn-controller-vtep.h \
  + ovn/controller-vtep/vtep.c \
  + ovn/controller-vtep/vtep.h
   ovn_controller_vtep_ovn_controller_vtep_LDADD = ovn/lib/libovn.la lib/
 libopenvswitch.la vtep/libvtep.la
   man_MANS += ovn/controller-vtep/ovn-controller-vtep.8
   EXTRA_DIST += ovn/controller-vtep/ovn-controller-vtep.8.xml
  diff --git a/ovn/controller-vtep/binding.c
 b/ovn/controller-vtep/binding.c
  index 652852d..d65f43c 100644
  --- a/ovn/controller-vtep/binding.c
  +++ b/ovn/controller-vtep/binding.c
  @@ -226,7 +226,8 @@ binding_run(struct controller_vtep_ctx *ctx)
   }
 
   /* Removes all port binding association with vtep gateway chassis.
  - * Returns true when all done. */
  + * Returns true when done (i.e. there is no change made to 'ovnsb_idl'),
  + * otherwise returns false. */
   bool
   binding_cleanup(struct controller_vtep_ctx *ctx)
   {
  diff --git a/ovn/controller-vtep/gateway.c
 b/ovn/controller-vtep/gateway.c
  index 025aff8..963d419 100644
  --- a/ovn/controller-vtep/gateway.c
  +++ b/ovn/controller-vtep/gateway.c
  @@ -189,7 +189,8 @@ gateway_run(struct controller_vtep_ctx *ctx)
   }
 
   /* Destroys the chassis table entries for vtep physical switches.
  - * Returns true when all done. */
  + * Returns true when done (i.e. there is no change made to 'ovnsb_idl'),
  + * otherwise returns false. */
   bool
   gateway_cleanup(struct controller_vtep_ctx *ctx)
   {
  diff --git a/ovn/controller-vtep/ovn-controller-vtep.c
 b/ovn/controller-vtep/ovn-controller-vtep.c
  index 7e98f69..429ac23 100644
  --- a/ovn/controller-vtep/ovn-controller-vtep.c
  +++ b/ovn/controller-vtep/ovn-controller-vtep.c
  @@ -39,6 +39,7 @@
 
   #include binding.h
   #include gateway.h
  +#include vtep.h
   #include ovn-controller-vtep.h
 
   static unixctl_cb_func ovn_controller_vtep_exit;
  @@ -99,6 +100,7 @@ main(int argc, char *argv[])
 
   gateway_run(ctx);
   binding_run(ctx);
  +vtep_run(ctx);
   unixctl_server_run(unixctl);
 
   unixctl_server_wait(unixctl);
  @@ -127,6 +129,7 @@ main(int argc, char *argv[])
* We're done if all of them return true. */
   done = binding_cleanup(ctx);
   done = gateway_cleanup(ctx)  done;
  +done = vtep_cleanup(ctx)  done;
   if (done) {
   poll_immediate_wake();
   }
  diff --git a/ovn/controller-vtep/vtep.c b/ovn/controller-vtep/vtep.c
  new file mode 100644
  index 000..9870296
  --- /dev/null
  +++ b/ovn/controller-vtep/vtep.c
  @@ -0,0 +1,149 @@
  +/* Copyright (c) 2015 Nicira, Inc.
  + *
  + * Licensed under the Apache License, Version 2.0 (the License);
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at:
  + *
  + * http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an AS IS BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#include config.h
  +
  +#include vtep.h
  +
  

Re: [ovs-dev] [ovn-controller-vtep V7 1/3] ovn-controller-vtep: Add vtep module.

2015-08-20 Thread Alex Wang
As well as a test to cover that~ ;D

On Thu, Aug 20, 2015 at 9:06 AM, Alex Wang al...@nicira.com wrote:



 On Thu, Aug 20, 2015 at 8:24 AM, Russell Bryant rbry...@redhat.com
 wrote:

 acked this earlier, but just came across something while reviewing the
 next patch ... let me know if I'm missing something.

 On 08/18/2015 05:58 PM, Alex Wang wrote:
  This commit adds the vtep module to ovn-controller-vtep.  The
  module will scan through the Port_Binding table in OVN-SB database,
  and update the vtep logcial switches tunnel keys.
 
  Signed-off-by: Alex Wang al...@nicira.com
  ---
  V6-V7:
  - change the assertion to VLOG_ERR in vtep_lswitch_run().
  - refine the vtep_lswitch_run() as suggested by Russell.
  - refine vtep_lswitch_cleanup() as suggested by Russell.
 
  V5-V6:
  - rebase.
 
  V5: new patch.
  ---
   ovn/controller-vtep/automake.mk   |4 +-
   ovn/controller-vtep/binding.c |3 +-
   ovn/controller-vtep/gateway.c |3 +-
   ovn/controller-vtep/ovn-controller-vtep.c |3 +
   ovn/controller-vtep/vtep.c|  149
 +
   ovn/controller-vtep/vtep.h|   27 ++
   tests/ovn-controller-vtep.at  |   32 +++
   7 files changed, 218 insertions(+), 3 deletions(-)
   create mode 100644 ovn/controller-vtep/vtep.c
   create mode 100644 ovn/controller-vtep/vtep.h
 
  diff --git a/ovn/controller-vtep/automake.mk b/ovn/controller-vtep/
 automake.mk
  index 33f063f..cacfae6 100644
  --- a/ovn/controller-vtep/automake.mk
  +++ b/ovn/controller-vtep/automake.mk
  @@ -5,7 +5,9 @@ ovn_controller_vtep_ovn_controller_vtep_SOURCES = \
ovn/controller-vtep/gateway.c \
ovn/controller-vtep/gateway.h \
ovn/controller-vtep/ovn-controller-vtep.c \
  - ovn/controller-vtep/ovn-controller-vtep.h
  + ovn/controller-vtep/ovn-controller-vtep.h \
  + ovn/controller-vtep/vtep.c \
  + ovn/controller-vtep/vtep.h
   ovn_controller_vtep_ovn_controller_vtep_LDADD = ovn/lib/libovn.la lib/
 libopenvswitch.la vtep/libvtep.la
   man_MANS += ovn/controller-vtep/ovn-controller-vtep.8
   EXTRA_DIST += ovn/controller-vtep/ovn-controller-vtep.8.xml
  diff --git a/ovn/controller-vtep/binding.c
 b/ovn/controller-vtep/binding.c
  index 652852d..d65f43c 100644
  --- a/ovn/controller-vtep/binding.c
  +++ b/ovn/controller-vtep/binding.c
  @@ -226,7 +226,8 @@ binding_run(struct controller_vtep_ctx *ctx)
   }
 
   /* Removes all port binding association with vtep gateway chassis.
  - * Returns true when all done. */
  + * Returns true when done (i.e. there is no change made to
 'ovnsb_idl'),
  + * otherwise returns false. */
   bool
   binding_cleanup(struct controller_vtep_ctx *ctx)
   {
  diff --git a/ovn/controller-vtep/gateway.c
 b/ovn/controller-vtep/gateway.c
  index 025aff8..963d419 100644
  --- a/ovn/controller-vtep/gateway.c
  +++ b/ovn/controller-vtep/gateway.c
  @@ -189,7 +189,8 @@ gateway_run(struct controller_vtep_ctx *ctx)
   }
 
   /* Destroys the chassis table entries for vtep physical switches.
  - * Returns true when all done. */
  + * Returns true when done (i.e. there is no change made to
 'ovnsb_idl'),
  + * otherwise returns false. */
   bool
   gateway_cleanup(struct controller_vtep_ctx *ctx)
   {
  diff --git a/ovn/controller-vtep/ovn-controller-vtep.c
 b/ovn/controller-vtep/ovn-controller-vtep.c
  index 7e98f69..429ac23 100644
  --- a/ovn/controller-vtep/ovn-controller-vtep.c
  +++ b/ovn/controller-vtep/ovn-controller-vtep.c
  @@ -39,6 +39,7 @@
 
   #include binding.h
   #include gateway.h
  +#include vtep.h
   #include ovn-controller-vtep.h
 
   static unixctl_cb_func ovn_controller_vtep_exit;
  @@ -99,6 +100,7 @@ main(int argc, char *argv[])
 
   gateway_run(ctx);
   binding_run(ctx);
  +vtep_run(ctx);
   unixctl_server_run(unixctl);
 
   unixctl_server_wait(unixctl);
  @@ -127,6 +129,7 @@ main(int argc, char *argv[])
* We're done if all of them return true. */
   done = binding_cleanup(ctx);
   done = gateway_cleanup(ctx)  done;
  +done = vtep_cleanup(ctx)  done;
   if (done) {
   poll_immediate_wake();
   }
  diff --git a/ovn/controller-vtep/vtep.c b/ovn/controller-vtep/vtep.c
  new file mode 100644
  index 000..9870296
  --- /dev/null
  +++ b/ovn/controller-vtep/vtep.c
  @@ -0,0 +1,149 @@
  +/* Copyright (c) 2015 Nicira, Inc.
  + *
  + * Licensed under the Apache License, Version 2.0 (the License);
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at:
  + *
  + * http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an AS IS BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 implied.
  + * See the License for the specific language governing 

Re: [ovs-dev] [ovn-controller-vtep V7 1/3] ovn-controller-vtep: Add vtep module.

2015-08-19 Thread Russell Bryant
On 08/18/2015 05:58 PM, Alex Wang wrote:
 This commit adds the vtep module to ovn-controller-vtep.  The
 module will scan through the Port_Binding table in OVN-SB database,
 and update the vtep logcial switches tunnel keys.
 
 Signed-off-by: Alex Wang al...@nicira.com

Acked-by: Russell Bryant rbry...@redhat.com

-- 
Russell Bryant
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [ovn-controller-vtep V7 1/3] ovn-controller-vtep: Add vtep module.

2015-08-18 Thread Alex Wang
This commit adds the vtep module to ovn-controller-vtep.  The
module will scan through the Port_Binding table in OVN-SB database,
and update the vtep logcial switches tunnel keys.

Signed-off-by: Alex Wang al...@nicira.com
---
V6-V7:
- change the assertion to VLOG_ERR in vtep_lswitch_run().
- refine the vtep_lswitch_run() as suggested by Russell.
- refine vtep_lswitch_cleanup() as suggested by Russell.

V5-V6:
- rebase.

V5: new patch.
---
 ovn/controller-vtep/automake.mk   |4 +-
 ovn/controller-vtep/binding.c |3 +-
 ovn/controller-vtep/gateway.c |3 +-
 ovn/controller-vtep/ovn-controller-vtep.c |3 +
 ovn/controller-vtep/vtep.c|  149 +
 ovn/controller-vtep/vtep.h|   27 ++
 tests/ovn-controller-vtep.at  |   32 +++
 7 files changed, 218 insertions(+), 3 deletions(-)
 create mode 100644 ovn/controller-vtep/vtep.c
 create mode 100644 ovn/controller-vtep/vtep.h

diff --git a/ovn/controller-vtep/automake.mk b/ovn/controller-vtep/automake.mk
index 33f063f..cacfae6 100644
--- a/ovn/controller-vtep/automake.mk
+++ b/ovn/controller-vtep/automake.mk
@@ -5,7 +5,9 @@ ovn_controller_vtep_ovn_controller_vtep_SOURCES = \
ovn/controller-vtep/gateway.c \
ovn/controller-vtep/gateway.h \
ovn/controller-vtep/ovn-controller-vtep.c \
-   ovn/controller-vtep/ovn-controller-vtep.h
+   ovn/controller-vtep/ovn-controller-vtep.h \
+   ovn/controller-vtep/vtep.c \
+   ovn/controller-vtep/vtep.h
 ovn_controller_vtep_ovn_controller_vtep_LDADD = ovn/lib/libovn.la 
lib/libopenvswitch.la vtep/libvtep.la
 man_MANS += ovn/controller-vtep/ovn-controller-vtep.8
 EXTRA_DIST += ovn/controller-vtep/ovn-controller-vtep.8.xml
diff --git a/ovn/controller-vtep/binding.c b/ovn/controller-vtep/binding.c
index 652852d..d65f43c 100644
--- a/ovn/controller-vtep/binding.c
+++ b/ovn/controller-vtep/binding.c
@@ -226,7 +226,8 @@ binding_run(struct controller_vtep_ctx *ctx)
 }
 
 /* Removes all port binding association with vtep gateway chassis.
- * Returns true when all done. */
+ * Returns true when done (i.e. there is no change made to 'ovnsb_idl'),
+ * otherwise returns false. */
 bool
 binding_cleanup(struct controller_vtep_ctx *ctx)
 {
diff --git a/ovn/controller-vtep/gateway.c b/ovn/controller-vtep/gateway.c
index 025aff8..963d419 100644
--- a/ovn/controller-vtep/gateway.c
+++ b/ovn/controller-vtep/gateway.c
@@ -189,7 +189,8 @@ gateway_run(struct controller_vtep_ctx *ctx)
 }
 
 /* Destroys the chassis table entries for vtep physical switches.
- * Returns true when all done. */
+ * Returns true when done (i.e. there is no change made to 'ovnsb_idl'),
+ * otherwise returns false. */
 bool
 gateway_cleanup(struct controller_vtep_ctx *ctx)
 {
diff --git a/ovn/controller-vtep/ovn-controller-vtep.c 
b/ovn/controller-vtep/ovn-controller-vtep.c
index 7e98f69..429ac23 100644
--- a/ovn/controller-vtep/ovn-controller-vtep.c
+++ b/ovn/controller-vtep/ovn-controller-vtep.c
@@ -39,6 +39,7 @@
 
 #include binding.h
 #include gateway.h
+#include vtep.h
 #include ovn-controller-vtep.h
 
 static unixctl_cb_func ovn_controller_vtep_exit;
@@ -99,6 +100,7 @@ main(int argc, char *argv[])
 
 gateway_run(ctx);
 binding_run(ctx);
+vtep_run(ctx);
 unixctl_server_run(unixctl);
 
 unixctl_server_wait(unixctl);
@@ -127,6 +129,7 @@ main(int argc, char *argv[])
  * We're done if all of them return true. */
 done = binding_cleanup(ctx);
 done = gateway_cleanup(ctx)  done;
+done = vtep_cleanup(ctx)  done;
 if (done) {
 poll_immediate_wake();
 }
diff --git a/ovn/controller-vtep/vtep.c b/ovn/controller-vtep/vtep.c
new file mode 100644
index 000..9870296
--- /dev/null
+++ b/ovn/controller-vtep/vtep.c
@@ -0,0 +1,149 @@
+/* Copyright (c) 2015 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include config.h
+
+#include vtep.h
+
+#include lib/hash.h
+#include lib/hmap.h
+#include lib/smap.h
+#include lib/util.h
+#include ovn-controller-vtep.h
+#include openvswitch/vlog.h
+#include ovn/lib/ovn-sb-idl.h
+#include vtep/vtep-idl.h
+
+VLOG_DEFINE_THIS_MODULE(vtep);
+
+/*
+ * Scans through the Binding table in ovnsb and updates the vtep logical
+ * switch tunnel keys.
+ *
+ */
+
+/* Updates the vtep Logical_Switch table entries' tunnel keys based
+ * on the port bindings. */
+static void