From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Gk6OGpKb; dkim-atps=neutral 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 E58855A026D for ; Thu, 16 Apr 2026 00:04:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776290676; 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=UTj3eFjdf17ZOsF/uh0fTlKRzfXW3+n/EYEOo5bP+rE=; b=Gk6OGpKbIWcmm08HPmeDEVgNJi0g4gnOewCIZOmQEbjHPFb0xt0BAokvhmQlzcO37hS0TL gNWVddEbFHYdcP4bO3IG9WS5EAtdszpkqyIU+R4HnWv5aQNRFSbDa8jwJl418Ifg0KdHdj NMbBuqNQbho7jFYY3Jisoshf4fnJZuI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-574-TpNVDLQPOD2J5NQ1_-Dh7w-1; Wed, 15 Apr 2026 18:04:35 -0400 X-MC-Unique: TpNVDLQPOD2J5NQ1_-Dh7w-1 X-Mimecast-MFC-AGG-ID: TpNVDLQPOD2J5NQ1_-Dh7w_1776290674 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-43d1dea12aaso5363553f8f.1 for ; Wed, 15 Apr 2026 15:04:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776290674; x=1776895474; h=date:content-transfer-encoding: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; bh=UTj3eFjdf17ZOsF/uh0fTlKRzfXW3+n/EYEOo5bP+rE=; b=MvjmBpFHhDsBeLDqH8lsl5gG6zEqE/Gj4eSUIQDScs4Jaj3mgRed09UA6UHMnF3Ka+ aFlEYbd9X3+Xf+3ZbX61G91XYV67xS4gpj9pCfP8hlyU77EP1KCw4RFo8iYeZab1vYT5 3aSSbPhU7rvSDOD2jOBdceNP906bdOeUsUrmiiaGFnyL+CQCFREwV4MeAExSh1HkZ8gj MA6AlI1Va1e+dnYma3qZM75WREEyxHljswVHMshDImugb51yXra2ZARAeln8ZCO/D9Vd NMS7TXuaGgeeYqOGoehOlM7I5VZreLoCfDOGvf0Wg+ahhK7J7wOqfuvJ9fbZnpFl+WYT owDg== X-Gm-Message-State: AOJu0YwQECTAunTSJzZDywaZqvUysv3lg77WAMCptq75vbgebBfPtLiS tvxsiktMbc5nbyWHIYXx4LxivXfgi6f68UPFBcmzrZGOo2orb8CcfGK6GmJdZiYfDd6+bFDqehq KLi6+FNR9zGFg9wrQOxZ07WxdJ5D9ge1f38w7HKfRR8p/Gh5w/xzXQQ== X-Gm-Gg: AeBDievsNnPchE6OaGGFGnZiRclzreE02WFUU/zug41DzMn5Vz3kLS2YbygR4zdlHCh VKj/L2pzS1fsgT9FWPtFnqQVsnZ0JobPHaGTRYbjWP52B49PdQovGXZqtd8oM5h1NpG2x67clEP FGK2n0HzELzDr1H8uDYHNM8H0mZBiZRJlpmGCKAyu3B5rVq4zu0Z4/8BnNhGDSbOJHyAOohDAqS p1ikhkf83K/cSaXEkmWxlxxL5VUXZ0KGL7hHlULC1L5NOSDqyGJG27ABSAjgGlgDWK1zh7EHFdi 5MqTIw/vB9DPGlqQL5TVWAODAjLQ119HAEevttJvM6HsOeKiy3ddhCP2BMQerrTWsg5KefdGVnj bXICHghT9A/rNWgft886PkbxnKOhmud7Q X-Received: by 2002:a5d:5f53:0:b0:43d:a58:b05c with SMTP id ffacd0b85a97d-43d642d9f56mr36017410f8f.49.1776290674192; Wed, 15 Apr 2026 15:04:34 -0700 (PDT) X-Received: by 2002:a5d:5f53:0:b0:43d:a58:b05c with SMTP id ffacd0b85a97d-43d642d9f56mr36017375f8f.49.1776290673721; Wed, 15 Apr 2026 15:04:33 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43ead3fd3b7sm8591299f8f.35.2026.04.15.15.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 15:04:33 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 11/23] fwd: Improve error handling in fwd_rule_add() Message-ID: <20260416000432.49626da5@elisabeth> In-Reply-To: <20260410010309.736855-12-david@gibson.dropbear.id.au> References: <20260410010309.736855-1-david@gibson.dropbear.id.au> <20260410010309.736855-12-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Thu, 16 Apr 2026 00:04:33 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Swu34Zn5LRX3tt-E0KrHFRZDCilVgEH9uXOczCe-ym0_1776290674 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 3LYYAYZVDWVC5Z6BTRXAHYMJGANAIJZV X-Message-ID-Hash: 3LYYAYZVDWVC5Z6BTRXAHYMJGANAIJZV 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 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 Fri, 10 Apr 2026 11:02:57 +1000 David Gibson wrote: > fwd_rule_add() sanity checks the given rule, however all errors are fatal: > either they're assert()s in the case of things that callers should have > already verified, or die()s if we run out of space for the new rule. > > This won't suffice any more when we allow rule updates from a > configuration client. We don't want to trust the input we get from > the client any more than we have to. > > Replace the assert()s and die()s with a return value. Also include warn()s > so that the user gets a more specific idea of the problem in the logs or > stderr. > > Signed-off-by: David Gibson > --- > conf.c | 15 ++++++++++++--- > fwd.c | 41 +++++++++++++++++++++++++++++++---------- > fwd.h | 2 +- > fwd_rule.c | 3 +-- > fwd_rule.h | 1 + > 5 files changed, 46 insertions(+), 16 deletions(-) > > diff --git a/conf.c b/conf.c > index b871646f..5c913820 100644 > --- a/conf.c > +++ b/conf.c > @@ -157,6 +157,7 @@ static void conf_ports_range_except(const struct ctx *c, char optname, > .proto = proto, > .flags = flags, > }; > + char rulestr[FWD_RULE_STRLEN]; > unsigned delta = to - first; > unsigned base, i; > > @@ -207,20 +208,28 @@ static void conf_ports_range_except(const struct ctx *c, char optname, > rulev.addr = inany_loopback4; > fwd_rule_conflict_check(&rulev, > fwd->rules, fwd->count); > - fwd_rule_add(fwd, &rulev); > + if (fwd_rule_add(fwd, &rulev) < 0) > + goto fail; > } > if (c->ifi6) { > rulev.addr = inany_loopback6; > fwd_rule_conflict_check(&rulev, > fwd->rules, fwd->count); > - fwd_rule_add(fwd, &rulev); > + if (fwd_rule_add(fwd, &rulev) < 0) > + goto fail; > } > } else { > fwd_rule_conflict_check(&rule, fwd->rules, fwd->count); > - fwd_rule_add(fwd, &rule); > + if (fwd_rule_add(fwd, &rule) < 0) > + goto fail; > } > base = i - 1; > } > + return; > + > +fail: > + die("Unable to add rule %s", > + fwd_rule_fmt(&rule, rulestr, sizeof(rulestr))); Similar to my comment to 10/23: I expected this die() to be gone by the end of the series, but it's still there. Is it just a placeholder die() that will go once pesto(1) is added? -- Stefano