[ovs-dev] [PATCH v10 2/4] ovn-controller: Add a new action - 'put_nd_ra_opts'

Ben Pfaff blp at ovn.org
Thu Nov 2 20:39:40 UTC 2017


On Thu, Nov 02, 2017 at 06:19:24AM +0530, nusiddiq at redhat.com wrote:
> From: Numan Siddique <nusiddiq at redhat.com>
> 
> This patch adds a new OVN action 'put_nd_ra_opts' to support native
> IPv6 Router Advertisement in OVN. This action can be used to respond
> to the IPv6 Router Solicitation requests.

Thanks for the patch!  I folded in the following changes because I
didn't think it made sense to mention the function name in error
messages; we don't do that elsewhere.

diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c
index 8cec5c7d0871..0df5edbaa51d 100644
--- a/ovn/lib/actions.c
+++ b/ovn/lib/actions.c
@@ -1851,69 +1851,57 @@ parse_put_nd_ra_opts(struct action_context *ctx, const struct expr_field *dst,
             o < &po->options[po->n_options]; o++) {
         const union expr_constant *c = o->value.values;
         if (o->value.n_values > 1) {
-            lexer_error(ctx->lexer, "parse_put_nd_ra_opts -Invalid value for"
-                        " the option %s.", o->option->name);
+            lexer_error(ctx->lexer, "Invalid value for \"%s\" option",
+                        o->option->name);
             return;
         }
 
+        bool ok = true;
         switch (o->option->code) {
         case ND_RA_FLAG_ADDR_MODE:
-            if (!c->string || (strcmp(c->string, "slaac") &&
-                               strcmp(c->string, "dhcpv6_stateful") &&
-                               strcmp(c->string, "dhcpv6_stateless"))) {
-                lexer_error(ctx->lexer, "parse_put_nd_ra_opts -Invalid value "
-                            "for the option %s.", o->option->name);
-                return;
-            }
-
-            if (!strcmp(c->string, "dhcpv6_stateful")) {
+            ok = (c->string && (!strcmp(c->string, "slaac") ||
+                                !strcmp(c->string, "dhcpv6_stateful") ||
+                                !strcmp(c->string, "dhcpv6_stateless")));
+            if (ok && !strcmp(c->string, "dhcpv6_stateful")) {
                 addr_mode_stateful = true;
             }
             break;
 
         case ND_OPT_SOURCE_LINKADDR:
-            if (c->format != LEX_F_ETHERNET) {
-                lexer_error(ctx->lexer, "parse_put_nd_ra_opts -Invalid value "
-                           "for the option %s.", o->option->name);
-            }
+            ok = c->format == LEX_F_ETHERNET;
             slla_present = true;
             break;
 
         case ND_OPT_PREFIX_INFORMATION:
-            if (c->format != LEX_F_IPV6 || !c->masked) {
-                lexer_error(ctx->lexer, "parse_put_nd_ra_opts -Invalid value "
-                            "for the option %s.", o->option->name);
-            }
+            ok = c->format == LEX_F_IPV6 && c->masked;
             prefix_set = true;
             break;
 
         case ND_OPT_MTU:
-            if (c->format != LEX_F_DECIMAL) {
-                lexer_error(ctx->lexer, "parse_put_nd_ra_opts -Invalid value "
-                            "for the option %s.", o->option->name);
-            }
+            ok = c->format == LEX_F_DECIMAL;
             break;
         }
-    }
 
-    if (ctx->lexer->error) {
-        return;
+        if (!ok) {
+            lexer_error(ctx->lexer, "Invalid value for \"%s\" option",
+                        o->option->name);
+            return;
+        }
     }
 
     if (!slla_present) {
-        lexer_error(ctx->lexer, "parse_put_nd_ra_opts - slla option not"
-                    " present.");
+        lexer_error(ctx->lexer, "slla option not present");
         return;
     }
 
     if (addr_mode_stateful && prefix_set) {
-        lexer_error(ctx->lexer, "parse_put_nd_ra_opts - prefix option can't be"
+        lexer_error(ctx->lexer, "prefix option can't be"
                     " set when address mode is dhcpv6_stateful.");
         return;
     }
 
     if (!addr_mode_stateful && !prefix_set) {
-        lexer_error(ctx->lexer, "parse_put_nd_ra_opts - prefix option needs "
+        lexer_error(ctx->lexer, "prefix option needs "
                     "to be set when address mode is slaac/dhcpv6_stateless.");
         return;
     }
diff --git a/tests/ovn.at b/tests/ovn.at
index 320ec4bb2b72..93515aa329d1 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -1083,25 +1083,25 @@ reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateless", slla = ae:01:02:03:04:0
     encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.40.ff.ff.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.06.03.04.40.c0.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00,pause)
     has prereqs ip6
 reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::/64);
-    parse_put_nd_ra_opts - slla option not present.
+    slla option not present
 reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", mtu = 1450, prefix = aef0::/64, prefix = bef0::/64, slla = ae:01:02:03:04:10);
-    parse_put_nd_ra_opts - prefix option can't be set when address mode is dhcpv6_stateful.
+    prefix option can't be set when address mode is dhcpv6_stateful.
 reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", mtu = 1450, prefix = aef0::/64, prefix = bef0::/64, slla = ae:01:02:03:04:10);
-    parse_put_nd_ra_opts - prefix option can't be set when address mode is dhcpv6_stateful.
+    prefix option can't be set when address mode is dhcpv6_stateful.
 reg1[0] = put_nd_ra_opts(addr_mode = "slaac", slla = ae:01:02:03:04:10);
-    parse_put_nd_ra_opts - prefix option needs to be set when address mode is slaac/dhcpv6_stateless.
+    prefix option needs to be set when address mode is slaac/dhcpv6_stateless.
 reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateless", slla = ae:01:02:03:04:10);
-    parse_put_nd_ra_opts - prefix option needs to be set when address mode is slaac/dhcpv6_stateless.
+    prefix option needs to be set when address mode is slaac/dhcpv6_stateless.
 reg1[0] = put_nd_ra_opts(addr_mode = dhcpv6_stateless, prefix = aef0::/64, slla = ae:01:02:03:04:10);
     Syntax error at `dhcpv6_stateless' expecting constant.
 reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::, slla = ae:01:02:03:04:10);
-    parse_put_nd_ra_opts -Invalid value for the option prefix.
+    Invalid value for "prefix" option
 reg1[0] = put_nd_ra_opts(addr_mode = "foo", mtu = 1500, slla = ae:01:02:03:04:10);
-    parse_put_nd_ra_opts -Invalid value for the option addr_mode.
+    Invalid value for "addr_mode" option
 reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = "1500", slla = ae:01:02:03:04:10);
     IPv6 ND RA option mtu requires numeric value.
 reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 10.0.0.4, slla = ae:01:02:03:04:10);
-    parse_put_nd_ra_opts -Invalid value for the option mtu.
+    Invalid value for "mtu" option
 
 # Contradictionary prerequisites (allowed but not useful):
 ip4.src = ip6.src[0..31];
-- 
2.10.2



More information about the dev mailing list