From patchwork Wed Feb 14 19:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13556969 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E888D138488 for ; Wed, 14 Feb 2024 19:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939535; cv=none; b=f+FwlXbFneG6mxsz3v0WxsLK9E1oIwa0k3j5YdUCpl193xQPIwrWR9uaHfBksIMyI2zEr5m4+7nni3APECvtb6JHyNFBk/u/vlXFYQYaR9bt+2e6IBWGxLaez4d9Lx4maOtXF8BL2k+ICOIMnhEpc2zCfs2itVHWv9aftqM+98U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939535; c=relaxed/simple; bh=JyNsKP+I/qB+DgwNWT+XvdAENmrt3cBG7GNT1NzO0rM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lXNeW5hoNtBj5hIVQ0wQGpJgSK7uUbPtFmuTZYBFYmXKJih0qgEU7rDVZ3GnvsqNb1QsvsEoWiujL9VA0XEawQlM2iLS+ClLi6fidEI4M8qu5mTyxkFWdXqSfRw7z9aZU5O480VlV/RyDNGJciy47h3topyqun5K2EoZZ3A6fAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lgewilgA; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lgewilgA" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1d934c8f8f7so775345ad.2 for ; Wed, 14 Feb 2024 11:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707939533; x=1708544333; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qxoAzV9F1JlwiHJUV26mJsU1NDAasvYRAeNf4MhWL68=; b=lgewilgAY9blI9ukfUk831VdgoNolAkEsWOYrCprNLPVzJx5Q/Q0BMegIu2qzOJwvn xXdChqTMzhSAUi/Jle/gLi2/xrdcN8aWZXTr/rVHfPGgOx4jlySVHyAUr26d5EDMgnms k3PN3lfAyulnlwZh7hf4oN+xhD3Lo7fHOEpNV+E9IMhO7DAFCAPh1vCQY2zLujmk/INs T4XNvj9M8+Q7vQskTaj4RXC7gPEbzimuH4UOC8PJ44WbC2Y8tpGs3ZNUP9H3Za0d85a3 aNbKhbvTGs70Vhr/gOiFxK7+Jtz8UVCs/P7li72IZXGabwsNvqEVZgs2h4M7n/VZVtjB mKoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707939533; x=1708544333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qxoAzV9F1JlwiHJUV26mJsU1NDAasvYRAeNf4MhWL68=; b=nSkn1WoVlbOM0VHPrlDdDbLoHXpdhX+6OTKrGtOdbn6SlWn71/6/O7IxjnNJkKIAT9 E/S358m54ajbrbMegQaRQq6NaWM27oKxQV97c3XCO7j3tmNkPf8a8sIzuUegdV6WH5lZ 07I78WbwB8nsXTCDMXQ4PDMjKBYDrWB9vjl0J4NV79kwllXxSi/DlTHFSd4RN0gHyUJO IVvGjjD0tlLgb50mb5ImxM2VoekqRalQM1u3wWlwx7kfYewkSr3rsIU3hgmvTmhrwPWn cAM6UCz5jX/gDykzS9zKOju05DelKGpTptH2KDevGDdTOF9L7LqX5Z2kn2uEwAVLm/IR 4Y8A== X-Gm-Message-State: AOJu0YyB0ESvU1jmSQBdYG48EUbHuwCcBvCvOK80b9C7RbFKjM34YpQq mq2kXnT/gMMYCJgrpcp/n2gLUR0lXVVQgKc9dSeIMelCkPhhVhfwB/JVRbb4eWc= X-Google-Smtp-Source: AGHT+IGer4IvMC/+iq3EyfC+KvFUzLoztPvINSksn227uIgiY64eXF58WrntLcW3gO+9ClV4rlcpDw== X-Received: by 2002:a17:902:db06:b0:1d9:ca7e:f0a8 with SMTP id m6-20020a170902db0600b001d9ca7ef0a8mr4822627plx.1.1707939532957; Wed, 14 Feb 2024 11:38:52 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id v2-20020a170902d08200b001db53ccb856sm1761606plv.108.2024.02.14.11.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:38:52 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFC 1/5] main: add runtime flag for setting the logger Date: Wed, 14 Feb 2024 11:37:39 -0800 Message-Id: <20240214193743.963349-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214193743.963349-1-prestwoj@gmail.com> References: <20240214193743.963349-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The --logger,-l flag can now be used to specify the logger type. Unset (default) will set log output to stderr as it is today. The other valid options are "syslog" and "journal". --- src/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 3ce8340f..acbfdc0c 100644 --- a/src/main.c +++ b/src/main.c @@ -63,6 +63,7 @@ static const char *nointerfaces; static const char *phys; static const char *nophys; static const char *debugopt; +static const char *logger; static bool developeropt; static bool terminating; static bool nl80211_complete; @@ -164,6 +165,7 @@ static const struct option main_options[] = { { "nointerfaces", required_argument, NULL, 'I' }, { "phys", required_argument, NULL, 'p' }, { "nophys", required_argument, NULL, 'P' }, + { "logger", required_argument, NULL, 'l' }, { "debug", optional_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, { } @@ -474,7 +476,7 @@ int main(int argc, char *argv[]) for (;;) { int opt; - opt = getopt_long(argc, argv, "Ei:I:p:P:d::vh", + opt = getopt_long(argc, argv, "Ei:I:p:P:d::vhl:", main_options, NULL); if (opt < 0) break; @@ -503,6 +505,9 @@ int main(int argc, char *argv[]) else debugopt = "*"; break; + case 'l': + logger = optarg; + break; case 'v': printf("%s\n", VERSION); return EXIT_SUCCESS; @@ -519,7 +524,12 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - l_log_set_stderr(); + if (logger && !strcmp(logger, "syslog")) + l_log_set_syslog(); + else if (logger && !strcmp(logger, "journal")) + l_log_set_journal(); + else + l_log_set_stderr(); if (check_crypto() < 0) return EXIT_FAILURE; From patchwork Wed Feb 14 19:37:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13556970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3ECD138488 for ; Wed, 14 Feb 2024 19:38:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939537; cv=none; b=HTRPdlX1ca5s43KYL2ui5W0Im1m8RSxskchnca3AOv/RtRufpNcvDaTCU9BFs21rLHJiQQ5DsDeubLM4uLKk+jEyrI7kpoSt9TGgArqDbZatJn7uTqkI/ubi/4IHzMGBnFiDJq3py+7ytKce13TJIfHQzTSSWh9DuzPSrpaPEws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939537; c=relaxed/simple; bh=MjPjBS7yuQ3yAyfpRxhmwICpWOeBZ9kHqLFk26SkV1Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W4t5iXn20Mjrk139cJQVBdK7vpawgW5LSJRenm50KS0zUhzOW2bGNfeth6m2D0jBYDZ2bk5l4WekSppqubDGemUPQRoNpgbkdR6YU0EHEI52BZehYlpmJP7XXXHSHP4V9F/5S1PntwvF7AiS/jAFaRgVitpLy5tzUgHg2xwrlZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R8q4nFFB; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R8q4nFFB" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d91397bd22so776495ad.0 for ; Wed, 14 Feb 2024 11:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707939535; x=1708544335; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bEO1rfbP4xIiW9H4MjMKHumuk4OaCq9eBSHXt9UovzA=; b=R8q4nFFB5QAzo1pJweqTP2t4bfUK3jI/FVrz+vJ7QIDhwEdehjxNWJbomGUmAKQq7j zBbbqbRQovmkNMJdUBmruR8VWvil7tkADRqQ1yLLrBY6rGUpSGG6gl3CQkU6S5Tk9Pd2 JS5OrQ4NlEZnC3P/Yprn2qYGeqHaRtkF3ZGKdLTWokO1VyEpd9vqa8h2A1Lp7Me8N8Me CG3bbaM3CKfbIE6ueecDY2VbiwDOuF2t0SNq0rRtTdg/3gdCoO+z/u63BztZF/DovCJF bHZ6JV8l/M9qPFl/vqC7Jg1lNHN0zeBuhnCGdcErh8LuCBSuV0Glr9O4JPYPaAn78VQD 1aMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707939535; x=1708544335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bEO1rfbP4xIiW9H4MjMKHumuk4OaCq9eBSHXt9UovzA=; b=eLC2rgiazCo7MX1gHOO/hM6tyLS3Ydc3yxpsUGQ7cE282GrW2RqWkdkrlwPqGfIjVi thTEVtrFAE0iAzdRzUYeCzFooSnz852hzEvMZ3H0bmyRCZ+vn3r1u37quGbwC3DnfdB+ FZ7TotKIORRZewFEBqQVC1S5bjtebYL3wSxPbvswbxt8r8DV1y+/rMxDADZJRcj89BNX JEV6nxuLQ9fw1DQsShRhyInCrx++NtGaQ/BMMWo6ylRp05TzokbgmXCLNVuCfrlh522V ePhdQms5bvToaXgcupbP7qlFeriImXLwExnTcQgczC7ArDA7xKDjoqnMHbGryRh4s5FF Xp+w== X-Gm-Message-State: AOJu0YwzwKEwIuqm55uuNAOKpIXj2x+ybB8egOsozsbK3vZIxtyxFuKL lr8T6YAHvhi5ylK/2M7awc8Kwd1RvnFDPd5Y/ec32PVPfvDadN4S/bQEPjWqwos= X-Google-Smtp-Source: AGHT+IG9Y3/2kAZ9ZVBoTiLSHTK7ukwBaOcigwjYpxkwbg49kobRG5jPUABx8jJOP7hF6Hv2VN8Tzg== X-Received: by 2002:a17:902:bd0a:b0:1db:5319:4d86 with SMTP id p10-20020a170902bd0a00b001db53194d86mr3788159pls.52.1707939534620; Wed, 14 Feb 2024 11:38:54 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id v2-20020a170902d08200b001db53ccb856sm1761606plv.108.2024.02.14.11.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:38:54 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFC 2/5] station: use l_notice for station_debug_event, allow arguments Date: Wed, 14 Feb 2024 11:37:40 -0800 Message-Id: <20240214193743.963349-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214193743.963349-1-prestwoj@gmail.com> References: <20240214193743.963349-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For anyone debugging or trying to identify network infrastructure problems the IWD DBus API isn't all that useful and ultimately requires going through debug logs to figure out exactly what happened. Having a concise set of debug logs containing only relavent information would be very useful. In addition, having some kind of syntax for these logs to be parsed by tooling could automate these tasks. This is being done, starting with station, by using l_notice. The use of l_notice in IWD will be strictly for the type of messages described above. Modules using l_notice should follow the same log format so tooling can parse the messages generically. The format should be zero or more comma-separated key value pairs, starting with "event: ". station_debug_event is being modified to use l_notice as most of the events are useful for debugging. This was modified slightly to allow arguments to be passed in order to provide extra information if available. --- src/station.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/station.c b/src/station.c index ea505ca2..a097174e 100644 --- a/src/station.c +++ b/src/station.c @@ -215,15 +215,13 @@ static bool station_is_roaming(struct station *station) station->state == STATION_STATE_FW_ROAMING; } -static bool station_debug_event(struct station *station, const char *name) +static bool station_emit_event(struct station *station, const char *name) { struct l_dbus_message *signal; if (!iwd_is_developer_mode()) return true; - l_debug("StationDebug.Event(%s)", name); - signal = l_dbus_message_new_signal(dbus_get_bus(), netdev_get_path(station->netdev), IWD_STATION_DEBUG_INTERFACE, "Event"); @@ -233,6 +231,12 @@ static bool station_debug_event(struct station *station, const char *name) return l_dbus_send(dbus_get_bus(), signal) != 0; } +#define station_debug_event(station, name, fmt, ...) \ +({ \ + l_notice("event: %s, " fmt, name, ##__VA_ARGS__); \ + station_emit_event(station, name); \ +}) + static void station_property_set_scanning(struct station *station, bool scanning) { @@ -1565,7 +1569,7 @@ static void station_enter_state(struct station *station, station_state_to_string(station->state), station_state_to_string(state)); - station_debug_event(station, station_state_to_string(state)); + station_debug_event(station, station_state_to_string(state), ""); disconnected = !station_is_busy(station); @@ -2351,13 +2355,14 @@ static bool station_ft_work_ready(struct wiphy_radio_work_item *item) l_queue_insert(station->roam_bss_list, rbss, roam_bss_rank_compare, NULL); - station_debug_event(station, "ft-fallback-to-reassoc"); + station_debug_event(station, "ft-fallback-to-reassoc", ""); station_transition_start(station); l_steal_ptr(rbss); break; case -ENOENT: - station_debug_event(station, "ft-roam-failed"); + station_debug_event(station, "ft-roam-failed", + "reason: authentication timeout"); try_next: station_transition_start(station); break; @@ -2560,7 +2565,7 @@ static void station_roam_scan_triggered(int err, void *user_data) return; } - station_debug_event(station, "roam-scan-triggered"); + station_debug_event(station, "roam-scan-triggered", ""); /* * Do not update the Scanning property as we won't be updating the @@ -2704,7 +2709,7 @@ next: /* See if we have anywhere to roam to */ if (l_queue_isempty(station->roam_bss_list)) { - station_debug_event(station, "no-roam-candidates"); + station_debug_event(station, "no-roam-candidates", ""); goto fail; } @@ -3393,7 +3398,7 @@ static void station_packets_lost(struct station *station, uint32_t num_pkts) if (station_cannot_roam(station)) return; - station_debug_event(station, "packet-loss-roam"); + station_debug_event(station, "packet-loss-roam", "count: %u", num_pkts); elapsed = l_time_diff(station->last_roam_scan, l_time_now()); @@ -3423,7 +3428,7 @@ static void station_beacon_lost(struct station *station) if (station_cannot_roam(station)) return; - station_debug_event(station, "beacon-loss-roam"); + station_debug_event(station, "beacon-loss-roam", ""); if (station->roam_trigger_timeout) return; From patchwork Wed Feb 14 19:37:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13556971 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3391613A272 for ; Wed, 14 Feb 2024 19:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939538; cv=none; b=VYZe2qqeg6Q7FIGK3duLi/yARtaO4F38OWYMbTPUJPTug+R5bmV0xZsIC3InIpEZvMr6XJhXp/cdCH1KDtGtQ5vGAowbXT2rfSSzhRMpcCdcyzg8n6XxZ5ROShdJgu4SfpX1/E83hPUQ8db1uFmi5k5FgqNZhkWi9W4Gpl4JF+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939538; c=relaxed/simple; bh=oyLfx7/pnzUxmYnnnTiool80jLMxFi8o1pp12AKBvjw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LiZ7mkb6BZ3W5yqNJagSv6dpKUIWh41u6OD/d2eT4jb6Lrzr8K7ox1rU+KN1rmL6/imlQOFsjC+vmwsUH9/d5rVlW2KgNJDjyQXwOikUldo0SSzptKfbdjCXETUA8IM3S2SjXNtVlLHmnxB4gFMiSOwuWFC1uS2QLULx+/Hoxcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MAkcZEnN; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MAkcZEnN" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d73066880eso696885ad.3 for ; Wed, 14 Feb 2024 11:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707939536; x=1708544336; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KnLoxeM6Ty2uLw1/hnm+dZ2siXT53vfl6N5L3jiKhsQ=; b=MAkcZEnN+9ividRviUd9hc+uoOdAU96B12WRi2runrNEDv++2NkB8xgrfaXANQaJRY S6HjLrrTbeKKU3TcKI1eahdEZ5suA3d9MxyEfscHz1TEtQryJ5umMTmvP+T3grbiR4uR 26kzUxWHyEra9Pc/nX7fkmDhLF4dmagG/Wk1Fa9fTAvhhMC3ZE7g5OiJWoXM7Htq5i03 Pbhp1hCX83UPKYdz+NW+U4Hm6DrzVzN6zsP/bCJDDsbycvuFVXzaEsnxze4or7SIxu5I 4OnqvzU6oQXRICDP5m5pSok++A30tes/+s2HtZJRSg8yaTnldWtTf5WIM2wO7Xw3oB2k FkQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707939536; x=1708544336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KnLoxeM6Ty2uLw1/hnm+dZ2siXT53vfl6N5L3jiKhsQ=; b=hhevC/m5V/1KCWbuDMuWZgsVB90lQM9bQXu+HNsX/qarDaNiZnODLSQExNng3s3kcE KXQ36/Cj2cdCvBRfx4qqVfqKJi1j/Vy4T6ofhu2Db9jATbS1DoyySe+8Bj35iLjpgIMq l2YDwDiPWZgvTYGyVTWpHYaWVy6Vf3cgtlIti/7CB6rjPKXUCYht2Xep6xuq54JEnEDz 5O8EUdF4syC/Vw7dsm1llmTmvn7LF9EBW9XABmVH265MDLExaRX/tUSLr7nv114ZQa5p 2i5/uHJ5OflAiZH+0yVjmksRwmP0MzADxUyj39i9i5DQjufe9Gnxf/bBgrXfuaeSvFql mXcw== X-Gm-Message-State: AOJu0YxVecGGUXfuSy84BRYdXh/e8aSvfVxTnPpuV7X8NjrlAqEbHi0i ZqL8OLltQbIX0y3i22DUKGuWr5svxKbfr1AwMATL7wvgx28LJEIJtYcOWWEB/Jk= X-Google-Smtp-Source: AGHT+IH0ds7LpZpT6ZKmV6td9M8+9B37eeg+zWwdUx11p0enmU3WiLn36+dBxV7m6a5asfdM6J4qtw== X-Received: by 2002:a17:903:120b:b0:1d9:c876:b825 with SMTP id l11-20020a170903120b00b001d9c876b825mr4853270plh.56.1707939536071; Wed, 14 Feb 2024 11:38:56 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id v2-20020a170902d08200b001db53ccb856sm1761606plv.108.2024.02.14.11.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:38:55 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFC 3/5] station: add additional station_debug_event's Date: Wed, 14 Feb 2024 11:37:41 -0800 Message-Id: <20240214193743.963349-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214193743.963349-1-prestwoj@gmail.com> References: <20240214193743.963349-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add events/notifications for roaming, connecting and disconnecting information. --- src/station.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/station.c b/src/station.c index a097174e..7d6a8023 100644 --- a/src/station.c +++ b/src/station.c @@ -2389,8 +2389,11 @@ disassociate: station_disassociated(station); break; default: - if (ret > 0) + if (ret > 0) { + station_debug_event(station, "ft-roam-failed", + "status: %d", ret); goto try_next; + } station_roam_failed(station); break; @@ -2462,8 +2465,11 @@ static bool station_try_next_transition(struct station *station, struct handshake_state *new_hs; struct ie_rsn_info cur_rsne, target_rsne; - l_debug("%u, target %s", netdev_get_ifindex(station->netdev), - util_address_to_string(bss->addr)); + station_debug_event(station, "roaming-info", "bss: "MAC", " + "signal: %d, load: %d/255", + MAC_STR(bss->addr), + bss->signal_strength / 100, + bss->utilization); /* Reset AP roam flag, at this point the roaming behaves the same */ station->ap_directed_roaming = false; @@ -3164,6 +3170,9 @@ static bool station_retry_owe_default_group(struct station *station) static bool station_retry_with_reason(struct station *station, uint16_t reason_code) { + station_debug_event(station, "connect-failed", "reason: %u", + reason_code); + /* * We don't want to cause a retry and blacklist if the password was * incorrect. Otherwise we would just continue to fail. @@ -3214,6 +3223,9 @@ static bool station_retry_with_status(struct station *station, else blacklist_add_bss(station->connected_bss->addr); + station_debug_event(station, "connect-failed", "status: %u", + status_code); + return station_try_next_bss(station); } @@ -3374,6 +3386,8 @@ static void station_disconnect_event(struct station *station, void *event_data) case STATION_STATE_FT_ROAMING: case STATION_STATE_FW_ROAMING: case STATION_STATE_NETCONFIG: + station_debug_event(station, "disconnected-info", "reason: %u", + l_get_u16(event_data)); station_disassociated(station); return; default: @@ -3513,7 +3527,12 @@ int __station_connect_network(struct station *station, struct network *network, return r; } - l_debug("connecting to BSS "MAC, MAC_STR(bss->addr)); + station_debug_event(station, "connecting-info", "ssid: %s, bss: "MAC", " + "signal: %d, load: %d/255", + network_get_ssid(network), + MAC_STR(bss->addr), + bss->signal_strength / 100, + bss->utilization); station->connected_bss = bss; station->connected_network = network; From patchwork Wed Feb 14 19:37:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13556972 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BC8C5C905 for ; Wed, 14 Feb 2024 19:38:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939539; cv=none; b=Y7pjR7XFlU53OsZOCIKvYOzj5TaejB3D/rCBMBI1UmbA+7vwpVtBOxwzS1AqrYchSje7gQGy3TuDEfpLslq8JxbEolh6cye9ZeP0tIaFxqvXGrQRbKtiS7lid8b/PPyuRv22RufnVyCw2AsudA0c1HneBaRZkRKEj+7fuMhcn6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939539; c=relaxed/simple; bh=maL4fwIRXzzNZlSLRxDll4JrkGtQ2cJKwVr7KHntFrA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RTZM1oe9f+r6W2ivYKKtlwJvNRy9V8CcgKKcVN2o4j9b0z0PqXAUQaOJ64cbvTUKWm8v5NA/gJn05roxSs0Q3BQeocksdwuZVLaiZLtOlc+bAq9KYwNd5CZYVJfH7HBKcidK40PkwcEqvQHKsG4vjDB1CFi9nbUJXI2oPcdkivM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PJDEfDGu; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PJDEfDGu" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d932f6ccfaso893175ad.1 for ; Wed, 14 Feb 2024 11:38:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707939537; x=1708544337; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OcsB0D0Znm1KShBRPj68Fl4RcuiUzTTN/UICyWBNJ6I=; b=PJDEfDGuLDp8eY93t+YbMm4DbjvU89pHElAezHngw5c9J1ZRXtUpSFhH2sF5DtpwYL stW3h4At6YxaEOSLG6pKCz3p0S5b82S8hu8WU8nSM0OnZBSiU6mzJuWhL47wu5p0qOf2 fQbT6pS1gynWHG1noQIRiq0OOkLL1Bl0e5Qy300qBw97Ey1zziA8gVjyYg9ZTBd/pYbf jis0ooNbTxN64Gmni2SAuVG6fgjUFdN00THvhM2u3bzyZSxFxN0TJms47AeeyKTV84DF AXhcw5eVXCdjOkG02vP0DAIzqFnNdGBhfBPaOLFTV4HZ1PhVk5RVnRNRFKBRrlidVrOe cU2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707939537; x=1708544337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OcsB0D0Znm1KShBRPj68Fl4RcuiUzTTN/UICyWBNJ6I=; b=pI88xz7lalaIWN6tci2wxgj52aqMRSRCNh1fCmGLn1HJINh3m4khp5UB04/iUfElGu KPydcoudVj7vt0YfkAjd1dmSz0fpvJ39jABZinfAN4s4z65j7VV5pQ3jJWRp57bBdV5g v+HAavgeBuai5mUkPO2KbqLYc60VXXySHBCRxxjeSZ8xeOhEcfDbB1FqrQrzpbY943qt kkjfSZMfHQ0XH9gwZ2umOVv+RKpGqQnTAeUht58XF/WeAhJocjJdhi7WMl/09CoQPlFT r4QuySmkQCScCE7SCz2mqqzKdtTq6joR+sUis9ZksRjHDhsiruv3jiHyHigLP6wobz+n 0H0Q== X-Gm-Message-State: AOJu0YzlSVNyO14obY45vmnft6J/Af7joG66nKakcpBQWbI0YRXED+Ab aOpTVQ7RX05strWyvByKnbQ71O7FPkfibKuf9MJnm4Mp+gKcVPGik/kupLsfdo4= X-Google-Smtp-Source: AGHT+IE0NIwC3IakL+8+lpigUg/FJNtUke0CprXx64UxGlf5Tdo0wtqi6Po0HytIoDe+1g6yNKGEyQ== X-Received: by 2002:a17:902:c94e:b0:1db:68a3:86e7 with SMTP id i14-20020a170902c94e00b001db68a386e7mr2153871pla.60.1707939537508; Wed, 14 Feb 2024 11:38:57 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id v2-20020a170902d08200b001db53ccb856sm1761606plv.108.2024.02.14.11.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:38:57 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFC 4/5] netdev: add notice events for connection timeouts Date: Wed, 14 Feb 2024 11:37:42 -0800 Message-Id: <20240214193743.963349-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214193743.963349-1-prestwoj@gmail.com> References: <20240214193743.963349-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The information specific to auth/assoc/connect timeouts isn't communicated to station so emit the notice events within netdev. We could communicate this to station by adding separate netdev events, but this does not seem worth it for this use case as these notice events aren't strictly limited to station. --- src/netdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 48fb15df..a213b606 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2639,7 +2639,7 @@ static void netdev_connect_event(struct l_genl_msg *msg, struct netdev *netdev) } if (timeout) { - l_warn("connect event timed out, reason=%u", timeout_reason); + l_notice("event: connect-timeout, reason: %u", timeout_reason); goto error; } @@ -2931,7 +2931,7 @@ static void netdev_authenticate_event(struct l_genl_msg *msg, while (l_genl_attr_next(&attr, &type, &len, &data)) { switch (type) { case NL80211_ATTR_TIMED_OUT: - l_warn("authentication event timed out"); + l_notice("event: authentication-timeout"); if (auth_proto_auth_timeout(netdev->ap)) return; @@ -3032,7 +3032,7 @@ static void netdev_associate_event(struct l_genl_msg *msg, while (l_genl_attr_next(&attr, &type, &len, &data)) { switch (type) { case NL80211_ATTR_TIMED_OUT: - l_warn("association timed out"); + l_notice("event: association-timeout"); if (auth_proto_assoc_timeout(netdev->ap)) return; From patchwork Wed Feb 14 19:37:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13556973 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E865613A272 for ; Wed, 14 Feb 2024 19:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939541; cv=none; b=d16080FxcynwgRRbaJPnAERRb8FfImkZIi2gn41lf2kUNcaeKRKjwMqsZY+3WVLKfS4QOnt62BSSz8Zc/aR7cvaA3MqPfh0wQPFiogcGSLP2MDQ/ewROWug2lGh9II9UIYwY7f0p46fWN/jw/+FHNCUNwinzYhOB5AQthoxY0R0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707939541; c=relaxed/simple; bh=VrUsBi7vvEmY9B3aShvVPIxonDCcFEZ6mQfimLd/1ac=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rpnn7U4dmrgXLJIqn/RiyRfnC5ZCzuubfMtbqhTC3kmiKdPlss+cl0SH4cfHRUgxFv9VarGJCStMEQvhHFg7OXkS72obFtbU/dhxuchP6fxQ+t58b9wkvY+zs4JIn9r6ZFaw3EEh/rwNFLGZQz5ccHW67WF6IzImpe686PVCO3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I4vacAZM; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I4vacAZM" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1d73066880eso697345ad.3 for ; Wed, 14 Feb 2024 11:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707939539; x=1708544339; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hwBYWyuNokiqudKDRORBvRUNZjblHmGp8dCISEwBfvM=; b=I4vacAZMGdq9lnq+PuldXJ1tFLsTZeR3q1H8GzAkdMYXJT40UIJDSH3uqH7MpzG98j Vhw80L3xPfOLuwet1719Fa3uiSoNFmq/0mSwx0F3epaOGhR1z+0qalSeRHXE+8MDZCvA zPuxu5flfPTLkzUUwDZVKkRbYN1GobV/bFc4KNc1YVVttSBHNtq21lCOsOmPsFLZQhUf yPneAwBDFX+SDNpmtDjq0YsIyVj/Vv41leW58QSFlIKE14d+DO8ruPenoSA0SBzUCknn UXazXHiXcn6gSsi7IykdGB/EOAn5iEeifFFqAVkEubSeCjWXwqW8rrj67wn+sHvO8yG2 Mdrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707939539; x=1708544339; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hwBYWyuNokiqudKDRORBvRUNZjblHmGp8dCISEwBfvM=; b=uWkdtKkgiA43W3zh5uBRISaGdsxM5UA0gMGWW+DQOE4cZBoklusrWicl6FgL3opysK rPajpjLz9ogbVhzKUfsie/3pQ7zS9fd/DyvEn7HZTeBrKhU8TNtteBqZSPIBn3VEnhUy ANwiUckLEG0oyIj0s8GyGIQg31jSVKq71E/FAHLMLr2gjYCtAVTHW+CGNvNjFGvJ8Ctm snaTh2N1ypXTkWnzUo+yINlUuUqHoBzOBmgBYvtjvyZQRx1DhkEDxgEWP2vdFuE7lLT8 s54oLEaDjtqnYXSlQDnBHYnhh/vpCQOpcKOoOglTEDb8DTJZ8IlLoCYRBNIawBJwOpWs STLA== X-Gm-Message-State: AOJu0YzBlbSm3plRmgAkd9yHVnjssrESajm1y4DIpYQH1HyVUv4mMTqp GWtjcAaqBnCtNJrLXqghpQcLSj86IXKqBGsdcvUrhgxMmxsz3ncq7G4AXdNndQA= X-Google-Smtp-Source: AGHT+IGCWG1O8BRpihQBw15/BgKHOsqmFF73Rpp9QyJqFTeb/8FHWSYi9Wdzhd12b/t8Iugtc44DKA== X-Received: by 2002:a17:902:fe83:b0:1d9:8def:6942 with SMTP id x3-20020a170902fe8300b001d98def6942mr3376221plm.23.1707939538915; Wed, 14 Feb 2024 11:38:58 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id v2-20020a170902d08200b001db53ccb856sm1761606plv.108.2024.02.14.11.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:38:58 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFC 5/5] doc: document use of l_log APIs Date: Wed, 14 Feb 2024 11:37:43 -0800 Message-Id: <20240214193743.963349-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214193743.963349-1-prestwoj@gmail.com> References: <20240214193743.963349-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With the introduction of l_notice in IWD some guidelines need to be set for l_info, l_warn, l_error, l_debug and l_notice. --- doc/coding-style.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/coding-style.txt b/doc/coding-style.txt index bf0535c5..fdd9e0e3 100644 --- a/doc/coding-style.txt +++ b/doc/coding-style.txt @@ -317,6 +317,30 @@ Functions that are static should not be forward-declared. The only exception to this rule is if a circular dependency condition exists, and the forward declaration cannot be avoided. +M18: Use appropriate logging levels +=================================== +An appropriate log level should be used depending on the type of message +being logged. Logging is done using the l_log APIs in ELL: + +l_info Information that is expected during normal operation. l_info's use + should be very limited so non-debug logs are concise +l_warn An unexpected, but non-fatal condition ocurred +l_error An unexpected condition ocurred. These are generally fatal to the + current connection/protocol that is running but not generally to IWD's + overall operation. +l_debug General debugging. These can be used relatively freely but should + provide some piece of useful information. +l_notice Reserved for specific event-type notifications about IWD's internal + state. These are logs that are mean to be both human-readable and + parsed by tooling so they are required to be of a certain syntax. They + should start with "event: " followed by comma separated key + value pairs containing the data of interest. Event names and their + arguments should be consistent across the code base, i.e. two events + called in different locations should have the same arguments. + + For example: + + l_notice("event: mycondition, arg1: value1, arg2: value2, ..."); O1: Shorten the name ====================