From owner-freebsd-questions@FreeBSD.ORG Thu Apr 1 18:58:43 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 392D9106564A for ; Thu, 1 Apr 2010 18:58:43 +0000 (UTC) (envelope-from faust64@gmail.com) Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by mx1.freebsd.org (Postfix) with ESMTP id AD6FA8FC08 for ; Thu, 1 Apr 2010 18:58:42 +0000 (UTC) Received: by bwz8 with SMTP id 8so1136941bwz.3 for ; Thu, 01 Apr 2010 11:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:cc:content-type; bh=Iskga2HYJUj2Q3KoZPvnbI2yb05Zb4UhRgTGc1j151Y=; b=UH/50Ar/xg9So2Ny1n3+lQsUe7ah9DJ6LB8el/WVlsTyIwIW8iVstOoz3QsWjEmsYB cHJPm2VpfheIFFHYnKQ2wOl6c6jOmUG4rM+iNt3dNPgqr7Fk0tdtSQq3tPP7lA8qXAeo vsyz4N0m5nBsgo/YidWy6hc5P602x8aRt60bE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=B4X601LmyXbHfXBiTAs/4/zTVryt4jciqeQtfFkE1Rm/kHMFaKlR4ezaFlU1M6fjY0 Q7Cdmo0lsPoA4b+Y3sBF/lY4zPt5NuzWUcyruXsadV0s10z1AYJQNpu088lPKpno6x41 sg00snZOl8ljfi/DvjJTAY8VtqWOkKFW8NL2U= MIME-Version: 1.0 Received: by 10.204.61.5 with HTTP; Thu, 1 Apr 2010 11:58:21 -0700 (PDT) In-Reply-To: <4BB4EC44.2070804@comcast.net> References: <7B9397B189EB6E46A5EE7B4C8A4BB7CB3B65FC5D@MBX03.exg5.exghost.com> <4BB4EC44.2070804@comcast.net> From: =?ISO-8859-1?Q?Samuel_Mart=EDn_Moro?= Date: Thu, 1 Apr 2010 20:58:21 +0200 Received: by 10.204.81.145 with SMTP id x17mr1846057bkk.31.1270148321397; Thu, 01 Apr 2010 11:58:41 -0700 (PDT) Message-ID: To: Steve Polyack Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Peter Steele , "freebsd-questions@freebsd.org" Subject: Re: 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:58:43 -0000 I don't remember everything, but I used to do a program to do that. You should also check ifmr.ifm_active value. There was some "strange" behaviour (obviously normal, but unexpected when I coded it), about up/down interfaces and plug or unplugged cables and yep, ifconfig's doing it 'wrong' :) Samuel Mart=EDn Moro {EPITECH.} tek4 CamTrace S.A.S On Thu, Apr 1, 2010 at 8:56 PM, Steve Polyack wrote: > On 04/01/10 14:21, Peter Steele wrote: > >> What's the best what to test the status of an Ethernet interface >> programmatically? 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 >> that 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? >> >> > I was going to suggest that you look at the ifconfig(8) source code, but > then I did so myself - it looks like you're doing it pretty much exactly = how > they are. I've never noticed ifconfig(8) returning an incorrect value, n= ot > to say it's not possible. > > Are you sure that nothing is causing interface state resets? i.e. > mismatched duplex/speed settings between the FreeBSD machine and the swit= ch? > Have you checked dmesg(8) for logs of interface state changes? You can > also check the output of 'netstat -i' to check for interface errors. > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" >