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
This commit is contained in:
parent
eb3f9a7aec
commit
2c24ad3377
@ -1719,11 +1719,19 @@ ifmaybeload(const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Try to load the module. */
|
||||||
* Try to load the module. But ignore failures, because ifconfig can't
|
if (kldload(ifkind) < 0) {
|
||||||
* infer the names of all drivers (eg mlx4en(4)).
|
switch (errno) {
|
||||||
*/
|
case ENOENT:
|
||||||
(void) kldload(ifkind);
|
/*
|
||||||
|
* 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[] = {
|
static struct cmd basic_cmds[] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user