From owner-freebsd-questions@FreeBSD.ORG Thu Apr 1 18:21:03 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 824C71065670 for ; Thu, 1 Apr 2010 18:21:03 +0000 (UTC) (envelope-from psteele@maxiscale.com) Received: from server505.appriver.com (server505a.appriver.com [98.129.35.4]) by mx1.freebsd.org (Postfix) with ESMTP id 4AE798FC3A for ; Thu, 1 Apr 2010 18:21:03 +0000 (UTC) X-Policy: GLOBAL - maxiscale.com X-Primary: psteele@maxiscale.com X-Note: This Email was scanned by AppRiver SecureTide X-ALLOW: psteele@maxiscale.com ALLOWED X-Virus-Scan: V- X-Note: Spam Tests Failed: X-Country-Path: UNITED STATES->UNITED STATES->UNITED STATES X-Note-Sending-IP: 98.129.23.15 X-Note-Reverse-DNS: ht02.exg5.exghost.com X-Note-WHTLIST: psteele@maxiscale.com X-Note: User Rule Hits: X-Note: Global Rule Hits: G179 G180 G181 G182 G186 G187 G198 G285 X-Note: Encrypt Rule Hits: X-Note: Mail Class: ALLOWEDSENDER X-Note: Headers Injected Received: from [98.129.23.15] (HELO ht02.exg5.exghost.com) by server505.appriver.com (CommuniGate Pro SMTP 5.3.2) with ESMTPS id 34919906 for freebsd-questions@freebsd.org; Thu, 01 Apr 2010 13:21:07 -0500 Received: from mbx03.exg5.exghost.com ([169.254.1.132]) by ht02.exg5.exghost.com ([98.129.23.15]) with mapi; Thu, 1 Apr 2010 13:21:02 -0500 From: Peter Steele To: "freebsd-questions@freebsd.org" Date: Thu, 1 Apr 2010 13:21:00 -0500 Thread-Topic: Testing ethernet interface status Thread-Index: AcrRyBTCr9jjnOjCQiOAipykloaEFg== Message-ID: <7B9397B189EB6E46A5EE7B4C8A4BB7CB3B65FC5D@MBX03.exg5.exghost.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Testing ethernet interface status X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Apr 2010 18:21:03 -0000 What's the best what to test the status of an Ethernet interface programmat= ically? We've been using this code similar to this: struct ifmediareq ifmr; memset(&ifmr, 0, sizeof(ifmr)); strcpy(ifmr.ifm_name, "nfe0"); ioctl(sockfd, SIOCGIFMEDIA, (caddr_t)&ifmr) and then checking the value of ifmr.ifm_status & IFM_ACTIVE. We've found th= at every once in a while this code will return a false positive, indicating= that the interface has gone offline when in fact it has not. So, is there a more reliable call to test if an Ethernet interface has gone= offline?