Date: Mon, 2 Nov 2020 21:47:35 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367285 - head/sbin/ifconfig Message-ID: <202011022147.0A2LlZsR009322@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Mon Nov 2 21:47:34 2020 New Revision: 367285 URL: https://svnweb.freebsd.org/changeset/base/367285 Log: 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 Modified: head/sbin/ifconfig/ifmedia.c Modified: head/sbin/ifconfig/ifmedia.c ============================================================================== --- head/sbin/ifconfig/ifmedia.c Mon Nov 2 21:10:49 2020 (r367284) +++ head/sbin/ifconfig/ifmedia.c Mon Nov 2 21:47:34 2020 (r367285) @@ -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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202011022147.0A2LlZsR009322>