teamd: config: update local prio to kernel
diff mbox series

Message ID 20190107075849.6509-1-liuhangbin@gmail.com
State New
Headers show
Series
  • teamd: config: update local prio to kernel
Related show

Commit Message

Hangbin Liu Jan. 7, 2019, 7:58 a.m. UTC
Team port's priority will affect the active port selection. Update the
local config is not enough. We also need to update kernel configs.

Reported-by: Liang Li <liali@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 teamd/teamd_config.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

Jiri Pirko Jan. 14, 2019, 6:08 p.m. UTC | #1
Mon, Jan 07, 2019 at 08:58:49AM CET, liuhangbin@gmail.com wrote:
>Team port's priority will affect the active port selection. Update the
>local config is not enough. We also need to update kernel configs.
>
>Reported-by: Liang Li <liali@redhat.com>
>Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

applied, thanks.

Patch
diff mbox series

diff --git a/teamd/teamd_config.c b/teamd/teamd_config.c
index 94158ce..69b25de 100644
--- a/teamd/teamd_config.c
+++ b/teamd/teamd_config.c
@@ -155,6 +155,31 @@  errout:
 	return err;
 }
 
+static int teamd_config_port_set(struct teamd_context *ctx, const char *port_name,
+				 json_t *port_obj)
+{
+	struct teamd_port *tdport;
+	json_t *config;
+	int tmp, err;
+
+	tdport = teamd_get_port_by_ifname(ctx, port_name);
+	if (!tdport)
+		return -ENODEV;
+
+	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;
+		}
+	}
+
+	return 0;
+}
+
 int teamd_config_port_update(struct teamd_context *ctx, const char *port_name,
 			     const char *json_port_cfg_str)
 {
@@ -184,6 +209,13 @@  int teamd_config_port_update(struct teamd_context *ctx, const char *port_name,
 	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);
+	}
+
 new_port_decref:
 	json_decref(port_new_obj);
 	return err;