teamd: improve the error output for non-integer port prio
diff mbox series

Message ID 56d8b977834692b0b4829fd0727acdbd7a0a1dd2.1562067236.git.lucien.xin@gmail.com
State New
Headers show
Series
  • teamd: improve the error output for non-integer port prio
Related show

Commit Message

Xin Long July 2, 2019, 11:33 a.m. UTC
This patch is to improve the error log when users pass
a non-integer value to set port's prio. After that, we
can remove the error output for teamd_config_port_set
failure from teamd_config_port_update.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 teamd/teamd_config.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

Comments

Jiri Pirko July 2, 2019, 1:16 p.m. UTC | #1
Tue, Jul 02, 2019 at 01:33:56PM CEST, lucien.xin@gmail.com wrote:
>This patch is to improve the error log when users pass
>a non-integer value to set port's prio. After that, we
>can remove the error output for teamd_config_port_set
>failure from teamd_config_port_update.
>
>Signed-off-by: Xin Long <lucien.xin@gmail.com>

applied, thanks!

Patch
diff mbox series

diff --git a/teamd/teamd_config.c b/teamd/teamd_config.c
index 1bf85ac..610ad5f 100644
--- a/teamd/teamd_config.c
+++ b/teamd/teamd_config.c
@@ -167,17 +167,19 @@  static int teamd_config_port_set(struct teamd_context *ctx, const char *port_nam
 		return 0;
 
 	config = json_object_get(port_obj, "prio");
-	if (json_is_integer(config)) {
-		tmp = json_integer_value(config);
-		err = team_set_port_priority(ctx->th, tdport->ifindex, tmp);
-		if (err) {
-			teamd_log_err("%s: Failed to set \"priority\".",
-				      tdport->ifname);
-			return err;
-		}
+	if (!json_is_integer(config)) {
+		teamd_log_err("%s: Failed to get integer for \"priority\".",
+			      tdport->ifname);
+		return -ENOENT;
 	}
 
-	return 0;
+	tmp = json_integer_value(config);
+	err = team_set_port_priority(ctx->th, tdport->ifindex, tmp);
+	if (err)
+		teamd_log_err("%s: Failed to update \"priority\" to kernel",
+			      tdport->ifname);
+
+	return err;
 }
 
 int teamd_config_port_update(struct teamd_context *ctx, const char *port_name,
@@ -206,16 +208,14 @@  int teamd_config_port_update(struct teamd_context *ctx, const char *port_name,
 	/* replace existing object content */
 	json_object_clear(port_obj);
 	err = json_object_update(port_obj, port_new_obj);
-	if (err)
+	if (err) {
 		teamd_log_err("%s: Failed to update existing config "
 			      "port object", port_name);
-	else {
-		err = teamd_config_port_set(ctx, port_name, port_new_obj);
-		if (err)
-			teamd_log_err("%s: Failed to update config to kernel",
-				      port_name);
+		goto new_port_decref;
 	}
 
+	err = teamd_config_port_set(ctx, port_name, port_new_obj);
+
 new_port_decref:
 	json_decref(port_new_obj);
 	return err;