Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144281678
D54918.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D54918.diff
View Options
diff --git a/sbin/ifconfig/iffib.c b/sbin/ifconfig/iffib.c
--- a/sbin/ifconfig/iffib.c
+++ b/sbin/ifconfig/iffib.c
@@ -69,14 +69,12 @@
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 @@
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
--- 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
--- /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
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 8, 2:13 PM (12 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28462333
Default Alt Text
D54918.diff (1 KB)
Attached To
Mode
D54918: ifconfig: Report errors from failed FIB commands
Attached
Detach File
Event Timeline
Log In to Comment