[ISSUE] Failed to find "enabled" option.
by Xin Long
I found this err in "loadbalance" and "lacp" runner when adding ports.
It's caused by trying to set "enabled" option in .port_link_changed()
or .port_changed().
When a new port is added, the first 'port changed event' process is
earlier than CMD TEAM_CMD_OPTIONS_GET, in this CMD, all
the options are synchronized from kernel.
It means there's no 'enabled' option yet when calling port_link_changed
in the first 'port changed event' process. In lb_event_watch_port_link_changed
and lacp_event_watch_port_changed, they call teamd_port_check_enable
to set 'enabled' option. this err is triggered.
I'm not sure why teamd_port_check_enable needs to check if
'enabled' option exists. I checked the ab's .port_link_changed(),
it just sets it by calling team_set_port_enabled(), instead of
checking 'enabled' option first.
can we just use team_set_port_enabled to set it directly in
.port(_link)_changed OR improve teamd_port_check_enable
to avoid this err ?
Thanks.
4 years
[PATCH] teamd: add an option to force log output to stdout, stderr or syslog
by Hangbin Liu
By default, libdaemon prints the logs to stderr, and switches to syslog
if the precess daemonizes.
When some users, e.g. NetworkManager, run teamd foreground, the logs printed
in syslog will as coming from NetworkManager, with mixed NetworkManager's
own debug logs, which makes people feel a mess and hard to debug.
Add option -l to support force teamd log output to stdout, stderr or
syslog. Also add a global env TEAM_LOG_OUTPUT, which could be used for
old version compatibility.
Signed-off-by: Hangbin Liu <liuhangbin(a)gmail.com>
---
man/teamd.8 | 3 +++
teamd/teamd.c | 18 +++++++++++++++++-
teamd/teamd.h | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/man/teamd.8 b/man/teamd.8
index 03b525c..3d27eae 100644
--- a/man/teamd.8
+++ b/man/teamd.8
@@ -69,6 +69,9 @@ Use the specified PID file.
.B "\-g, \-\-debug"
Turns on debugging messages. Repeating the option increases verbosity.
.TP
+.B "\-l, \-\-log-output"
+Force teamd log output to stdout, stderr or syslog.
+.TP
.B "\-r, \-\-force-recreate"
Force team device recreation in case it already exists.
.TP
diff --git a/teamd/teamd.c b/teamd/teamd.c
index aac2511..6c47312 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -107,6 +107,7 @@ static void print_help(const struct teamd_context *ctx) {
" file will be ignored)\n"
" -p --pid-file=FILE Use the specified PID file\n"
" -g --debug Increase verbosity\n"
+ " -l --log-output Force teamd log output to stdout, stderr or syslog\n"
" -r --force-recreate Force team device recreation in case it\n"
" already exists\n"
" -o --take-over Take over the device if it already exists\n"
@@ -140,6 +141,7 @@ static int parse_command_line(struct teamd_context *ctx,
{ "config", required_argument, NULL, 'c' },
{ "pid-file", required_argument, NULL, 'p' },
{ "debug", no_argument, NULL, 'g' },
+ { "log-output", required_argument, NULL, 'l' },
{ "force-recreate", no_argument, NULL, 'r' },
{ "take-over", no_argument, NULL, 'o' },
{ "no-quit-destroy", no_argument, NULL, 'N' },
@@ -152,7 +154,7 @@ static int parse_command_line(struct teamd_context *ctx,
{ NULL, 0, NULL, 0 }
};
- while ((opt = getopt_long(argc, argv, "hdkevf:c:p:groNt:nDZ:Uu",
+ while ((opt = getopt_long(argc, argv, "hdkevf:c:p:gl:roNt:nDZ:Uu",
long_options, NULL)) >= 0) {
switch(opt) {
@@ -191,6 +193,10 @@ static int parse_command_line(struct teamd_context *ctx,
case 'g':
ctx->debug++;
break;
+ case 'l':
+ free(ctx->log_output);
+ ctx->log_output = strdup(optarg);
+ break;
case 'r':
ctx->force_recreate = true;
break;
@@ -1494,6 +1500,16 @@ static int teamd_start(struct teamd_context *ctx, enum teamd_exit_code *p_ret)
/* Child */
}
+ ctx->log_output = ctx->log_output ? : getenv("TEAM_LOG_OUTPUT");
+ if (ctx->log_output) {
+ if (strcmp(ctx->log_output, "stdout") == 0)
+ daemon_log_use = DAEMON_LOG_STDOUT;
+ else if (strcmp(ctx->log_output, "stderr") == 0)
+ daemon_log_use = DAEMON_LOG_STDERR;
+ else if (strcmp(ctx->log_output, "syslog") == 0)
+ daemon_log_use = DAEMON_LOG_SYSLOG;
+ }
+
if (daemon_close_all(-1) < 0) {
teamd_log_err("Failed to close all file descriptors.");
daemon_retval_send(errno);
diff --git a/teamd/teamd.h b/teamd/teamd.h
index 3934fc2..01bd022 100644
--- a/teamd/teamd.h
+++ b/teamd/teamd.h
@@ -99,6 +99,7 @@ struct teamd_context {
enum teamd_command cmd;
bool daemonize;
unsigned int debug;
+ char * log_output;
bool force_recreate;
bool take_over;
bool no_quit_destroy;
--
2.5.5
4 years, 10 months
[patch libteam] teamd/teamd_runner_lacp: lacp_port_set_state
by MK Lim
if new state is PORT_STATE_DEFAULTED, set lacp_port->partner.state
to 0x02
This ensures LACPDU is sent to update the far side when local
local port transitions from default to current
Currently, local port moves from default to current without
sending LACPDU until 30sec later. This causes traffic disruption
because far side has not completed negotiation
Using 0x02 also cause LACPDU to be sent every 1 sec as long as
port remains in defaulted state and LACP mode used is "active"
---
teamd/teamd_runner_lacp.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 7b8f0a7..555aa06 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -965,7 +965,12 @@ static int lacp_port_set_state(struct lacp_port *lacp_port,
case PORT_STATE_DEFAULTED:
teamd_loop_callback_disable(lacp_port->ctx,
LACP_TIMEOUT_CB_NAME, lacp_port);
- /* fall through */
+ memset(&lacp_port->partner, 0, sizeof(lacp_port->partner));
+ lacp_port->partner.state |= INFO_STATE_LACP_TIMEOUT;
+ err = lacp_port_partner_update(lacp_port);
+ if (err)
+ return err;
+ break;
case PORT_STATE_DISABLED:
memset(&lacp_port->partner, 0, sizeof(lacp_port->partner));
err = lacp_port_partner_update(lacp_port);
--
2.15.1 (Apple Git-101)
4 years, 10 months