From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: Static networking should wait for interfaces to be up Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: julien@lepiller.eu, bug-guix@gnu.org Resent-Date: Mon, 15 May 2023 09:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Julien Lepiller X-Debbugs-Original-To: bug-guix@gnu.org X-Debbugs-Original-Xcc: Julien Lepiller Received: via spool by submit@debbugs.gnu.org id=B.168414307325086 (code B ref -1); Mon, 15 May 2023 09:32:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 May 2023 09:31:13 +0000 Received: from localhost ([127.0.0.1]:42760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyUXw-0006WY-Ly for submit@debbugs.gnu.org; Mon, 15 May 2023 05:31:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:49316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyUXu-0006WQ-U1 for submit@debbugs.gnu.org; Mon, 15 May 2023 05:31:11 -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 1pyUXs-0002wb-C6 for bug-guix@gnu.org; Mon, 15 May 2023 05:31:10 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyUXn-0003ap-ID for bug-guix@gnu.org; Mon, 15 May 2023 05:31:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=sf0PmdCOqc0k4xHwwI1tObNVbynUJJIvhG22U+poB8s=; b=rc5DxcE1YCdwhVyc7yidc0a726ZicTHWPswP3anGQDB2epuw3S+arsOU KHMjjSanJ7vF+Vb3ABunl7frNL4YzQ7xMl3pIWHSEZTdGNwYTEbmQy9Qr EIioii4HzEcAyOGn4HGO4e0rL14OWELx/ZLX72++nZr2/EbkkXIExLPgT 8=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=ludovic.courtes@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.99,276,1677538800"; d="scan'208";a="56075926" Received: from unknown (HELO ribbon) ([193.50.110.247]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2023 11:30:58 +0200 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Sextidi 26 =?UTF-8?Q?Flor=C3=A9al?= an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour du Fusain X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 15 May 2023 11:30:58 +0200 Message-ID: <87pm726iwd.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=192.134.164.104; envelope-from=ludovic.courtes@inria.fr; helo=mail3-relais-sop.national.inria.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi! With shepherd 0.10.0 starting services in parallel, I observed =E2=80=98networking=E2=80=99 (from =E2=80=98static-networking-service-type= =E2=80=99) starting too early, before the corresponding interfaces were available: --8<---------------cut here---------------start------------->8--- [ 21.863249] shepherd[1]: Service udev started. [ 21.863414] shepherd[1]: Service udev running with value 196. [ 21.865686] shepherd[1]: Starting service networking... [ 21.865822] shepherd[1]: Starting service file-system-/boot/efi... [ 21.986025] shepherd[1]: Exception caught while starting #< 7f9= bf08434e0>: (no-such-device "eno1" [ 22.738237] udevd[196]: starting eudev-3.2.11 [ 22.767830] udevd[196]: no sender credentials received, message ignored [...] [ 23.562275] tg3 0000:05:00.0 eth0: Tigon3 [partno(BCM95720) rev 5720000]= (PCI Express) MAC address b8:cb:2 [ 23.562290] tg3 0000:05:00.0 eth0: attached PHY is 5720C (10/100/1000Bas= e-T Ethernet) (WireSpeed[1], EEE[1 [ 23.562298] tg3 0000:05:00.0 eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF= [1] TSOcap[1] [ 23.562305] tg3 0000:05:00.0 eth0: dma_rwctrl[00000001] dma_mask[64-bit] [ 23.596221] tg3 0000:05:00.1 eth1: Tigon3 [partno(BCM95720) rev 5720000]= (PCI Express) MAC address b8:cb:2 [ 23.596234] tg3 0000:05:00.1 eth1: attached PHY is 5720C (10/100/1000Bas= e-T Ethernet) (WireSpeed[1], EEE[1 [ 23.596242] tg3 0000:05:00.1 eth1: RXcsums[1] LinkChgREG[0] MIirq[0] ASF= [1] TSOcap[1] [ 23.596249] tg3 0000:05:00.1 eth1: dma_rwctrl[00000001] dma_mask[64-bit] [ 23.599725] tg3 0000:05:00.0 eno1: renamed from eth0 [ 23.613468] iTCO_vendor_support: vendor-support=3D0 [ 23.619114] iTCO_wdt iTCO_wdt: Found a Intel PCH TCO device (Version=3D6= , TCOBASE=3D0x0400) [ 23.619327] iTCO_wdt iTCO_wdt: initialized. heartbeat=3D30 sec (nowayout= =3D0) [ 23.645196] tg3 0000:05:00.1 eno2: renamed from eth1 [ 23.727153] Error: Driver 'pcspkr' is already registered, aborting... [ 23.738237] ipmi_si dmi-ipmi-si.0: Removing SMBIOS-specified kcs state m= achine in favor of ACPI [ 23.738239] ipmi_si: Adding ACPI-specified kcs state machine [ 23.738273] ipmi_si: Trying ACPI-specified kcs state machine at i/o addr= ess 0xca8, slave address 0x20, irq [ 23.926348] shepherd[1]: Service file-system-/boot/efi has been started. [ 23.927164] shepherd[1]: Service networking failed to start. --8<---------------cut here---------------end--------------->8--- Before doing =E2=80=98addr-add=E2=80=99 in =E2=80=98network-set-up/linux=E2= =80=99, should we wait for the interface to show up, by calling =E2=80=98get-links=E2=80=99 from Guile= -Netlink or something like that? Ludo=E2=80=99. From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: Static networking should wait for interfaces to be up Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 20 May 2023 23:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Julien Lepiller Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.16846238221041 (code B ref 63516); Sat, 20 May 2023 23:04:01 +0000 Received: (at 63516) by debbugs.gnu.org; 20 May 2023 23:03:42 +0000 Received: from localhost ([127.0.0.1]:59515 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0Vbx-0000Gj-MD for submit@debbugs.gnu.org; Sat, 20 May 2023 19:03:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0Vbt-0000GP-Vd for 63516@debbugs.gnu.org; Sat, 20 May 2023 19:03:40 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0Vbl-0001Ai-Me; Sat, 20 May 2023 19:03:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=7OwbSfM7BCtWxCiYA/t16Kqo0vTY/g+Jarpz2snG6/o=; b=NXUFVU+gZrO8IyseV/Oc 24iDuvSuYyOn8ACujy4z+ZEdg+gUq8pwfCz3f9FGMNp1bg8CIdphpZTdbw5VuHaonobtt2Vg5YdLs z6Px+Yo9TYaK0tscByaQxUXWDk5zBhS4LVhnJOYfcptNmKloVy0MZUkHhmj8+M+mlY0WmB+2eXTGN iXahPtBiEc4Wb4EJspP220J5JKhXZFFEb6uyHHVG7xe3jnTwfP2PIW88az09cMcsyho0QreX9esD4 WMUv6rO0Do0/sjeZhQYWK68US+npyluPjan825OV/yctaFPGMZCySXrj/CV0Nwk53WjlHH4K8d7JO xQCovyHJ4NMwBg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0Vbl-0001GO-9s; Sat, 20 May 2023 19:03:29 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87pm726iwd.fsf@inria.fr> Date: Sun, 21 May 2023 01:03:26 +0200 In-Reply-To: <87pm726iwd.fsf@inria.fr> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Mon, 15 May 2023 11:30:58 +0200") Message-ID: <871qjawqpt.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s skribis: > Before doing =E2=80=98addr-add=E2=80=99 in =E2=80=98network-set-up/linux= =E2=80=99, should we wait for > the interface to show up, by calling =E2=80=98get-links=E2=80=99 from Gui= le-Netlink or > something like that? Below is a simple workaround. How does that sound? A better fix would be to poll(2) on the underlying AF_NETLINK socket. In fact, we could also implement something like systemd=E2=80=99s =E2=80=98network-online.target=E2=80=99 by doing that. For that we=E2=80= =99d need Guile-Netlink to let us create SOCK_NONBLOCK sockets and to use real ports instead of raw file descriptors; Fibers would then take care of the rest. Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/services/base.scm b/gnu/services/base.scm index fd79c9e232..5d43d998c3 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -2794,10 +2794,39 @@ (define (network-set-up/linux config) (scheme-file "set-up-network" (with-extensions (list guile-netlink) #~(begin - (use-modules (ip addr) (ip link) (ip route)) + (use-modules (ip addr) (ip link) (ip route) + (srfi srfi-1)) + + (define (wait-for-device device) + ;; Wait for DEVICE to show up. + ;; XXX: Polling is ridiculous. We should open a + ;; SOCK_NONBLOCK netlink socket and wait on it. + (let loop ((attempts 0)) + (unless (find (lambda (link) + (string=? (link-name link) + device)) + (get-links)) + (if (< attempts 30) + (begin + (format #t + "waiting for \ +networking device '~a'...~%" + device) + ((@ (fibers) sleep) 1) + (loop (+ 1 attempts))) + (begin + (format #t "networking device '~a' \ +did not show up; bailing out~%" + device) + #f))))) #$@(map (lambda (address) #~(begin + ;; Before going any further, wait for the + ;; device to show up. + (wait-for-device + #$(network-address-device address)) + (addr-add #$(network-address-device address) #$(network-address-value address) #:ipv6? --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 20 19:03:46 2023 Received: (at control) by debbugs.gnu.org; 20 May 2023 23:03:46 +0000 Received: from localhost ([127.0.0.1]:59519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0Vc2-0000H0-2K for submit@debbugs.gnu.org; Sat, 20 May 2023 19:03:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0Vc0-0000Gb-Rq for control@debbugs.gnu.org; Sat, 20 May 2023 19:03:45 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0Vbv-0001BA-MI for control@debbugs.gnu.org; Sat, 20 May 2023 19:03:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:Subject:From:To:Date:in-reply-to: references; bh=MqBWeD7h46qQ9hn5SIyb3aT5W0tseVffaHCqnihiAMs=; b=X0KOWVHyvQmx7A rswI1CXaGXbPoPNrmOMISdtFqS25NsuZDiipJhbFmtZMaMPWNboz51+esmT8p9AZ6QSIqagtx/rla wz3qTmudqjuxOrRsVL87+DQS1jXBsdyNjGA86DpJsiQq7eDIzaBNdP6VhfjmB/yEtsHNpYfamOnO0 MHS3Ps3QGqRzT0H2bEO9fGbJc9M256e+keSmYpAIWtZZVUp7MhWVEo3yxu5sjFSZwUkMvcBQH+bZa vmydON3QBrxH5H2RzlDOv1iuIHLePE/BImbzeyAqt7L0EFMoHanOsJexrZOs4cpQykPbmqQCA1nVN MMeH7jjxnQHZzwqgeN0w==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0Vbv-0001Gl-9h for control@debbugs.gnu.org; Sat, 20 May 2023 19:03:39 -0400 Date: Sun, 21 May 2023 01:03:38 +0200 Message-Id: <87zg5yvc51.fsf@gnu.org> To: control@debbugs.gnu.org From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: control message for bug #63516 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) severity 63516 important quit From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 00/11] Add 'wait-for-link' and related code Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: julien@lepiller.eu, bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Julien Lepiller X-Debbugs-Original-Xcc: Julien Lepiller Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484560911629 (code B ref 63516); Tue, 23 May 2023 12:41:02 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:09 +0000 Received: from localhost ([127.0.0.1]:38505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJA-00031O-I3 for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJ8-00030k-9s for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:07 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ2-0002xJ-DF; Tue, 23 May 2023 08:40:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=WH2ukp0IY3xywm4UMyPb7cfN0ir8Np+sNLR7HLpaUgM=; b=JRWdSsWzFzR3xZuDT2Jl wKAtyrQkeeZn0ODGShbY7EW8pytEq8C0UnwgptEPpt8a8binU0iurF/acbrJqh5eipy9QHrKHuPHP +a1E6e2WMqmKAeJiPFRrwNI67kWUY8EvZI/f2wWqQ2CHk7FmtsB02NUHqAMwXr3EYA70bjWVb/Dfr 8AAEwrgAilZM9JhFqtU6Sud4euKbb10QZ4vefPa2dSgQvAtu4vQG5TP0XvCDgtqoDvvu+3OJE0OQ2 t8qn3HEoAoKSToYYOej7RAXnBve/Z7dg4iO2HG+3pyiACf/TTg5gsjXKyhBK8ldicc86A6/h+/XdK 334To9AV25KWaQ==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ1-00081G-Vt; Tue, 23 May 2023 08:40:00 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:40 +0200 Message-Id: <20230523123951.6225-1-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <871qjawqpt.fsf@gnu.org> References: <871qjawqpt.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi Julien, As a followup to , here is code that lets us wait for a link to show up “the right way”—i.e., without polling. It works over SOCK_NONBLOCK sockets, for use in Fibers programs. I tested it in a VM created with ‘guix system vm’. If the “ens3” device is already there, (wait-for-link "ens3") returns immediately. Then I ran “rmmod e1000” to make the device disappear, and made another (wait-for-link "ens3") call: that call returns once I’ve run “modprobe e1000” in another terminal. Wonderful. :-) Now, it would be good to have a test suite that can run without complicated setups. We should check the strategy used by libnl, systemd, and the likes. Thoughts? Ludo’. Ludovic Courtès (11): connection: Remove unused procedure. connection: Use Guile's 'socket' procedure to open a socket. connection: Throw upon errors in FFI bindings. connection: Add support for suspendable sockets. connection: Allow users to pass extra SOCK_ flags to 'socket'. link: Extract 'new-link-message->link'. addr: Extract 'new-address-message->address'. connection: Add 'add-socket-membership'. error: Add 'sub-type' field to '&netlink-decoder-error' and use it. doc: Add indexes. link: Add 'wait-for-link'. doc/guile-netlink.texi | 51 +++++++++++++++-- ip/addr.scm | 46 +++++++-------- ip/link.scm | 122 ++++++++++++++++++++++++++++++--------- ip/route.scm | 6 +- netlink/connection.scm | 126 +++++++++++++++++++++++++++-------------- netlink/constant.scm | 40 +++++++++++++ netlink/data.scm | 13 +++-- netlink/error.scm | 4 +- 8 files changed, 303 insertions(+), 105 deletions(-) base-commit: beceb4cfea4739954e558411f46e07425891c774 -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 01/11] connection: Remove unused procedure. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484561411652 (code B ref 63516); Tue, 23 May 2023 12:41:02 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:14 +0000 Received: from localhost ([127.0.0.1]:38511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJG-00031p-6U for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJA-000319-Hd for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ3-0002xY-9z; Tue, 23 May 2023 08:40:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=znkFplcQx28LYO3UjRKGrC3+mIa8TSFxPOHWZcHew/8=; b=GggHvGIpCFVKxDbQFF64 MD9In0L+utsg5K7+yMV4JWzEAOX2ACtayWX/y8up8hyR4BHdlKpAd5iAJnTgpCn6PnTNhNDnGV/uv /jSoinFEgyRYd7Vw5VnIl8m0j4SIchWptMGbSgDi2RpdTy9C4Ta05DA3UoV5brW4wGZqIu63aUQiQ 091MYRi+ojlRa7U4pLvONTg1AIv6+/MYhPAQZQhYVZnCj99pFrPs8CvR00YFLUGPpthmMO5HdHZcr XvUVOYqhg4MBInHHwfvQpp8iwC6fwhi5ePKuAsUdDyfh77sCK4anFepFF6muE1ucjwKkg3wyDG1IV zjl35ityV/wluA==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ2-00081G-Jc; Tue, 23 May 2023 08:40:00 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:41 +0200 Message-Id: <20230523123951.6225-2-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * netlink/connection.scm (ffi-sendmsg): Remove. --- netlink/connection.scm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/netlink/connection.scm b/netlink/connection.scm index 4d2ceca..11f004f 100644 --- a/netlink/connection.scm +++ b/netlink/connection.scm @@ -40,10 +40,6 @@ (define ffi-close (pointer->procedure void (dynamic-func "close" libc) (list int))) -(define ffi-sendmsg (pointer->procedure int - (dynamic-func "sendmsg" libc) - (list int '* int) - #:return-errno? #t)) (define ffi-sendto (pointer->procedure int (dynamic-func "sendto" libc) (list int '* size_t int '* int) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 02/11] connection: Use Guile's 'socket' procedure to open a socket. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484561611661 (code B ref 63516); Tue, 23 May 2023 12:41:03 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:16 +0000 Received: from localhost ([127.0.0.1]:38513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJH-00031t-GS for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJC-00031D-Me for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ7-00039m-Fr; Tue, 23 May 2023 08:40:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=zli4anNn4KKLwvoWb2n8p/hisVQubUKreKWBEumvH8c=; b=cJtVmJeulVMyd647IDSl uNThUpokvRvEILvVceD2xYY7CIUaPJLYL+yWqgDDCeRZhtFT2ifAUk+w7FWRrpi55D/Bz9cWxqaou KSmSRGuyoD5N3vG5svuW/PL8vCHPEYsyhcCHGj84jrs1a3PetmEVrkRhHa7nMsofRIctC6mI/oT8B jrAcnvW5VPVG7gabr7Rv+0Xqad58CA+rByQsOqyoAdnK7kYyXq+R09jTOL4GHcsFTrFcFEpMcJVNO bJ4G8YE50L7FHThNILWGVQWAtF0GBnzqK76AOR39bnM37q8pYON78PoSUP9MC0aNyMY3MG+YfOWFV scmzL/7WmwKRKQ==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ3-00081G-Cx; Tue, 23 May 2023 08:40:04 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:42 +0200 Message-Id: <20230523123951.6225-3-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This gives us a real port, which can then let us benefit from the suspendable port facilities. * netlink/connection.scm (ffi-socket, ffi-close): Remove. (socket): Remove record type. (open-socket): Use Guile's 'socket' procedure. (close-socket): Make a deprecated alias for 'close-port'. (get-addr): Add docstring. (connect, send-msg, receive-msg): Use 'fileno' instead of 'socket-num'. * ip/addr.scm (addr-del, addr-add, get-addrs): Use 'close-port' instead of 'close-socket'. * ip/link.scm (get-links, link-set, link-add, link-del): Likewise. * ip/route.scm (route-del, route-add, get-routes): Likewise. * doc/guile-netlink.texi (Netlink Connections): Remove 'close-socket'. --- doc/guile-netlink.texi | 4 ---- ip/addr.scm | 6 +++--- ip/link.scm | 8 ++++---- ip/route.scm | 6 +++--- netlink/connection.scm | 35 +++++++++++++---------------------- 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/doc/guile-netlink.texi b/doc/guile-netlink.texi index 548e47b..48ca6d7 100644 --- a/doc/guile-netlink.texi +++ b/doc/guile-netlink.texi @@ -256,10 +256,6 @@ rtnetlink protocol, binds it to the kernel and returns it. By passing the optional @var{groups} keyword, you can select broadcast groups to subscribe to. @end deffn -@deffn {Scheme Procedure} close-socket @var{socket} -Closes a netlink socket. The socket cannot be used afterwards. -@end deffn - @deffn {Scheme Procedure} send-msg @var{msg} @var{sock} [#:@var{addr}] Send @var{msg} (it must be of type message, @xref{Netlink Headers}) to @var{addr} using @var{sock}. If not passed, @var{addr} is the address of diff --git a/ip/addr.scm b/ip/addr.scm index 0976ab9..fcb286f 100644 --- a/ip/addr.scm +++ b/ip/addr.scm @@ -100,7 +100,7 @@ (let ((sock (connect-route))) (send-msg message sock) (let ((answer (receive-and-decode-msg sock %default-route-decoder))) - (close-socket sock) + (close-port sock) (answer-ok? (last answer))))) (define* (addr-add device cidr #:key (ipv6? #f) (peer (cidr->addr cidr)) @@ -180,7 +180,7 @@ (let ((sock (connect-route))) (send-msg message sock) (let ((answer (receive-and-decode-msg sock %default-route-decoder))) - (close-socket sock) + (close-port sock) (answer-ok? (last answer))))) (define (get-addrs) @@ -216,7 +216,7 @@ (get-attr attrs IFA_BROADCAST) (get-attr attrs IFA_CACHEINFO)))) addrs))) - (close-socket sock) + (close-port sock) addrs))) (define print-addr diff --git a/ip/link.scm b/ip/link.scm index 0957a5e..814a008 100644 --- a/ip/link.scm +++ b/ip/link.scm @@ -94,7 +94,7 @@ (get-attr attrs IFLA_ADDRESS) (get-attr attrs IFLA_BROADCAST)))) links))) - (close-socket sock) + (close-port sock) links))) (define print-link @@ -246,7 +246,7 @@ criteria." (let ((answer (receive-and-decode-msg sock %default-route-decoder))) (when netnsfd (close netnsfd)) - (close-socket sock) + (close-port sock) (answer-ok? (last answer))))) (define* (bond-type-args #:key (mode #f) (miimon #f) (lacp-active #f) (lacp-rate #f) @@ -364,7 +364,7 @@ balance-rr|active-backup|balance-xor|broadcast|802.3ad|balance-tlb|balance-alb" (let ((sock (connect-route))) (send-msg message sock) (let ((answer (receive-and-decode-msg sock %default-route-decoder))) - (close-socket sock) + (close-port sock) (answer-ok? (last answer))))) (define* (link-del device) @@ -390,5 +390,5 @@ balance-rr|active-backup|balance-xor|broadcast|802.3ad|balance-tlb|balance-alb" (let ((sock (connect-route))) (send-msg message sock) (let ((answer (receive-and-decode-msg sock %default-route-decoder))) - (close-socket sock) + (close-port sock) (answer-ok? (last answer))))) diff --git a/ip/route.scm b/ip/route.scm index bf43c18..d5e1275 100644 --- a/ip/route.scm +++ b/ip/route.scm @@ -106,7 +106,7 @@ (let ((sock (connect-route))) (send-msg message sock) (let ((answer (receive-and-decode-msg sock %default-route-decoder))) - (close-socket sock) + (close-port sock) (answer-ok? (last answer))))) (define* (route-add dest @@ -170,7 +170,7 @@ (let ((sock (connect-route))) (send-msg message sock) (let ((answer (receive-and-decode-msg sock %default-route-decoder))) - (close-socket sock) + (close-port sock) (answer-ok? (last answer))))) (define (link-ref links id) @@ -221,7 +221,7 @@ (get-attr attrs RTA_PRIORITY) (link-ref links (get-attr attrs RTA_OIF))))) routes))) - (close-socket sock) + (close-port sock) routes))) (define print-route diff --git a/netlink/connection.scm b/netlink/connection.scm index 11f004f..6f41ef8 100644 --- a/netlink/connection.scm +++ b/netlink/connection.scm @@ -22,7 +22,6 @@ #:use-module (netlink message) #:use-module (rnrs bytevectors) #:use-module (system foreign) - #:use-module (srfi srfi-9) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:export (connect @@ -34,12 +33,7 @@ get-addr)) (define libc (dynamic-link)) -(define ffi-socket (pointer->procedure int - (dynamic-func "socket" libc) - (list int int int))) -(define ffi-close (pointer->procedure void - (dynamic-func "close" libc) - (list int))) + (define ffi-sendto (pointer->procedure int (dynamic-func "sendto" libc) (list int '* size_t int '* int) @@ -51,22 +45,19 @@ (dynamic-func "bind" libc) (list int '* int))) -;; define socket type -(define-record-type socket - (make-socket num open?) - socket? - (num socket-num) - (open? socket-open?)) - ;; define simple functions to open/close sockets (define (open-socket proto) - (make-socket (ffi-socket AF_NETLINK (logior SOCK_RAW SOCK_CLOEXEC) proto) #t)) -(define (close-socket socket) - (if (socket-open? socket) - (ffi-close (socket-num socket))) - (make-socket (socket-num socket) #f)) + (socket AF_NETLINK (logior SOCK_RAW SOCK_CLOEXEC) proto)) + +(define (close-socket sock) + (issue-deprecation-warning + "'close-socket' is deprecated; use 'close-port' instead.") + (close-port sock)) (define (get-addr family pid groups) + "This is a variant of 'make-socket-address' for AF_NETLINK sockets. The +main difference is that it returns a raw bytevector that libguile procedures +such as 'bind' cannot handle." (let ((addr (make-bytevector 12))) (bytevector-u16-set! addr 0 family (native-endianness)) (bytevector-u32-set! addr 4 pid (native-endianness)) @@ -85,7 +76,7 @@ (define* (connect proto addr) (let ((sock (open-socket proto))) - (ffi-bind (socket-num sock) + (ffi-bind (fileno sock) (bytevector->pointer addr) 12) sock)) @@ -101,7 +92,7 @@ (let* ((len (data-size msg)) (bv (make-bytevector len))) (serialize msg 0 bv) - (ffi-sendto (socket-num sock) (bytevector->pointer bv) len 0 %null-pointer 0))) + (ffi-sendto (fileno sock) (bytevector->pointer bv) len 0 %null-pointer 0))) (define* (receive-msg sock #:key (addr (get-addr AF_NETLINK 0 0))) (let* ((len (* 1024 32)) @@ -111,7 +102,7 @@ iovec 1 %null-pointer 0 0)) - (size (ffi-recvmsg (socket-num sock) msghdr 0)) + (size (ffi-recvmsg (fileno sock) msghdr 0)) (answer (make-bytevector size))) (when (> size (* 1024 32)) (raise (condition (&netlink-answer-too-big-error (size size))))) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 03/11] connection: Throw upon errors in FFI bindings. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484562511732 (code B ref 63516); Tue, 23 May 2023 12:41:03 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:25 +0000 Received: from localhost ([127.0.0.1]:38533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJR-000339-3Y for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJJ-00031j-6O for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:17 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ9-0003Af-Af; Tue, 23 May 2023 08:40:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=ej7mfhboHb9U79Nt3rKXKtleDDIvybI9C0rOeRDnAgU=; b=M63dnaoYH6D6iny/b5W/ hkuVFi4RmC+AEJfPgcP7WV2Ji/NjicoP78+LbRVAhsKUUaaEz8/G7cdVgdoC5OsanxKwpw0Epks43 Wv/ffz4YRkzofanuirdGCCcN4zyXyYGeRYIwCGkKl4lk6q2uFcba72PCA4ywOk1wVnPVjlL3QdnHg /0RLTMobRJFpDhXuT9Zwk6zadXtu1HzTvy9SAcmn/RiGr3/EwmPamf0aG/nLUFjO+gDi8BAYwUBMi cnScYBK9/zpPNJnRdSiTXyO2tSD+6QHLhBcmztep0Fo/BWw/fx7KpPZ8kBysQ/XMDi5YSVzmiwXew hW5MfO7HaW4iqQ==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ7-00081G-ML; Tue, 23 May 2023 08:40:06 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:43 +0200 Message-Id: <20230523123951.6225-4-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * netlink/connection.scm (syscall->procedure): New procedure. (ffi-sendto, ffi-recvmsg, ffi-bind): Use it. --- netlink/connection.scm | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/netlink/connection.scm b/netlink/connection.scm index 6f41ef8..f4a5cc6 100644 --- a/netlink/connection.scm +++ b/netlink/connection.scm @@ -1,7 +1,8 @@ ;;;; This file is part of Guile Netlink ;;;; ;;;; Copyright (C) 2021 Julien Lepiller -;;;; +;;;; Copyright (C) 2023 Ludovic Courtès +;;;; ;;;; This library is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or @@ -24,6 +25,7 @@ #:use-module (system foreign) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module (srfi srfi-71) #:export (connect connect-route close-socket @@ -34,16 +36,27 @@ (define libc (dynamic-link)) -(define ffi-sendto (pointer->procedure int - (dynamic-func "sendto" libc) - (list int '* size_t int '* int) - #:return-errno? #t)) -(define ffi-recvmsg (pointer->procedure int - (dynamic-func "recvmsg" libc) - (list int '* int))) -(define ffi-bind (pointer->procedure int - (dynamic-func "bind" libc) - (list int '* int))) +(define (syscall->procedure return-type function + argument-types) + "Return a procedure that calls FUNCTION, a syscall wrapper from the C library +with the given RETURN-TYPE and ARGUMENT-TYPES." + (let ((proc (pointer->procedure return-type + (dynamic-func function libc) + argument-types + #:return-errno? #t))) + (lambda args + (let ((ret errno (apply proc args))) + (when (< ret 0) + (throw 'system-error function "~A" + (list (strerror errno)) (list errno))) + ret)))) + +(define ffi-sendto + (syscall->procedure int "sendto" (list int '* size_t int '* int))) +(define ffi-recvmsg + (syscall->procedure int "recvmsg" (list int '* int))) +(define ffi-bind + (syscall->procedure int "bind" (list int '* int))) ;; define simple functions to open/close sockets (define (open-socket proto) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 04/11] connection: Add support for suspendable sockets. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484562611740 (code B ref 63516); Tue, 23 May 2023 12:41:03 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:26 +0000 Received: from localhost ([127.0.0.1]:38535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJR-00033B-Fc for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJK-00031l-9F for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJF-0003DI-22; Tue, 23 May 2023 08:40:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=5Sf0BlFTZb/+7gIB1vr0wD/T5wQaBY2pRjut+ynAQig=; b=Es9EjUZPL02hEtsqQFOu unb5dQ3Sw8u5Kvva249/EkoUb1lue23xpxVm+//HqV51Fpst841HEGic4Dz7yEkMChX9fH1puOWkY EEdKK9msvGnLQvJC2S7i4SDnAM3XOge+avNjbfnknEjhom/8dhKbubLPvYUfeBOMIThUeGTrEMXdZ 5BUvN1bZ3SGb3yyOLFaQCkkXpwaNqZNlDUntmyqxbI9SVy9+1yVg7XCQj1zopaDe4Mb9DKnT0aIov saBoTnkv3kXK3SLnmRZL0o0N+r7+Rr2enCeFsxBQbGqXd2fhWlDIlGYEEmKYfyQc4VUxO5azuDpaq 8QpGY5fdQ8G6og==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJ9-00081G-GY; Tue, 23 May 2023 08:40:12 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:44 +0200 Message-Id: <20230523123951.6225-5-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * netlink/connection.scm (syscall->procedure): Add #:waiter. Distinguish first argument and call WAITER upon EWOULDBLOCK or EAGAIN when the first argument is a port. (ffi-sendto, ffi-recvmsg, ffi-bind): Pass #:waiter. (connect, send-msg, receive-msg): Pass SOCK instead of (fileno sock). --- netlink/connection.scm | 45 ++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/netlink/connection.scm b/netlink/connection.scm index f4a5cc6..42f7dbb 100644 --- a/netlink/connection.scm +++ b/netlink/connection.scm @@ -26,6 +26,8 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (srfi srfi-71) + #:autoload (ice-9 suspendable-ports) (current-read-waiter + current-write-waiter) #:export (connect connect-route close-socket @@ -36,27 +38,40 @@ (define libc (dynamic-link)) -(define (syscall->procedure return-type function - argument-types) +(define* (syscall->procedure return-type function + argument-types + #:key waiter) "Return a procedure that calls FUNCTION, a syscall wrapper from the C library -with the given RETURN-TYPE and ARGUMENT-TYPES." +with the given RETURN-TYPE and ARGUMENT-TYPES. When WAITER is true and the +first argument is a port, call it upon EAGAIN or EWOULDBLOCK." (let ((proc (pointer->procedure return-type (dynamic-func function libc) argument-types #:return-errno? #t))) - (lambda args - (let ((ret errno (apply proc args))) - (when (< ret 0) - (throw 'system-error function "~A" - (list (strerror errno)) (list errno))) - ret)))) + (lambda (first . rest) + (let loop () + (let ((ret errno (apply proc + (if (port? first) (fileno first) first) + rest))) + (if (< ret 0) + (if (and (memv errno (list EAGAIN EWOULDBLOCK)) + (port? first) waiter) + (begin + ((waiter) first) + (loop)) + (throw 'system-error function "~A" + (list (strerror errno)) (list errno))) + ret)))))) (define ffi-sendto - (syscall->procedure int "sendto" (list int '* size_t int '* int))) + (syscall->procedure int "sendto" (list int '* size_t int '* int) + #:waiter (lambda () (current-write-waiter)))) (define ffi-recvmsg - (syscall->procedure int "recvmsg" (list int '* int))) + (syscall->procedure int "recvmsg" (list int '* int) + #:waiter (lambda () (current-read-waiter)))) (define ffi-bind - (syscall->procedure int "bind" (list int '* int))) + (syscall->procedure int "bind" (list int '* int) + #:waiter (lambda () (current-read-waiter)))) ;; define simple functions to open/close sockets (define (open-socket proto) @@ -89,7 +104,7 @@ such as 'bind' cannot handle." (define* (connect proto addr) (let ((sock (open-socket proto))) - (ffi-bind (fileno sock) + (ffi-bind sock (bytevector->pointer addr) 12) sock)) @@ -105,7 +120,7 @@ such as 'bind' cannot handle." (let* ((len (data-size msg)) (bv (make-bytevector len))) (serialize msg 0 bv) - (ffi-sendto (fileno sock) (bytevector->pointer bv) len 0 %null-pointer 0))) + (ffi-sendto sock (bytevector->pointer bv) len 0 %null-pointer 0))) (define* (receive-msg sock #:key (addr (get-addr AF_NETLINK 0 0))) (let* ((len (* 1024 32)) @@ -115,7 +130,7 @@ such as 'bind' cannot handle." iovec 1 %null-pointer 0 0)) - (size (ffi-recvmsg (fileno sock) msghdr 0)) + (size (ffi-recvmsg sock msghdr 0)) (answer (make-bytevector size))) (when (> size (* 1024 32)) (raise (condition (&netlink-answer-too-big-error (size size))))) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 05/11] connection: Allow users to pass extra SOCK_ flags to 'socket'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484562611746 (code B ref 63516); Tue, 23 May 2023 12:41:04 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:26 +0000 Received: from localhost ([127.0.0.1]:38537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJR-00033J-UC for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJK-00031n-SE for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJF-0003DT-Lf; Tue, 23 May 2023 08:40:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=3ZWJIywS7JHii2kE3zo5gnR6AD+IPo1qEKfii84G7pA=; b=daNDzVKF6CRZiLSAk0Dc bk9Yno7Tc3GUeD4Zo6+5zgaui7Kz/AACLtZN1l/d9mo0eUMwT3wcbfExYN5Lv41C57OdPQ6d7kKar MPGNKsA7TjgHpZhHEU1O4PuBj4ujXRnRofAswRy3GZWDyDz6ZZeViFgxbX2i9ZjEzNyC3pzWC2pQX wZO+aQ2BYsmYSilHJqW+DX7drwDd+Hf9LDSy1rolec524jcC7lE51V8LN+jBhyQiGGFMVxsWfu5Oi 6p0j2oU87jLIgHNLGgOmqBrOou3IRUUk4hV77Ef9McqWwPTtWpOLZDyqEn73Ebmr2jWYGoYNTd8e5 xri56f94axxLYA==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJF-00081G-8E; Tue, 23 May 2023 08:40:13 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:45 +0200 Message-Id: <20230523123951.6225-6-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) In particular, this lets users pass SOCK_NONBLOCK. * netlink/connection.scm (open-socket): Add 'flags' parameter and honor it. (connect): Add #:flags and pass it to 'open-socket'. (connect-route): Add #:flags and pass it to 'connect'. * doc/guile-netlink.texi (Netlink Connections): Adjust accordingly. --- doc/guile-netlink.texi | 11 +++++++++-- netlink/connection.scm | 13 +++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/guile-netlink.texi b/doc/guile-netlink.texi index 48ca6d7..bdb20c6 100644 --- a/doc/guile-netlink.texi +++ b/doc/guile-netlink.texi @@ -240,7 +240,8 @@ to communicate or 0 for the kernel. @var{groups} is an integer representing the set of broadcast groups to which the connection subscribes. @end deffn -@deffn {Scheme Procedure} connect @var{proto} @var{addr} +@cindex non-blocking socket +@deffn {Scheme Procedure} connect @var{proto} @var{addr} [#:flags 0] Creates a netlink socket for @var{proto} and binds it to @var{addr}. @var{proto} is the integer representing the protocol. For instance, rtnetlink @@ -248,12 +249,18 @@ can be selected by usin @code{NETLINK_ROUTE} (defined in @code{(netlink constant)}). @var{addr} is a bytevector, as returned by @code{get-addr}. + +@var{flags} is a set of additional flags to pass as the second argument +to the @code{socket} system call---e.g., @code{SOCK_NONBLOCK}. @end deffn -@deffn {Scheme Procedure} connect-route [#:groups @code{0}] +@deffn {Scheme Procedure} connect-route [#:groups 0] [#:flags 0] This procedure is a wrapper for @code{connect} that creates a socket for the rtnetlink protocol, binds it to the kernel and returns it. By passing the optional @var{groups} keyword, you can select broadcast groups to subscribe to. + +@var{flags} is a set of additional flags to pass as the second argument +to the @code{socket} system call---e.g., @code{SOCK_NONBLOCK}. @end deffn @deffn {Scheme Procedure} send-msg @var{msg} @var{sock} [#:@var{addr}] diff --git a/netlink/connection.scm b/netlink/connection.scm index 42f7dbb..4ad9b10 100644 --- a/netlink/connection.scm +++ b/netlink/connection.scm @@ -74,8 +74,8 @@ first argument is a port, call it upon EAGAIN or EWOULDBLOCK." #:waiter (lambda () (current-read-waiter)))) ;; define simple functions to open/close sockets -(define (open-socket proto) - (socket AF_NETLINK (logior SOCK_RAW SOCK_CLOEXEC) proto)) +(define (open-socket proto flags) + (socket AF_NETLINK (logior SOCK_RAW SOCK_CLOEXEC flags) proto)) (define (close-socket sock) (issue-deprecation-warning @@ -102,15 +102,16 @@ such as 'bind' cannot handle." (list '* size_t) (list content size))) -(define* (connect proto addr) - (let ((sock (open-socket proto))) +(define* (connect proto addr #:key (flags 0)) + (let ((sock (open-socket proto flags))) (ffi-bind sock (bytevector->pointer addr) 12) sock)) -(define* (connect-route #:key (groups 0)) - (connect NETLINK_ROUTE (get-addr AF_NETLINK 0 groups))) +(define* (connect-route #:key (groups 0) (flags 0)) + (connect NETLINK_ROUTE (get-addr AF_NETLINK 0 groups) + #:flags flags)) (define* (send-msg msg sock #:key (addr (get-addr AF_NETLINK 0 0))) (unless (message? msg) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 06/11] link: Extract 'new-link-message->link'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484563611767 (code B ref 63516); Tue, 23 May 2023 12:41:04 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:36 +0000 Received: from localhost ([127.0.0.1]:38539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJc-00033i-D8 for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJM-000320-Ho for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:20 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJG-0003E3-AG; Tue, 23 May 2023 08:40:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=nMX11wN6Bmr+rtVcSRbMA+J7MSCCYjT7YP2yT/OwH5s=; b=RRhnKXkOgcWGQbwVkUgC L8wNsTkxq0tPinoPEWbM1mXvud7xvoGqJ4lolllJZeKoaj4BeAoN7Ld1h4C8xwgdWXQZyS08Op/Uc u9VYsOeWWuNK7lPDJbu+QwKxcKsIe4V046bMGDmZ8GIDynnRpih9+tVmPZGBeTtQuZmKbNpLEi8vQ 3J1tkaPE6ICl8ZG5SZFQ9GXSechG8UAZ975dpGPjD07HIEEstaWi76oaPzPQDVDXMCxJn7G7VQGO/ MiN3e/VTAlU4INXE7VringXNlTxESDg5ntj43pzZcllzz4EMLeQqkITcDGhW3i1CGehodAsm2OQhG 5a5QidHAv3Mzeg==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJF-00081G-Rt; Tue, 23 May 2023 08:40:14 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:46 +0200 Message-Id: <20230523123951.6225-7-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * ip/link.scm (new-link-message->link): New procedure. (get-links): Use it, and use 'filter-map' instead of 'filter' followed by 'map'. --- ip/link.scm | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/ip/link.scm b/ip/link.scm index 814a008..7e0ae6b 100644 --- a/ip/link.scm +++ b/ip/link.scm @@ -59,6 +59,25 @@ (addr link-addr) (brd link-brd)) +(define (new-link-message->link msg) + "If MSG has type 'RTM_NEWLINK', return the corresponding object. +Otherwise return #f." + (and (eqv? (message-kind msg) RTM_NEWLINK) + (let* ((data (message-data msg)) + (attrs (link-message-attrs data))) + (make-link (get-attr attrs IFLA_IFNAME) + (link-message-index data) + (link-message-kind data) + (map int->device-flags (split-flags (link-message-flags data))) + (get-attr attrs IFLA_MTU) + (get-attr attrs IFLA_QDISC) + (get-attr attrs IFLA_OPERSTATE) + (get-attr attrs IFLA_LINKMODE) + (get-attr attrs IFLA_GROUP) + (get-attr attrs IFLA_TXQLEN) + (get-attr attrs IFLA_ADDRESS) + (get-attr attrs IFLA_BROADCAST))))) + (define (get-links) (define request-num (random 65535)) (define message @@ -72,28 +91,7 @@ (let ((sock (connect-route))) (send-msg message sock) (let* ((answer (receive-and-decode-msg sock %default-route-decoder)) - (links (filter - (lambda (msg) (equal? (message-kind msg) RTM_NEWLINK)) - answer)) - (links - (map - (lambda (msg) - (let* ((data (message-data msg)) - (attrs (link-message-attrs data))) - (make-link - (get-attr attrs IFLA_IFNAME) - (link-message-index data) - (link-message-kind data) - (map int->device-flags (split-flags (link-message-flags data))) - (get-attr attrs IFLA_MTU) - (get-attr attrs IFLA_QDISC) - (get-attr attrs IFLA_OPERSTATE) - (get-attr attrs IFLA_LINKMODE) - (get-attr attrs IFLA_GROUP) - (get-attr attrs IFLA_TXQLEN) - (get-attr attrs IFLA_ADDRESS) - (get-attr attrs IFLA_BROADCAST)))) - links))) + (links (filter-map new-link-message->link answer))) (close-port sock) links))) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 07/11] addr: Extract 'new-address-message->address'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484563711775 (code B ref 63516); Tue, 23 May 2023 12:41:05 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:37 +0000 Received: from localhost ([127.0.0.1]:38541 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJc-00033k-QB for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44374) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJN-000327-5u for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJH-0003EH-Ub; Tue, 23 May 2023 08:40:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=/TCf++XSAlYK4R8WSq1KFzsd9FTMjmXsX0cL03mgz0A=; b=HrgXyZMsUlNCs5IZD8d2 kNlrI0GhLZKwBK2DyTefWDplSrZJxsKPqg2aHCRHHkKpPK7WpQ805tgZA8nlDpUxBR4dZHUWnpRf8 2dPyExoZzs8Xw3LihZve8wYrFUWc8e6chGkDI7xmKWWoSVLF19tQgh3gdaDZZhFO3FL5NkopxGAQm uETYpNk6Vb5Iuo9PX01OcvCG6OaOKMAgDAOOUE6uXzdm+BWqinj9h19xw4Tmqn14LczxDYxya1sZU DDRqdQVVBAeC9UAVxkmQh4NDbkeTLdSlAqJL9xQinLoD00y40qJqTPS1QMtr7YFGge+yGPrdGaV9B ORaF7zNhgksPow==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJG-00081G-GW; Tue, 23 May 2023 08:40:14 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:47 +0200 Message-Id: <20230523123951.6225-8-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * ip/addr.scm (new-address-message->address): New procedure. (get-addrs): Use it, and use 'filter-map' instead of 'filter' followed by 'map'. --- ip/addr.scm | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/ip/addr.scm b/ip/addr.scm index fcb286f..f82d733 100644 --- a/ip/addr.scm +++ b/ip/addr.scm @@ -183,6 +183,24 @@ (close-port sock) (answer-ok? (last answer))))) +(define (new-address-message->address msg) + "If MSG has type 'RTM_NEWADDR', return the corresponding object. +Otherwise return #f." + (and (eqv? (message-kind msg) RTM_NEWADDR) + (let* ((data (message-data msg)) + (attrs (addr-message-attrs data))) + (make-addr (addr-message-family data) + (addr-message-prefix-len data) + (map int->ifa-flag + (split-flags (logior (addr-message-flags data) + (get-attr attrs IFA_FLAGS)))) + (addr-message-scope data) + (addr-message-index data) + (get-attr attrs IFA_LABEL) + (get-attr attrs IFA_ADDRESS) + (get-attr attrs IFA_BROADCAST) + (get-attr attrs IFA_CACHEINFO))))) + (define (get-addrs) (define request-num (random 65535)) (define message @@ -195,27 +213,7 @@ (let ((sock (connect-route))) (send-msg message sock) (let* ((answer (receive-and-decode-msg sock %default-route-decoder)) - (addrs (filter - (lambda (msg) (equal? (message-kind msg) RTM_NEWADDR)) - answer)) - (addrs (map - (lambda (msg) - (let* ((data (message-data msg)) - (attrs (addr-message-attrs data))) - (make-addr - (addr-message-family data) - (addr-message-prefix-len data) - (map - int->ifa-flag - (split-flags (logior (addr-message-flags data) - (get-attr attrs IFA_FLAGS)))) - (addr-message-scope data) - (addr-message-index data) - (get-attr attrs IFA_LABEL) - (get-attr attrs IFA_ADDRESS) - (get-attr attrs IFA_BROADCAST) - (get-attr attrs IFA_CACHEINFO)))) - addrs))) + (addrs (filter-map new-address-message->address answer))) (close-port sock) addrs))) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 08/11] connection: Add 'add-socket-membership'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484563811782 (code B ref 63516); Tue, 23 May 2023 12:41:05 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:38 +0000 Received: from localhost ([127.0.0.1]:38543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJd-00033s-6L for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44382) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJO-00032A-0z for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:22 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJI-0003F5-OL; Tue, 23 May 2023 08:40:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=VATPyz346osWd6D8wiwySaFlErKwYpeUzAY6Tt4MPL0=; b=BlrIJpKou2Fq4aqflvN2 emMix/sgfL6A4t5xwPTs/A4FSFSxpfmzlmllowI161jiaUtiPK/rljxmKkKROqYVkjcF3BfWp454c oq1tnZR9vpq0YhdutjOtW6hJjY0dj86rCvAVVQsNi7afmbaQcnkvKvCVxYf8+ahbneqPeXgHwAf18 XurxLZ+n3g1JDvRYzcTQHZA2L0uqBocWEYrmqpG90ebw1x/VGBMmvMz3cLkNFjW8/aR/SFxKmHwtQ pU1aeoenVekompd2WnEJgfv0sIChA9ZtVKOR3lWxrdMpWlCVwHNx3BnRAsrXKftGYQSESb/SZ6Zqo DDL+TODySI1B3Q==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJH-00081G-4b; Tue, 23 May 2023 08:40:16 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:48 +0200 Message-Id: <20230523123951.6225-9-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * netlink/connection.scm (socklen_t, ffi-setsockopt, SOL_NETLINK) * netlink/connection.scm (NETLINK_ADD_MEMBERSHIP): (NETLINK_DROP_MEMBERSHIP, NETLINK_PKTINFO) (NETLINK_BROADCAST_ERROR, NETLINK_NO_ENOBUFS) (NETLINK_LISTEN_ALL_NSID, NETLINK_LIST_MEMBERSHIPS) (NETLINK_CAP_ACK, NETLINK_EXT_ACK, NETLINK_GET_STRICT_CHK): New variables. (add-socket-membership): New procedure. * netlink/constant.scm (int->rtnetlink-group): New enum. * doc/guile-netlink.texi (Netlink Connections): Document it. --- doc/guile-netlink.texi | 18 ++++++++++++++++++ netlink/connection.scm | 26 ++++++++++++++++++++++++++ netlink/constant.scm | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/doc/guile-netlink.texi b/doc/guile-netlink.texi index bdb20c6..19db019 100644 --- a/doc/guile-netlink.texi +++ b/doc/guile-netlink.texi @@ -263,6 +263,24 @@ optional @var{groups} keyword, you can select broadcast groups to subscribe to. to the @code{socket} system call---e.g., @code{SOCK_NONBLOCK}. @end deffn +@cindex subscribing, to an rtnetlink group +@deffn {Scheme Procedure} add-socket-membership @var{sock} @var{group} +Make @var{sock} a member of @var{group}, an @code{RTNLGRP_} constant, +meaning that it will be subscribed to events of that group. + +For example, here is how you could create a netlink socket and subscribe +it to the ``link'' group so that it receives notifications for new and +removed links: + +@lisp +(let ((sock (connect-route))) + (add-socket-membership sock RTNLGRP_LINK) + @dots{}) +@end lisp + +This procedure is implemented as a @code{setsockopt} call. +@end deffn + @deffn {Scheme Procedure} send-msg @var{msg} @var{sock} [#:@var{addr}] Send @var{msg} (it must be of type message, @xref{Netlink Headers}) to @var{addr} using @var{sock}. If not passed, @var{addr} is the address of diff --git a/netlink/connection.scm b/netlink/connection.scm index 4ad9b10..1b6e1c5 100644 --- a/netlink/connection.scm +++ b/netlink/connection.scm @@ -30,6 +30,7 @@ current-write-waiter) #:export (connect connect-route + add-socket-membership close-socket send-msg receive-msg @@ -73,10 +74,35 @@ first argument is a port, call it upon EAGAIN or EWOULDBLOCK." (syscall->procedure int "bind" (list int '* int) #:waiter (lambda () (current-read-waiter)))) +(define socklen_t uint32) ;per +(define ffi-setsockopt + (syscall->procedure int "setsockopt" (list int int int '* socklen_t))) + +(define SOL_NETLINK 270) + +(define NETLINK_ADD_MEMBERSHIP 1) +(define NETLINK_DROP_MEMBERSHIP 2) +(define NETLINK_PKTINFO 3) +(define NETLINK_BROADCAST_ERROR 4) +(define NETLINK_NO_ENOBUFS 5) +(define NETLINK_LISTEN_ALL_NSID 8) +(define NETLINK_LIST_MEMBERSHIPS 9) +(define NETLINK_CAP_ACK 10) +(define NETLINK_EXT_ACK 11) +(define NETLINK_GET_STRICT_CHK 12) + ;; define simple functions to open/close sockets (define (open-socket proto flags) (socket AF_NETLINK (logior SOCK_RAW SOCK_CLOEXEC flags) proto)) +(define (add-socket-membership sock group) + "Make @var{sock} a member of @var{group}, an @code{RTNLGRP_} constant, +meaning that it will be subscribed to events of that group." + (let ((bv (make-bytevector (sizeof int)))) + (bytevector-uint-set! bv 0 group (native-endianness) (sizeof int)) + (ffi-setsockopt sock SOL_NETLINK NETLINK_ADD_MEMBERSHIP + (bytevector->pointer bv) (bytevector-length bv)))) + (define (close-socket sock) (issue-deprecation-warning "'close-socket' is deprecated; use 'close-port' instead.") diff --git a/netlink/constant.scm b/netlink/constant.scm index e7a681e..02c905a 100644 --- a/netlink/constant.scm +++ b/netlink/constant.scm @@ -345,3 +345,43 @@ (define-enum int->link-type (ARPHRD_ETHER 1) (ARPHRD_LOOPBACK 772)) + +;; enum rtnetlink_groups +(define-enum int->rtnetlink-group + (RTNLGRP_NONE 0) + RTNLGRP_LINK + RTNLGRP_NOTIFY + RTNLGRP_NEIGH + RTNLGRP_TC + RTNLGRP_IPV4_IFADDR + RTNLGRP_IPV4_MROUTE + RTNLGRP_IPV4_ROUTE + RTNLGRP_IPV4_RULE + RTNLGRP_IPV6_IFADDR + RTNLGRP_IPV6_MROUTE + RTNLGRP_IPV6_ROUTE + RTNLGRP_IPV6_IFINFO + RTNLGRP_DECnet_IFADDR + RTNLGRP_NOP2 + RTNLGRP_DECnet_ROUTE + RTNLGRP_DECnet_RULE + RTNLGRP_NOP4 + RTNLGRP_IPV6_PREFIX + RTNLGRP_IPV6_RULE + RTNLGRP_ND_USEROPT + RTNLGRP_PHONET_IFADDR + RTNLGRP_PHONET_ROUTE + RTNLGRP_DCB + RTNLGRP_IPV4_NETCONF + RTNLGRP_IPV6_NETCONF + RTNLGRP_MDB + RTNLGRP_MPLS_ROUTE + RTNLGRP_NSID + RTNLGRP_MPLS_NETCONF + RTNLGRP_IPV4_MROUTE_R + RTNLGRP_IPV6_MROUTE_R + RTNLGRP_NEXTHOP + RTNLGRP_BRVLAN + RTNLGRP_MCTP_IFADDR + RTNLGRP_TUNNEL + RTNLGRP_STATS) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 09/11] error: Add 'sub-type' field to '&netlink-decoder-error' and use it. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484563811792 (code B ref 63516); Tue, 23 May 2023 12:41:06 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:38 +0000 Received: from localhost ([127.0.0.1]:38547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJd-00033z-SV for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44392) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJO-00032B-LD for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:22 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJJ-0003FX-Cc; Tue, 23 May 2023 08:40:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=u1PoUccrSeG3hdYBw5K98/oJaEaJX1D2eYEGSq2N8+8=; b=E+O97LhJUy9PHu+gz7q0 pRO6Ox4e0U3EZn7VdDZy2/+clzwNzcFGPJVDfvroBW5vAIFVnvH2YswuhZtn/eTPFas726nhvTJmd MjcaEppIoDuRlsGn1w1auI6uCvhL0J575cLNszB+/cLSgNm7wWE4XhhoVb0daxwF1s3fI8ke57gvt 7P/en7MG9rkfqzpZwja2jxBMxtfTyPRr9w3c68BmMnFFsTGWJSjeEjbP4AVJcFyTOqvS6zJqr/7Iz kMg8tKVLeM9tKMp5f9ncgawO0r6dyCXy+G52iYgCgPO9AEPzYeTFCWL5yGKg+5qFaYTk/GLNVO5Ou rI3S1Ht0kUQEkQ==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJI-00081G-UI; Tue, 23 May 2023 08:40:17 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:49 +0200 Message-Id: <20230523123951.6225-10-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * netlink/error.scm (&netlink-decoder-error)[sub-type]: New field. * netlink/data.scm (get-next-deserialize, get-current-deserialize): Fill it out. --- netlink/data.scm | 13 +++++++++---- netlink/error.scm | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/netlink/data.scm b/netlink/data.scm index c9b5fb8..ac95051 100644 --- a/netlink/data.scm +++ b/netlink/data.scm @@ -51,15 +51,20 @@ (match (assoc-ref decoder current-type) ((_ . type-alist) (or (assoc-ref type-alist target-type) - (assoc-ref type-alist 'default))) + (assoc-ref type-alist 'default) + (raise (condition (&netlink-decoder-error + (type current-type) + (sub-type target-type)))))) (#f (raise (condition (&netlink-decoder-error - (type current-type))))))) - + (type current-type) + (sub-type target-type))))))) + (define (get-current-deserialize decoder current-type) (match (assoc-ref decoder current-type) ((current-deserialize . _) current-deserialize) (#f (raise (condition (&netlink-decoder-error - (type current-type))))))) + (type current-type) + (sub-type #f))))))) (define (deserialize type decoder bv pos) (let ((deserialize (get-current-deserialize decoder type))) diff --git a/netlink/error.scm b/netlink/error.scm index 3e101ed..fa1dba6 100644 --- a/netlink/error.scm +++ b/netlink/error.scm @@ -23,6 +23,7 @@ &netlink-decoder-error netlink-decoder-error? netlink-decoder-error-type + netlink-decoder-error-sub-type &netlink-family-error netlink-family-error? @@ -57,7 +58,8 @@ ;; No decoder for type (define-condition-type &netlink-decoder-error &netlink-error netlink-decoder-error? - (type netlink-decoder-error-type)) + (type netlink-decoder-error-type) + (sub-type netlink-decoder-error-sub-type)) ;; Unknown protocol family (define-condition-type &netlink-family-error &netlink-error -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 10/11] doc: Add indexes. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484563911804 (code B ref 63516); Tue, 23 May 2023 12:41:06 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:39 +0000 Received: from localhost ([127.0.0.1]:38549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJe-000348-DD for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40430) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJQ-00032P-BS for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJJ-0003Fk-Vf; Tue, 23 May 2023 08:40:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=oxw4h/4FsePsFrFrV+f6+hxPcnc6ypTfzKOTISgUfm8=; b=f0SZ85nc82ew7UDFaJQA vLYOhLhhC9zAnUedziu19ZGp8Vi00LvUFKLPfd2D0r2d6/7uGOjOENLVnivHqA+OSqai4aPhpiMeG 2PFUbBOPZf46u9drOKjrcAZA/UW3I65dhkM5FKw72ewIwxnKHwF7+8GJv40Dy1JRxy/PseNJbs9Qq uQ275vBeGfOawawWr2jjWsbyR58NyoC01d0nytAYmIIzuhookhj1+dLkN/5tulbO0GJEoVa62IEJr nlMPPt37CQv9Teo/OiH7RyThEUdneczgb9JEpwmdnZ2lUsuHI4CuMQ+J7z+mysCxfR97oi+2uLcvJ 9Z/xxOtjY0vyww==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJJ-00081G-Hm; Tue, 23 May 2023 08:40:17 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:50 +0200 Message-Id: <20230523123951.6225-11-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * doc/guile-netlink.texi (Concept Index, Programming Index): New nodes. --- doc/guile-netlink.texi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/guile-netlink.texi b/doc/guile-netlink.texi index 19db019..4dbeafe 100644 --- a/doc/guile-netlink.texi +++ b/doc/guile-netlink.texi @@ -34,6 +34,9 @@ implementation of the netlink protocol. * API Reference:: Description of the library interface. * IP Library:: High-level functions for network devices. +* Concept Index:: Concepts. +* Programming Index:: Data types, procedures, and variables. + @detailmenu --- The Detailed Node Listing --- @@ -795,4 +798,15 @@ number of routes displayed, you can specify the family as in this example. @end example @end deffn +@c ********************************************************************* +@node Concept Index +@unnumbered Concept Index +@printindex cp + +@node Programming Index +@unnumbered Programming Index +@syncodeindex tp fn +@syncodeindex vr fn +@printindex fn + @bye -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 11/11] link: Add 'wait-for-link'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 12:41:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 63516@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168484565711837 (code B ref 63516); Tue, 23 May 2023 12:41:06 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 12:40:57 +0000 Received: from localhost ([127.0.0.1]:38551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJw-00034r-6N for submit@debbugs.gnu.org; Tue, 23 May 2023 08:40:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60086) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1RJd-00033c-DJ for 63516@debbugs.gnu.org; Tue, 23 May 2023 08:40:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJY-0003Ok-4w; Tue, 23 May 2023 08:40:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=96dPjYGBHJpAqssVQymcJ5iGYyIfM9S6xobENvE0cQ0=; b=InXohDxO6rIckaMVPzHw epZVuKRzYZU83P/LCrswgX6buw19Q0G8cuDVKoJOdyAXR95y4UAQvnK+fKu7xRHVpWxVuZvPQpF7e AAb7qW6EUngE0vXK/SCejWJlv74osrN9acxFCROR4ijlsZFr6bi0aarCRA7Rze2og/kaAf1InMhXM LVhnz8R91M3yHcMFXh/ZyzZxDgCacXTAvVscc9FiBEttIKYhc172gbrNAd4lWi2mr3qI+OlWBnBRK /WH33AgqLLrTZzpg8M2aSQAthS+EY1jTfOH1dxdXKkkWGIQb4aEi5XgQrPtYUG8BiSqAWc7Mhp745 Ga9N4dsHyHX/kw==; Received: from [193.50.110.247] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1RJK-00081G-5x; Tue, 23 May 2023 08:40:31 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 23 May 2023 14:39:51 +0200 Message-Id: <20230523123951.6225-12-ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * ip/link.scm (message->event+link): New procedure. (new-link-message->link): Use it. (monitor-links, wait-for-link): New procedures. * doc/guile-netlink.texi (Link): Document 'wait-for-link'. --- doc/guile-netlink.texi | 8 ++++ ip/link.scm | 102 ++++++++++++++++++++++++++++++++++------- 2 files changed, 94 insertions(+), 16 deletions(-) diff --git a/doc/guile-netlink.texi b/doc/guile-netlink.texi index 4dbeafe..3355c27 100644 --- a/doc/guile-netlink.texi +++ b/doc/guile-netlink.texi @@ -567,6 +567,14 @@ Returns the list of existing links in the system, as a list of @code{} objects. @end deffn +@deffn {Scheme Procedure} wait-for-link @var{name} [#:blocking? #t] +Wait until a link called @var{name} (a string such as @code{"ens3"}) shows +up. + +When @var{blocking?} is false, use a non-blocking socket and cooperate via +@code{current-read-waiter}---useful when using Fibers. +@end deffn + @deffn {Sceme Procedure} print-link @var{link} Display @var{link} on the standard output, using a format similar to @command{ip link} from @code{iproute2}. diff --git a/ip/link.scm b/ip/link.scm index 7e0ae6b..1323444 100644 --- a/ip/link.scm +++ b/ip/link.scm @@ -1,7 +1,8 @@ ;;;; This file is part of Guile Netlink ;;;; ;;;; Copyright (C) 2021 Julien Lepiller -;;;; +;;;; Copyright (C) 2023 Ludovic Courtès +;;;; ;;;; This library is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or @@ -31,12 +32,14 @@ #:use-module (srfi srfi-9) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module (srfi srfi-71) #:export (link-add link-del link-set link-show link-name->index get-links + wait-for-link print-link make-link link? @@ -59,24 +62,35 @@ (addr link-addr) (brd link-brd)) +(define (message->event+link msg) + "If MSG relates to a link event, return two values: its kind (e.g., +RTM_NEWLINK) and its associated value. Otherwise return #f and #f." + (if (memv (message-kind msg) + (list RTM_NEWLINK + RTM_DELLINK + RTM_SETLINK)) + (values (message-kind msg) + (let* ((data (message-data msg)) + (attrs (link-message-attrs data))) + (make-link (get-attr attrs IFLA_IFNAME) + (link-message-index data) + (link-message-kind data) + (map int->device-flags (split-flags (link-message-flags data))) + (get-attr attrs IFLA_MTU) + (get-attr attrs IFLA_QDISC) + (get-attr attrs IFLA_OPERSTATE) + (get-attr attrs IFLA_LINKMODE) + (get-attr attrs IFLA_GROUP) + (get-attr attrs IFLA_TXQLEN) + (get-attr attrs IFLA_ADDRESS) + (get-attr attrs IFLA_BROADCAST)))) + (values #f #f))) + (define (new-link-message->link msg) "If MSG has type 'RTM_NEWLINK', return the corresponding object. Otherwise return #f." - (and (eqv? (message-kind msg) RTM_NEWLINK) - (let* ((data (message-data msg)) - (attrs (link-message-attrs data))) - (make-link (get-attr attrs IFLA_IFNAME) - (link-message-index data) - (link-message-kind data) - (map int->device-flags (split-flags (link-message-flags data))) - (get-attr attrs IFLA_MTU) - (get-attr attrs IFLA_QDISC) - (get-attr attrs IFLA_OPERSTATE) - (get-attr attrs IFLA_LINKMODE) - (get-attr attrs IFLA_GROUP) - (get-attr attrs IFLA_TXQLEN) - (get-attr attrs IFLA_ADDRESS) - (get-attr attrs IFLA_BROADCAST))))) + (let ((kind link (message->event+link msg))) + (and (eqv? kind RTM_NEWLINK) link))) (define (get-links) (define request-num (random 65535)) @@ -390,3 +404,59 @@ balance-rr|active-backup|balance-xor|broadcast|802.3ad|balance-tlb|balance-alb" (let ((answer (receive-and-decode-msg sock %default-route-decoder))) (close-port sock) (answer-ok? (last answer))))) + +(define* (monitor-links proc init terminate? ;TODO: Make public? + #:key (blocking? #t)) + "Wait for link events until @var{terminate?} returns true. Call @var{init} +with the initial list of links; use its result as the initial state. From +then on, call @code{(@var{proc} @var{event} @var{link} @var{state})} where +@var{event} is a constant such as @code{RTM_NEWLINK} and @var{link} is the +corresponding link. Return the final state. + +When @code{blocking?} is false, use a non-blocking socket and cooperate via +@code{current-read-waiter}---useful when using Fibers." + (define request-num (random 65536)) + (define message + (make-message + RTM_GETLINK + (logior NLM_F_REQUEST NLM_F_DUMP) + request-num + 0 + (make-link-message AF_UNSPEC 0 0 0 0 '()))) + + (let ((sock (connect-route #:flags (if blocking? 0 SOCK_NONBLOCK)))) + ;; Subscribe to the "link" group. + (add-socket-membership sock RTNLGRP_LINK) + + (send-msg message sock) + (let* ((answer (receive-and-decode-msg sock %default-route-decoder)) + (links (filter-map new-link-message->link answer))) + (let loop ((state (init links))) + (if (terminate? state) + (begin + (close-port sock) + state) + (loop (fold (lambda (msg state) + (let ((event link (message->event+link msg))) + (proc event link state))) + state + (receive-and-decode-msg sock %default-route-decoder)))))))) + + +(define* (wait-for-link name #:key (blocking? #t)) + "Wait until a link called @var{name} (a string such as @code{\"ens3\"}) shows +up. + +When @var{blocking?} is false, use a non-blocking socket and cooperate via +@code{current-read-waiter}---useful when using Fibers." + (monitor-links (lambda (event link result) + (and (= RTM_NEWLINK) + (string=? (link-name link) name) + link)) + (lambda (links) + (find (lambda (link) + (string=? (link-name link) name)) + links)) + (lambda (link) ;if LINK is true, terminate + link) + #:blocking? blocking?)) -- 2.40.1 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 00/11] Add 'wait-for-link' and related code Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 23 May 2023 18:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 63516@debbugs.gnu.org Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168486799927900 (code B ref 63516); Tue, 23 May 2023 18:54:01 +0000 Received: (at 63516) by debbugs.gnu.org; 23 May 2023 18:53:19 +0000 Received: from localhost ([127.0.0.1]:40419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1X8I-0007Fw-Hs for submit@debbugs.gnu.org; Tue, 23 May 2023 14:53:18 -0400 Received: from lepiller.eu ([89.234.186.109]:55690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1X8B-0007Fg-60 for 63516@debbugs.gnu.org; Tue, 23 May 2023 14:53:17 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 9220406d; Tue, 23 May 2023 18:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:cc:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=dkim; bh=2/5ePyTGqjla 7qhfgbYMi+UP+ZzYr9eY8wG3GN4MNMs=; b=CNobsHvhjtQsjH07ea9k2FW565zj q12AKnWIgb1+0ae/FEoNEd+3BlBwCta2FfaSrvBinIjMS3lDJNvx3mazMsKwyIir G+qj+6t471VcWHCFNAKAnBkdJVRR6MoZWMWrhx+2kMKUqS72zN6I7NbSpmrH6nAO RxKnShS7VkA6irZgzsJxvKUM/hLUewvXzk6EIH/XjcPPAHo0e97TxK4MbLL5o8O+ huFLBTuYkOMhryO5Y7oIC0WEhsPtmkl0qzs80QhenYhtuBtJ+O88xbEn5qHaqFaf pgOx9Uk5K/AAZbYInARWvVoMOzeAZaUMxaJCA//xuBbtB8SuxCghbbJCVA== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 8f2be33d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 23 May 2023 18:53:07 +0000 (UTC) Date: Tue, 23 May 2023 20:53:04 +0200 From: Julien Lepiller Message-ID: <20230523205304.52d3c06a@sybil.lepiller.eu> In-Reply-To: <20230523123951.6225-1-ludo@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Thanks, I was able to test it simply by doing something like (wait-for-link "veth0") and from another terminal, "ip l add veth0 type veth peer veth1" (it doesn't have to be veth, it's the first one I thought of that I didn't have to reach the manual for). Pushed to guile-netlink's master :) Le Tue, 23 May 2023 14:39:40 +0200, Ludovic Court=C3=A8s a =C3=A9crit : > Hi Julien, >=20 > As a followup to , here is code > that lets us wait for a link to show up =E2=80=9Cthe right way=E2=80=9D= =E2=80=94i.e., without > polling. It works over SOCK_NONBLOCK sockets, for use in Fibers > programs. >=20 > I tested it in a VM created with =E2=80=98guix system vm=E2=80=99. If th= e =E2=80=9Cens3=E2=80=9D > device is already there, (wait-for-link "ens3") returns immediately. > Then I ran =E2=80=9Crmmod e1000=E2=80=9D to make the device disappear, an= d made > another (wait-for-link "ens3") call: that call returns once I=E2=80=99ve = run > =E2=80=9Cmodprobe e1000=E2=80=9D in another terminal. Wonderful. :-) >=20 > Now, it would be good to have a test suite that can run without > complicated setups. We should check the strategy used by libnl, > systemd, and the likes. >=20 > Thoughts? >=20 > Ludo=E2=80=99. >=20 > Ludovic Court=C3=A8s (11): > connection: Remove unused procedure. > connection: Use Guile's 'socket' procedure to open a socket. > connection: Throw upon errors in FFI bindings. > connection: Add support for suspendable sockets. > connection: Allow users to pass extra SOCK_ flags to 'socket'. > link: Extract 'new-link-message->link'. > addr: Extract 'new-address-message->address'. > connection: Add 'add-socket-membership'. > error: Add 'sub-type' field to '&netlink-decoder-error' and use it. > doc: Add indexes. > link: Add 'wait-for-link'. >=20 > doc/guile-netlink.texi | 51 +++++++++++++++-- > ip/addr.scm | 46 +++++++-------- > ip/link.scm | 122 ++++++++++++++++++++++++++++++--------- > ip/route.scm | 6 +- > netlink/connection.scm | 126 > +++++++++++++++++++++++++++-------------- netlink/constant.scm | > 40 +++++++++++++ netlink/data.scm | 13 +++-- > netlink/error.scm | 4 +- > 8 files changed, 303 insertions(+), 105 deletions(-) >=20 >=20 > base-commit: beceb4cfea4739954e558411f46e07425891c774 From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 00/11] Add 'wait-for-link' and related code Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 24 May 2023 14:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Julien Lepiller Cc: 63516@debbugs.gnu.org Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168494016717018 (code B ref 63516); Wed, 24 May 2023 14:57:01 +0000 Received: (at 63516) by debbugs.gnu.org; 24 May 2023 14:56:07 +0000 Received: from localhost ([127.0.0.1]:44378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1puI-0004QO-MJ for submit@debbugs.gnu.org; Wed, 24 May 2023 10:56:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59126) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1puF-0004Of-My for 63516@debbugs.gnu.org; Wed, 24 May 2023 10:56:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1puA-0004Xx-FN; Wed, 24 May 2023 10:55:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=7yDZR/Caq4IEpNY9r7zdJg6krjg/YRoLK/i84Motblw=; b=is1ndaoq6svmwQGWwEbq XK0p5ZjJDfxO1QGM2cNU81xbVYlT4F47WaP0zKiGiHPbN6RdhAwVKQX/1CHBbqlPaQDTTPZHYahqx FXaB+2h9eaof8Dvc2VlRh/PZZNmzKXpj/V4t40RFjt1wGCi8DHmdTBbpocSMlQe4QhuxWUZjUl2X0 jsU+bOrMEd03hnV3BHTr2AX82BNNC5xNsMgAVhnChX1rZd/PhLl6tzVzMosy0XbtZ2VB1bF4jRDEK cyQzmluUHs795MbVqis28e4HnKwMojlT+t5fdtdi1TaKzRAKRjyL3DYzTDrQbQfrMh74Hl5tNfOTw gPm4Inlz8aaiig==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1puA-00031Q-2b; Wed, 24 May 2023 10:55:58 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> <20230523205304.52d3c06a@sybil.lepiller.eu> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quintidi 5 Prairial an 231 de la =?UTF-8?Q?R=C3=A9volution,?= jour du Canard X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 24 May 2023 16:55:56 +0200 In-Reply-To: <20230523205304.52d3c06a@sybil.lepiller.eu> (Julien Lepiller's message of "Tue, 23 May 2023 20:53:04 +0200") Message-ID: <87jzwxixs3.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, Julien Lepiller skribis: > Thanks, I was able to test it simply by doing something like > (wait-for-link "veth0") and from another terminal, "ip l add veth0 type > veth peer veth1" (it doesn't have to be veth, it's the first one I > thought of that I didn't have to reach the manual for). Neat (I really need to take modern networking class :-)). > Pushed to guile-netlink's master :) That was fast, thanks a lot! Are you planning to tag a release soonish? If you do, we could use =E2=80=98wait-for-link=E2=80=99 to fix . Ludo=E2=80=99. From unknown Fri Sep 05 15:36:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#63516: [PATCH Guile-Netlink 00/11] Add 'wait-for-link' and related code Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 24 May 2023 15:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63516 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 63516@debbugs.gnu.org Received: via spool by 63516-submit@debbugs.gnu.org id=B63516.168494118218843 (code B ref 63516); Wed, 24 May 2023 15:14:02 +0000 Received: (at 63516) by debbugs.gnu.org; 24 May 2023 15:13:02 +0000 Received: from localhost ([127.0.0.1]:44402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1qAf-0004tk-JT for submit@debbugs.gnu.org; Wed, 24 May 2023 11:13:01 -0400 Received: from lepiller.eu ([89.234.186.109]:33696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1qAZ-0004tL-KA for 63516@debbugs.gnu.org; Wed, 24 May 2023 11:12:59 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id c87a6e64; Wed, 24 May 2023 15:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:cc:subject:in-reply-to:references:message-id:mime-version :content-type:content-transfer-encoding; s=dkim; bh=JyICqI/h8xeh K8giwmpwuNiOT53ze4bowJcvaSeD9Cs=; b=SwqOHQTJUFtXEBzMdFqmeoGj/jDC gj5wqx3TU4cbT6CJgqjiQQamSYhsvGmCgr90dVGbF6L4ztvx1EFwonFL5ysEMeQl PSuOWjOP6D26jUGbuWVSuO/M7b/kZagvx8mLBpgbWbZcZfnDcIr7LP3ArVzaaigZ DT5FMJOniWMhQhUizIrwQnkdM7pMjBrJBbsFIgOY+44n9WqUEGqwXDMEQM54AU/+ 0HZs3uvHH58TTJUBXoRo3HFaonbEfpjL40871Ft7gjXvLC2jiQdVBkNR+zQBOtHv MrUzkPEST7asLUaGfTLE1ioHjnaCu/arQj0p+fKMauwc7/ZoyzAfrSmdIQ== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id c12d2fa7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 24 May 2023 15:12:52 +0000 (UTC) Date: Wed, 24 May 2023 17:12:41 +0200 From: Julien Lepiller User-Agent: K-9 Mail for Android In-Reply-To: <87jzwxixs3.fsf@gnu.org> References: <871qjawqpt.fsf@gnu.org> <20230523123951.6225-1-ludo@gnu.org> <20230523205304.52d3c06a@sybil.lepiller.eu> <87jzwxixs3.fsf@gnu.org> Message-ID: <84FCC1C4-E32C-40C9-BC19-EE309EAC520D@lepiller.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I'll probably tag a release this week-end=2E Le 24 mai 2023 16:55:56 GMT+02:00, "Ludovic Court=C3=A8s" = a =C3=A9crit=C2=A0: >Hello, > >Julien Lepiller skribis: > >> Thanks, I was able to test it simply by doing something like >> (wait-for-link "veth0") and from another terminal, "ip l add veth0 type >> veth peer veth1" (it doesn't have to be veth, it's the first one I >> thought of that I didn't have to reach the manual for)=2E > >Neat (I really need to take modern networking class :-))=2E > >> Pushed to guile-netlink's master :) > >That was fast, thanks a lot! > >Are you planning to tag a release soonish? If you do, we could use >=E2=80=98wait-for-link=E2=80=99 to fix =2E > >Ludo=E2=80=99=2E From unknown Fri Sep 05 15:36:59 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#63516: closed (Re: bug#63516: Static networking should wait for interfaces to be up) Message-ID: References: <878rclpv6w.fsf@gnu.org> <87pm726iwd.fsf@inria.fr> X-Gnu-PR-Message: they-closed 63516 X-Gnu-PR-Package: guix Reply-To: 63516@debbugs.gnu.org Date: Wed, 14 Jun 2023 21:54:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1686779642-573-1" This is a multi-part message in MIME format... ------------=_1686779642-573-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #63516: Static networking should wait for interfaces to be up which was filed against the guix package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 63516@debbugs.gnu.org. --=20 63516: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63516 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1686779642-573-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 63516-done) by debbugs.gnu.org; 14 Jun 2023 21:53:39 +0000 Received: from localhost ([127.0.0.1]:45660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9YQs-00008e-Lw for submit@debbugs.gnu.org; Wed, 14 Jun 2023 17:53:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9YQp-00008Q-SQ for 63516-done@debbugs.gnu.org; Wed, 14 Jun 2023 17:53:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9YQk-0000FO-KW; Wed, 14 Jun 2023 17:53:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=DcFrp+c4Pw+HukaPCMxt6ek8YG96RwGOKb7t8dYFZMw=; b=klLeIUV4ye19PxZtdkYo mtZJXoqZlewcB1MYim2ubwDJo8cLJfb0zpW1MdC6yPOFivgMZZYmhpPCTKyTzzdASVuLQUxb/euiw dAdrJqaCnj7pa5m51seSkfW39KNUsLAcOIiNFU3qP38+QeSVTlMBIaOdEu9C7UVaZsKr657PDKWwh 53Uk8zfofCPKxoU0hVongB+GXuBDgdQVxjEV6m0Va82mmzxfQwLhLsHImVzatosrQFq0TMrDJtQs3 8R6HZwALily/hiFl/7d+svkgcYTRWHOl+15x9ugs/av68wV5ctoyX2SQji7eUnn8T6sC87DpKNwTl N3qZSlslyUaEwg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9YQk-00027O-7a; Wed, 14 Jun 2023 17:53:30 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 63516-done@debbugs.gnu.org Subject: Re: bug#63516: Static networking should wait for interfaces to be up References: <87pm726iwd.fsf@inria.fr> <871qjawqpt.fsf@gnu.org> Date: Wed, 14 Jun 2023 23:53:27 +0200 In-Reply-To: <871qjawqpt.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sun, 21 May 2023 01:03:26 +0200") Message-ID: <878rclpv6w.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63516-done Cc: Julien Lepiller X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ludovic Court=C3=A8s skribis: > Ludovic Court=C3=A8s skribis: > >> Before doing =E2=80=98addr-add=E2=80=99 in =E2=80=98network-set-up/linux= =E2=80=99, should we wait for >> the interface to show up, by calling =E2=80=98get-links=E2=80=99 from Gu= ile-Netlink or >> something like that? > > Below is a simple workaround. How does that sound? > > A better fix would be to poll(2) on the underlying AF_NETLINK socket. > In fact, we could also implement something like systemd=E2=80=99s > =E2=80=98network-online.target=E2=80=99 by doing that. For that we=E2=80= =99d need Guile-Netlink > to let us create SOCK_NONBLOCK sockets and to use real ports instead of > raw file descriptors; Fibers would then take care of the rest. Pushed the =E2=80=9Cbetter fix=E2=80=9D as 26602f4063a6e0c626e8deb3423166bc= d0abeb90, building upon =E2=80=98wait-for-link=E2=80=99 from Guile-Netlink 1.2. Thank you Julien for the Guile-Netlink release! Ludo=E2=80=99. ------------=_1686779642-573-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 May 2023 09:31:13 +0000 Received: from localhost ([127.0.0.1]:42760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyUXw-0006WY-Ly for submit@debbugs.gnu.org; Mon, 15 May 2023 05:31:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:49316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyUXu-0006WQ-U1 for submit@debbugs.gnu.org; Mon, 15 May 2023 05:31:11 -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 1pyUXs-0002wb-C6 for bug-guix@gnu.org; Mon, 15 May 2023 05:31:10 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyUXn-0003ap-ID for bug-guix@gnu.org; Mon, 15 May 2023 05:31:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=sf0PmdCOqc0k4xHwwI1tObNVbynUJJIvhG22U+poB8s=; b=rc5DxcE1YCdwhVyc7yidc0a726ZicTHWPswP3anGQDB2epuw3S+arsOU KHMjjSanJ7vF+Vb3ABunl7frNL4YzQ7xMl3pIWHSEZTdGNwYTEbmQy9Qr EIioii4HzEcAyOGn4HGO4e0rL14OWELx/ZLX72++nZr2/EbkkXIExLPgT 8=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=ludovic.courtes@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.99,276,1677538800"; d="scan'208";a="56075926" Received: from unknown (HELO ribbon) ([193.50.110.247]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2023 11:30:58 +0200 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: bug-guix@gnu.org Subject: Static networking should wait for interfaces to be up X-Debbugs-Cc: Julien Lepiller X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Sextidi 26 =?utf-8?Q?Flor=C3=A9al?= an 231 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du Fusain X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 15 May 2023 11:30:58 +0200 Message-ID: <87pm726iwd.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=192.134.164.104; envelope-from=ludovic.courtes@inria.fr; helo=mail3-relais-sop.national.inria.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi! With shepherd 0.10.0 starting services in parallel, I observed =E2=80=98networking=E2=80=99 (from =E2=80=98static-networking-service-type= =E2=80=99) starting too early, before the corresponding interfaces were available: --8<---------------cut here---------------start------------->8--- [ 21.863249] shepherd[1]: Service udev started. [ 21.863414] shepherd[1]: Service udev running with value 196. [ 21.865686] shepherd[1]: Starting service networking... [ 21.865822] shepherd[1]: Starting service file-system-/boot/efi... [ 21.986025] shepherd[1]: Exception caught while starting #< 7f9= bf08434e0>: (no-such-device "eno1" [ 22.738237] udevd[196]: starting eudev-3.2.11 [ 22.767830] udevd[196]: no sender credentials received, message ignored [...] [ 23.562275] tg3 0000:05:00.0 eth0: Tigon3 [partno(BCM95720) rev 5720000]= (PCI Express) MAC address b8:cb:2 [ 23.562290] tg3 0000:05:00.0 eth0: attached PHY is 5720C (10/100/1000Bas= e-T Ethernet) (WireSpeed[1], EEE[1 [ 23.562298] tg3 0000:05:00.0 eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF= [1] TSOcap[1] [ 23.562305] tg3 0000:05:00.0 eth0: dma_rwctrl[00000001] dma_mask[64-bit] [ 23.596221] tg3 0000:05:00.1 eth1: Tigon3 [partno(BCM95720) rev 5720000]= (PCI Express) MAC address b8:cb:2 [ 23.596234] tg3 0000:05:00.1 eth1: attached PHY is 5720C (10/100/1000Bas= e-T Ethernet) (WireSpeed[1], EEE[1 [ 23.596242] tg3 0000:05:00.1 eth1: RXcsums[1] LinkChgREG[0] MIirq[0] ASF= [1] TSOcap[1] [ 23.596249] tg3 0000:05:00.1 eth1: dma_rwctrl[00000001] dma_mask[64-bit] [ 23.599725] tg3 0000:05:00.0 eno1: renamed from eth0 [ 23.613468] iTCO_vendor_support: vendor-support=3D0 [ 23.619114] iTCO_wdt iTCO_wdt: Found a Intel PCH TCO device (Version=3D6= , TCOBASE=3D0x0400) [ 23.619327] iTCO_wdt iTCO_wdt: initialized. heartbeat=3D30 sec (nowayout= =3D0) [ 23.645196] tg3 0000:05:00.1 eno2: renamed from eth1 [ 23.727153] Error: Driver 'pcspkr' is already registered, aborting... [ 23.738237] ipmi_si dmi-ipmi-si.0: Removing SMBIOS-specified kcs state m= achine in favor of ACPI [ 23.738239] ipmi_si: Adding ACPI-specified kcs state machine [ 23.738273] ipmi_si: Trying ACPI-specified kcs state machine at i/o addr= ess 0xca8, slave address 0x20, irq [ 23.926348] shepherd[1]: Service file-system-/boot/efi has been started. [ 23.927164] shepherd[1]: Service networking failed to start. --8<---------------cut here---------------end--------------->8--- Before doing =E2=80=98addr-add=E2=80=99 in =E2=80=98network-set-up/linux=E2= =80=99, should we wait for the interface to show up, by calling =E2=80=98get-links=E2=80=99 from Guile= -Netlink or something like that? Ludo=E2=80=99. ------------=_1686779642-573-1--