[ovs-dev] [PATCH v3] ovs-router: Report ovs/route/add errors as errors.

Ben Pfaff blp at ovn.org
Tue Nov 24 04:49:35 UTC 2015


The _error version should be used to report errors.

Also, add missing return in one error case.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
v1->v2: Add missing return in error case (thanks Cascardo!).
v2->v3: Add missing return in another error case (thanks Cascardo!).

 lib/ovs-router.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index 2f093e8..a43cce8 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -275,7 +275,8 @@ ovs_router_add(struct unixctl_conn *conn, int argc,
             gw6 = in6addr_any;
         }
     } else {
-        unixctl_command_reply(conn, "Invalid parameters");
+        unixctl_command_reply_error(conn, "Invalid parameters");
+        return;
     }
     ovs_router_insert__(plen + 32, &ip6, plen, argv[2], &gw6);
     unixctl_command_reply(conn, "OK");
@@ -293,13 +294,14 @@ ovs_router_del(struct unixctl_conn *conn, int argc OVS_UNUSED,
         in6_addr_set_mapped_ipv4(&ip6, ip);
         plen += 96;
     } else if (!scan_ipv6_route(argv[1], &ip6, &plen)) {
-        unixctl_command_reply(conn, "Invalid parameters");
+        unixctl_command_reply_error(conn, "Invalid parameters");
+        return;
     }
     if (rt_entry_delete(plen + 32, &ip6, plen)) {
         unixctl_command_reply(conn, "OK");
         seq_change(tnl_conf_seq);
     } else {
-        unixctl_command_reply(conn, "Not found");
+        unixctl_command_reply_error(conn, "Not found");
     }
 }
 
@@ -347,7 +349,8 @@ ovs_router_lookup_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
     if (scan_ipv4_route(argv[1], &ip, &plen) && plen == 32) {
         in6_addr_set_mapped_ipv4(&ip6, ip);
     } else if (!(scan_ipv6_route(argv[1], &ip6, &plen) && plen == 128)) {
-        unixctl_command_reply(conn, "Invalid parameters");
+        unixctl_command_reply_error(conn, "Invalid parameters");
+        return;
     }
 
     if (ovs_router_lookup(&ip6, iface, &gw)) {
@@ -358,7 +361,7 @@ ovs_router_lookup_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
         unixctl_command_reply(conn, ds_cstr(&ds));
         ds_destroy(&ds);
     } else {
-        unixctl_command_reply(conn, "Not found");
+        unixctl_command_reply_error(conn, "Not found");
     }
 }
 
-- 
2.1.3




More information about the dev mailing list