Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-15 Thread Ben Pfaff
On Fri, Apr 15, 2016 at 10:52:13PM +0800, Na Zhu wrote:
> 5.7.9 Application-specific password required. Learn more at
> 5.7.9  https://support.google.com/accounts/answer/185833 

Did you read that webpage?
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-15 Thread Na Zhu
Hi Russell,

In fact, I tried git send-email, it failed. So I send the review email 
again by my gmail, not IBM mail.
I do not know why it still can not be applied even by my gmail.


juno@ovn:/opt/stack/ovs$ git send-email outgoing/* 
outgoing/-cover-letter.patch
outgoing/0001-ovn-Update-ACL-flow-docs.patch
outgoing/0002-ovn-add-column-enabled-to-table-Logical_Router.patch
Who should the emails be sent to (if any)? dev@openvswitch.org
Message-ID to be used as In-Reply-To for the first email (if any)? 
(mbox) Adding cc: Na <na...@cn.ibm.com> from line 'From: Na 
<na...@cn.ibm.com>'

From: JunoZhu <na...@cn.ibm.com>
To: dev@openvswitch.org
Cc: Na <na...@cn.ibm.com>
Subject: [PATCH 0/2] *** SUBJECT HERE ***
Date: Fri, 15 Apr 2016 09:47:34 -0500
Message-Id: <1460731656-3894-1-git-send-email-na...@cn.ibm.com>
X-Mailer: git-send-email 2.5.0

The Cc list above has been expanded by additional
addresses found in the patch commit message. By default
send-email prompts before sending whenever this occurs.
This behavior is controlled by the sendemail.confirm
configuration setting.

For additional information, run 'git send-email --help'.
To retain the current behavior, but squelch this message,
run 'git config --global sendemail.confirm auto'.

Send this email? ([y]es|[n]o|[q]uit|[a]ll): y
Password for 'smtp://zhunat...@gmail.com@smtp.gmail.com:587': 
5.7.9 Application-specific password required. Learn more at
5.7.9  https://support.google.com/accounts/answer/185833 
t101sm29148141ioi.29 - gsmtp
steve@ovn:/opt/stack/ovs$ 





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)



From:   Russell Bryant <russ...@ovn.org>
To: Na Zhu/China/IBM@IBMCN
Cc: Ben Pfaff <b...@ovn.org>, ovs dev <dev@openvswitch.org>, Na Zhu 
<zhunat...@gmail.com>
Date:   2016/04/15 22:22
Subject:    Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to 
table Logical_Router





On Fri, Apr 15, 2016 at 9:51 AM, Na Zhu <na...@cn.ibm.com> wrote:
Hi Ben,

How to fix the word-wrapped issue?

I've suggested this a couple of times already, but have you tried posting 
with git-send-email yet?

https://git-scm.com/docs/git-send-email

-- 
Russell Bryant


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


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-15 Thread Russell Bryant
On Fri, Apr 15, 2016 at 9:51 AM, Na Zhu  wrote:

> Hi Ben,
>
> How to fix the word-wrapped issue?
>

I've suggested this a couple of times already, but have you tried posting
with git-send-email yet?

https://git-scm.com/docs/git-send-email

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


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-15 Thread Na Zhu
Hi Ben,

How to fix the word-wrapped issue?



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)



From:   Ben Pfaff <b...@ovn.org>
To: Na Zhu <zhunat...@gmail.com>
Cc: ovs dev <dev@openvswitch.org>
Date:   2016/04/15 05:51
Subject:        Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to 
table Logical_Router
Sent by:"dev" <dev-boun...@openvswitch.org>



On Tue, Apr 12, 2016 at 11:43:23AM +0800, Na Zhu wrote:
> 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>

Thanks for submitting a patch!

This patch cannot be applied because it is word-wrapped.

Thanks,

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



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


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-14 Thread Ben Pfaff
On Tue, Apr 12, 2016 at 11:43:23AM +0800, Na Zhu wrote:
> 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 

Thanks for submitting a patch!

This patch cannot be applied because it is word-wrapped.

Thanks,

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


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-12 Thread Russell Bryant
On Mon, Apr 11, 2016 at 11:13 PM, Na Zhu  wrote:

> Hi Russel,
>
> If i use "git send-mail", can i still use IBM mail client, or should i
> change to use gmail client?
>

You configure git-send-email with your SMTP server of choice.  I don't know
if it will work with an IBM SMTP server.  I do know that it will work with
gmail as the SMTP server.

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


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-11 Thread Na Zhu
Hi Russel,

I use my gmail to send the review again, now it is available in below 
place.
https://patchwork.ozlabs.org/patch/609231/



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)



From:   Na Zhu/China/IBM
To: Russell Bryant 
Cc: ovs dev 
Date:   2016/04/12 11:13
Subject:Re: [PATCH v3 1/1] ovn: Add column enabled to table 
Logical_Router


Hi Russel,

If i use "git send-mail", can i still use IBM mail client, or should i 
change to use gmail client?



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)




From:   Russell Bryant 
To: Na Zhu/China/IBM@IBMCN
Cc: ovs dev , Ryan Moats 
Date:   2016/04/11 21:42
Subject:Re: [PATCH v3 1/1] ovn: Add column enabled to table 
Logical_Router




On Mon, Apr 11, 2016 at 12:47 AM, Na Zhu  wrote:
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 

I'm unable to apply this patch.  It looks to be because it was sent using 
your IBM mail client.  Can you try sending with "git send-email" instead?

Thanks,

-- 
Russell Bryant


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


[ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-11 Thread Na Zhu
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 
---
 ovn/northd/ovn-northd.8.xml |   4 ++
 ovn/northd/ovn-northd.c |  10 
 ovn/ovn-nb.ovsschema|   5 +-
 ovn/ovn-nb.xml  |   7 +++
 tests/ovn.at| 142

 5 files changed, 166 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;

 Logical Router Datapaths

+
+Logical router datapaths will only exist for  rows in the  database that do not have  set to false
+
+
 Ingress Table 0: L2 Admission Control

 
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, );
 }

+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,
 >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.
 

+
+  This column is used to administratively set router state.  If this
column
+  is empty or is set to true, the router is enabled.  If
this
+  column is set to false, the router is disabled.  A
disabled
+  router has all ingress and egress traffic dropped.
+
+
 
   
 See External IDs at the beginning of this document.
diff --git a/tests/ovn.at b/tests/ovn.at
index 22121e1..f5bfa9c 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -2141,3 +2141,145 @@ OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
 OVS_APP_EXIT_AND_WAIT([ovsdb-server])

 AT_CLEANUP
+
+
+AT_SETUP([ovn -- 1 HVs, 2 LSs, 1 lport/LS, 1 LR])
+AT_KEYWORDS([router-admin-state])
+AT_SKIP_IF([test $HAVE_PYTHON = no])
+ovn_start
+
+# Logical network:
+# One LR - R1 has switch ls1 (191.168.1.0/24) connected to it,
+# and has switch ls2 (172.16.1.0/24) connected to it.
+
+ovn-nbctl create Logical_Router name=R1
+
+ovn-nbctl lswitch-add ls1
+ovn-nbctl lswitch-add ls2
+
+# Connect ls1 to R1
+ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls1 \
+network=192.168.1.1/24 mac=\"00:00:00:01:02:03\" -- add Logical_Router R1 \
+ports @lrp -- lport-add ls1 rp-ls1
+
+ovn-nbctl set Logical_port rp-ls1 type=router options:router-port=ls1 \
+addresses=\"00:00:00:01:02:03\"
+
+# Connect ls2 to R1
+ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls2 \
+network=172.16.1.1/24 mac=\"00:00:00:01:02:04\" -- add Logical_Router R1 \
+ports @lrp -- lport-add ls2 rp-ls2
+
+ovn-nbctl set Logical_port rp-ls2 type=router options:router-port=ls2 \
+addresses=\"00:00:00:01:02:04\"
+
+# Create logical port ls1-lp1 in ls1
+ovn-nbctl lport-add ls1 ls1-lp1 \
+-- lport-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
+
+# Create logical port ls2-lp1 in ls2
+ovn-nbctl lport-add ls2 ls2-lp1 \
+-- lport-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2"
+
+# Create one hypervisor and create OVS ports corresponding to logical
ports.
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 

Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-11 Thread Na Zhu
Hi Russel,

If i use "git send-mail", can i still use IBM mail client, or should i 
change to use gmail client?



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)



From:   Russell Bryant 
To: Na Zhu/China/IBM@IBMCN
Cc: ovs dev , Ryan Moats 
Date:   2016/04/11 21:42
Subject:Re: [PATCH v3 1/1] ovn: Add column enabled to table 
Logical_Router




On Mon, Apr 11, 2016 at 12:47 AM, Na Zhu  wrote:
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 

I'm unable to apply this patch.  It looks to be because it was sent using 
your IBM mail client.  Can you try sending with "git send-email" instead?

Thanks,

-- 
Russell Bryant


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


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-11 Thread Russell Bryant
On Mon, Apr 11, 2016 at 9:47 AM, Ryan Moats  wrote:

> Russell Bryant  wrote on 04/11/2016 08:40:34 AM:
>
> > From: Russell Bryant 
> > To: Na Zhu 
> > Cc: ovs dev , Ryan Moats/Omaha/IBM@IBMUS
> > Date: 04/11/2016 08:41 AM
> > Subject: Re: [PATCH v3 1/1] ovn: Add column enabled to table
> Logical_Router
>
> >
> > On Mon, Apr 11, 2016 at 12:47 AM, Na Zhu  wrote:
> > 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 
> >
> > I'm unable to apply this patch.  It looks to be because it was sent
> > using your IBM mail client.  Can you try sending with "git send-
> > email" instead?
> >
> > Thanks,
> >
> > --
> > Russell Bryant
>
> Russell beat me to my first point.
>
> Second, I'm still not convinced as to whether this is the best way to
> go about this.  While it should work, it is adding/removing multiple
> flows as a logical router scales horizontally.  Instead, could we just
> add/remove a single high priority drop flow for the router so that we
> are only manipulating a single flow?
>

Logical ports use another, but similar approach.  It just skips creating
the first ingress flow and final egress flow if the port is disabled,
defaulting to drop in that case.  It still only had to touch 2 places in
ovn-northd, so it's not that complicated.  I'd be OK with something like
that, too.

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


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-11 Thread Ryan Moats

Russell Bryant  wrote on 04/11/2016 08:40:34 AM:

> From: Russell Bryant 
> To: Na Zhu 
> Cc: ovs dev , Ryan Moats/Omaha/IBM@IBMUS
> Date: 04/11/2016 08:41 AM
> Subject: Re: [PATCH v3 1/1] ovn: Add column enabled to table
Logical_Router
>
> On Mon, Apr 11, 2016 at 12:47 AM, Na Zhu  wrote:
> 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 
>
> I'm unable to apply this patch.  It looks to be because it was sent
> using your IBM mail client.  Can you try sending with "git send-
> email" instead?
>
> Thanks,
>
> --
> Russell Bryant

Russell beat me to my first point.

Second, I'm still not convinced as to whether this is the best way to
go about this.  While it should work, it is adding/removing multiple
flows as a logical router scales horizontally.  Instead, could we just
add/remove a single high priority drop flow for the router so that we
are only manipulating a single flow?

Ryan Moats (regXboi)
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-11 Thread Russell Bryant
On Mon, Apr 11, 2016 at 12:47 AM, Na Zhu  wrote:

> 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 


I'm unable to apply this patch.  It looks to be because it was sent using
your IBM mail client.  Can you try sending with "git send-email" instead?

Thanks,

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


[ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-10 Thread Na Zhu
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 
---
 ovn/northd/ovn-northd.8.xml |   4 ++
 ovn/northd/ovn-northd.c |  10 
 ovn/ovn-nb.ovsschema|   5 +-
 ovn/ovn-nb.xml  |   7 +++
 tests/ovn.at| 142 

 5 files changed, 166 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;
 
 Logical Router Datapaths
 
+
+Logical router datapaths will only exist for  rows in the  database that do not have  set to false
+
+
 Ingress Table 0: L2 Admission Control
 
 
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, );
 }
 
+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,
 >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.
 
 
+
+  This column is used to administratively set router state.  If this 
column
+  is empty or is set to true, the router is enabled.  If 
this
+  column is set to false, the router is disabled.  A 
disabled
+  router has all ingress and egress traffic dropped.
+
+ 
 
   
 See External IDs at the beginning of this document.
diff --git a/tests/ovn.at b/tests/ovn.at
index 22121e1..f5bfa9c 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -2141,3 +2141,145 @@ OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
 
 AT_CLEANUP
+
+
+AT_SETUP([ovn -- 1 HVs, 2 LSs, 1 lport/LS, 1 LR])
+AT_KEYWORDS([router-admin-state])
+AT_SKIP_IF([test $HAVE_PYTHON = no])
+ovn_start
+
+# Logical network:
+# One LR - R1 has switch ls1 (191.168.1.0/24) connected to it,
+# and has switch ls2 (172.16.1.0/24) connected to it.
+
+ovn-nbctl create Logical_Router name=R1
+
+ovn-nbctl lswitch-add ls1
+ovn-nbctl lswitch-add ls2
+
+# Connect ls1 to R1
+ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls1 \
+network=192.168.1.1/24 mac=\"00:00:00:01:02:03\" -- add Logical_Router R1 
\
+ports @lrp -- lport-add ls1 rp-ls1
+
+ovn-nbctl set Logical_port rp-ls1 type=router options:router-port=ls1 \
+addresses=\"00:00:00:01:02:03\"
+
+# Connect ls2 to R1
+ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls2 \
+network=172.16.1.1/24 mac=\"00:00:00:01:02:04\" -- add Logical_Router R1 
\
+ports @lrp -- lport-add ls2 rp-ls2
+
+ovn-nbctl set Logical_port rp-ls2 type=router options:router-port=ls2 \
+addresses=\"00:00:00:01:02:04\"
+
+# Create logical port ls1-lp1 in ls1
+ovn-nbctl lport-add ls1 ls1-lp1 \
+-- lport-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
+
+# Create logical port ls2-lp1 in ls2
+ovn-nbctl lport-add ls2 ls2-lp1 \
+-- lport-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2"
+
+# Create one hypervisor and create OVS ports corresponding to logical 
ports.
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+ovn_attach 

[ovs-dev] [PATCH v3 1/1] ovn: Add column enabled to table Logical_Router

2016-04-06 Thread Na Zhu
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 
---
 ovn/northd/ovn-northd.8.xml |   4 ++
 ovn/northd/ovn-northd.c |  10 
 ovn/ovn-nb.ovsschema|   5 +-
 ovn/ovn-nb.xml  |   7 +++
 tests/ovn.at| 142 

 5 files changed, 166 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;
 
 Logical Router Datapaths
 
+
+Logical router datapaths will only exist for  rows in the  database that do not have  set to false
+
+
 Ingress Table 0: L2 Admission Control
 
 
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, );
 }
 
+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,
 >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.
 
 
+
+  This column is used to administratively set router state.  If this 
column
+  is empty or is set to true, the router is enabled.  If 
this
+  column is set to false, the router is disabled.  A 
disabled
+  router has all ingress and egress traffic dropped.
+
+ 
 
   
 See External IDs at the beginning of this document.
diff --git a/tests/ovn.at b/tests/ovn.at
index 22121e1..f5bfa9c 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -2141,3 +2141,145 @@ OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
 
 AT_CLEANUP
+
+
+AT_SETUP([ovn -- 1 HVs, 2 LSs, 1 lport/LS, 1 LR])
+AT_KEYWORDS([router-admin-state])
+AT_SKIP_IF([test $HAVE_PYTHON = no])
+ovn_start
+
+# Logical network:
+# One LR - R1 has switch ls1 (191.168.1.0/24) connected to it,
+# and has switch ls2 (172.16.1.0/24) connected to it.
+
+ovn-nbctl create Logical_Router name=R1
+
+ovn-nbctl lswitch-add ls1
+ovn-nbctl lswitch-add ls2
+
+# Connect ls1 to R1
+ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls1 \
+network=192.168.1.1/24 mac=\"00:00:00:01:02:03\" -- add Logical_Router R1 
\
+ports @lrp -- lport-add ls1 rp-ls1
+
+ovn-nbctl set Logical_port rp-ls1 type=router options:router-port=ls1 \
+addresses=\"00:00:00:01:02:03\"
+
+# Connect ls2 to R1
+ovn-nbctl -- --id=@lrp create Logical_Router_port name=ls2 \
+network=172.16.1.1/24 mac=\"00:00:00:01:02:04\" -- add Logical_Router R1 
\
+ports @lrp -- lport-add ls2 rp-ls2
+
+ovn-nbctl set Logical_port rp-ls2 type=router options:router-port=ls2 \
+addresses=\"00:00:00:01:02:04\"
+
+# Create logical port ls1-lp1 in ls1
+ovn-nbctl lport-add ls1 ls1-lp1 \
+-- lport-set-addresses ls1-lp1 "f0:00:00:01:02:03 192.168.1.2"
+
+# Create logical port ls2-lp1 in ls2
+ovn-nbctl lport-add ls2 ls2-lp1 \
+-- lport-set-addresses ls2-lp1 "f0:00:00:01:02:04 172.16.1.2"
+
+# Create one hypervisor and create OVS ports corresponding to logical 
ports.
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+ovn_attach