Compare commits

...

No commits in common. "imports/c8s/libteam-1.29-5.el8" and "c8" have entirely different histories.

13 changed files with 295 additions and 1102 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/libteam-1.29.tar.gz
SOURCES/libteam-1.31.tar.gz

View File

@ -1 +1 @@
2dbdd6769c61381f84a31553bc5502a60376e33b SOURCES/libteam-1.29.tar.gz
4e5e0a0d0682f27a0850fac1f9bababdb991f14a SOURCES/libteam-1.31.tar.gz

View File

@ -0,0 +1,55 @@
From 61efd6de2fbb8ee077863ee5a355ac3dfd9365b9 Mon Sep 17 00:00:00 2001
Message-Id: <61efd6de2fbb8ee077863ee5a355ac3dfd9365b9.1599144624.git.lucien.xin@gmail.com>
From: Xin Long <lucien.xin@gmail.com>
Date: Tue, 1 Sep 2020 13:59:27 +0800
Subject: [PATCH] Revert "teamd: Disregard current state when considering port
enablement"
This reverts commit deadb5b715227429a1879b187f5906b39151eca9.
As Patrick noticed, with that commit, teamd_port_check_enable()
would set the team port to the new state unconditionally, which
triggers another change message from kernel to userspace, then
teamd_port_check_enable() is called again to set the team port
to the new state.
This would go around and around to update the team port state,
and even cause teamd to consume 100% cpu.
As the issue caused by that commit is serious, it has to be
reverted. As for the issued fixed by that commit, I would
propose a new fix later.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
teamd/teamd_per_port.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c
index 166da57..d429753 100644
--- a/teamd/teamd_per_port.c
+++ b/teamd/teamd_per_port.c
@@ -442,14 +442,18 @@ int teamd_port_check_enable(struct teamd_context *ctx,
bool should_enable, bool should_disable)
{
bool new_enabled_state;
+ bool curr_enabled_state;
int err;
if (!teamd_port_present(ctx, tdport))
return 0;
+ err = teamd_port_enabled(ctx, tdport, &curr_enabled_state);
+ if (err)
+ return err;
- if (should_enable)
+ if (!curr_enabled_state && should_enable)
new_enabled_state = true;
- else if (should_disable)
+ else if (curr_enabled_state && should_disable)
new_enabled_state = false;
else
return 0;
--
2.18.1

View File

@ -1,848 +0,0 @@
From f32310b9a5cc0322d8f5c85d94e3866326bc68ce Mon Sep 17 00:00:00 2001
Message-Id: <f32310b9a5cc0322d8f5c85d94e3866326bc68ce.1588051704.git.lucien.xin@gmail.com>
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Mon, 2 Dec 2019 16:28:17 +0800
Subject: [PATCH 1/4] libteam: wapper teamd_log_dbg with teamd_log_dbgx
Recently some users reported that they start to see debug messages in their
syslogs even with daemon_verbosity_level = LOG_INFO and without -g option.
Actually this issue is there at the begining, the user would see the debug
messages if they run teamd with -d option. The reason that most users did
not notice this is because they are using libteam via NetworkManager, and
NetworkManager run libteam in frontend.
But after commit e47d5db53873 ("teamd: add an option to force log
output to stdout, stderr or syslog"), NetworkManager will set
TEAM_LOG_OUTPUT=syslog in the environment. At the same time libdaemon
does not filter log levels if we use syslog(see function daemon_logv in
libdaemon). Then all the users would see the debug messages suddenly and
feels annoying.
And here is the quote for daemon_set_verbosity() from libdaemon/dlog.h
"""
Allows to decide which messages to output on standard output/error
streams. All messages are logged to syslog and this setting does
not influence that.
"""
Since we should not limit how our user(NM) used libteam. And libdaemon
is intend to not filter logs if use syslog. We'd better filter the
debug message ourselves, like via -g option. So I would prefer to
move all teamd_log_dbg to teamd_log_dbgx. After that, the user could
decide whether to enable debug or not by themselves with -g option.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd.c | 38 +++++++++++++++++++-------------------
teamd/teamd.h | 5 +++--
teamd/teamd_balancer.c | 15 +++++++++------
teamd/teamd_dbus.c | 6 +++---
teamd/teamd_hash_func.c | 2 +-
teamd/teamd_link_watch.c | 8 ++++----
teamd/teamd_lw_arp_ping.c | 12 ++++++------
teamd/teamd_lw_ethtool.c | 4 ++--
teamd/teamd_lw_nsna_ping.c | 2 +-
teamd/teamd_lw_psr.c | 8 ++++----
teamd/teamd_lw_tipc.c | 10 +++++-----
teamd/teamd_per_port.c | 6 +++---
teamd/teamd_runner_activebackup.c | 10 +++++-----
teamd/teamd_runner_lacp.c | 34 +++++++++++++++++-----------------
teamd/teamd_usock.c | 12 ++++++------
teamd/teamd_zmq.c | 10 +++++-----
16 files changed, 93 insertions(+), 89 deletions(-)
diff --git a/teamd/teamd.c b/teamd/teamd.c
index 6c47312..9744021 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -332,7 +332,7 @@ static int teamd_run_loop_do_callbacks(struct list_item *lcb_list, fd_set *fds,
if (err) {
teamd_log_warn("Loop callback failed with: %s",
strerror(-err));
- teamd_log_dbg("Failed loop callback: %s, %p",
+ teamd_log_dbg(ctx, "Failed loop callback: %s, %p",
lcb->name, lcb->priv);
}
}
@@ -519,7 +519,7 @@ static int __teamd_loop_callback_fd_add(struct teamd_context *ctx,
list_add_tail(&ctx->run_loop.callback_list, &lcb->list);
else
list_add(&ctx->run_loop.callback_list, &lcb->list);
- teamd_log_dbg("Added loop callback: %s, %p", lcb->name, lcb->priv);
+ teamd_log_dbg(ctx, "Added loop callback: %s, %p", lcb->name, lcb->priv);
return 0;
lcb_free:
@@ -636,7 +636,7 @@ void teamd_loop_callback_del(struct teamd_context *ctx, const char *cb_name,
list_del(&lcb->list);
if (lcb->is_period)
close(lcb->fd);
- teamd_log_dbg("Removed loop callback: %s, %p",
+ teamd_log_dbg(ctx, "Removed loop callback: %s, %p",
lcb->name, lcb->priv);
free(lcb->name);
free(lcb);
@@ -645,7 +645,7 @@ void teamd_loop_callback_del(struct teamd_context *ctx, const char *cb_name,
if (found)
teamd_run_loop_restart(ctx);
else
- teamd_log_dbg("Callback named \"%s\" not found.", cb_name);
+ teamd_log_dbg(ctx, "Callback named \"%s\" not found.", cb_name);
}
int teamd_loop_callback_enable(struct teamd_context *ctx, const char *cb_name,
@@ -820,7 +820,7 @@ static int teamd_set_hwaddr(struct teamd_context *ctx)
if (err)
return 0; /* addr is not defined in config, no change needed */
- teamd_log_dbg("Hwaddr string: \"%s\".", hwaddr_str);
+ teamd_log_dbg(ctx, "Hwaddr string: \"%s\".", hwaddr_str);
err = parse_hwaddr(hwaddr_str, &hwaddr, &hwaddr_len);
if (err) {
teamd_log_err("Failed to parse hardware address.");
@@ -953,16 +953,16 @@ static int teamd_runner_init(struct teamd_context *ctx)
err = teamd_config_string_get(ctx, &runner_name, "$.runner.name");
if (err) {
- teamd_log_dbg("Failed to get team runner name from config.");
+ teamd_log_dbg(ctx, "Failed to get team runner name from config.");
runner_name = TEAMD_DEFAULT_RUNNER_NAME;
err = teamd_config_string_set(ctx, runner_name, "$.runner.name");
if (err) {
teamd_log_err("Failed to set default team runner name in config.");
return err;
}
- teamd_log_dbg("Using default team runner \"%s\".", runner_name);
+ teamd_log_dbg(ctx, "Using default team runner \"%s\".", runner_name);
} else {
- teamd_log_dbg("Using team runner \"%s\".", runner_name);
+ teamd_log_dbg(ctx, "Using team runner \"%s\".", runner_name);
}
ctx->runner = teamd_find_runner(runner_name);
if (!ctx->runner) {
@@ -1108,12 +1108,12 @@ static void debug_log_port_list(struct teamd_context *ctx)
char buf[120];
bool trunc;
- teamd_log_dbg("<port_list>");
+ teamd_log_dbg(ctx, "<port_list>");
team_for_each_port(port, ctx->th) {
trunc = team_port_str(port, buf, sizeof(buf));
- teamd_log_dbg("%s %s", buf, trunc ? "<trunc>" : "");
+ teamd_log_dbg(ctx, "%s %s", buf, trunc ? "<trunc>" : "");
}
- teamd_log_dbg("</port_list>");
+ teamd_log_dbg(ctx, "</port_list>");
}
static void debug_log_option_list(struct teamd_context *ctx)
@@ -1139,12 +1139,12 @@ static void debug_log_ifinfo_list(struct teamd_context *ctx)
char buf[120];
bool trunc;
- teamd_log_dbg("<ifinfo_list>");
+ teamd_log_dbg(ctx, "<ifinfo_list>");
team_for_each_ifinfo(ifinfo, ctx->th) {
trunc = team_ifinfo_str(ifinfo, buf, sizeof(buf));
- teamd_log_dbg("%s %s", buf, trunc ? "<trunc>" : "");
+ teamd_log_dbg(ctx, "%s %s", buf, trunc ? "<trunc>" : "");
}
- teamd_log_dbg("</ifinfo_list>");
+ teamd_log_dbg(ctx, "</ifinfo_list>");
}
static int debug_change_handler_func(struct team_handle *th, void *priv,
@@ -1573,7 +1573,7 @@ static int teamd_generate_devname(struct teamd_context *ctx)
if (err)
return err;
} while (ifindex);
- teamd_log_dbg("Generated team device name \"%s\".", buf);
+ teamd_log_dbg(ctx, "Generated team device name \"%s\".", buf);
ctx->team_devname = strdup(buf);
if (!ctx->team_devname)
@@ -1597,7 +1597,7 @@ static int teamd_get_devname(struct teamd_context *ctx, bool generate_enabled)
}
goto skip_set;
} else {
- teamd_log_dbg("Failed to get team device name from config.");
+ teamd_log_dbg(ctx, "Failed to get team device name from config.");
if (generate_enabled) {
err = teamd_generate_devname(ctx);
if (err) {
@@ -1617,7 +1617,7 @@ static int teamd_get_devname(struct teamd_context *ctx, bool generate_enabled)
}
skip_set:
- teamd_log_dbg("Using team device \"%s\".", ctx->team_devname);
+ teamd_log_dbg(ctx, "Using team device \"%s\".", ctx->team_devname);
err = asprintf(&ctx->ident, "%s_%s", ctx->argv0, ctx->team_devname);
if (err == -1) {
@@ -1835,9 +1835,9 @@ int main(int argc, char **argv)
daemon_log_ident = ctx->ident;
daemon_pid_file_proc = teamd_pid_file_proc;
- teamd_log_dbg("Using PID file \"%s\"", daemon_pid_file_proc());
+ teamd_log_dbg(ctx, "Using PID file \"%s\"", daemon_pid_file_proc());
if (ctx->config_file)
- teamd_log_dbg("Using config file \"%s\"", ctx->config_file);
+ teamd_log_dbg(ctx, "Using config file \"%s\"", ctx->config_file);
switch (ctx->cmd) {
case DAEMON_CMD_HELP:
diff --git a/teamd/teamd.h b/teamd/teamd.h
index 01bd022..469b769 100644
--- a/teamd/teamd.h
+++ b/teamd/teamd.h
@@ -49,15 +49,16 @@
#define teamd_log_err(args...) daemon_log(LOG_ERR, ##args)
#define teamd_log_warn(args...) daemon_log(LOG_WARNING, ##args)
#define teamd_log_info(args...) daemon_log(LOG_INFO, ##args)
-#define teamd_log_dbg(args...) daemon_log(LOG_DEBUG, ##args)
#define teamd_log_dbgx(ctx, val, args...) \
if (val <= ctx->debug) \
daemon_log(LOG_DEBUG, ##args)
+#define teamd_log_dbg(ctx, args...) teamd_log_dbgx(ctx, 1, ##args)
+
static inline void TEAMD_BUG(void)
{
- teamd_log_dbg("BUG: %s:%d\n", __FILE__, __LINE__);
+ daemon_log(LOG_DEBUG, "BUG: %s:%d\n", __FILE__, __LINE__);
assert(0);
}
diff --git a/teamd/teamd_balancer.c b/teamd/teamd_balancer.c
index 25e8613..aa6389f 100644
--- a/teamd/teamd_balancer.c
+++ b/teamd/teamd_balancer.c
@@ -174,12 +174,14 @@ static void tb_clear_rebalance_data(struct teamd_balancer *tb)
}
}
-static int tb_hash_to_port_remap(struct team_handle *th,
+static int tb_hash_to_port_remap(struct teamd_balancer *tb,
+ struct team_handle *th,
struct tb_hash_info *tbhi,
struct tb_port_info *tbpi)
{
struct team_option *option;
struct teamd_port *new_tdport = tbpi->tdport;
+ struct teamd_context *ctx = tb->ctx;
uint8_t hash = tbhi->hash;
int err;
@@ -192,7 +194,7 @@ static int tb_hash_to_port_remap(struct team_handle *th,
err = team_set_option_value_u32(th, option, new_tdport->ifindex);
if (err)
return err;
- teamd_log_dbg("Remapped hash \"%u\" (delta %" PRIu64 ") to port %s.",
+ teamd_log_dbg(ctx, "Remapped hash \"%u\" (delta %" PRIu64 ") to port %s.",
hash, tb_stats_get_delta(&tbhi->stats),
new_tdport->ifname);
return 0;
@@ -203,6 +205,7 @@ static int tb_rebalance(struct teamd_balancer *tb, struct team_handle *th)
int err;
struct tb_hash_info *tbhi;
struct tb_port_info *tbpi;
+ struct teamd_context *ctx = tb->ctx;
if (!tb->tx_balancing_enabled)
return 0;
@@ -216,7 +219,7 @@ static int tb_rebalance(struct teamd_balancer *tb, struct team_handle *th)
tbhi->rebalance.processed = true;
continue;
}
- err = tb_hash_to_port_remap(th, tbhi, tbpi);
+ err = tb_hash_to_port_remap(tb, th, tbhi, tbpi);
if (err) {
tbpi->rebalance.unusable = true;
continue;
@@ -228,7 +231,7 @@ static int tb_rebalance(struct teamd_balancer *tb, struct team_handle *th)
list_for_each_node_entry(tbpi, &tb->port_info_list, list) {
if (tbpi->rebalance.unusable)
continue;
- teamd_log_dbg("Port %s rebalanced, delta: %" PRIu64,
+ teamd_log_dbg(ctx, "Port %s rebalanced, delta: %" PRIu64,
tbpi->tdport->ifname, tbpi->rebalance.bytes);
}
return 0;
@@ -303,7 +306,7 @@ static int tb_option_change_handler_func(struct team_handle *th, void *priv,
array_index);
return -EINVAL;
}
- teamd_log_dbg("stats update for hash \"%u\": \"%" PRIu64 "\".",
+ teamd_log_dbg(ctx, "stats update for hash \"%u\": \"%" PRIu64 "\".",
array_index, lb_stats->tx_bytes);
tb_stats_update_hash(tb, array_index,
lb_stats->tx_bytes);
@@ -319,7 +322,7 @@ static int tb_option_change_handler_func(struct team_handle *th, void *priv,
port_ifindex);
return -EINVAL;
}
- teamd_log_dbg("stats update for port %s: \"%" PRIu64 "\".",
+ teamd_log_dbg(ctx, "stats update for port %s: \"%" PRIu64 "\".",
tdport->ifname, lb_stats->tx_bytes);
tb_stats_update_port(tb, tdport,
lb_stats->tx_bytes);
diff --git a/teamd/teamd_dbus.c b/teamd/teamd_dbus.c
index cdf21b1..5e7ea69 100644
--- a/teamd/teamd_dbus.c
+++ b/teamd/teamd_dbus.c
@@ -178,7 +178,7 @@ static DBusHandlerResult message_handler(DBusConnection *con,
msg_interface = dbus_message_get_interface(message);
if (!method || !path || !msg_interface)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- teamd_log_dbg("dbus: %s.%s (%s)", msg_interface, method, path);
+ teamd_log_dbg(ctx, "dbus: %s.%s (%s)", msg_interface, method, path);
if (!strcmp(method, "Introspect") &&
!strcmp(msg_interface, "org.freedesktop.DBus.Introspectable")) {
@@ -504,7 +504,7 @@ int teamd_dbus_init(struct teamd_context *ctx)
if (err)
goto iface_fini;
id = dbus_connection_get_server_id(ctx->dbus.con),
- teamd_log_dbg("dbus: connected to %s with name %s", id,
+ teamd_log_dbg(ctx, "dbus: connected to %s with name %s", id,
dbus_bus_get_unique_name(ctx->dbus.con));
dbus_free(id);
return 0;
@@ -541,7 +541,7 @@ int teamd_dbus_expose_name(struct teamd_context *ctx)
err = dbus_bus_request_name(ctx->dbus.con, service_name, 0,
&error);
if (err == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- teamd_log_dbg("dbus: have name %s", service_name);
+ teamd_log_dbg(ctx, "dbus: have name %s", service_name);
err = 0;
} else if (dbus_error_is_set(&error)) {
teamd_log_err("dbus: Failed to acquire %s: %s: %s",
diff --git a/teamd/teamd_hash_func.c b/teamd/teamd_hash_func.c
index 8923849..8c91639 100644
--- a/teamd/teamd_hash_func.c
+++ b/teamd/teamd_hash_func.c
@@ -170,7 +170,7 @@ int teamd_hash_func_set(struct teamd_context *ctx)
int err;
if (!teamd_config_path_exists(ctx, "$.runner.tx_hash")) {
- teamd_log_dbg("No Tx hash recipe found in config.");
+ teamd_log_dbg(ctx, "No Tx hash recipe found in config.");
err = teamd_hash_func_add_default_frags(ctx);
if (err)
return err;
diff --git a/teamd/teamd_link_watch.c b/teamd/teamd_link_watch.c
index 62f8267..5c626eb 100644
--- a/teamd/teamd_link_watch.c
+++ b/teamd/teamd_link_watch.c
@@ -281,7 +281,7 @@ static int link_watch_load_config_one(struct teamd_context *ctx,
err = team_get_port_user_linkup(ctx->th, tdport->ifindex, &linkup);
if (!err) {
- teamd_log_dbg("%s: Current user link state is \"%s\".",
+ teamd_log_dbg(ctx, "%s: Current user link state is \"%s\".",
tdport->ifname, linkup ? "up" : "down");
}
@@ -351,7 +351,7 @@ static int link_watch_event_watch_port_added(struct teamd_context *ctx,
cpcookie = teamd_config_path_cookie_get(ctx, "$.ports.%s.link_watch",
tdport->ifname);
if (cpcookie) {
- teamd_log_dbg("%s: Got link watch from port config.",
+ teamd_log_dbg(ctx, "%s: Got link watch from port config.",
tdport->ifname);
err = link_watch_load_config(ctx, tdport, cpcookie);
if (err)
@@ -360,7 +360,7 @@ static int link_watch_event_watch_port_added(struct teamd_context *ctx,
cpcookie = teamd_config_path_cookie_get(ctx, "$.link_watch");
if (cpcookie) {
- teamd_log_dbg("%s: Got link watch from global config.",
+ teamd_log_dbg(ctx, "%s: Got link watch from global config.",
tdport->ifname);
err = link_watch_load_config(ctx, tdport, cpcookie);
if (err)
@@ -380,7 +380,7 @@ static int link_watch_event_watch_port_added(struct teamd_context *ctx,
tdport->ifname);
return err;
}
- teamd_log_dbg("%s: Using implicit link watch.", tdport->ifname);
+ teamd_log_dbg(ctx, "%s: Using implicit link watch.", tdport->ifname);
return link_watch_event_watch_port_added(ctx, tdport, priv);
}
return 0;
diff --git a/teamd/teamd_lw_arp_ping.c b/teamd/teamd_lw_arp_ping.c
index 81806f0..c3d4710 100644
--- a/teamd/teamd_lw_arp_ping.c
+++ b/teamd/teamd_lw_arp_ping.c
@@ -178,7 +178,7 @@ static int lw_ap_load_options(struct teamd_context *ctx,
* If source_host is not provided, just use address 0.0.0.0 according
* to RFC 5227 (IPv4 Address Conflict Detection).
*/
- teamd_log_dbg("source address \"%s\".",
+ teamd_log_dbg(ctx, "source address \"%s\".",
str_in_addr(&ap_ppriv->src));
err = teamd_config_string_get(ctx, &host, "@.target_host", cpcookie);
@@ -189,25 +189,25 @@ static int lw_ap_load_options(struct teamd_context *ctx,
err = set_in_addr(&ap_ppriv->dst, host);
if (err)
return err;
- teamd_log_dbg("target address \"%s\".", str_in_addr(&ap_ppriv->dst));
+ teamd_log_dbg(ctx, "target address \"%s\".", str_in_addr(&ap_ppriv->dst));
err = teamd_config_bool_get(ctx, &ap_ppriv->validate_active,
"@.validate_active", cpcookie);
if (err)
ap_ppriv->validate_active = false;
- teamd_log_dbg("validate_active \"%d\".", ap_ppriv->validate_active);
+ teamd_log_dbg(ctx, "validate_active \"%d\".", ap_ppriv->validate_active);
err = teamd_config_bool_get(ctx, &ap_ppriv->validate_inactive,
"@.validate_inactive", cpcookie);
if (err)
ap_ppriv->validate_inactive = false;
- teamd_log_dbg("validate_inactive \"%d\".", ap_ppriv->validate_inactive);
+ teamd_log_dbg(ctx, "validate_inactive \"%d\".", ap_ppriv->validate_inactive);
err = teamd_config_bool_get(ctx, &ap_ppriv->send_always,
"@.send_always", cpcookie);
if (err)
ap_ppriv->send_always = false;
- teamd_log_dbg("send_always \"%d\".", ap_ppriv->send_always);
+ teamd_log_dbg(ctx, "send_always \"%d\".", ap_ppriv->send_always);
err = teamd_config_int_get(ctx, &tmp, "@.vlanid", cpcookie);
if (!err) {
@@ -217,7 +217,7 @@ static int lw_ap_load_options(struct teamd_context *ctx,
}
ap_ppriv->vlanid_in_use = true;
ap_ppriv->vlanid = tmp;
- teamd_log_dbg("vlan id \"%u\".", ap_ppriv->vlanid);
+ teamd_log_dbg(ctx, "vlan id \"%u\".", ap_ppriv->vlanid);
}
return 0;
diff --git a/teamd/teamd_lw_ethtool.c b/teamd/teamd_lw_ethtool.c
index 2010136..b44656e 100644
--- a/teamd/teamd_lw_ethtool.c
+++ b/teamd/teamd_lw_ethtool.c
@@ -115,7 +115,7 @@ static int lw_ethtool_load_options(struct teamd_context *ctx,
teamd_log_err("\"delay_up\" must not be negative number.");
return -EINVAL;
}
- teamd_log_dbg("delay_up \"%d\".", tmp);
+ teamd_log_dbg(ctx, "delay_up \"%d\".", tmp);
ms_to_timespec(&ethtool_ppriv->delay_up, tmp);
}
err = teamd_config_int_get(ctx, &tmp, "@.delay_down", cpcookie);
@@ -124,7 +124,7 @@ static int lw_ethtool_load_options(struct teamd_context *ctx,
teamd_log_err("\"delay_down\" must not be negative number.");
return -EINVAL;
}
- teamd_log_dbg("delay_down \"%d\".", tmp);
+ teamd_log_dbg(ctx, "delay_down \"%d\".", tmp);
ms_to_timespec(&ethtool_ppriv->delay_down, tmp);
}
return 0;
diff --git a/teamd/teamd_lw_nsna_ping.c b/teamd/teamd_lw_nsna_ping.c
index 82371c4..9273462 100644
--- a/teamd/teamd_lw_nsna_ping.c
+++ b/teamd/teamd_lw_nsna_ping.c
@@ -175,7 +175,7 @@ static int lw_nsnap_load_options(struct teamd_context *ctx,
err = set_sockaddr_in6(&nsnap_ppriv->dst, host);
if (err)
return err;
- teamd_log_dbg("target address \"%s\".",
+ teamd_log_dbg(ctx, "target address \"%s\".",
str_sockaddr_in6(&nsnap_ppriv->dst));
return 0;
diff --git a/teamd/teamd_lw_psr.c b/teamd/teamd_lw_psr.c
index ad6e56b..b0a41f4 100644
--- a/teamd/teamd_lw_psr.c
+++ b/teamd/teamd_lw_psr.c
@@ -46,7 +46,7 @@ static int lw_psr_callback_periodic(struct teamd_context *ctx, int events, void
} else {
psr_ppriv->missed++;
if (psr_ppriv->missed > psr_ppriv->missed_max && link_up) {
- teamd_log_dbg("%s: Missed %u replies (max %u).",
+ teamd_log_dbg(ctx, "%s: Missed %u replies (max %u).",
tdport->ifname, psr_ppriv->missed,
psr_ppriv->missed_max);
link_up = false;
@@ -86,7 +86,7 @@ static int lw_psr_load_options(struct teamd_context *ctx,
} else {
tmp = LW_PSR_DEFAULT_INTERVAL;
}
- teamd_log_dbg("interval \"%d\".", tmp);
+ teamd_log_dbg(ctx, "interval \"%d\".", tmp);
ms_to_timespec(&psr_ppriv->interval, tmp);
err = teamd_config_int_get(ctx, &tmp, "@.init_wait", cpcookie);
@@ -95,7 +95,7 @@ static int lw_psr_load_options(struct teamd_context *ctx,
/* if init_wait is set to 0, use default_init_wait */
if (err || !tmp)
psr_ppriv->init_wait = lw_psr_default_init_wait;
- teamd_log_dbg("init_wait \"%d\".", timespec_to_ms(&psr_ppriv->init_wait));
+ teamd_log_dbg(ctx, "init_wait \"%d\".", timespec_to_ms(&psr_ppriv->init_wait));
err = teamd_config_int_get(ctx, &tmp, "@.missed_max", cpcookie);
if (!err) {
@@ -106,7 +106,7 @@ static int lw_psr_load_options(struct teamd_context *ctx,
} else {
tmp = LW_PSR_DEFAULT_MISSED_MAX;
}
- teamd_log_dbg("missed_max \"%d\".", tmp);
+ teamd_log_dbg(ctx, "missed_max \"%d\".", tmp);
psr_ppriv->missed_max = tmp;
return 0;
diff --git a/teamd/teamd_lw_tipc.c b/teamd/teamd_lw_tipc.c
index 6d7277d..e5b51ce 100644
--- a/teamd/teamd_lw_tipc.c
+++ b/teamd/teamd_lw_tipc.c
@@ -88,8 +88,8 @@ static int lw_tipc_link_state_change(struct teamd_context *ctx,
if (strcmp(link->name, lnr->linkname))
continue;
link->up = link_up;
- teamd_log_dbg("tipc: link <%s> went %s.",
- lnr->linkname, link_up ? "up" : "down");
+ teamd_log_dbg(ctx, "tipc: link <%s> went %s.",
+ lnr->linkname, link_up ? "up" : "down");
check:
path_ok = lw_tipc_topology_check(priv, link->peer);
return teamd_link_watch_check_link_up(ctx, ppriv->tdport, ppriv,
@@ -100,7 +100,7 @@ check:
lnr->linkname);
return -EINVAL;
}
- teamd_log_dbg("tipc: established new link <%s>", lnr->linkname);
+ teamd_log_dbg(ctx, "tipc: established new link <%s>", lnr->linkname);
link = malloc(sizeof(struct tipc_link));
if (!link)
return -ENOMEM;
@@ -153,7 +153,7 @@ static int lw_tipc_callback_socket(struct teamd_context *ctx, int events, void *
else if (event.event == htonl(TIPC_WITHDRAWN))
return lw_tipc_link_state_change(ctx, &lnr, tipc_ppriv, false);
tipc_cb_err:
- teamd_log_dbg("tipc: link state event error");
+ teamd_log_dbg(ctx, "tipc: link state event error");
return -EINVAL;
}
@@ -234,7 +234,7 @@ static void lw_tipc_port_removed(struct teamd_context *ctx,
struct lw_tipc_port_priv *tipc_ppriv = priv;
struct tipc_link *link;
- teamd_log_dbg("tipc port removed\n");
+ teamd_log_dbg(ctx, "tipc port removed\n");
teamd_loop_callback_del(ctx, LW_TIPC_TOPSRV_SOCKET, priv);
close(tipc_ppriv->topsrv_sock);
while (!LIST_EMPTY(&tipc_ppriv->links)) {
diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c
index 2882ed2..327aefb 100644
--- a/teamd/teamd_per_port.c
+++ b/teamd/teamd_per_port.c
@@ -340,7 +340,7 @@ int teamd_port_add_ifname(struct teamd_context *ctx, const char *port_name)
uint32_t ifindex;
ifindex = team_ifname2ifindex(ctx->th, port_name);
- teamd_log_dbg("%s: Adding port (found ifindex \"%d\").",
+ teamd_log_dbg(ctx, "%s: Adding port (found ifindex \"%d\").",
port_name, ifindex);
return team_port_add(ctx->th, ifindex);
}
@@ -350,7 +350,7 @@ static int teamd_port_remove(struct teamd_context *ctx,
{
int err;
- teamd_log_dbg("%s: Removing port (found ifindex \"%d\").",
+ teamd_log_dbg(ctx, "%s: Removing port (found ifindex \"%d\").",
tdport->ifname, tdport->ifindex);
err = team_port_remove(ctx->th, tdport->ifindex);
if (err)
@@ -440,7 +440,7 @@ int teamd_port_check_enable(struct teamd_context *ctx,
else
return 0;
- teamd_log_dbg("%s: %s port", tdport->ifname,
+ teamd_log_dbg(ctx, "%s: %s port", tdport->ifname,
new_enabled_state ? "Enabling": "Disabling");
err = team_set_port_enabled(ctx->th, tdport->ifindex,
new_enabled_state);
diff --git a/teamd/teamd_runner_activebackup.c b/teamd/teamd_runner_activebackup.c
index f92d341..35b39a3 100644
--- a/teamd/teamd_runner_activebackup.c
+++ b/teamd/teamd_runner_activebackup.c
@@ -255,7 +255,7 @@ static int ab_clear_active_port(struct teamd_context *ctx, struct ab *ab,
ab->active_ifindex = 0;
if (!tdport || !teamd_port_present(ctx, tdport))
return 0;
- teamd_log_dbg("Clearing active port \"%s\".", tdport->ifname);
+ teamd_log_dbg(ctx, "Clearing active port \"%s\".", tdport->ifname);
err = team_set_port_enabled(ctx->th, tdport->ifindex, false);
if (err) {
@@ -368,7 +368,7 @@ static int ab_link_watch_handler(struct teamd_context *ctx, struct ab *ab)
active_tdport = teamd_get_port(ctx, ab->active_ifindex);
if (active_tdport) {
- teamd_log_dbg("Current active port: \"%s\" (ifindex \"%d\", prio \"%d\").",
+ teamd_log_dbg(ctx, "Current active port: \"%s\" (ifindex \"%d\", prio \"%d\").",
active_tdport->ifname, active_tdport->ifindex,
teamd_port_prio(ctx, active_tdport));
@@ -404,7 +404,7 @@ static int ab_link_watch_handler(struct teamd_context *ctx, struct ab *ab)
if (!best.tdport || best.tdport == active_tdport)
return 0;
- teamd_log_dbg("Found best port: \"%s\" (ifindex \"%d\", prio \"%d\").",
+ teamd_log_dbg(ctx, "Found best port: \"%s\" (ifindex \"%d\", prio \"%d\").",
best.tdport->ifname, best.tdport->ifindex, best.prio);
if (!active_tdport || !ab_is_port_sticky(ab, active_tdport)) {
@@ -459,7 +459,7 @@ static int ab_port_load_config(struct teamd_context *ctx,
"$.ports.%s.sticky", port_name);
if (err)
ab_port->cfg.sticky = AB_DFLT_PORT_STICKY;
- teamd_log_dbg("%s: Using sticky \"%d\".", port_name,
+ teamd_log_dbg(ctx, "%s: Using sticky \"%d\".", port_name,
ab_port->cfg.sticky);
return 0;
}
@@ -558,7 +558,7 @@ static int ab_load_config(struct teamd_context *ctx, struct ab *ab)
hwaddr_policy_name);
return err;
}
- teamd_log_dbg("Using hwaddr_policy \"%s\".", ab->hwaddr_policy->name);
+ teamd_log_dbg(ctx, "Using hwaddr_policy \"%s\".", ab->hwaddr_policy->name);
return 0;
}
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index d292d69..7d940b3 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -254,7 +254,7 @@ static int lacp_load_config(struct teamd_context *ctx, struct lacp *lacp)
err = teamd_config_bool_get(ctx, &lacp->cfg.active, "$.runner.active");
if (err)
lacp->cfg.active = LACP_CFG_DFLT_ACTIVE;
- teamd_log_dbg("Using active \"%d\".", lacp->cfg.active);
+ teamd_log_dbg(ctx, "Using active \"%d\".", lacp->cfg.active);
err = teamd_config_int_get(ctx, &tmp, "$.runner.sys_prio");
if (err) {
@@ -265,12 +265,12 @@ static int lacp_load_config(struct teamd_context *ctx, struct lacp *lacp)
} else {
lacp->cfg.sys_prio = tmp;
}
- teamd_log_dbg("Using sys_prio \"%d\".", lacp->cfg.sys_prio);
+ teamd_log_dbg(ctx, "Using sys_prio \"%d\".", lacp->cfg.sys_prio);
err = teamd_config_bool_get(ctx, &lacp->cfg.fast_rate, "$.runner.fast_rate");
if (err)
lacp->cfg.fast_rate = LACP_CFG_DFLT_FAST_RATE;
- teamd_log_dbg("Using fast_rate \"%d\".", lacp->cfg.fast_rate);
+ teamd_log_dbg(ctx, "Using fast_rate \"%d\".", lacp->cfg.fast_rate);
err = teamd_config_int_get(ctx, &tmp, "$.runner.min_ports");
if (err) {
@@ -281,7 +281,7 @@ static int lacp_load_config(struct teamd_context *ctx, struct lacp *lacp)
} else {
lacp->cfg.min_ports = tmp;
}
- teamd_log_dbg("Using min_ports \"%d\".", lacp->cfg.min_ports);
+ teamd_log_dbg(ctx, "Using min_ports \"%d\".", lacp->cfg.min_ports);
err = teamd_config_string_get(ctx, &agg_select_policy_name, "$.runner.agg_select_policy");
if (err)
@@ -292,7 +292,7 @@ static int lacp_load_config(struct teamd_context *ctx, struct lacp *lacp)
agg_select_policy_name);
return err;
}
- teamd_log_dbg("Using agg_select_policy \"%s\".",
+ teamd_log_dbg(ctx, "Using agg_select_policy \"%s\".",
lacp_get_agg_select_policy_name(lacp));
return 0;
}
@@ -634,7 +634,7 @@ static void lacp_switch_agg_lead(struct lacp_port *agg_lead,
struct teamd_port *tdport;
struct lacp_port *lacp_port;
- teamd_log_dbg("Renaming aggregator %u to %u",
+ teamd_log_dbg(new_agg_lead->ctx, "Renaming aggregator %u to %u",
lacp_agg_id(agg_lead), lacp_agg_id(new_agg_lead));
if (lacp->selected_agg_lead == agg_lead)
lacp->selected_agg_lead = new_agg_lead;
@@ -649,12 +649,12 @@ static void lacp_port_agg_select(struct lacp_port *lacp_port)
{
struct lacp_port *agg_lead;
- teamd_log_dbg("%s: Selecting LACP port", lacp_port->tdport->ifname);
+ teamd_log_dbg(lacp_port->ctx, "%s: Selecting LACP port", lacp_port->tdport->ifname);
agg_lead = lacp_get_agg_lead(lacp_port);
lacp_port->agg_lead = agg_lead;
if (lacp_port_better(lacp_port, agg_lead))
lacp_switch_agg_lead(agg_lead, lacp_port);
- teamd_log_dbg("%s: LACP port selected into aggregator %u",
+ teamd_log_dbg(lacp_port->ctx, "%s: LACP port selected into aggregator %u",
lacp_port->tdport->ifname, lacp_port_agg_id(lacp_port));
}
@@ -677,8 +677,8 @@ static void lacp_port_agg_unselect(struct lacp_port *lacp_port)
{
struct lacp_port *agg_lead = lacp_port->agg_lead;
- teamd_log_dbg("%s: Unselecting LACP port", lacp_port->tdport->ifname);
- teamd_log_dbg("%s: LACP port unselected from aggregator %u",
+ teamd_log_dbg(lacp_port->ctx, "%s: Unselecting LACP port", lacp_port->tdport->ifname);
+ teamd_log_dbg(lacp_port->ctx, "%s: LACP port unselected from aggregator %u",
lacp_port->tdport->ifname, lacp_port_agg_id(lacp_port));
lacp_port->agg_lead = NULL;
if (lacp_port == agg_lead) {
@@ -715,7 +715,7 @@ static int lacp_selected_agg_update(struct lacp *lacp,
if (!next_agg_lead)
next_agg_lead = lacp_get_next_agg(lacp);
if (lacp->selected_agg_lead != next_agg_lead)
- teamd_log_dbg("Selecting aggregator %u",
+ teamd_log_dbg(lacp->ctx, "Selecting aggregator %u",
lacp_agg_id(next_agg_lead));
lacp->selected_agg_lead = next_agg_lead;
@@ -827,7 +827,7 @@ static int lacp_port_periodic_set(struct lacp_port *lacp_port)
int fast_on;
fast_on = lacp_port->partner.state & INFO_STATE_LACP_TIMEOUT;
- teamd_log_dbg("%s: Setting periodic timer to \"%s\".",
+ teamd_log_dbg(lacp_port->ctx, "%s: Setting periodic timer to \"%s\".",
lacp_port->tdport->ifname, fast_on ? "fast": "slow");
ms = fast_on ? LACP_PERIODIC_SHORT: LACP_PERIODIC_LONG;
ms_to_timespec(&ts, ms);
@@ -929,8 +929,8 @@ static void lacp_port_actor_update(struct lacp_port *lacp_port)
state |= INFO_STATE_DEFAULTED;
if (teamd_port_count(lacp_port->ctx) > 0)
state |= INFO_STATE_AGGREGATION;
- teamd_log_dbg("%s: lacp info state: 0x%02X.", lacp_port->tdport->ifname,
- state);
+ teamd_log_dbg(lacp_port->ctx, "%s: lacp info state: 0x%02X.",
+ lacp_port->tdport->ifname, state);
lacp_port->actor.state = state;
}
@@ -1198,7 +1198,7 @@ static int lacp_port_load_config(struct teamd_context *ctx,
} else {
lacp_port->cfg.lacp_prio = tmp;
}
- teamd_log_dbg("%s: Using lacp_prio \"%d\".", port_name,
+ teamd_log_dbg(ctx, "%s: Using lacp_prio \"%d\".", port_name,
lacp_port->cfg.lacp_prio);
err = teamd_config_int_get(ctx, &tmp,
@@ -1212,14 +1212,14 @@ static int lacp_port_load_config(struct teamd_context *ctx,
} else {
lacp_port->cfg.lacp_key = tmp;
}
- teamd_log_dbg("%s: Using lacp_key \"%d\".", port_name,
+ teamd_log_dbg(ctx, "%s: Using lacp_key \"%d\".", port_name,
lacp_port->cfg.lacp_key);
err = teamd_config_bool_get(ctx, &lacp_port->cfg.sticky,
"$.ports.%s.sticky", port_name);
if (err)
lacp_port->cfg.sticky = LACP_PORT_CFG_DFLT_STICKY;
- teamd_log_dbg("%s: Using sticky \"%d\".", port_name,
+ teamd_log_dbg(ctx, "%s: Using sticky \"%d\".", port_name,
lacp_port->cfg.sticky);
return 0;
}
diff --git a/teamd/teamd_usock.c b/teamd/teamd_usock.c
index c421c7a..1adfdf8 100644
--- a/teamd/teamd_usock.c
+++ b/teamd/teamd_usock.c
@@ -171,28 +171,28 @@ static int process_rcv_msg(struct teamd_context *ctx, int sock, char *rcv_msg)
str = teamd_usock_msg_getline(&rest);
if (!str) {
- teamd_log_dbg("usock: Incomplete message.");
+ teamd_log_dbg(ctx, "usock: Incomplete message.");
return 0;
}
if (strcmp(TEAMD_USOCK_REQUEST_PREFIX, str)) {
- teamd_log_dbg("usock: Unsupported message type.");
+ teamd_log_dbg(ctx, "usock: Unsupported message type.");
return 0;
}
str = teamd_usock_msg_getline(&rest);
if (!str) {
- teamd_log_dbg("usock: Incomplete message.");
+ teamd_log_dbg(ctx, "usock: Incomplete message.");
return 0;
}
if (!teamd_ctl_method_exists(str)) {
- teamd_log_dbg("usock: Unknown method \"%s\".", str);
+ teamd_log_dbg(ctx, "usock: Unknown method \"%s\".", str);
return 0;
}
usock_ops_priv.sock = sock;
usock_ops_priv.rcv_msg_args = rest;
- teamd_log_dbg("usock: calling method \"%s\"", str);
+ teamd_log_dbg(ctx, "usock: calling method \"%s\"", str);
return teamd_ctl_method_call(ctx, str, &teamd_usock_ctl_method_ops,
&usock_ops_priv);
@@ -315,7 +315,7 @@ static int teamd_usock_sock_open(struct teamd_context *ctx)
teamd_usock_get_sockpath(addr.sun_path, sizeof(addr.sun_path),
ctx->team_devname);
- teamd_log_dbg("usock: Using sockpath \"%s\"", addr.sun_path);
+ teamd_log_dbg(ctx, "usock: Using sockpath \"%s\"", addr.sun_path);
err = unlink(addr.sun_path);
if (err == -1 && errno != ENOENT) {
teamd_log_err("usock: Failed to remove socket file.");
diff --git a/teamd/teamd_zmq.c b/teamd/teamd_zmq.c
index c39e38d..3f3c2f6 100644
--- a/teamd/teamd_zmq.c
+++ b/teamd/teamd_zmq.c
@@ -138,28 +138,28 @@ static int process_rcv_msg(struct teamd_context *ctx, char *rcv_msg)
str = teamd_zmq_msg_getline(&rest);
if (!str) {
- teamd_log_dbg("zmq: Incomplete message.");
+ teamd_log_dbg(ctx, "zmq: Incomplete message.");
return 0;
}
if (strcmp(TEAMD_ZMQ_REQUEST_PREFIX, str)) {
- teamd_log_dbg("zmq: Unsupported message type.");
+ teamd_log_dbg(ctx, "zmq: Unsupported message type.");
return 0;
}
str = teamd_zmq_msg_getline(&rest);
if (!str) {
- teamd_log_dbg("zmq: Incomplete message.");
+ teamd_log_dbg(ctx, "zmq: Incomplete message.");
return 0;
}
if (!teamd_ctl_method_exists(str)) {
- teamd_log_dbg("zmq: Unknown method \"%s\".", str);
+ teamd_log_dbg(ctx, "zmq: Unknown method \"%s\".", str);
return 0;
}
zmq_ops_priv.sock = ctx->zmq.sock;
zmq_ops_priv.rcv_msg_args = rest;
- teamd_log_dbg("zmq: calling method \"%s\"", str);
+ teamd_log_dbg(ctx, "zmq: calling method \"%s\"", str);
return teamd_ctl_method_call(ctx, str, &teamd_zmq_ctl_method_ops,
&zmq_ops_priv);
--
2.1.0

View File

@ -1,55 +0,0 @@
From 337bae54278a112bab9d99e05ee7ec825b12c646 Mon Sep 17 00:00:00 2001
Message-Id: <337bae54278a112bab9d99e05ee7ec825b12c646.1566966529.git.lucien.xin@gmail.com>
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Wed, 24 Jul 2019 17:02:21 +0800
Subject: [PATCH] man teamd.conf: update some parameter default values
Update default runner.name to roundrobin, default runner.tx_hash array
to ["eth", "ipv4", "ipv6"], default runner.fast_rate to false.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
man/teamd.conf.5 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/man/teamd.conf.5 b/man/teamd.conf.5
index 9090b4a..350ffc9 100644
--- a/man/teamd.conf.5
+++ b/man/teamd.conf.5
@@ -42,6 +42,9 @@ To do passive load balancing, runner only sets up BPF hash function which will d
.PP
.BR "lacp "\(em
Implements 802.3ad LACP protocol. Can use same Tx port selection possibilities as loadbalance runner.
+.PP
+Default:
+.BR "roundrobin"
.RE
.TP
.BR "notify_peers.count " (int)
@@ -182,6 +185,10 @@ Uses source and destination SCTP ports.
.PP
.BR "l4 "\(em
Uses source and destination TCP and UDP and SCTP ports.
+.PP
+Default:
+.B
+["eth", "ipv4", "ipv6"]
.RE
.TP
.BR "runner.tx_balancer.name " (string)
@@ -217,6 +224,11 @@ Default:
Option specifies the rate at which our link partner is asked to transmit LACPDU packets. If this is
.BR "true"
then packets will be sent once per second. Otherwise they will be sent every 30 seconds.
+.RS 7
+.PP
+Default:
+.BR "false"
+.RE
.TP
.BR "runner.tx_hash " (array)
Same as for load balance runner.
--
2.18.1

View File

@ -0,0 +1,46 @@
From dbb2cfca35d2cd15125eb84e8f3940f8cc3ea860 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Mon, 10 Oct 2022 18:33:53 +0200
Subject: [PATCH] teamd: do no remove the ports on shutdown with -N
With -N, teamd currently leaves the team device in place on shutdown,
as it's supposed to, but it removes all the ports. This severely limits
usefullness of the option, because it's still impossible to replace
the daemon with another one without disrupting connectivity.
One use case where this is important is the handover from initrd to real
root, when a team device was used to provide connectivity to a network
root filesystem:
Systemd's isolation of switch-root.target stops NetworkManager.service and
then terminates its kids, including teamd. The real NetworkManager.service
would eventually catch up and restart it, but there's a short period when
team ports are removed which is not great if we're booting off that device.
Also, it may be that ports come up in different order, causing team to get
a different MAC address, which will invalidate the DHCP lease we got
beforehands and screwing up L3 addressing.
Let's not flush the ports when -N is used.
Suggested-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
teamd/teamd_per_port.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c
index d429753..9689df4 100644
--- a/teamd/teamd_per_port.c
+++ b/teamd/teamd_per_port.c
@@ -217,7 +217,6 @@ static void port_obj_remove(struct teamd_context *ctx,
struct teamd_port *tdport = _port(port_obj);
teamd_event_port_removed(ctx, tdport);
- teamd_port_remove(ctx, tdport);
port_obj_destroy(ctx, port_obj);
port_obj_free(port_obj);
}
--
2.31.1

View File

@ -1,49 +0,0 @@
From 575edc0dbc7ae3dfa34e30c1496c3504eacbf56e Mon Sep 17 00:00:00 2001
Message-Id: <575edc0dbc7ae3dfa34e30c1496c3504eacbf56e.1588051704.git.lucien.xin@gmail.com>
In-Reply-To: <f32310b9a5cc0322d8f5c85d94e3866326bc68ce.1588051704.git.lucien.xin@gmail.com>
References: <f32310b9a5cc0322d8f5c85d94e3866326bc68ce.1588051704.git.lucien.xin@gmail.com>
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Thu, 12 Dec 2019 14:22:21 +0800
Subject: [PATCH 3/4] teamd: fix build error in expansion of macro
teamd_log_dbgx
With gcc 8.3 I got the following build error:
In file included from teamd_dbus.c:33:
teamd_dbus.c: In function 'teamd_dbus_init':
teamd.h:54:2: error: expected expression before 'if'
if (val <= ctx->debug) \
^~
teamd.h:57:37: note: in expansion of macro 'teamd_log_dbgx'
#define teamd_log_dbg(ctx, args...) teamd_log_dbgx(ctx, 1, ##args)
^~~~~~~~~~~~~~
teamd_dbus.c:507:2: note: in expansion of macro 'teamd_log_dbg'
teamd_log_dbg(ctx, "dbus: connected to %s with name %s", id,
^~~~~~~~~~~~~
Fix it by adding parentheses and braces around the content.
Fixes: f32310b9a5cc ("libteam: wapper teamd_log_dbg with teamd_log_dbgx")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/teamd/teamd.h b/teamd/teamd.h
index 469b769..fb2872e 100644
--- a/teamd/teamd.h
+++ b/teamd/teamd.h
@@ -51,8 +51,7 @@
#define teamd_log_info(args...) daemon_log(LOG_INFO, ##args)
#define teamd_log_dbgx(ctx, val, args...) \
- if (val <= ctx->debug) \
- daemon_log(LOG_DEBUG, ##args)
+ ({ if (val <= ctx->debug) daemon_log(LOG_DEBUG, ##args); })
#define teamd_log_dbg(ctx, args...) teamd_log_dbgx(ctx, 1, ##args)
--
2.1.0

View File

@ -1,35 +0,0 @@
From bbffa4223299c18e9886e423f80909b560713e5e Mon Sep 17 00:00:00 2001
Message-Id: <bbffa4223299c18e9886e423f80909b560713e5e.1590163956.git.lucien.xin@gmail.com>
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Thu, 21 May 2020 19:45:22 +0800
Subject: [PATCH] teamd: fix ctx->hwaddr value assignment
We should use memcpy to copy the data to ctx->hwaddr.
Use ctx->hwaddr = hwaddr will change the ctx->hwaddr to
a wrong address and cause the team hwaddr unable to be updated.
Reported-by: Li Liang <liali@redhat.com>
Suggested-by: Xin Long <lucien.xin@gmail.com>
Fixes: 9ca6bf9 ("teamd: update ctx->hwaddr after setting team dev to new hwaddr")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/teamd/teamd.c b/teamd/teamd.c
index f955b19..9360cbf 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -896,7 +896,7 @@ static int teamd_hwaddr_check_change(struct teamd_context *ctx,
teamd_log_err("Failed to set team device hardware address.");
return err;
}
- ctx->hwaddr = hwaddr;
+ memcpy(ctx->hwaddr, hwaddr, hwaddr_len);
ctx->hwaddr_len = hwaddr_len;
return 0;
}
--
2.18.1

View File

@ -1,44 +0,0 @@
From 4990a8cea7e9111cffe3842058942099a009ed62 Mon Sep 17 00:00:00 2001
Message-Id: <4990a8cea7e9111cffe3842058942099a009ed62.1588051704.git.lucien.xin@gmail.com>
In-Reply-To: <f32310b9a5cc0322d8f5c85d94e3866326bc68ce.1588051704.git.lucien.xin@gmail.com>
References: <f32310b9a5cc0322d8f5c85d94e3866326bc68ce.1588051704.git.lucien.xin@gmail.com>
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Fri, 13 Dec 2019 22:17:14 +0800
Subject: [PATCH 4/4] teamd/lacp: fix segfault due to NULL pointer dereference
If we set a team0 link down with lacp mode, we will call like
- lacp_port_agg_unselect()
- lacp_switch_agg_lead()
- teamd_log_dbg()
while the new_agg_lead in lacp_switch_agg_lead() may be NULL, then we
will got NULL pointer dereference as we called new_agg_lead->ctx in
new teamd_log_dbg().
Fix it by using agg_lead->ctx, which is safe as we referenced it in function
lacp_switch_agg_lead().
Fixes: f32310b9a5cc ("libteam: wapper teamd_log_dbg with teamd_log_dbgx")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd_runner_lacp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 7d940b3..ec01237 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -634,7 +634,7 @@ static void lacp_switch_agg_lead(struct lacp_port *agg_lead,
struct teamd_port *tdport;
struct lacp_port *lacp_port;
- teamd_log_dbg(new_agg_lead->ctx, "Renaming aggregator %u to %u",
+ teamd_log_dbg(agg_lead->ctx, "Renaming aggregator %u to %u",
lacp_agg_id(agg_lead), lacp_agg_id(new_agg_lead));
if (lacp->selected_agg_lead == agg_lead)
lacp->selected_agg_lead = new_agg_lead;
--
2.1.0

View File

@ -0,0 +1,105 @@
From ffc6a52bd285a476b547312012078af69220574b Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Mon, 10 Oct 2022 18:37:31 +0200
Subject: [PATCH] teamd: stop iterating callbacks when a loop restart is
requested
A crash was observed:
Added loop callback: dbus_watch, 0x560d279e4530
Added loop callback: dbus_watch, 0x560d279e4580
...
Removed loop callback: dbus_watch, 0x560d279e4580
Removed loop callback: dbus_watch, 0x560d279e4530
Aug 31 11:54:11 holaprdel kernel: traps: teamd[557] general protection fault ip:560d26469a55 sp:7ffd43ca9650 error:0 in teamd[560d26463000+16000]
Traceback (from a different run than above):
Core was generated by `/usr/bin/teamd -o -n -U -D -N -t team0 -gg'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00005600ac090a55 in teamd_run_loop_do_callbacks (ctx=0x5600ad9bac70, fds=0x7fff40861250, lcb_list=0x5600ad9bad58) at /usr/src/debug/libteam-1.31-14.el9.x86_64/teamd/teamd.c:321
321 list_for_each_node_entry_safe(lcb, tmp, lcb_list, list) {
(gdb) bt
#0 0x00005600ac090a55 in teamd_run_loop_do_callbacks (ctx=0x5600ad9bac70, fds=0x7fff40861250, lcb_list=0x5600ad9bad58) at /usr/src/debug/libteam-1.31-14.el9.x86_64/teamd/teamd.c:321
#1 teamd_run_loop_run (ctx=0x5600ad9bac70) at /usr/src/debug/libteam-1.31-14.el9.x86_64/teamd/teamd.c:415
#2 0x00005600ac08d8cb in teamd_start (p_ret=<synthetic pointer>, ctx=<optimized out>) at /usr/src/debug/libteam-1.31-14.el9.x86_64/teamd/teamd.c:1557
#3 main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/libteam-1.31-14.el9.x86_64/teamd/teamd.c:1876
(gdb) print *lcb
Cannot access memory at address 0x9dd29944fb7e97fc
(gdb) print *tmp
Cannot access memory at address 0x9dd29944fb7e9804
(gdb)
What has happened is that libdbus called the remove_watch callback twice
in a single go, causing two callbacks being destroyed in one iteration
of teamd_run_loop_do_callbacks()'s list_for_each_node_entry_safe().
This basically turns the _safe() variant of the macro unhelpful, as tmp
points to stale data anyway.
Let's use the unsafe variant then, and terminate the loop once
teamd_loop_callback_del() asks for main loop's attention via
teamd_run_loop_restart(). If there are other callbacks pending an action,
they will get their turn in the next main loop iteration.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
teamd/teamd.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/teamd/teamd.c b/teamd/teamd.c
index b310140..a89b702 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -309,16 +309,28 @@ static void teamd_run_loop_set_fds(struct list_item *lcb_list,
}
}
+static int teamd_check_ctrl(struct teamd_context *ctx)
+{
+ int ctrl_fd = ctx->run_loop.ctrl_pipe_r;
+ struct timeval tv;
+ fd_set rfds;
+
+ FD_ZERO(&rfds);
+ FD_SET(ctrl_fd, &rfds);
+ tv.tv_sec = tv.tv_usec = 0;
+
+ return select(ctrl_fd + 1, &rfds, NULL, NULL, &tv);
+}
+
static int teamd_run_loop_do_callbacks(struct list_item *lcb_list, fd_set *fds,
struct teamd_context *ctx)
{
struct teamd_loop_callback *lcb;
- struct teamd_loop_callback *tmp;
int i;
int events;
int err;
- list_for_each_node_entry_safe(lcb, tmp, lcb_list, list) {
+ list_for_each_node_entry(lcb, lcb_list, list) {
for (i = 0; i < 3; i++) {
if (!(lcb->fd_event & (1 << i)))
continue;
@@ -339,6 +351,16 @@ static int teamd_run_loop_do_callbacks(struct list_item *lcb_list, fd_set *fds,
teamd_log_dbg(ctx, "Failed loop callback: %s, %p",
lcb->name, lcb->priv);
}
+
+ /*
+ * If there's a control byte ready, it's possible that
+ * one or more entries have been removed from the
+ * callback list and restart has been requested. In any
+ * case, let the main loop deal with it first so that
+ * we know we're safe to proceed.
+ */
+ if (teamd_check_ctrl(ctx))
+ return 0;
}
}
return 0;
--
2.31.1

View File

@ -1,61 +0,0 @@
From 9ca6bf9bad49d1e3f7fa01c719c075f79c184336 Mon Sep 17 00:00:00 2001
Message-Id: <9ca6bf9bad49d1e3f7fa01c719c075f79c184336.1588051704.git.lucien.xin@gmail.com>
In-Reply-To: <f32310b9a5cc0322d8f5c85d94e3866326bc68ce.1588051704.git.lucien.xin@gmail.com>
References: <f32310b9a5cc0322d8f5c85d94e3866326bc68ce.1588051704.git.lucien.xin@gmail.com>
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Wed, 4 Dec 2019 15:17:11 +0800
Subject: [PATCH 2/4] teamd: update ctx->hwaddr after setting team dev to new
hwaddr
When adding the first slave to team dev, the team dev's hwaddr will
be updated to this slave's hwaddr in function:
teamd_event_watch_port_added()
- teamd_hwaddr_check_change(),
But we didn't update the ctx->hwaddr, which is still the team's init hwaddr.
Later in the following functions:
lacp_port_set_mac()
lb_event_watch_port_added()
ab_hwaddr_policy_same_all_port_added()
they will set the first slave's hwaddr to team's init hwaddr(ctx->hwaddr).
This will cause that the first slave(most likely the active slave)'s hwaddr
changes to team dev's original hwaddr, and later back to its old hwaddr
again, which would make the LACPDUs have different Actor System IDs.
Fix it by updating ctx->hwaddr when set ctx->ifindex to new hwaddr.
Note that teamd_set_hwaddr() doesn't need this fix as it will set
ctx->hwaddr_explicit = true.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/teamd/teamd.c b/teamd/teamd.c
index 9744021..e035ac5 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -867,7 +867,7 @@ static int teamd_add_ports(struct teamd_context *ctx)
static int teamd_hwaddr_check_change(struct teamd_context *ctx,
struct teamd_port *tdport)
{
- const char *hwaddr;
+ char *hwaddr;
unsigned char hwaddr_len;
int err;
@@ -885,6 +885,8 @@ static int teamd_hwaddr_check_change(struct teamd_context *ctx,
teamd_log_err("Failed to set team device hardware address.");
return err;
}
+ ctx->hwaddr = hwaddr;
+ ctx->hwaddr_len = hwaddr_len;
return 0;
}
--
2.1.0

View File

@ -0,0 +1,61 @@
From 3bbce8a171deab6cd3d7d57d128bc2dbaea451f0 Mon Sep 17 00:00:00 2001
Message-Id: <3bbce8a171deab6cd3d7d57d128bc2dbaea451f0.1664556124.git.lucien.xin@gmail.com>
From: Xin Long <lucien.xin@gmail.com>
Date: Fri, 15 Apr 2022 11:41:39 -0400
Subject: [PATCH] libteamdctl: validate the bus name before using it
Using bus name without validating it will cause core dump generated,
and it can be reproduced by:
# ip link add dummy0.1 type dummy
# teamdctl dummy0.1 state dump
This is normally a bug in some application using the D-Bus library.
D-Bus not built with -rdynamic so unable to print a backtrace
Aborted (core dumped)
Doing this many times can even create too many core files, customers
may complain about it.
This is triggered when calling cli_method_call("ConfigDump") in
cli_init(), so fix it by returning err in cli->init/cli_dbus_init()
if the bus name fails to validate.
Note this is safe, as with dbus, we can't use invalid dbus name to
create the team dev either.
Fixes: d8163e34c25c ("libteamdctl: do test method call instead or Introspect call")
Reported-by: Uday Patel <upatel@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
libteamdctl/cli_dbus.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libteamdctl/cli_dbus.c b/libteamdctl/cli_dbus.c
index dfef5c4..242ef86 100644
--- a/libteamdctl/cli_dbus.c
+++ b/libteamdctl/cli_dbus.c
@@ -183,12 +183,17 @@ static int cli_dbus_init(struct teamdctl *tdc, const char *team_name, void *priv
if (ret == -1)
return -errno;
+ err = -EINVAL;
dbus_error_init(&error);
+ if (!dbus_validate_bus_name(cli_dbus->service_name, &error)) {
+ err(tdc, "dbus: Could not validate bus name: %s - %s",
+ error.name, error.message);
+ goto free_service_name;
+ }
cli_dbus->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
if (!cli_dbus->conn) {
err(tdc, "dbus: Could not acquire the system bus: %s - %s",
error.name, error.message);
- err = -EINVAL;
goto free_service_name;
}
err = 0;
--
2.27.0

View File

@ -1,17 +1,15 @@
Name: libteam
Version: 1.29
Release: 5%{?dist}
Version: 1.31
Release: 4%{?dist}
Summary: Library for controlling team network device
Group: System Environment/Libraries
License: LGPLv2+
URL: http://www.libteam.org
Source: http://www.libteam.org/files/libteam-%{version}.tar.gz
Patch1: libteam-man-teamd.conf-update-some-parameter-default-values.patch
Patch2: libteam-libteam-wapper-teamd_log_dbg-with-teamd_log_dbgx.patch
Patch3: libteam-teamd-update-ctx-hwaddr-after-setting-team-dev-to-ne.patch
Patch4: libteam-teamd-fix-build-error-in-expansion-of-macro-teamd_lo.patch
Patch5: libteam-teamd-lacp-fix-segfault-due-to-NULL-pointer-derefere.patch
Patch6: libteam-teamd-fix-ctx-hwaddr-value-assignment.patch
Patch1: libteam-Revert-teamd-Disregard-current-state-when-considerin.patch
Patch2: libteamdctl-validate-the-bus-name-before-using-it.patch
Patch3: libteam-teamd-do-no-remove-the-ports-on-shutdown-with-N.patch
Patch4: libteam-teamd-stop-iterating-callbacks-when-a-loop-restart-i.patch
BuildRequires: jansson-devel
BuildRequires: libdaemon-devel
BuildRequires: libnl3-devel
@ -170,6 +168,26 @@ cd binding/python
%{_sysconfdir}/sysconfig/network-scripts/ifdown-TeamPort
%changelog
* Mon Dec 05 2022 Xin Long <lxin@redhat.com> - 1.31-4
- teamd: do no remove the ports on shutdown with -N [2148856]
- teamd: stop iterating callbacks when a loop restart is requested [2148855]
* Fri Sep 30 2022 Xin Long <lxin@redhat.com> - 1.31-3
- libteamdctl: validate the bus name before using it [2065227]
* Tue Sep 01 2020 Xin Long <lxin@redhat.com> - 1.31-2
- Revert "teamd: Disregard current state when considering port enablement" [1874001]
* Thu Jul 30 2020 Xin Long <lxin@redhat.com> - 1.31-1
- 1.31 release
- utils/bond2team: remove TYPE in ifcfg file [1858518]
- utils/bond2team: keep delivering config to file if stdout not supplied [1858518]
- teamd/lacp: silence ignore none LACP frames
- Send LACP PDU right after the Actor state has been changed
- Skip setting the same hwaddr to a lag port if not needed
- Make all netlink socket RCVBUF sizes configurable
- Don't return an error when timerfd socket return 0
- Fix ifinfo_link_with_port race condition with newlink
- teamd: fix possible race in master ifname callback
- 1.30 release
- teamd: Disregard current state when considering port enablement [1851460]
* Sat May 23 2020 Xin Long <lxin@redhat.com> - 1.29-5
- teamd: fix ctx->hwaddr value assignment [1838952]
* Mon May 18 2020 Xin Long <lxin@redhat.com> - 1.29-4