Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147519054
D21527.id61662.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D21527.id61662.diff
View Options
Index: sbin/ifconfig/ifmedia.c
===================================================================
--- sbin/ifconfig/ifmedia.c
+++ sbin/ifconfig/ifmedia.c
@@ -80,6 +80,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -110,18 +111,20 @@
media_status(int s)
{
struct ifmediareq ifmr;
+ struct ifdownreason ifdr;
int *media_list, i;
- int xmedia = 1;
+ bool no_carrier, xmedia;
(void) memset(&ifmr, 0, sizeof(ifmr));
(void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
+ xmedia = true;
/*
* Check if interface supports extended media types.
*/
if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0)
- xmedia = 0;
- if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
+ xmedia = false;
+ if (!xmedia && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
/*
* Interface doesn't support SIOC{G,S}IFMEDIA.
*/
@@ -158,6 +161,7 @@
putchar('\n');
if (ifmr.ifm_status & IFM_AVALID) {
+ no_carrier = false;
printf("\tstatus: ");
switch (IFM_TYPE(ifmr.ifm_active)) {
case IFM_ETHER:
@@ -165,7 +169,7 @@
if (ifmr.ifm_status & IFM_ACTIVE)
printf("active");
else
- printf("no carrier");
+ no_carrier = true;
break;
case IFM_IEEE80211:
@@ -176,9 +180,16 @@
else
printf("running");
} else
- printf("no carrier");
+ no_carrier = true;
break;
}
+ if (no_carrier) {
+ printf("no carrier");
+ memset(&ifdr, 0, sizeof(ifdr));
+ strlcpy(ifdr.ifdr_name, name, sizeof(ifdr.ifdr_name));
+ if (ioctl(s, SIOCGIFDOWNREASON, (caddr_t)&ifdr) == 0)
+ printf(" (%s)", ifdr.ifdr_msg);
+ }
putchar('\n');
}
Index: sys/net/if.h
===================================================================
--- sys/net/if.h
+++ sys/net/if.h
@@ -585,6 +585,12 @@
#define IFNET_PCP_NONE 0xff /* PCP disabled */
+#define IFDR_MSG_SIZE 64
+struct ifdownreason {
+ char ifdr_name[IFNAMSIZ];
+ char ifdr_msg[IFDR_MSG_SIZE];
+};
+
#endif /* __BSD_VISIBLE */
#ifdef _KERNEL
Index: sys/net/if.c
===================================================================
--- sys/net/if.c
+++ sys/net/if.c
@@ -2889,6 +2889,7 @@
case SIOCGIFGENERIC:
case SIOCGIFRSSKEY:
case SIOCGIFRSSHASH:
+ case SIOCGIFDOWNREASON:
if (ifp->if_ioctl == NULL)
return (EOPNOTSUPP);
error = (*ifp->if_ioctl)(ifp, cmd, data);
Index: sys/sys/sockio.h
===================================================================
--- sys/sys/sockio.h
+++ sys/sys/sockio.h
@@ -143,4 +143,6 @@
#define SIOCGLANPCP _IOWR('i', 152, struct ifreq) /* Get (V)LAN PCP */
#define SIOCSLANPCP _IOW('i', 153, struct ifreq) /* Set (V)LAN PCP */
+#define SIOCGIFDOWNREASON _IOWR('i', 154, struct ifdownreason)
+
#endif /* !_SYS_SOCKIO_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 12, 2:38 PM (19 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29586476
Default Alt Text
D21527.id61662.diff (2 KB)
Attached To
Mode
D21527: Add SIOCGIFDOWNREASON
Attached
Detach File
Event Timeline
Log In to Comment