Bug 269042 - ifconfig list fails since 2c24ad3377a6f58 / D37873 w/o kldload syscall perm
Summary: ifconfig list fails since 2c24ad3377a6f58 / D37873 w/o kldload syscall perm
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL: https://github.com/freebsd/freebsd-sr...
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-19 07:33 UTC by Michael Paepcke
Modified: 2023-01-21 04:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Paepcke 2023-01-19 07:33:32 UTC
Hello all, 

https://cgit.freebsd.org/src/commit/sbin/ifconfig?id=2c24ad3377a6f584e484656db8390e4eb7cfc119

https://reviews.freebsd.org/D37873

Since this commit replaced the general silent fail
for any kind of kdload error with a hard (exit) fail,
except for ENOENT - ifconfig fails hard (exit) even
in case the user has not even the permission to launch
the syscall to kldload. 

-	/*
-	 * Try to load the module.  But ignore failures, because ifconfig can't
-	 * infer the names of all drivers (eg mlx4en(4)).
-	 */
-	(void) kldload(ifkind);
+	/* Try to load the module. */
+	if (kldload(ifkind) < 0) {
+		switch (errno) {
+		case ENOENT:
+			/*
+			 * Ignore ENOENT, because ifconfig can't infer the
+			 * names of all drivers (eg mlx4en(4)).
+			 */
+			break;
+		default:
+			err(1, "kldload(%s)", ifkind);
+		}
+	}

Was this intentional or can we add nother exception
for informal msg without (hard) exit here?

Thank you! 
Michael
Comment 1 Michael Paepcke 2023-01-19 11:41:20 UTC
proposal for a fix 

https://github.com/freebsd/freebsd-src/pull/638
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-01-20 17:24:49 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=520590881667b4536e6861c710a80353a0564334

commit 520590881667b4536e6861c710a80353a0564334
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-01-20 17:17:21 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2023-01-20 17:17:21 +0000

    Revert "ifconfig: abort if loading a module fails other than for ENOENT"

    This reverts commit 2c24ad3377a6f584e484656db8390e4eb7cfc119.

    This change causes some commands to fail, for example when working with
    renamed interfaces or when trying to list a nonexistent interface by
    name.

    PR:             269042
    Reported by:    dbaio, Michael Paepcke <bugs.fbsd@paepcke.de>
    MFC with:       2c24ad3377a6f584e484656db8390e4eb7cfc119

 sbin/ifconfig/ifconfig.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
Comment 3 Michael Paepcke 2023-01-21 04:44:24 UTC
Many thanks for the quick response!

I'm convinced that D37873 is an improvement!
The silent fail works for me and maybe others,
but is not real/stable solution.

Seems ifconfig is missing the glue code to 
figure out the correct parent node. 

Thank you, 
Michael!