ifconfig: improve trimming off interface number at end
When trying to auto-load a module, we trim the interface number off the end. Currently we stop at the first digit. For interfaces which have numbers in the driver name this does not work well. In the current example ifconfig ath10k0 would load ath(4) instead of ath10k(4). For module/interface names like rtw88[0] we never guess correctly. To improve for the case we can, start trimming off digits from the end rather than the front. Sponsored by: The FreeBSD Foundation Reported by: thierry MFC after: 20 days Reviewed by: melifaro, thierry Differential Revision: https://reviews.freebsd.org/D40137
This commit is contained in:
parent
dc5361ea16
commit
2e6756b752
@ -1752,9 +1752,11 @@ ifmaybeload(struct ifconfig_args *args, const char *name)
|
|||||||
|
|
||||||
/* trim the interface number off the end */
|
/* trim the interface number off the end */
|
||||||
strlcpy(ifname, name, sizeof(ifname));
|
strlcpy(ifname, name, sizeof(ifname));
|
||||||
for (dp = ifname; *dp != 0; dp++)
|
dp = ifname + strlen(ifname) - 1;
|
||||||
if (isdigit(*dp)) {
|
for (; dp > ifname; dp--) {
|
||||||
*dp = 0;
|
if (isdigit(*dp))
|
||||||
|
*dp = '\0';
|
||||||
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user