This patch add column "enabled" to table Logical_Router
for setting router administrative state.

The type of "enabled" is bool.

If the administrative state is false, delete all the flows
relevant to the logical router from table Logical_Flow.

Signed-off-by: Na Zhu <na...@cn.ibm.com>
Acked-by:
---
 ovn/northd/ovn-northd.8.xml |  4 ++++
 ovn/northd/ovn-northd.c     | 10 ++++++++++
 ovn/ovn-nb.ovsschema        |  5 +++--
 ovn/ovn-nb.xml              |  7 +++++++
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml
index da776e1..f7a11c4 100644
--- a/ovn/northd/ovn-northd.8.xml
+++ b/ovn/northd/ovn-northd.8.xml
@@ -397,6 +397,10 @@ output;
 
     <h2>Logical Router Datapaths</h2>
 
+    <p>
+    Logical router datapaths will only exist for <ref 
table="Logical_Router" db="OVN_Northbound"/> rows in the <ref 
db="OVN_Northbound"/> database that do not have <ref column="enabled" 
table="Logical_Router" db="OVN_Northbound"/> set to <code>false</code>
+    </p>
+
     <h3>Ingress Table 0: L2 Admission Control</h3>
 
     <p>
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 4b1d611..da11efd 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -316,6 +316,12 @@ ovn_datapath_from_sbrec(struct hmap *datapaths,
     return ovn_datapath_find(datapaths, &key);
 }
 
+static bool
+lrouter_is_enabled(const struct nbrec_logical_router *lrouter)
+{
+    return !lrouter->enabled || *lrouter->enabled;
+}
+
 static void
 join_datapaths(struct northd_context *ctx, struct hmap *datapaths,
                struct ovs_list *sb_only, struct ovs_list *nb_only,
@@ -373,6 +379,10 @@ join_datapaths(struct northd_context *ctx, struct 
hmap *datapaths,
 
     const struct nbrec_logical_router *nbr;
     NBREC_LOGICAL_ROUTER_FOR_EACH (nbr, ctx->ovnnb_idl) {
+        if (!lrouter_is_enabled(nbr)) {
+            continue;
+        }
+
         struct ovn_datapath *od = ovn_datapath_find(datapaths,
                                                     &nbr->header_.uuid);
         if (od) {
diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
index 40a7a97..e3e41e3 100644
--- a/ovn/ovn-nb.ovsschema
+++ b/ovn/ovn-nb.ovsschema
@@ -1,7 +1,7 @@
 {
     "name": "OVN_Northbound",
-    "version": "2.0.2",
-    "cksum": "4289495412 4436",
+    "version": "2.1.0",
+    "cksum": "2201582413 4513",
     "tables": {
         "Logical_Switch": {
             "columns": {
@@ -72,6 +72,7 @@
                                    "min": 0,
                                    "max": "unlimited"}},
                 "default_gw": {"type": {"key": "string", "min": 0, "max": 
1}},
+                "enabled": {"type": {"key": "boolean", "min": 0, "max": 
1}},
                 "external_ids": {
                     "type": {"key": "string", "value": "string",
                              "min": 0, "max": "unlimited"}}},
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index e65bc3a..843ae4c 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -627,6 +627,13 @@
       IP address to use as default gateway, if any.
     </column>
 
+    <column name="enabled">
+      This column is used to administratively set router state.  If this 
column
+      is empty or is set to <code>true</code>, the router is enabled.  If 
this
+      column is set to <code>false</code>, the router is disabled.  A 
disabled
+      router has all ingress and egress traffic dropped.
+    </column>
+ 
     <group title="Common Columns">
       <column name="external_ids">
         See <em>External IDs</em> at the beginning of this document.
-- 
2.5.0




Regards,
Juno Zhu
IBM China Development Labs (CDL) Cloud IaaS Lab
Email: na...@cn.ibm.com
5F, Building 10, 399 Keyuan Road, Zhangjiang Hi-Tech Park, Pudong New 
District, Shanghai, China (201203)

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to