From nobody Mon Feb 16 15:44:26 2026 X-Original-To: dev-commits-src-branches@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 4fF6XC038vz6RxdD for ; Mon, 16 Feb 2026 15:44:27 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fF6XB28brz4PMr for ; Mon, 16 Feb 2026 15:44:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771256666; 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=EOu7YRU3VRm8yTRJPdtx8TsetGswcpX7abzaVnG2VPk=; b=j483MeNE3H3mQUYDY6Hx54BGdZ31HIalpOMllRbZvHAfQTzrKzpOBuYp7uvJdAzm/mJneE zwSB1wkXfDO4yPca2Cj5IEUjT8ALdM4UOeHxq32WqHH0/spcjbmTFj8AHDUnact7WH56jF yUPTOl4eafiemkNvSK5EkkoAgTWOuxEGJI5o7zt42W8yRc3FlGK6FHrE+X05vLQDNSXb2O wIXyGIwM8VrBhz95mLrW8JpafVE3lP2JWuTPlTgHWRvtHTX+3RypKWGEJICe8Etz+sZHcR dRWSiV/tFekp0SuuHhO2LTSlWQ6fcbceIcxmXBApR3mOmaD47FCUncaIyUpOXg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1771256666; a=rsa-sha256; cv=none; b=WYP0SUkSE27bRBJJ7h09Pcil5/GjCdm2tDr4GfvhCOg+7oCgThr3VWaihyrVsy/inlMpb0 OktJ5dsOs55wZtPMhP1Nkfm7HO+aqRo7zELwnf1ejpwjQ70h0DeYKhFcuXYH9K/dPiHipI qyMb4qfrX4B0kkloej7NH4tyNTabACdPcpBLAWSf6yjil66rouPJHDxPyf96lWMDv+pOIt JjA5rP5ea07Nf/lDlb8hmkjKZH0yK1OLfXSOS2/Vi9L0y3E7tB8oI6FA2cfRp5M6rkvjWc 5Nmc/epDt3rF1EwAbhkNw6l7WiWRjPmfb2w9ZRs6YX1dZO1HsjgqMS5oaEYyaQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771256666; 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=EOu7YRU3VRm8yTRJPdtx8TsetGswcpX7abzaVnG2VPk=; b=CoBz3wnT1ABTA7ICTTjQTs6DNVoTi2+Xno3G2lmRw45YS54QyRoM7X6uTCfAiLZ7GTwk71 Y2NlNNF4Q8qbR+XG3U5HiiiA3iU8Dy6rsDE36lfodxSHjw25fFhPhlYly7qNBPGmA5PCdY 1FOmNRoISFPKJxYLKw+FMY4cKDhXtwia7yYOAawoo9yQCdsBsL60psj3HHXPO3nDUB7xre d1ihXey995d4sJoLZ5bvQ7fAnwUkbpswiIs+GgBMEP1f/mXj73c65SA7CnSBJUMr8PZno/ iMyan+uoKfkgBhzq7XIf/vXeauDHP9KZ5oftGPtTBnBiDQfl2BH7mimKYMgdkw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fF6XB1lNRzTXR for ; Mon, 16 Feb 2026 15:44:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2085f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Feb 2026 15:44:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 147873a1a7d8 - stable/15 - ifconfig: Exit with a non-zero status when SIOCSIFFIB fails List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 147873a1a7d82de1c792f0afff11707954c83e02 Auto-Submitted: auto-generated Date: Mon, 16 Feb 2026 15:44:26 +0000 Message-Id: <69933b5a.2085f.2dbc3f4d@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=147873a1a7d82de1c792f0afff11707954c83e02 commit 147873a1a7d82de1c792f0afff11707954c83e02 Author: Mark Johnston AuthorDate: 2026-01-28 16:11:47 +0000 Commit: Mark Johnston CommitDate: 2026-02-16 13:42:11 +0000 ifconfig: Exit with a non-zero status when SIOCSIFFIB fails Previously, setting an interface FIB to some invalid value would result in a warning being printed, but the ifconfig command would exit with status 0, but this is wrong. Add a little regression test. Reviewed by: pouria, zlei, melifaro MFC after: 2 weeks Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D54918 (cherry picked from commit 2ea85a622bcba92a7b58901d6a6e945df3022c4e) --- sbin/ifconfig/iffib.c | 16 ++++++---------- sbin/ifconfig/tests/Makefile | 3 ++- sbin/ifconfig/tests/ifconfig.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/sbin/ifconfig/iffib.c b/sbin/ifconfig/iffib.c index a99dd6885d08..c1f9b3defb40 100644 --- a/sbin/ifconfig/iffib.c +++ b/sbin/ifconfig/iffib.c @@ -69,14 +69,12 @@ setiffib(if_ctx *ctx, const char *val, int dummy __unused) char *ep; fib = strtoul(val, &ep, 0); - if (*ep != '\0' || fib > UINT_MAX) { - warn("fib %s not valid", val); - return; - } + if (*ep != '\0' || fib > UINT_MAX) + errx(1, "fib %s not valid", val); ifr.ifr_fib = fib; if (ioctl_ctx_ifr(ctx, SIOCSIFFIB, &ifr) < 0) - warn("ioctl (SIOCSIFFIB)"); + err(1, "ioctl (SIOCSIFFIB)"); } static void @@ -87,14 +85,12 @@ settunfib(if_ctx *ctx, const char *val, int dummy __unused) char *ep; fib = strtoul(val, &ep, 0); - if (*ep != '\0' || fib > UINT_MAX) { - warn("fib %s not valid", val); - return; - } + if (*ep != '\0' || fib > UINT_MAX) + errx(1, "fib %s not valid", val); ifr.ifr_fib = fib; if (ioctl_ctx_ifr(ctx, SIOCSTUNFIB, &ifr) < 0) - warn("ioctl (SIOCSTUNFIB)"); + err(1, "ioctl (SIOCSTUNFIB)"); } static struct cmd fib_cmds[] = { diff --git a/sbin/ifconfig/tests/Makefile b/sbin/ifconfig/tests/Makefile index e902f262552a..8203c97cb013 100644 --- a/sbin/ifconfig/tests/Makefile +++ b/sbin/ifconfig/tests/Makefile @@ -1,5 +1,6 @@ NETBSD_ATF_TESTS_SH= nonexistent_test -ATF_TESTS_SH+= inet6 +ATF_TESTS_SH+= ifconfig \ + inet6 TEST_METADATA+= execenv="jail" TEST_METADATA+= execenv_jail_params="vnet allow.raw_sockets" diff --git a/sbin/ifconfig/tests/ifconfig.sh b/sbin/ifconfig/tests/ifconfig.sh new file mode 100644 index 000000000000..f95581ea97ba --- /dev/null +++ b/sbin/ifconfig/tests/ifconfig.sh @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2026 Stormshield + +. $(atf_get_srcdir)/../../sys/common/vnet.subr + +atf_test_case "badfib" "cleanup" +badfib_head() +{ + atf_set descr "Test adding an interface to a non-existent FIB" + atf_set require.user root +} +badfib_body() +{ + local epair + + vnet_init + + epair=$(vnet_mkepair) + atf_check -s exit:0 ifconfig ${epair}a fib 0 + atf_check -s not-exit:0 -e not-empty \ + ifconfig ${epair}a fib $(sysctl -n net.fibs) +} +badfib_cleanup() +{ + vnet_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case badfib +}