From patchwork Mon Jun 26 21:59:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 51378 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C1E3827BBE2; Mon, 26 Jun 2023 23:03:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E2B6727BBE9 for ; Mon, 26 Jun 2023 23:03:25 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDuGr-0005ak-9n; Mon, 26 Jun 2023 18:01:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qDuGk-00052Z-3h for guix-patches@gnu.org; Mon, 26 Jun 2023 18:01:11 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDuGg-0005XN-G0 for guix-patches@gnu.org; Mon, 26 Jun 2023 18:01:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qDuGg-0008Tc-At for guix-patches@gnu.org; Mon, 26 Jun 2023 18:01:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63985] [PATCH v3 10/11] services: NetworkManager: add log-configuration field. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 26 Jun 2023 22:01:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63985 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63985@debbugs.gnu.org Cc: Bruno Victal Received: via spool by 63985-submit@debbugs.gnu.org id=B63985.168781686532573 (code B ref 63985); Mon, 26 Jun 2023 22:01:06 +0000 Received: (at 63985) by debbugs.gnu.org; 26 Jun 2023 22:01:05 +0000 Received: from localhost ([127.0.0.1]:47201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qDuGe-0008T9-OI for submit@debbugs.gnu.org; Mon, 26 Jun 2023 18:01:05 -0400 Received: from smtpm5.myservices.hosting ([185.26.105.236]:55252) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qDuGM-0008RN-QT for 63985@debbugs.gnu.org; Mon, 26 Jun 2023 18:00:48 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm5.myservices.hosting (Postfix) with ESMTP id 2991A20DB5 for <63985@debbugs.gnu.org>; Tue, 27 Jun 2023 00:00:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 3CE728009B; Tue, 27 Jun 2023 00:00:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6-L-W1LkITRE; Tue, 27 Jun 2023 00:00:44 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 501658009A; Tue, 27 Jun 2023 00:00:44 +0200 (CEST) From: Bruno Victal Date: Mon, 26 Jun 2023 22:59:36 +0100 Message-Id: <79ae045eeb94e92221fcff8272cae9673c376f9b.1687816734.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/networking.scm (network-manager-log-level?) (network-manager-log-domain?, network-manager-log-domains?): New predicate. (serialize-network-manager-log-level, serialize-network-manager-log-domains): New procedure. (network-manager-log-configuration): New record type. (network-manager-configuration)[log-configuration]: New field. * doc/guix.texi (Networking Setup): Document it. --- doc/guix.texi | 43 +++++++++++++++ gnu/services/networking.scm | 107 ++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 974bfa3fb0..76bd1b1413 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -20361,6 +20361,10 @@ Networking Setup @code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet networks. +@item @code{log-configuration} (default: @code{(network-manager-log-configuration)}) +Logging configuration for NetworkManager. +This is a @code{} record object. + @item @code{dns} (default: @code{"default"}) Processing mode for DNS, which affects how NetworkManager uses the @code{resolv.conf} configuration file. @@ -20412,6 +20416,45 @@ Networking Setup @end table @end deftp +@deftp {Data Type} network-manager-log-configuration +Available @code{network-manager-log-configuration} fields are: + +@table @asis +@item @code{level} (type: maybe-network-manager-log-level) +The default logging verbosity level. Valid values are (in increasing +order of verbosity): @code{'off}, @code{'err}, @code{'warn}, +@code{'info}, @code{'debug} and @code{'trace}. + +@item @code{domains} (type: maybe-network-manager-log-domains) +Log messages by topic. The value for this field is a list of +@var{domains} or pairs of @var{domains} and @var{levels} where the valid +values for @var{levels} are the same as those described in the ``level'' +field and @var{domains} are any of: @code{'platform}, @code{'rfkill}, +@code{'ether}, @code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4}, +@code{'dhcp6}, @code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6}, +@code{'autoip4}, @code{'dns}, @code{'vpn}, @code{'sharing}, +@code{'supplicant}, @code{'agents}, @code{'settings}, @code{'suspend}, +@code{'core}, @code{'device}, @code{'olpc}, @code{'wimax}, +@code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond}, +@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team}, +@code{'concheck}, @code{'dcb}, @code{'dispatch}, @code{'audit}, +@code{'systemd}, @code{'vpn-plugin}, @code{'proxy}, @code{'none}, +@code{'all}, @code{'default}, @code{'dhcp} and @code{'ip}. The log +level can be overrided per-domain in a pair with a @var{level}. +For example: +@lisp +(network-manager-log-configuration + (level 'warn) + (domains '(all (wifi . debug) (wifi-scan . off)))) +@end lisp + +@item @code{audit?} (type: maybe-boolean) +Whether to send audit records to @command{auditd}. + +@end table +@end deftp + + @cindex Connman @defvar connman-service-type This is the service type to run @url{https://01.org/connman,Connman}, diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 496ff0f0ec..33ff5e040f 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -78,7 +78,10 @@ (define-module (gnu services networking) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) #:use-module (srfi srfi-43) + #:use-module (srfi srfi-171) + #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 string-fun) #:use-module (json) #:re-export (static-networking-service static-networking-service-type) @@ -164,10 +167,16 @@ (define-module (gnu services networking) tor-hidden-service ; deprecated tor-service-type + network-manager-log-configuration + network-manager-log-configuration? + network-manager-log-configuration-level + network-manager-log-configuration-domains? + network-manager-log-configuration-audit? network-manager-configuration network-manager-configuration? network-manager-configuration-package network-manager-configuration-shepherd-requirement + network-manager-configuration-log-configuration network-manager-configuration-dns network-manager-configuration-vpn-plugins network-manager-service-type @@ -1158,6 +1167,92 @@ (define-record-type* ;;; NetworkManager ;;; +(define-maybe boolean) + +;; See the logging section at +;; for +;; the list of valid values for the predicates below. +(define (network-manager-log-level? x) + (memq x '(off err warn info debug trace))) + +(define (network-manager-log-domain? x) + (memq x '(platform rfkill ether wifi bt mb dhcp4 dhcp6 ppp wifi-scan ip4 ip6 + autoip4 dns vpn sharing supplicant agents settings + suspend core device olpc wimax infiniband firewall adsl + bond vlan bridge dbus-props team concheck dcb dispatch + audit systemd vpn-plugin proxy + ;; Special NetworkManager domains: + none all default dhcp ip))) + +(define (network-manager-log-domains? x) + (every + (match-lambda + (((? network-manager-log-domain?) . (? network-manager-log-level?)) #t) + ((? network-manager-log-domain?) #t) + (_ #f)) + x)) + +(define (serialize-network-manager-log-level field-name value) + `(logging level ,(format #f "~:@(~a~)" value))) + +(define (serialize-network-manager-log-domains field-name value) + (define (uglify-domain-symbol x) + (string-replace-substring (symbol->string x) "-" "_")) + + (define serialize-entry + (match-lambda + (((= uglify-domain-symbol domain) . value) + (format #f "~:@(~a:~a~)" domain value)) + ((= uglify-domain-symbol domain) + (format #f "~:@(~a~)" domain)))) + + (let ((serialized-value (list-transduce (compose (tmap serialize-entry) + (tadd-between ",")) + string-append value))) + `(logging domains ,serialized-value))) + +(define-maybe network-manager-log-level) +(define-maybe network-manager-log-domains) + +;; This implicitly belongs to the INI "logging" section. +(define-configuration network-manager-log-configuration + (level + maybe-network-manager-log-level + "The default logging verbosity level. Valid values are (in increasing +order of verbosity): @code{'off}, @code{'err}, @code{'warn}, @code{'info}, +@code{'debug} and @code{'trace}.") + + (domains + maybe-network-manager-log-domains + "Log messages by topic. The value for this field is a list of @var{domains} +or pairs of @var{domains} and @var{levels} where the valid values for +@var{levels} are the same as those described in the ``level'' field and +@var{domains} are any of: @code{'platform}, @code{'rfkill}, @code{'ether}, +@code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4}, @code{'dhcp6}, +@code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6}, @code{'autoip4}, +@code{'dns}, @code{'vpn}, @code{'sharing}, @code{'supplicant}, @code{'agents}, +@code{'settings}, @code{'suspend}, @code{'core}, @code{'device}, @code{'olpc}, +@code{'wimax}, @code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond}, +@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team}, @code{'concheck}, +@code{'dcb}, @code{'dispatch}, @code{'audit}, @code{'systemd}, +@code{'vpn-plugin}, @code{'proxy}, @code{'none}, @code{'all}, @code{'default}, +@code{'dhcp} and @code{'ip}. + +The log level can be overrided per-domain in a pair with a @var{level}. +For example: +@lisp +(network-manager-log-configuration + (level 'warn) + (domains '(all (wifi . debug) (wifi-scan . off)))) +@end lisp") + + (audit? + maybe-boolean + "Whether to send audit records to @command{auditd}." + (serializer generic-ini-serialize-boolean) + (serializer-options `(#:section logging + #:field-name-transform ,(const 'audit))))) + ;; TODO: deprecated field, remove later. (define (warn-iwd?-field-deprecation value) (when value @@ -1181,6 +1276,18 @@ (define-configuration network-manager-configuration networks." empty-serializer) + (log-configuration + (network-manager-log-configuration (network-manager-log-configuration)) + "Logging configuration for NetworkManager. This is a +@code{} record object." + (serializer + (lambda (_ value) + ;; Wrap the serialization of the log-configuration which is a list + ;; of INI entries in a ‘ini-entries’ object. + (ini-entries (list-transduce + (base-transducer value) rcons + network-manager-log-configuration-fields))))) + (dns (string "default") "Processing mode for DNS, which affects how NetworkManager uses the