aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-08-12 04:51:54 +0800
committerjhb <jhb@FreeBSD.org>2015-08-12 04:51:54 +0800
commit1b203136463fa83ca6d2ba96bfa131a623bfa8a1 (patch)
tree9f881b64da83fba7d8da54dbd95a8254d1ebe8c6
parent6fccc0c2f3b33108c13a635edd8490596dcb847d (diff)
downloadfreebsd-ports-gnome-1b203136463fa83ca6d2ba96bfa131a623bfa8a1.tar.gz
freebsd-ports-gnome-1b203136463fa83ca6d2ba96bfa131a623bfa8a1.tar.zst
freebsd-ports-gnome-1b203136463fa83ca6d2ba96bfa131a623bfa8a1.zip
Fix some nits with displaying Ethernet media status exposed by the recent
extended Ethernet media states: - Don't apply IFM_SUBTYPE to the raw subtype in the description table. IFM_SUBTYPE() requires a fully populated word and was truncating values in the table when comparing resulting in false matches (notably "10GBase-KX4" for the no media case). - Explicitly check for IFM_ETHER. - Use SIOCGIFXMEDIA when present to obtain extended media states. - Explicitly handle "no carrier". PR: 202247 Reviewed by: bapt
-rw-r--r--x11/i3status/Makefile2
-rw-r--r--x11/i3status/files/patch-print_eth_info.c45
2 files changed, 46 insertions, 1 deletions
diff --git a/x11/i3status/Makefile b/x11/i3status/Makefile
index 75e1ab37e7a9..9ecb3a2e9919 100644
--- a/x11/i3status/Makefile
+++ b/x11/i3status/Makefile
@@ -2,7 +2,7 @@
PORTNAME= i3status
PORTVERSION= 2.8
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= x11
MASTER_SITES= http://i3wm.org/i3status/
diff --git a/x11/i3status/files/patch-print_eth_info.c b/x11/i3status/files/patch-print_eth_info.c
new file mode 100644
index 000000000000..321145268385
--- /dev/null
+++ b/x11/i3status/files/patch-print_eth_info.c
@@ -0,0 +1,45 @@
+--- src/print_eth_info.c.orig 2015-08-11 09:37:31.470359000 -0700
++++ src/print_eth_info.c 2015-08-11 10:12:38.744033000 -0700
+@@ -21,8 +21,6 @@
+
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+ #include <net/if_media.h>
+-#define IFM_TYPE_MATCH(dt, t) \
+- (IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t)))
+
+ #define PART_ETHSPEED "E: %s (%s)"
+ #endif
+@@ -52,19 +50,29 @@
+ struct ifmediareq ifm;
+ (void)memset(&ifm, 0, sizeof(ifm));
+ (void)strncpy(ifm.ifm_name, interface, sizeof(ifm.ifm_name));
+- int ret = ioctl(general_socket, SIOCGIFMEDIA, (caddr_t)&ifm);
++ int ret;
++#ifdef SIOCGIFXMEDIA
++ ret = ioctl(general_socket, SIOCGIFXMEDIA, (caddr_t)&ifm);
++ if (ret < 0)
++#endif
++ ret = ioctl(general_socket, SIOCGIFMEDIA, (caddr_t)&ifm);
++ if (ret < 0)
++ return sprintf(outwalk, "?");
+
+ /* Get the description of the media type, partially taken from
+ * FreeBSD's ifconfig */
+ const struct ifmedia_description *desc;
+- struct ifmedia_description ifm_subtype_descriptions[] =
++ static struct ifmedia_description ifm_subtype_descriptions[] =
+ IFM_SUBTYPE_ETHERNET_DESCRIPTIONS;
+
++ if (IFM_TYPE(ifm.ifm_active) != IFM_ETHER)
++ return sprintf(outwalk, "?");
++ if (ifm.ifm_status & IFM_AVALID && !(ifm.ifm_status & IFM_ACTIVE))
++ return sprintf(outwalk, "no carrier");
+ for (desc = ifm_subtype_descriptions;
+ desc->ifmt_string != NULL;
+ desc++) {
+- if (IFM_TYPE_MATCH(desc->ifmt_word, ifm.ifm_active) &&
+- IFM_SUBTYPE(desc->ifmt_word) == IFM_SUBTYPE(ifm.ifm_active))
++ if (desc->ifmt_word == IFM_SUBTYPE(ifm.ifm_active))
+ break;
+ }
+ ethspeed = (desc->ifmt_string != NULL ? desc->ifmt_string : "?");