From nobody Sun Sep 29 19:25:40 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XGvLX73Vlz5X5X1; Sun, 29 Sep 2024 19:25:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XGvLX6V1Jz4Kpp; Sun, 29 Sep 2024 19:25:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727637940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=12aeIUt7+EtU6AGnXzgwIgK1mFzWK4ayzB1NYWTUqts=; b=c/vOfErfIICnNcp7AVPfBq2zuyPvw+slYZP/ozN9EqJyM/lG4I9zNSzOIhr4wBKxh9JUOt 06I5TSrBT2hGGta1mVFooadNNXuxockzwhhyhQZ7/r3k9/PiiclFxWz62b78zL5zgSs6ra LhIfzJ3sC+Lj0TCOf3rR6o+aTPiwH5/sHnHJ/A43TO/hpqVRc1bQuvcQLlixfNQ4Ufq2bP eTrWidg/hv1Qp20wIuwTEkl3gp5pdsbOqt2t03rWQWf9x/IvcxvN3Wu1fSPyL3phyPpJAM JEXUFw+BXYmG5VIO6/aXtR4nBGyNT7NeQpOLvoqnNdSuXJT2CwUGyEtI2tsfiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727637940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=12aeIUt7+EtU6AGnXzgwIgK1mFzWK4ayzB1NYWTUqts=; b=g1VOOQ1QSF/jGTKTo/OidjAjVSwSBKvMiUqu4zH9vCWArAaS1RJkGffucmGtGoTa/x/sc7 9bNs4DYz9clpDqjdubQ/GH8q9JDNKewoqPViOAQ9C2WENWo1N8GS6aouQdo5QkKNMdND5Q nd2W33hjHQ51I5DzuV9cpEvUYZ1IjH6Tmw+9y1q0+rND2t3KUvu4Hocn45gL/1uFvuTnh3 q05KMFI/C4cIMZYqy68tj/oRKZ2lXu+h1gbxhxZ3zi/PWJJvfBGtihpkfDX0Xyk7xAMcS3 ApWEI66TgVkse0pgsE1T+IaiXfEQhZoU3RfD8BkvpR/OedMWHsfXxDfACFM7uA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727637940; a=rsa-sha256; cv=none; b=IrrYyiUKHwYmZpa/lDKXaRSVzj24ortY5Joei5M5Cs9jruSyoWQ6oha4G85/OOOruLwXB4 ln8XfVLqcd4SF4S/lmGdg+Qety4Mz6ywvo7J1ijwIAWtgtY0/G6MIvQyacQcjSSC5yYb/x lrXRePAtT4Vx7nCaLP+T83D06AJKlHFvWoRcKaTs/7rTGVUYdrAysZ3RWifBBeWH3KnR8f /gVU317HWxSB0Ba5F7nNjDeXLcJmMhTwhGbGucA//wEFE4MpCuTkC3ScqEhwD7YsqggaYN fM5vO0TKayCrtwArhFTTWrVfs4enJoG9qYjLTkw1NEwhbR93RcsGRVQIzMddXQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XGvLX5z08zLmb; Sun, 29 Sep 2024 19:25:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48TJPeI1037852; Sun, 29 Sep 2024 19:25:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48TJPe5m037849; Sun, 29 Sep 2024 19:25:40 GMT (envelope-from git) Date: Sun, 29 Sep 2024 19:25:40 GMT Message-Id: <202409291925.48TJPe5m037849@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: b26edf615c91 - stable/13 - libpfctl: ensure we return useful error codes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b26edf615c91768fe88bee98d70b55c8bf68fef1 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b26edf615c91768fe88bee98d70b55c8bf68fef1 commit b26edf615c91768fe88bee98d70b55c8bf68fef1 Author: Kristof Provost AuthorDate: 2024-09-20 09:36:22 +0000 Commit: Kristof Provost CommitDate: 2024-09-29 18:29:44 +0000 libpfctl: ensure we return useful error codes Return errno rather than -1 on error. This allows pfctl to report much more useful errors. Reported by: Alexander Leidinger MFC after: 1 week (cherry picked from commit 93e96359c980ccf318fe089b30b863f7c910b622) --- lib/libpfctl/libpfctl.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index f5ddbba79bfd..ddad467c3644 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -1035,8 +1035,12 @@ pfctl_clear_rules(int dev, const char *anchorname) ret = ioctl(dev, DIOCXBEGIN, &trans); if (ret != 0) - return (ret); - return ioctl(dev, DIOCXCOMMIT, &trans); + return (errno); + ret = ioctl(dev, DIOCXCOMMIT, &trans); + if (ret != 0) + return (errno); + + return (0); } int @@ -1070,8 +1074,12 @@ pfctl_clear_nat(int dev, const char *anchorname) ret = ioctl(dev, DIOCXBEGIN, &trans); if (ret != 0) - return (ret); - return ioctl(dev, DIOCXCOMMIT, &trans); + return (errno); + ret = ioctl(dev, DIOCXCOMMIT, &trans); + if (ret != 0) + return (errno); + + return (0); } static int @@ -1117,7 +1125,10 @@ pfctl_set_syncookies(int dev, const struct pfctl_syncookies *s) ret = ioctl(dev, DIOCSETSYNCOOKIES, &nv); free(nv.data); - return (ret); + if (ret != 0) + return (errno); + + return (0); } int @@ -1225,7 +1236,7 @@ pfctl_table_set_addrs(int dev, struct pfr_table *tbl, struct pfr_addr io.pfrio_size = size; io.pfrio_size2 = (size2 != NULL) ? *size2 : 0; if (ioctl(dev, DIOCRSETADDRS, &io)) - return (-1); + return (errno); if (nadd != NULL) *nadd = io.pfrio_nadd; if (ndel != NULL) @@ -1253,7 +1264,7 @@ int pfctl_table_get_addrs(int dev, struct pfr_table *tbl, struct pfr_addr *addr, io.pfrio_esize = sizeof(*addr); io.pfrio_size = *size; if (ioctl(dev, DIOCRGETADDRS, &io)) - return (-1); + return (errno); *size = io.pfrio_size; return (0); }