ifconfig: properly detect invalid mediaopt keywords.
When invalid keyword is specified, ifconfig(8) is silent about it, instead random request is sent to the driver. Before the patch: root@r-freeb43:~ # ifconfig mce0 mediaopt -txpause,-rxpause ifconfig: SIOCSIFMEDIA (media): Device not configured After: root@r-freeb43:~ # ifconfig mce0 mediaopt -txpause,-rxpause ifconfig: unknown option: -txpause Reviewed by: hselasky, kp Sponsored by: Mellanox Technologies / NVidia Networking MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27060
This commit is contained in:
parent
ea07005137
commit
3f113d5606
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367285
@ -566,7 +566,7 @@ get_media_options(int type, const char *val)
|
|||||||
struct ifmedia_description *desc;
|
struct ifmedia_description *desc;
|
||||||
struct ifmedia_type_to_subtype *ttos;
|
struct ifmedia_type_to_subtype *ttos;
|
||||||
char *optlist, *optptr;
|
char *optlist, *optptr;
|
||||||
int option = 0, i, rval = 0;
|
int option, i, rval = 0;
|
||||||
|
|
||||||
/* We muck with the string, so copy it. */
|
/* We muck with the string, so copy it. */
|
||||||
optlist = strdup(val);
|
optlist = strdup(val);
|
||||||
@ -587,12 +587,13 @@ get_media_options(int type, const char *val)
|
|||||||
*/
|
*/
|
||||||
optptr = optlist;
|
optptr = optlist;
|
||||||
for (; (optptr = strtok(optptr, ",")) != NULL; optptr = NULL) {
|
for (; (optptr = strtok(optptr, ",")) != NULL; optptr = NULL) {
|
||||||
|
option = -1;
|
||||||
for (i = 0; ttos->options[i].desc != NULL; i++) {
|
for (i = 0; ttos->options[i].desc != NULL; i++) {
|
||||||
option = lookup_media_word(ttos->options[i].desc, optptr);
|
option = lookup_media_word(ttos->options[i].desc, optptr);
|
||||||
if (option != -1)
|
if (option != -1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (option == 0)
|
if (option == -1)
|
||||||
errx(1, "unknown option: %s", optptr);
|
errx(1, "unknown option: %s", optptr);
|
||||||
rval |= option;
|
rval |= option;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user