Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Apr 2010 13:21:00 -0500
From:      Peter Steele <psteele@maxiscale.com>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Testing ethernet interface status
Message-ID:  <7B9397B189EB6E46A5EE7B4C8A4BB7CB3B65FC5D@MBX03.exg5.exghost.com>

next in thread | raw e-mail | index | archive | help
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?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7B9397B189EB6E46A5EE7B4C8A4BB7CB3B65FC5D>