[ovs-dev] [PATCHv2 1/2] ovn-northd: Allow lport 'addresses' to store multiple ips in each set

Ben Pfaff blp at ovn.org
Thu Feb 25 22:22:49 UTC 2016


On Mon, Feb 22, 2016 at 03:59:37PM +0530, Numan Siddique wrote:
> If a logical port has two ipv4 addresses and one ipv6 address
> it will be stored as ["MAC IPv41 IPv42 IPv61"] instead of
> ["MAC IPv41", "MAC IPv42", "MAC IPv61"].
> 
> Signed-off-by: Numan Siddique <nusiddiq at redhat.com>

Thanks.

I folded in the following changes to improve the comments and fix the
use of the "test" utility in ovn.at and applied this to master.
                                 
diff --git a/lib/packets.c b/lib/packets.c
index 005e015..daca1b3 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -425,9 +425,9 @@ ip_parse(const char *s, ovs_be32 *ip)
 }
 
 /* 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'.  (If 's' does not contain a netmask, 255.255.255.255 is
- * assumed.) and number of scanned characters in 'n'
+ * 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
+ * into '*n'.
  *
  * Returns NULL if successful, otherwise an error message that the caller must
  * free(). */
@@ -455,9 +455,9 @@ ip_parse_masked_len(const char *s, int *n, ovs_be32 *ip,
     return NULL;
 }
 
-/* This function is similar to ip_parse_masked_len(), but doesn't return
- * the number of scanned characters and expects 's' to be NULL terminated
- * at the end of the ip/(optional) mask.
+/* This function is similar to ip_parse_masked_len(), but doesn't return the
+ * number of scanned characters and expects 's' to end after the ip/(optional)
+ * mask.
  *
  * Returns NULL if successful, otherwise an error message that the caller must
  * free(). */
@@ -468,8 +468,7 @@ ip_parse_masked(const char *s, ovs_be32 *ip, ovs_be32 *mask)
 
     char *error = ip_parse_masked_len(s, &n, ip, mask);
     if (!error && s[n]) {
-        return xasprintf("%s: invalid IP address format. Not NULL terminated",
-                         s);
+        return xasprintf("%s: invalid IP address", s);
     }
     return error;
 }
@@ -504,7 +503,7 @@ ip_parse_cidr(const char *s, ovs_be32 *ip, unsigned int *plen)
 
     char *error = ip_parse_cidr_len(s, &n, ip, plen);
     if (!error && s[n]) {
-        return xasprintf("%s: Contains invalid characters.", s);
+        return xasprintf("%s: invalid IP address", s);
     }
     return error;
 }
@@ -519,8 +518,8 @@ ipv6_parse(const char *s, struct in6_addr *ip)
 
 /* Parses string 's', which must be an IPv6 address with an optional netmask or
  * CIDR prefix length.  Stores the IPv6 address into '*ip' and the netmask into
- * '*mask' (if 's' does not contain a netmask, all-one-bits is assumed.) and
- * number of scanned characters in 'n'.
+ * '*mask' (if 's' does not contain a netmask, all-one-bits is assumed), and
+ * number of scanned characters into '*n'.
  *
  * Returns NULL if successful, otherwise an error message that the caller must
  * free(). */
@@ -545,7 +544,7 @@ ipv6_parse_masked_len(const char *s, int *n, struct in6_addr *ip,
              }
             /* OK. */
         } else {
-            /* OK. No mask */
+            /* OK. No mask. */
             *mask = in6addr_exact;
         }
         return NULL;
@@ -553,11 +552,9 @@ ipv6_parse_masked_len(const char *s, int *n, struct in6_addr *ip,
     return xasprintf("%s: invalid IPv6 address", s);
 }
 
-/*
- * This function is similar to ipv6_parse_masked_len(), but doesn't return the
- * number of scanned characters and expects 's' to be NULL terminated at the
- * end of the ipv6/(optional) mask.
- */
+/* This function is similar to ipv6_parse_masked_len(), but doesn't return the
+ * number of scanned characters and expects 's' to end following the
+ * ipv6/(optional) mask. */
 char * OVS_WARN_UNUSED_RESULT
 ipv6_parse_masked(const char *s, struct in6_addr *ip, struct in6_addr *mask)
 {
@@ -565,7 +562,7 @@ ipv6_parse_masked(const char *s, struct in6_addr *ip, struct in6_addr *mask)
 
     char *error = ipv6_parse_masked_len(s, &n, ip, mask);
     if (!error && s[n]) {
-        return xasprintf("%s: Contains invalid characters.", s);
+        return xasprintf("%s: invalid IPv6 address", s);
     }
     return error;
 }
@@ -592,9 +589,7 @@ ipv6_parse_cidr_len(const char *s, int *n, struct in6_addr *ip,
 }
 
 /* Similar to ipv6_parse_cidr_len(), but doesn't return the number of scanned
- * characters and expects 's' to be NULL terminated at the end of the
- * ipv6/(optional) cidr.
- */
+ * characters and expects 's' to end after the ipv6/(optional) cidr. */
 char * OVS_WARN_UNUSED_RESULT
 ipv6_parse_cidr(const char *s, struct in6_addr *ip, unsigned int *plen)
 {
@@ -602,7 +597,7 @@ ipv6_parse_cidr(const char *s, struct in6_addr *ip, unsigned int *plen)
 
     char *error = ipv6_parse_cidr_len(s, &n, ip, plen);
     if (!error && s[n]) {
-        return xasprintf("%s: Contains invalid characters.", s);
+        return xasprintf("%s: invalid IPv6 address", s);
     }
     return error;
 }
diff --git a/tests/ovn.at b/tests/ovn.at
index 36c9117..0e71732 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -551,7 +551,7 @@ for i in 1 2 3; do
         if test $j = 1; then
             ovn-nbctl lport-set-addresses lp$i$j "f0:00:00:00:00:$i$j 192.168.0.$i$j" unknown
         else
-            if test $j == 3; then
+            if test $j = 3; then
                 ip_addrs="192.168.0.$i$j fe80::ea2a:eaff:fe28:$i$j/64 192.169.0.$i$j"
             else
                 ip_addrs="192.168.0.$i$j"
@@ -725,7 +725,7 @@ for is in 1 2 3; do
                 test_arp $s f000000000$s $sip $tip f000000000$d            #9
                 test_arp $s f000000000$s $sip $tip_unknown                 #10
 
-                if test $jd == 3; then
+                if test $jd = 3; then
                     # lport[123]3 has an additional ip 192.169.0.[123]3.
                     tip=`ip_to_hex 192 169 0 $id$jd`
                     test_arp $s f000000000$s $sip $tip f000000000$d        #9



More information about the dev mailing list