diff options
| author | Alan Somers <asomers@FreeBSD.org> | 2022-12-26 02:06:21 +0000 |
|---|---|---|
| committer | Alan Somers <asomers@FreeBSD.org> | 2023-01-10 02:56:18 +0000 |
| commit | 2c24ad3377a6f584e484656db8390e4eb7cfc119 (patch) | |
| tree | bbd47c44116111d1b9d224a9320031fd24042ca4 /sbin/ifconfig | |
| parent | eb3f9a7aece9473d678adddcf6aefe6c1eec0ac4 (diff) | |
| download | src-2c24ad3377a6f584e484656db8390e4eb7cfc119.tar.gz src-2c24ad3377a6f584e484656db8390e4eb7cfc119.zip | |
ifconfig: abort if loading a module fails other than for ENOENT
If "ifconfig create" tries to load a kernel module, and the module
exists but can't be loaded, fail the command with a useful error
message. This is helpful, for example, when trying to create a cloned
interface in a vnet jail. But ignore ENOENT, because sometimes ifconfig
can't correctly guess the name of the required kernel module.
MFC after: 2 weeks
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D37873
Diffstat (limited to 'sbin/ifconfig')
| -rw-r--r-- | sbin/ifconfig/ifconfig.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 462d543125c4..120207a6927e 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1719,11 +1719,19 @@ ifmaybeload(const char *name) } } - /* - * 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); + } + } } static struct cmd basic_cmds[] = { |
