From patchwork Thu Feb 15 13:53:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13558430 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 63BF213173A for ; Thu, 15 Feb 2024 13:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005207; cv=none; b=YA2PhmVD3X0kNsV+9SERVZ2NQMsGG3bClBOBm8z8y9iOb1c0alTSnA04YW7eQRZs3WUA8mAvyDwjKgYVlbd4AWJhfH28F5EPr/Mm9ZxX3WJTm6Oq+gt12R3LCWDNafS7G6yt9LIg9OmOByGU+SB9DH/wu0rETTQHhyYx9Vd1tEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005207; c=relaxed/simple; bh=JyNsKP+I/qB+DgwNWT+XvdAENmrt3cBG7GNT1NzO0rM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bpTuMyy07kcPHS0yvyuoXNGG4qX5OWeOf/fFGUaFsnLHX98isLEwHRs3GF68v5yW7uroaSSGn9piNlERMM7c49Z30P28Pdm6VxFAsyGP70GaF701LuDwdV4PFO4aR5VNqxaWqWDCBV1qZp43PWf6V9cyIXoTnemE2RaFzg502Bw= 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=jsG1z2Sa; arc=none smtp.client-ip=209.85.214.170 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="jsG1z2Sa" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d72f71f222so7073655ad.1 for ; Thu, 15 Feb 2024 05:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708005205; x=1708610005; 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=jsG1z2Saeh8ePo8dyXwvxJ9f2U9qq5vjOIRnLirEtQrMQEDSNqRAsxRJzVAoEbTvIh nUtANJOd+O3ZFRCEWEEOm/KzBBtuL8SEJ5jcssqyTVik0ewmCs/EtBK7GoPHlbICOY0Y SylX/AZ4xssVzEuOsbeMLfI+Vc8YQrkadZIfB1GEY8C1azyTsYzvgtUigmSS+oYV7o2o QFu+rsOCLEoZugUjN33cocBEOBP5NLbTYDSQR/bg4QeXvPTW5L+5jdU+aqkvAf9mnGCP 7zzY+EGgug1tDbjjRwyfAhMsSvhwZrwD8bOTkPjLsDv8apY39a7SYy32hZOk1EdKPlNZ MLsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708005205; x=1708610005; 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=tujFz/8wYweQKd0NGOW+tTRra679dblpdGPtbuDkPUQzsmsTJmp7IQ/e0LF8J+PXO2 ZOkTrt9ABZWGnjZqdmzdoIL4yZsu7qtIsKqv8jAoTCEqW5Ff95K8fDllC+SnHmtuut/B Wh627RQBsJhR6iMu7GFuqCUXkTWDW4dDXUogKYpiME+Z29U/1T3SS7uCraGzmc1gFLv0 tG2j2K3SL2KSi0ClyRvjnagdNDd1Waaqyl3R3tOEsJhgkC+dc6ZCiHOGSg7tVFWAMcEA zO9F5NjX+Uy2IyWfoDBnAB5kNycG5NZDHomPhcJg9XeYfrAq+zQ29P/Ch3nSchsLJEsS D6vA== X-Gm-Message-State: AOJu0YwuPxr42j5F7H6Qnfmx4cPqRWMX8Bog+OXhrL/fJ4c9rB1nDwqD C2bu08UacWMQQHhi4wnBf8aEWXKhVSXqSyklR3XcPcl8MGqwPJDG/4unQ++fj10= X-Google-Smtp-Source: AGHT+IG8ITbMDpzX4IbmGJ3T1suOdCklyxwL7fMo0RNeaUrx2LdpiaBlpI0fk5+3awcHddM11INjAQ== X-Received: by 2002:a17:902:ce01:b0:1db:8eb2:9a11 with SMTP id k1-20020a170902ce0100b001db8eb29a11mr1353355plg.53.1708005205416; Thu, 15 Feb 2024 05:53:25 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001db55d2e1e1sm1284787plq.63.2024.02.15.05.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:53:25 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFCv2 1/5] main: add runtime flag for setting the logger Date: Thu, 15 Feb 2024 05:53:10 -0800 Message-Id: <20240215135314.1017081-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215135314.1017081-1-prestwoj@gmail.com> References: <20240215135314.1017081-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 Thu Feb 15 13:53:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13558431 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 CEF14132C24 for ; Thu, 15 Feb 2024 13:53:27 +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=1708005209; cv=none; b=eFGJ3In7HqxyS258aarYAEY/PsBgZog4URnXUdQXo/b2HuLS69FOXvTa7vj+jQ7Ohsf8C0O0pRsuW7l+Y2N7MeP2Wyx8O/LziO6xpUyB48KTb2rKTYf1+bFculKWo4kSDzYqsrcFeXHbRHy/AjXhy6Qkmefn/NXaBtkrBTPGOCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005209; c=relaxed/simple; bh=GtkWb3cifPeyEywJy+2bGBeVj0O+vhSVTbbilMDePx8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IlkdiZ8xMb5sowCuMnb4hreQWPUdFRYf4irZ/wqFA/LJLlhaTyZ+25M2tX5qJAtxU3l0E460i4Kk1u4K0A51BxUWZ33pQGxG6vGJSAcU0+8azMHOpDCtzLD/OIT5rawKGxGm2biLoeSj4jsMzrHg202bbRW0aq+ciGz9KguhPjo= 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=h7CTcAVH; 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="h7CTcAVH" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1d73066880eso7729025ad.3 for ; Thu, 15 Feb 2024 05:53:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708005207; x=1708610007; 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=/YoQSgYGctnC+Lwnqy8uNsIX+5DbpRRsjsJh8WlxRD0=; b=h7CTcAVH8jvraBDB28opTaTheS8pBuZ/YgYxTPQBFsRW6RsJp4Rf92QCCDrYIZVf0w TOBTJCzyOAwFmA3zKB5aecLg8fHItgq3E1yOcG4AU++7y+JByj4g5FLJbx6Ur9CLWAxo XRchNBvKUVh117Jbb3PW2EU/QGPqoIFU/ThfUnd4sfgar7fTnV+ru8ukNJ+S2Bx0XDEz 1Dl7tJI+3aGSHwxyiitAhAcevcbW+5wADrVVBPFu+4GNcgtdknGWlxxA0MmV1niVeTMF PJCOkga9nc7x1/dhQ9lMbJO4tiLwJ/BVAgVnim41nACuZ4VA7OkkmIEuQ6CIwHbalCZb O+/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708005207; x=1708610007; 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=/YoQSgYGctnC+Lwnqy8uNsIX+5DbpRRsjsJh8WlxRD0=; b=fqdauwYFCB5W5cn60Xgu8ZVZkgOlXgveMCm9IcLHkOK6Bk6mlShaEe3zLZQWcVPxxa 3JuDsCGv6dQgIbfCBVYR7yK3V5NBIMWhD0ikdF+A/rd0jOfedygUkIVRu6hBf4OA1htJ svNVM2jjjyw2CGq7Fh0K4j6+y2sSxeb8X8XfscWTv1Y25q1z0hNz724/AHo0OG8wB47a lauv7alQ4P2MvvIRcMfsRcn5whSblUtxEdcR1uWjI/mUlLQrpAKEBsIVf0HVqeSd6L+l i2AWzMrxppYOz8/gmvLp1eqXTn7jU1ze3wAJ07hK8A2GgiDMWdG6QuSJkvCeFbkeV4N5 72mg== X-Gm-Message-State: AOJu0Yyqx5lPy5xtgGI9SGwrugm2CGBinLKdQhA9LlCERFqxCByP/VF3 2W42yO2kCdjZvXwylVKupekFXcJreVVmNkgrc0swIRNLqped9CV3GzerdktAvpI= X-Google-Smtp-Source: AGHT+IG0SU6eij5zw3TwbZhVnW0BfrOUfppPHUquRuVvcGadb4gblu6X9ORcO6i5pIrRDO7jjMe/9g== X-Received: by 2002:a17:903:1104:b0:1db:37b1:b1a3 with SMTP id n4-20020a170903110400b001db37b1b1a3mr1851727plh.17.1708005206819; Thu, 15 Feb 2024 05:53:26 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001db55d2e1e1sm1284787plq.63.2024.02.15.05.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:53:26 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFCv2 2/5] iwd: add iwd_notice for special event/state type of logging Date: Thu, 15 Feb 2024 05:53:11 -0800 Message-Id: <20240215135314.1017081-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215135314.1017081-1-prestwoj@gmail.com> References: <20240215135314.1017081-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 iwd_notice is being added so modules can communicate internal state or event information via the NOTICE log level. This log level will be reserved in IWD for only these type of messages. The iwd_notice macro aims to help enforce some formatting requirements for these type of log messages. The messages should be one or more comma-separated "key: value" pairs starting with "event: " and followed by any additional info that pertains to that event. iwd_notice only enforces the initial event key/value format and additional arguments are left to the caller to be formatted correctly. --- src/iwd.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/iwd.h b/src/iwd.h index 1be20df3..e25b4c03 100644 --- a/src/iwd.h +++ b/src/iwd.h @@ -42,3 +42,16 @@ const char *iwd_get_iface_blacklist(void); const char *iwd_get_phy_whitelist(void); const char *iwd_get_phy_blacklist(void); bool iwd_is_developer_mode(void); + +#define IWD_NOTICE_STATE "state" +#define IWD_NOTICE_CONNECT_INFO "connect-info" +#define IWD_NOTICE_ROAM_INFO "roam-info" +#define IWD_NOTICE_DISCONNECT_INFO "disconnect-info" +#define IWD_NOTICE_FT_ROAM_FAILED "ft-roam-failed" +#define IWD_NOTICE_CONNECT_FAILED "connect-failed" +#define IWD_NOTICE_AUTH_TIMEOUT "authentication-timeout" +#define IWD_NOTICE_ASSOC_TIMEOUT "association-timeout" +#define IWD_NOTICE_CONNECT_TIMEOUT "connect-timeout" + +#define iwd_notice(event, ...) \ + l_notice("event: " event ", " __VA_ARGS__) From patchwork Thu Feb 15 13:53:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13558432 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 2D226132C20 for ; Thu, 15 Feb 2024 13:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005210; cv=none; b=uv/ONP8ndVLNOpESvCszQFwvfYL9rnMR/Xu8aYKeTrJpLEiYAzRv/Opt3+kg6FVm2SxMxjb+rXeqxBqDtRL7/I9tq+FGkj8hAMxaebBZ7MMDXb42FVb8KA7QIZXYqS9b0fVUxKB+gWxefozKkcnGTcuyzYcGF3tUtqHilgarRhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005210; c=relaxed/simple; bh=Z61jTqYf3mrqIoBl4vwh0fodGPv+kblLyeNMBdac2vQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=egWrkdIFRo6W+/+W3PxmOQYstrPodtZXghfK23vuo3q56v0TsA7Acn9z+OMAw4poGYOaFwG8jrBSUq/+UeoJf1GaJPyn6IJlt3ht8NjUaRBQHcTMJkqlOp7Tto7quA6bP3z85P8wNiPt7EuhrLKiQFoPSvEZRWLosB+kIEUfOo4= 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=jRwjpcFt; arc=none smtp.client-ip=209.85.214.170 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="jRwjpcFt" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d73066880eso7729275ad.3 for ; Thu, 15 Feb 2024 05:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708005208; x=1708610008; 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=+RxDxZNcWgZxObjqXsUDIT4GiaFdU7jw+jB2BudVupQ=; b=jRwjpcFt6PQ5FEEw5YXCO1i85x2eAojlugmN/Uw1ChDYhs5f6VfOCtBmH1MkcJmRtU XafMXA2QYHi3m3Su9++Z0C8IJZTEQ7WhTgyUYQTObt0Y7JFRsK/Bv+1HaASFHQzbpolo DA0wlayO3Q1u/pyaoImM6yfmKj23sexjCwWZwYoncRtxuslBGc1klcNjkVkT/YnbiHiK 4I8WFeFYlsBQWVrrAiw2U3G8f/BX9cII6rW6O5Iw4AI8MO4JrwrC8snOLne/OgN4/hjL iKDBpw7pc9SM7oUqSBTzFYiSnTtFupLfz3QOUyIvhRcKhd8ewx05WvsZDMcl67g4tRm6 mXzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708005208; x=1708610008; 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=+RxDxZNcWgZxObjqXsUDIT4GiaFdU7jw+jB2BudVupQ=; b=K79vwpkKo72nTd3f0QDuHve7R0kTuyTXcR4LKOCAc7pLAjNj5Trrb34/DZkiZDyYQL 2jf9BwIuDRDVAPP476KFbUZqDwznW/BCPpkvfwuMd/p4Dsog1GsCq/41dNfNU3BcoNgb JVJizl5RGQFn9tj45XiPbyRCMrQTys/OQNBwAyH97PDAMf9FPXlY5BDzCM4zwJFKdXMk EaAjbxcq4tZM5/lvQIcH3AFucp/mKMHnyu2efSMo3/JZPVngBd0STnMKPZPge6R2pZd5 nT36CR3hzRxaegM2ESOKL97ojTGnz3WA7SCE47aI0URqtjMy4tHgZ7IifMyyzdVn7ITT i8yw== X-Gm-Message-State: AOJu0YxBfB5JvBRUPDTABXSMry2lEv5YegGauC+RENeAymGRGKYxPcTK qs3Li/7cl4HlKkjnPxYm0rCVHH0jaGHPYXdvlGV8Q01fhLW+fHi1DzUffTq/d68= X-Google-Smtp-Source: AGHT+IFX1LOnHz6D4VlNPGsecsDTB1ahkj86YUOBPJlIRBEsHrS5IKD3BnkHapaKXnGayBhb/QGAyA== X-Received: by 2002:a17:902:c402:b0:1db:28bd:2949 with SMTP id k2-20020a170902c40200b001db28bd2949mr2401254plk.0.1708005208166; Thu, 15 Feb 2024 05:53:28 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001db55d2e1e1sm1284787plq.63.2024.02.15.05.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:53:27 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFCv2 3/5] doc: document use of l_log APIs Date: Thu, 15 Feb 2024 05:53:12 -0800 Message-Id: <20240215135314.1017081-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215135314.1017081-1-prestwoj@gmail.com> References: <20240215135314.1017081-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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/coding-style.txt b/doc/coding-style.txt index bf0535c5..882de026 100644 --- a/doc/coding-style.txt +++ b/doc/coding-style.txt @@ -317,6 +317,21 @@ 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_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_warn An unexpected, but non-fatal condition ocurred +l_notice Should not be used directly. This log level is reserved for special + event type notifications which is handled by iwd_notice(). +l_info Information that is expected during normal operation. l_info's use + should be very limited so non-debug logs are concise +l_debug General debugging. These can be used relatively freely but should + provide some piece of useful information. O1: Shorten the name ==================== From patchwork Thu Feb 15 13:53:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13558433 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 7D7FB131744 for ; Thu, 15 Feb 2024 13:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005212; cv=none; b=HgvZKVFxWw4oElsluByX34Sk8r5ieJvyv/OvJ+n2xFDkNGnuiWNVBF8xdkcvWNbfyQh3WJ7WoEEW0jy9qI+1rT3yKHUVlUe9SjOycYpHA7KHKd1Ghl6CeLgMvIRmbQDfkYXx71qKa/9SKyS4ArN9T9nQeIJ3ZyCmNRxTKvhxF9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005212; c=relaxed/simple; bh=b9WrHQA+55sfpX5UTQUFQsRER7opRtgrtGrAVRimhao=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DObdGYkrHwyAkeX1yooeqpWbt8cDSLBNRQDeZi3Gp0GPPcH59MFAuykj9mrG4tDnGHEPxq5mC8DNEQ0I7EP0zuLOfwNUoCKABOXt2ea2ibNp8tiX3FImcF0TSyVD0jh81+rfyKohNWq/q62JA3fY2UvRZ/Q+LXEe4V6mZpWda5Y= 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=Jb+zvX4L; arc=none smtp.client-ip=209.85.214.177 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="Jb+zvX4L" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1d8da50bffaso4602525ad.2 for ; Thu, 15 Feb 2024 05:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708005209; x=1708610009; 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=nwB3hGZIe2RWXidkTeHREeCnsLJG0qjdm4/W+cSwMjI=; b=Jb+zvX4L7p+OrtKijlztD9djfuFK3BVndP0ctsB26uAqJ8nP/0Qgea0fXyvmr9HEvI nDG88DhK+xNVHLFEBdS8xl5j5qw+fO5u4BB/kxfabghW5eQ2BYlecSNmIRQNlw1qPP7t F/Jvm+A6itNUZ9xGukX9LNOk8UxEjVyEULH2JNraZRZdlJ9KeqogdOCCTBHqdSA9DG31 4xAPYv/ph8Vb6zB9mZn4rEbF2Ix3hpRwbqpy1+MEEhuC696s7HA7nn6E1Kv+h/WvxunN 71XUMN29tDKmm0wj/5ZYfhN/DyOVDIvR1hqAHKY/U4H4rvH2DCsSCO0oai1HCLM0WPGD fYsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708005209; x=1708610009; 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=nwB3hGZIe2RWXidkTeHREeCnsLJG0qjdm4/W+cSwMjI=; b=Aj3OAl2nYBxKzdvDacd48Nw9eIu/89M08XebqNjRwJwiRGbyFon5PudXX8uyT1hqTQ lHwLnDt3Xm+LUChmC9bHCMJOZJxBFyIo99dkOEeDq5MSN1zX9g8byJQARVqd1O01YrEL Pfn8ZVKzAfg72/0gFyMvsrmyWxiHpGcPDW2tngTUDTJadgF7iOPsLRYdBYWx/YAvlali REFLHLqKVzrKTvsAQvH4qgPXlQF3cT+pc2rvEVrLt4g4ktLHTi3k5dzptDZNn88orTPR XFE8McUWUGjFgTg5pOwF3ALdvT7T9VqVF7f2wbc9n8SYgDmvK2Op0MhScnd1c3tcZs0M +8uw== X-Gm-Message-State: AOJu0YyJaVtB6pT4DNP6NR8ce8GD0bMBsa2oyOyU1lFrN7po6BPUm8fb Fma59/esEsz2sdG5CNQ6NCOcdUyaSG2gUPwm1z/NaBQsgA/EOc7h0/v3pEgoH28= X-Google-Smtp-Source: AGHT+IEUDkBHtMfo0HwHsiezi70KfXPIHW/RMcN+ih6OeUO0f4bVHTKva7DAhPJVMQg8BUnY/OSBYw== X-Received: by 2002:a17:902:dac4:b0:1db:9f89:ea56 with SMTP id q4-20020a170902dac400b001db9f89ea56mr62044plx.63.1708005209540; Thu, 15 Feb 2024 05:53:29 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001db55d2e1e1sm1284787plq.63.2024.02.15.05.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:53:29 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFCv2 4/5] station: use iwd_notice for state/event information Date: Thu, 15 Feb 2024 05:53:13 -0800 Message-Id: <20240215135314.1017081-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215135314.1017081-1-prestwoj@gmail.com> References: <20240215135314.1017081-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 iwd_notice which internally uses l_notice. The use of the notice log level (5) in IWD will be strictly for the type of messages described above. --- src/station.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/station.c b/src/station.c index ea505ca2..51eee56e 100644 --- a/src/station.c +++ b/src/station.c @@ -1561,9 +1561,9 @@ static void station_enter_state(struct station *station, bool disconnected; int ret; - l_debug("Old State: %s, new state: %s", - station_state_to_string(station->state), - station_state_to_string(state)); + iwd_notice(IWD_NOTICE_STATE, "old: %s, new: %s", + station_state_to_string(station->state), + station_state_to_string(state)); station_debug_event(station, station_state_to_string(state)); @@ -2358,6 +2358,8 @@ static bool station_ft_work_ready(struct wiphy_radio_work_item *item) break; case -ENOENT: station_debug_event(station, "ft-roam-failed"); + iwd_notice(IWD_NOTICE_FT_ROAM_FAILED, + "status: authentication timeout"); try_next: station_transition_start(station); break; @@ -2384,8 +2386,10 @@ disassociate: station_disassociated(station); break; default: - if (ret > 0) + if (ret > 0) { + iwd_notice(IWD_NOTICE_FT_ROAM_FAILED, "status: %d", ret); goto try_next; + } station_roam_failed(station); break; @@ -2457,8 +2461,10 @@ 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)); + iwd_notice(IWD_NOTICE_ROAM_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; @@ -2561,6 +2567,7 @@ static void station_roam_scan_triggered(int err, void *user_data) } station_debug_event(station, "roam-scan-triggered"); + iwd_notice("roam-scan-triggered"); /* * Do not update the Scanning property as we won't be updating the @@ -3159,6 +3166,8 @@ static bool station_retry_owe_default_group(struct station *station) static bool station_retry_with_reason(struct station *station, uint16_t reason_code) { + iwd_notice(IWD_NOTICE_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. @@ -3209,6 +3218,8 @@ static bool station_retry_with_status(struct station *station, else blacklist_add_bss(station->connected_bss->addr); + iwd_notice(IWD_NOTICE_CONNECT_FAILED, "status: %u", status_code); + return station_try_next_bss(station); } @@ -3369,6 +3380,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: + iwd_notice(IWD_NOTICE_DISCONNECT_INFO, "reason: %u", + l_get_u16(event_data)); station_disassociated(station); return; default: @@ -3508,7 +3521,12 @@ int __station_connect_network(struct station *station, struct network *network, return r; } - l_debug("connecting to BSS "MAC, MAC_STR(bss->addr)); + iwd_notice(IWD_NOTICE_CONNECT_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 Thu Feb 15 13:53:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13558434 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 E83C212FF72 for ; Thu, 15 Feb 2024 13:53:31 +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=1708005213; cv=none; b=NCvcEZN83HVFyXvkq00aRduwtnPcNM+tQ4pKEIwecfZf8zTdXGECDWfBPbYU0ifjLmknsLTTaO6Ki68cBXKhHOmlpyze0sF0laLfCKJ9J4Y40Ba+EieXGKpeUQplwS02Yq/T6s5S/aAMPJJfy8ZQyFmuu5xg5blOlx9cXuTHk5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708005213; c=relaxed/simple; bh=OPTjDuDsRK7620EYtq3/5CDRjuN0n7CJU5rBzGMT2JA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dq0U3Yk1ZCXw7CWVoaqiWRo/QhQY8EJ3+760YSAeUkwXWInKXjUqGZNfHPZOkSa5xb7oo69dOvsrdQtIdf0zpw8cnsodlosH8L0Oltqkr1rhA6w2t49/nh6NkB0kfNgm21NyNiLYK9P1pakPv0JSLKIbr7Rtmh1utWHz2FlC5Bk= 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=AXtqQxKd; 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="AXtqQxKd" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d51ba18e1bso8759235ad.0 for ; Thu, 15 Feb 2024 05:53:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708005211; x=1708610011; 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=JypMPKGmXYBsDH+kYyFeMEQU9sI1BHdfLWt+nnqgLz0=; b=AXtqQxKdvrs4hSQypJbpaBKgHxbgpo16zxsjtFppAKFsnlhrXOubfY1SkrtGVzb8gO 0syvBWnectJJ9A7hrpjs0qGgwHBZBpNe0Okecy8p/H4yZmbrSRkqVyJL9+JCIhPnyDOX hP0FwmbtNamTi0w5P2LLf1TXBboj7zl16ceiIIIOuRaNbYZV9LKiRI733/DvqkAEpx9V GGzlY2N5bKBIJ3xllulo1TqBafssIpv0NZPzAGci4GUDwuTHCNgd3Mcm1U0bLWfz2ne1 Z1So/p8usoinBaccPzdjZFFJQKQpknS7P/3/gzv5jT+UCbTrSWlvP5jqA9wESCNEeqrZ fbUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708005211; x=1708610011; 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=JypMPKGmXYBsDH+kYyFeMEQU9sI1BHdfLWt+nnqgLz0=; b=DixDLmI5BV1MLslhwxANxb8CJ0Kwaz4x/GyyURGlBrujGdi3FujdSKrkj2sA7dxjBh z+PyPZGWuCssQdcsZ7YlZe7pm4/M0cCQb+brYvsaiJ4BkygaamS0F/t/1HsGN2mNGFWN zY9dmokfAM842fO3FVMi5M2Y4XI2XwrcUYEGbXIxO0nrCEr9GU6Wl3KqW4j5HAj/6784 V+PbAGse1phBfh3+cNGl1FeGSljcOZ0I4axguUPdwOnl6YTGxDZPqy+obVCTLw7NhcEu PEUdVe2aTWKJcqtGroV+AMImHKeDBNGPDP4O5qOc71xNWgINXa8/nlXYo9s66qDwq5jW h98g== X-Gm-Message-State: AOJu0YxNe3wkP26UqULWoWBMl44pweU2gaBscO9Yn/JzYMNTxKD1TlGf 4qddC2J1M14hYG4cZEM+0qsEvJw5xPMbDkSOL0gIcOBus7+JMQyuBLqdFZfYSdk= X-Google-Smtp-Source: AGHT+IFLcwf8WP+1XA1K5EqgBGrNIy/C5U8AVvH+q7DMyi2vdUuIMmtLcwTQHR+TJuqW+CJnvVIImw== X-Received: by 2002:a17:903:124f:b0:1d9:90d6:bed3 with SMTP id u15-20020a170903124f00b001d990d6bed3mr2092363plh.43.1708005210959; Thu, 15 Feb 2024 05:53:30 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001db55d2e1e1sm1284787plq.63.2024.02.15.05.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:53:30 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [RFCv2 5/5] netdev: add notice events for connection timeouts Date: Thu, 15 Feb 2024 05:53:14 -0800 Message-Id: <20240215135314.1017081-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215135314.1017081-1-prestwoj@gmail.com> References: <20240215135314.1017081-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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 48fb15df..8a7ff092 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2639,7 +2639,8 @@ 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); + iwd_notice(IWD_NOTICE_CONNECT_TIMEOUT, "reason: %u", + timeout_reason); goto error; } @@ -2931,7 +2932,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"); + iwd_notice(IWD_NOTICE_AUTH_TIMEOUT); if (auth_proto_auth_timeout(netdev->ap)) return; @@ -3032,7 +3033,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"); + iwd_notice(IWD_NOTICE_ASSOC_TIMEOUT); if (auth_proto_assoc_timeout(netdev->ap)) return;