libteam/SOURCES/libteam-teamd-config-update...

69 lines
1.9 KiB
Diff

From c8b356a3cd363af10d71e21a4fb7dc26cf90b5bc Mon Sep 17 00:00:00 2001
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Mon, 7 Jan 2019 15:58:49 +0800
Subject: [PATCH 2/6] teamd: config: update local prio to kernel
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>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd_config.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
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;
--
2.18.1