Re: [ovs-dev] [PATCH v10] ovn-nbctl: Add LB commands.

2016-10-07 Thread nickcooper-zhangtonghao
Good idea. I am interested in that. The patch will be submitted. Thanks.

> On Oct 8, 2016, at 2:09 AM, Guru Shetty  wrote:
> 
> On 5 October 2016 at 04:25, nickcooper-zhangtonghao 
>  > wrote:
> Thanks very much.
> 
> If it is of interest,  something similar can be done for NAT too.

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


Re: [ovs-dev] [PATCH v10] ovn-nbctl: Add LB commands.

2016-10-07 Thread Guru Shetty
On 5 October 2016 at 04:25, nickcooper-zhangtonghao <
nickcooper-zhangtong...@opencloud.tech> wrote:

> Thanks very much.
>

If it is of interest,  something similar can be done for NAT too.


>
> > On Oct 4, 2016, at 5:12 AM, Guru Shetty  wrote:
> >
> > I applied the patch. For future, when you version, please have some sort
> of versioning information that tells the difference between the versions
> below the "---" line.
>
> ___
> 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 v10] ovn-nbctl: Add LB commands.

2016-10-05 Thread nickcooper-zhangtonghao
Thanks very much.

> On Oct 4, 2016, at 5:12 AM, Guru Shetty  wrote:
> 
> I applied the patch. For future, when you version, please have some sort of 
> versioning information that tells the difference between the versions below 
> the "---" line.

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


Re: [ovs-dev] [PATCH v10] ovn-nbctl: Add LB commands.

2016-10-03 Thread Guru Shetty
On 3 October 2016 at 01:57, nickcooper-zhangtonghao <
nickcooper-zhangtong...@opencloud.tech> wrote:

> This patch provides the command line to create a load balancer.
> You can create a load balancer independently and add it to multiple
> switches or routers. A single load balancer can have multiple vips.
> Add a name column for the load balancer. With --add-duplicate,
> the command really creates a new load balancer with a duplicate name.
> This name has no special meaning or purpose other than to provide
> convenience for human interaction with the ovn-nb database.
> This patch also provides the unit tests and the documentation.
>
> Signed-off-by: nickcooper-zhangtonghao  opencloud.tech>
>
I applied the patch. For future, when you version, please have some sort of
versioning information that tells the difference between the versions below
the "---" line.


