aboutsummaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-11-02 21:47:34 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-11-02 21:47:34 +0000
commit3f113d56061ab4c877d837b0d683414d1303131a (patch)
tree6fb079a0b95a4feaa7a8f42b2d84e27832554517 /sbin/ifconfig
parentea07005137182d6fea2d5cc6967ddaa4a5bdbd5d (diff)
downloadsrc-3f113d56061ab4c877d837b0d683414d1303131a.tar.gz
src-3f113d56061ab4c877d837b0d683414d1303131a.zip
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
Notes
Notes: svn path=/head/; revision=367285
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifmedia.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
index fdf0d6fb62a0..cd3600df454c 100644
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -566,7 +566,7 @@ get_media_options(int type, const char *val)
struct ifmedia_description *desc;
struct ifmedia_type_to_subtype *ttos;
char *optlist, *optptr;
- int option = 0, i, rval = 0;
+ int option, i, rval = 0;
/* We muck with the string, so copy it. */
optlist = strdup(val);
@@ -587,12 +587,13 @@ get_media_options(int type, const char *val)
*/
optptr = optlist;
for (; (optptr = strtok(optptr, ",")) != NULL; optptr = NULL) {
+ option = -1;
for (i = 0; ttos->options[i].desc != NULL; i++) {
option = lookup_media_word(ttos->options[i].desc, optptr);
if (option != -1)
break;
}
- if (option == 0)
+ if (option == -1)
errx(1, "unknown option: %s", optptr);
rval |= option;
}