From patchwork Mon Dec 2 08:28:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 11268805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D88A6C1 for ; Mon, 2 Dec 2019 08:28:43 +0000 (UTC) Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE73C215E5 for ; Mon, 2 Dec 2019 08:28:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE73C215E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=libteam-bounces@lists.fedorahosted.org Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id 1D0436040EFF; Mon, 2 Dec 2019 08:28:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 1D0436040EFF Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 183E75BA00BFE; Mon, 2 Dec 2019 08:28:42 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 2C1A55BA00BFE; Mon, 2 Dec 2019 08:28:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mailman01.phx2.fedoraproject.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=disabled version=3.4.0 Received: from smtp-mm-ib01.fedoraproject.org (smtp-mm-ib01.vpn.fedoraproject.org [192.168.1.83]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id AFD405BA00BF8 for ; Mon, 2 Dec 2019 08:28:35 +0000 (UTC) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp-mm-ib01.fedoraproject.org (Postfix) with ESMTPS id 29A3D605D2E1 for ; Mon, 2 Dec 2019 08:28:35 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id ay6so15931736plb.0 for ; Mon, 02 Dec 2019 00:28:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uFR49uS3hGZH5BpfPz4foE9/DuNfUsKPVeFDFrA0RTU=; b=WQrQaohU9VlvlDYjoCE2Pe3TPc8aRLrY/ih/Rm/0p/k7hwBQuB1e9HTHuL+CAdRD18 3JuXzT3g2uzKYr+X3ZYZKP3QPH0aiJCizvjYSIkwRxDQm0kxSxXs75+ra0iAb7FjVJYk 1mWjNbcZjqgYtNiclksT/+BgflMr8COox1IiBeiiyZG1HAvDrzpGuSApnflA/ANJ7VLf WjatHRoPksfCPS6RcX7exfLX7KLcHxtM0ylBPLf20YSFBezZBpTljCNK6UpsGuV+dKMZ iXOJmNSP6OYcRFcv/OYAVaw9DqnecHFsZAt1DoaiYVexyt5WEqChMtn6Wj1683TjzBVn XDrA== X-Gm-Message-State: APjAAAX2ZpUciYBeoApNQ/LmRzoHJHXI928mji4kjHCJpKkwDT/QA1Eh AyH6t9hrIVhP1AAipmibC8qfXacKXcQwVg== X-Google-Smtp-Source: APXvYqzT8yBYNFVlkbQbRFo9d6GI61BB+901+PlxCVIUTmzptMRLWIs6SkjFRaGbnRW2CttuQfhH1A== X-Received: by 2002:a17:90a:e656:: with SMTP id ep22mr34578995pjb.58.1575275313280; Mon, 02 Dec 2019 00:28:33 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id u1sm176092pfn.133.2019.12.02.00.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 00:28:32 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [libteam PATCHv2] libteam: wapper teamd_log_dbg with teamd_log_dbgx Date: Mon, 2 Dec 2019 16:28:17 +0800 Message-Id: <20191202082817.7316-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20191106094855.13859-1-liuhangbin@gmail.com> References: <20191106094855.13859-1-liuhangbin@gmail.com> MIME-Version: 1.0 Message-ID-Hash: 2XQKXXSQMXR7MS2SW57A3S7FY4XX6PNB X-Message-ID-Hash: 2XQKXXSQMXR7MS2SW57A3S7FY4XX6PNB X-MailFrom: liuhangbin@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Hangbin Liu , Jiri Pirko X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: 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. v2: wapper teamd_log_dbg with teamd_log_dbgx as Jiri suggested. Move TEAMD_BUG to use daemon_log directly. Signed-off-by: Hangbin Liu --- 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(""); + teamd_log_dbg(ctx, ""); team_for_each_port(port, ctx->th) { trunc = team_port_str(port, buf, sizeof(buf)); - teamd_log_dbg("%s %s", buf, trunc ? "" : ""); + teamd_log_dbg(ctx, "%s %s", buf, trunc ? "" : ""); } - teamd_log_dbg(""); + teamd_log_dbg(ctx, ""); } 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(""); + teamd_log_dbg(ctx, ""); team_for_each_ifinfo(ifinfo, ctx->th) { trunc = team_ifinfo_str(ifinfo, buf, sizeof(buf)); - teamd_log_dbg("%s %s", buf, trunc ? "" : ""); + teamd_log_dbg(ctx, "%s %s", buf, trunc ? "" : ""); } - teamd_log_dbg(""); + teamd_log_dbg(ctx, ""); } 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(ðtool_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(ðtool_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 f98a90d..e5cbe2b 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) @@ -444,7 +444,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);