> ---
>  lib/packets.c |  18 ++
>  lib/packets.h |  10 +
>  ovn/ovn-nb.ovsschema  |   5 +-
>  ovn/ovn-nb.xml|   6 +
>  ovn/utilities/ovn-nbctl.8.xml | 105 +
>  ovn/utilities/ovn-nbctl.c | 486 ++
> +++-
>  tests/ovn-nbctl.at| 229 
>  7 files changed, 856 insertions(+), 3 deletions(-)
>
> diff --git a/lib/packets.c b/lib/packets.c
> index e4c29d5..11bb587 100644
> --- a/lib/packets.c
> +++ b/lib/packets.c
> @@ -427,6 +427,24 @@ ip_parse(const char *s, ovs_be32 *ip)
>  return inet_pton(AF_INET, s, ip) == 1;
>  }
>
> +/* Parses string 's', which must be an IP address with a port number
> + * with ":" as a separator (e.g.: 192.168.1.2:80).
> + * Stores the IP address into '*ip' and port number to '*port'. */
> +char * OVS_WARN_UNUSED_RESULT
> +ip_parse_port(const char *s, ovs_be32 *ip, ovs_be16 *port)
> +{
> +int n = 0;
> +if (!ovs_scan_len(s, , IP_PORT_SCAN_FMT,
> +IP_PORT_SCAN_ARGS(ip, port))) {
> +return xasprintf("%s: invalid IP address or port number", s);
> +}
> +
> +if (s[n]) {
> +return xasprintf("%s: invalid IP address or port number", s);
> +}
> +return NULL;
> +}
> +
>  /* Parses string 's', which must be an IP address with an optional
> netmask or
>   * CIDR prefix length.  Stores the IP address into '*ip', netmask into
> '*mask',
>   * (255.255.255.255, if 's' lacks a netmask), and number of scanned
> characters
> diff --git a/lib/packets.h b/lib/packets.h
> index dcfcd04..21bd35c 100644
> --- a/lib/packets.h
> +++ b/lib/packets.h
> @@ -537,6 +537,14 @@ mpls_lse_to_bos(ovs_be32 mpls_lse)
>  &((uint8_t *) ip)[2],   \
>  &((uint8_t *) ip)[3]
>
> +#define IP_PORT_SCAN_FMT "%"SCNu8".%"SCNu8".%"SCNu8".%"SCNu8":%"SCNu16
> +#define IP_PORT_SCAN_ARGS(ip, port)\
> +((void) (ovs_be32) *(ip), &((uint8_t *) ip)[0]),\
> +&((uint8_t *) ip)[1],   \
> +&((uint8_t *) ip)[2],   \
> +&((uint8_t *) ip)[3],   \
> +((void) (ovs_be16) *(port), (uint16_t *) port)
> +
>  /* Returns true if 'netmask' is a CIDR netmask, that is, if it consists
> of N
>   * high-order 1-bits and 32-N low-order 0-bits. */
>  static inline bool
> @@ -558,6 +566,8 @@ ip_is_local_multicast(ovs_be32 ip)
>  int ip_count_cidr_bits(ovs_be32 netmask);
>  void ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *);
>  bool ip_parse(const char *s, ovs_be32 *ip);
> +char *ip_parse_port(const char *s, ovs_be32 *ip, ovs_be16 *port)
> +OVS_WARN_UNUSED_RESULT;
>  char *ip_parse_masked(const char *s, ovs_be32 *ip, ovs_be32 *mask)
>  OVS_WARN_UNUSED_RESULT;
>  char *ip_parse_cidr(const char *s, ovs_be32 *ip, unsigned int *plen)
> diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
> index b7e70aa..5f2f2bf 100644
> --- a/ovn/ovn-nb.ovsschema
> +++ b/ovn/ovn-nb.ovsschema
> @@ -1,7 +1,7 @@
>  {
>  "name": "OVN_Northbound",
> -"version": "5.3.3",
> -"cksum": "2442952958 9945",
> +"version": "5.3.4",
> +"cksum": "1155817817 9975",
>  "tables": {
>  "NB_Global": {
>  "columns": {
> @@ -97,6 +97,7 @@
>  "isRoot": true},
>  "Load_Balancer": {
>  "columns": {
> +   "name": {"type": "string"},
>  "vips": {
>  "type": {"key": "string", "value": "string",
>   "min": 0, "max": "unlimited"}},
> diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
> index c45a444..b7690d0 100644
> --- a/ovn/ovn-nb.xml
> +++ b/ovn/ovn-nb.xml
> @@ -676,6 +676,12 @@
>Each row represents one load balancer.
>  
>
> +
> +  A name for the load balancer.  This name has no special meaning or
> +  purpose other than to provide convenience for human interaction with
> +  the ovn-nb database.
> +
> +
>  
>
>  A map 

[ovs-dev] [PATCH v10] ovn-nbctl: Add LB commands.

2016-10-03 Thread nickcooper-zhangtonghao
This patch provides the command line to create a load balancer.
You can create a load balancer independently and add it to multiple
switches or routers. A single load balancer can have multiple vips.
Add a name column for the load balancer. With --add-duplicate,
the command really creates a new load balancer with a duplicate name.
This name has no special meaning or purpose other than to provide
convenience for human interaction with the ovn-nb database.
This patch also provides the unit tests and the documentation.

Signed-off-by: nickcooper-zhangtonghao 
---
 lib/packets.c |  18 ++
 lib/packets.h |  10 +
 ovn/ovn-nb.ovsschema  |   5 +-
 ovn/ovn-nb.xml|   6 +
 ovn/utilities/ovn-nbctl.8.xml | 105 +
 ovn/utilities/ovn-nbctl.c | 486 +-
 tests/ovn-nbctl.at| 229 
 7 files changed, 856 insertions(+), 3 deletions(-)

diff --git a/lib/packets.c b/lib/packets.c
index e4c29d5..11bb587 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -427,6 +427,24 @@ ip_parse(const char *s, ovs_be32 *ip)
 return inet_pton(AF_INET, s, ip) == 1;
 }
 
+/* Parses string 's', which must be an IP address with a port number
+ * with ":" as a separator (e.g.: 192.168.1.2:80).
+ * Stores the IP address into '*ip' and port number to '*port'. */
+char * OVS_WARN_UNUSED_RESULT
+ip_parse_port(const char *s, ovs_be32 *ip, ovs_be16 *port)
+{
+int n = 0;
+if (!ovs_scan_len(s, , IP_PORT_SCAN_FMT,
+IP_PORT_SCAN_ARGS(ip, port))) {
+return xasprintf("%s: invalid IP address or port number", s);
+}
+
+if (s[n]) {
+return xasprintf("%s: invalid IP address or port number", s);
+}
+return NULL;
+}
+
 /* Parses string 's', which must be an IP address with an optional netmask or
  * CIDR prefix length.  Stores the IP address into '*ip', netmask into '*mask',
  * (255.255.255.255, if 's' lacks a netmask), and number of scanned characters
diff --git a/lib/packets.h b/lib/packets.h
index dcfcd04..21bd35c 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -537,6 +537,14 @@ mpls_lse_to_bos(ovs_be32 mpls_lse)
 &((uint8_t *) ip)[2],   \
 &((uint8_t *) ip)[3]
 
+#define IP_PORT_SCAN_FMT "%"SCNu8".%"SCNu8".%"SCNu8".%"SCNu8":%"SCNu16
+#define IP_PORT_SCAN_ARGS(ip, port)\
+((void) (ovs_be32) *(ip), &((uint8_t *) ip)[0]),\
+&((uint8_t *) ip)[1],   \
+&((uint8_t *) ip)[2],   \
+&((uint8_t *) ip)[3],   \
+((void) (ovs_be16) *(port), (uint16_t *) port)
+
 /* Returns true if 'netmask' is a CIDR netmask, that is, if it consists of N
  * high-order 1-bits and 32-N low-order 0-bits. */
 static inline bool
@@ -558,6 +566,8 @@ ip_is_local_multicast(ovs_be32 ip)
 int ip_count_cidr_bits(ovs_be32 netmask);
 void ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *);
 bool ip_parse(const char *s, ovs_be32 *ip);
+char *ip_parse_port(const char *s, ovs_be32 *ip, ovs_be16 *port)
+OVS_WARN_UNUSED_RESULT;
 char *ip_parse_masked(const char *s, ovs_be32 *ip, ovs_be32 *mask)
 OVS_WARN_UNUSED_RESULT;
 char *ip_parse_cidr(const char *s, ovs_be32 *ip, unsigned int *plen)
diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
index b7e70aa..5f2f2bf 100644
--- a/ovn/ovn-nb.ovsschema
+++ b/ovn/ovn-nb.ovsschema
@@ -1,7 +1,7 @@
 {
 "name": "OVN_Northbound",
-"version": "5.3.3",
-"cksum": "2442952958 9945",
+"version": "5.3.4",
+"cksum": "1155817817 9975",
 "tables": {
 "NB_Global": {
 "columns": {
@@ -97,6 +97,7 @@
 "isRoot": true},
 "Load_Balancer": {
 "columns": {
+   "name": {"type": "string"},
 "vips": {
 "type": {"key": "string", "value": "string",
  "min": 0, "max": "unlimited"}},
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index c45a444..b7690d0 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -676,6 +676,12 @@
   Each row represents one load balancer.
 
 
+
+  A name for the load balancer.  This name has no special meaning or
+  purpose other than to provide convenience for human interaction with
+  the ovn-nb database.
+
+
 
   
 A map of virtual IPv4 addresses (and an optional port number with
diff --git a/ovn/utilities/ovn-nbctl.8.xml b/ovn/utilities/ovn-nbctl.8.xml
index 76cf97e..7cd515f 100644
--- a/ovn/utilities/ovn-nbctl.8.xml
+++ b/ovn/utilities/ovn-nbctl.8.xml
@@ -400,6 +400,111 @@
   
 
 
+Load Balancer Commands
+
+  [--may-exist | --add-duplicate] 
lb-add lb vip ips 
[protocol]
+  
+
+ Creates a new load balancer named lb with the provided
+ vip and ips or adds the vip to
+