From nobody Mon Feb 16 19:47: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 4fFCwZ6zYcz6SFlJ for ; Mon, 16 Feb 2026 19:47:26 +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 4fFCwZ6Mrzz3p6m for ; Mon, 16 Feb 2026 19:47:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771271246; 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=6v7eW3eBSgTzXwA+ojIGQwdbrHINhBlhZLZUlk5xuxs=; b=mZPYKx+2OWnPYRLOiWmgscLu+2Nxge+YGCC/gzT5vXRao0KXhYhIHEwxMYYicQgap/F83g yOg/iJtyBGPPKSUH8BXsTYFuFrZplr/rGFM22HQWFba6p6qZge3FsLh1neb/mPqSZgOsVO AT/L7u1v0Y/YDhZut/8rcVZI3tOS8ru3pCbvY6NxNzReYjzpR6maW5Yoav7cHhhEdBw95H +Xl19RaokKd1fkagidix3ErLeTdHII/OsG7asd7CoT4etQtBk9JlHKo6vkEwkrWQo+q9iK nH8dgkK53lZ9c/p/hT3cNE/3ywwNypMyJeLX5f/0LpTx8kFX0r8eZee/u8CTmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1771271246; a=rsa-sha256; cv=none; b=Za1VCycZAQO6y4cwZ5wwi+y47oAmDgIcQQERQ2ZiXrwUqWer4f0V+itHZfxwA4xBdzltAV 1AyrjgCiWS+gA0GlEZpgvH4J3WhaSdfo3Ib2pvN78pX5PxK2RKOe6Y1wITmQkhL44z1BDt AV8sHX4FHpei/bZeUyYEVEQuADzQxWXbDsnQ9gbvQ24SXNyO0k9/8DlEHY5Mjqw0dnhHuy AlzMvOI4aWgzwRm62LqlKKAG3BF0BVnB7ME8LAhNTd/PTnc3PVKNkNTBXo+uq1AaHSWYmP vKDMqfgo8bMREzMoMgvocXk/QCzobBU1cH4lODok3dXD7Wotm4REtZJiFhdTBw== 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=1771271246; 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=6v7eW3eBSgTzXwA+ojIGQwdbrHINhBlhZLZUlk5xuxs=; b=auSg094AfQEjJb+QiyqfiJzMpuPK4Kl4nC1Nyu5sYz/9a7pKt33yIY2lfyg3fo+6ZOVTLm nyYCZxYpOkBSEAwm8nnUzzyO1lyjXRcwGP+fTpxpAfsMnHubhv1M5hgn5utP1/sugf4LiF H3nZsdx0MULMdDhEZOjqW/ftbkdAF1MMWegSOTvsRz6Mh8TEz3DRvUImKmyeGb8exJW9Ts +BQT+7KVJxFFrxfYsAVAECoQ3riuDi2vIkvoNwh+uytQz1QP7k/b47I7N8cI4u6DStBVVx UHTSZzTZ/nR0VBYFlWYyTMgQYvw2dN6NRnVX23LeH/+g7TI48izP/+J3ZROrjg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fFCwZ5VPmzdLW for ; Mon, 16 Feb 2026 19:47:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3f9c4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Feb 2026 19:47:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: d4763c1fe5bc - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: d4763c1fe5bcb803ad32645f6e316efce9e21571 Auto-Submitted: auto-generated Date: Mon, 16 Feb 2026 19:47:26 +0000 Message-Id: <6993744e.3f9c4.5407cd09@gitrepo.freebsd.org> The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d4763c1fe5bcb803ad32645f6e316efce9e21571 commit d4763c1fe5bcb803ad32645f6e316efce9e21571 Author: Mark Johnston AuthorDate: 2026-01-28 16:11:47 +0000 Commit: Mark Johnston CommitDate: 2026-02-16 16:09:28 +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 +}