From owner-svn-ports-head@freebsd.org Tue Aug 11 20:51:56 2015 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1317C99F04A; Tue, 11 Aug 2015 20:51:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 00951A56; Tue, 11 Aug 2015 20:51:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7BKptm9032864; Tue, 11 Aug 2015 20:51:55 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7BKptPW032861; Tue, 11 Aug 2015 20:51:55 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201508112051.t7BKptPW032861@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 11 Aug 2015 20:51:55 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r393973 - in head/x11/i3status: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2015 20:51:56 -0000 Author: jhb (src,doc committer) Date: Tue Aug 11 20:51:54 2015 New Revision: 393973 URL: https://svnweb.freebsd.org/changeset/ports/393973 Log: 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 Added: head/x11/i3status/files/ head/x11/i3status/files/patch-print_eth_info.c (contents, props changed) Modified: head/x11/i3status/Makefile Modified: head/x11/i3status/Makefile ============================================================================== --- head/x11/i3status/Makefile Tue Aug 11 20:41:29 2015 (r393972) +++ head/x11/i3status/Makefile Tue Aug 11 20:51:54 2015 (r393973) @@ -2,7 +2,7 @@ PORTNAME= i3status PORTVERSION= 2.8 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= x11 MASTER_SITES= http://i3wm.org/i3status/ Added: head/x11/i3status/files/patch-print_eth_info.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/x11/i3status/files/patch-print_eth_info.c Tue Aug 11 20:51:54 2015 (r393973) @@ -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 +-#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 : "?");