From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id D495C5A0269 for ; Fri, 20 Nov 2026 23:59:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795215549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8KiHlguTPvf55/wzftarNUlRh1ec6VY09YfyvHEA9uk=; b=Qe0344pTw793ar83Lz9GJeNUzglM/fad13D0MDS/bRy/SSfdFUh7JefTq+JYLWPujglceD PnL+2Zo9cIXuhP0WEvRgh5dN3StXHyRpaf8gni7WK/bBUYO4YrP2h83VxVi80aiDY9k24w Kc3aGV3wA/tSP2A519dBC4H4J52HD2U= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-48-UbhNYxi7PIu5mNQ5-qSUDw-1; Fri, 20 Nov 2026 22:59:05 +0000 X-MC-Unique: UbhNYxi7PIu5mNQ5-qSUDw-1 X-Mimecast-MFC-AGG-ID: UbhNYxi7PIu5mNQ5-qSUDw_1795215544 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4915ba023d4so845789f8f.0 for ; Fri, 20 Nov 2026 14:59:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795215544; x=1795820344; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=8KiHlguTPvf55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d-4abb31ae4e9mr8627087f8f.31.1795215544212; Fri, 20 Nov 2026 14:59:04 -0800 (PST) X-Received: by 2002:a05:6000:4616:b0:4a6:d298:832c with SMTP id ffacd0b85a97d-4abb31ae4e9mr8627057f8f.31.1795215543685; Fri, 20 Nov 2026 14:59:03 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf61b8sm7439318f8f.19.2026.11.20.14.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2026 14:59:02 -0800 (PST) From: Stefano Brivio To: Hayato Kiwata Subject: Re: [PATCH v2] conf, pesto: Notify client of the result of rule updates Message-ID: <20261120235844.75da1afa@elisabeth> In-Reply-To: <20261117174409.20250-1-dev@haytok.jp> References: <20261117174409.20250-1-dev@haytok.jp> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Fri, 20 Nov 2026 23:59:02 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: jM56LZw9sinnsRkHWO3LonO4jNjkcZMzA-wGdXo4ms0_1795215544 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: CNYMWTBW42GSANBFNNZFI4YTOR7G44UN X-Message-ID-Hash: CNYMWTBW42GSANBFNNZFI4YTOR7G44UN X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, david@gibson.dropbear.id.au X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 18 Nov 2026 02:44:09 +0900 Hayato Kiwata wrote: > Since commit 1776dcb7317e ("fwd, conf: Roll back to old rules if > switching to new ones fails"), pasta tries to restore the old rules when > switching to new rules fails. However, pesto has no way to know that, > and exits successfully as if the new rules were applied. > > In conf_handler(), write a one-byte status to the control socket after > trying to apply the new rules. The status has three values: > PESTO_STATUS_OK, PESTO_STATUS_ROLLBACK, and PESTO_STATUS_FAILED. In > pesto, read the status after send_conf(), and if the update failed, > print what happened and exit with a non-zero status. > > Note that we bump PESTO_PROTOCOL_VERSION to 3 because this adds a > message from the server. If the server version is lower than that, > pesto doesn't read the status. Also, if the server fails to receive > rules from the client, it still closes the connection without sending a > status. > > Link: https://archives.passt.top/passt-dev/20261025153025.600a4fe9@elisabeth/ > Signed-off-by: Hayato Kiwata Applied, thanks! One minor thing that _could_ be addressed as a follow-up: > [...] > > +++ b/pesto.c > @@ -318,6 +318,7 @@ int main(int argc, char **argv) > struct sockaddr_un a = { AF_UNIX, "" }; > struct configuration conf = { 0 }; > bool update = false, show = false; > + int exit_status = EXIT_SUCCESS; > struct pesto_hello hello; > struct sock_fprog prog; > int optname, ret, s; > @@ -513,9 +514,33 @@ int main(int argc, char **argv) > > send_conf(s, &conf); > > + if (s_version >= PESTO_VERSION_STATUS) { > + uint8_t status; > + > + if (read_u8(s, &status) < 0) > + die_perror("Couldn't read configuration status"); > + > + switch (status) { > + case PESTO_STATUS_OK: > + break; > + case PESTO_STATUS_ROLLBACK: > + exit_status = EXIT_FAILURE; > + warn("Failed to apply new rules, old rules restored"); > + break; > + case PESTO_STATUS_FAILED: > + exit_status = EXIT_FAILURE; > + warn( > +"Failed to apply new rules, couldn't restore old ones"); > + break; > + default: > + exit_status = EXIT_FAILURE; > + warn("Unknown configuration status %"PRIu8, status); > + } > + } > + > noupdate: > if (shutdown(s, SHUT_RDWR) < 0 || close(s) < 0) > die_perror("Error shutting down control socket"); > > - exit(0); > + exit(exit_status); We already have a 'status' variable, and the condition is trivial enough that we could probably drop 'exit_status', broaden the scope of 'status', and: exit(status == PESTO_STATUS_OK ? EXIT_SUCCESS : EXIT_FAILURE); which saves a few lines without impairing readability (...I think). Not a strong preference from my side though. -- Stefano