Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig Don't bail if SIOGIFMEDIA doesn't return any m...
details: https://anonhg.NetBSD.org/src/rev/bf9480839b43
branches: trunk
changeset: 347741:bf9480839b43
user: roy <roy%NetBSD.org@localhost>
date: Wed Sep 14 11:46:43 2016 +0000
description:
Don't bail if SIOGIFMEDIA doesn't return any media lists because we
can still report link status.
diffstat:
sbin/ifconfig/media.c | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
diffs (58 lines):
diff -r 49bad3de52f8 -r bf9480839b43 sbin/ifconfig/media.c
--- a/sbin/ifconfig/media.c Wed Sep 14 11:43:08 2016 +0000
+++ b/sbin/ifconfig/media.c Wed Sep 14 11:46:43 2016 +0000
@@ -1,6 +1,6 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: media.c,v 1.6 2011/08/29 14:35:00 joerg Exp $");
+__RCSID("$NetBSD: media.c,v 1.7 2016/09/14 11:46:43 roy Exp $");
#endif /* not lint */
#include <assert.h>
@@ -371,27 +371,27 @@
return;
}
- if (ifmr.ifm_count == 0) {
- warnx("%s: no media types?", ifname);
- return;
- }
+ /* Interface link status is queried through SIOCGIFMEDIA.
+ * Not all interfaces have actual media. */
+ if (ifmr.ifm_count != 0) {
+ media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
+ if (media_list == NULL)
+ err(EXIT_FAILURE, "malloc");
+ ifmr.ifm_ulist = media_list;
- media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
- if (media_list == NULL)
- err(EXIT_FAILURE, "malloc");
- ifmr.ifm_ulist = media_list;
+ if (prog_ioctl(s, SIOCGIFMEDIA, &ifmr) == -1)
+ err(EXIT_FAILURE, "SIOCGIFMEDIA");
- if (prog_ioctl(s, SIOCGIFMEDIA, &ifmr) == -1)
- err(EXIT_FAILURE, "SIOCGIFMEDIA");
-
- printf("\tmedia: %s ", get_media_type_string(ifmr.ifm_current));
- print_media_word(ifmr.ifm_current, " ");
- if (ifmr.ifm_active != ifmr.ifm_current) {
- printf(" (");
- print_media_word(ifmr.ifm_active, " ");
- printf(")");
- }
- printf("\n");
+ printf("\tmedia: %s ", get_media_type_string(ifmr.ifm_current));
+ print_media_word(ifmr.ifm_current, " ");
+ if (ifmr.ifm_active != ifmr.ifm_current) {
+ printf(" (");
+ print_media_word(ifmr.ifm_active, " ");
+ printf(")");
+ }
+ printf("\n");
+ } else
+ media_list = NULL;
if (ifmr.ifm_status & IFM_STATUS_VALID) {
const struct ifmedia_status_description *ifms;
Home |
Main Index |
Thread Index |
Old Index