From 2d794fd653f04fa86c233d93d59a069cd4d85ad0 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 6 Jul 2010 08:42:54 +0200 Subject: BUG: MII register probing fails on e1000e MII register probing is only tested on the BMSR but not on the 31 other registers. The e1000e driver only supports a few registers including the BMSR, so the other ones fail with a log message. The correct fix consists in checking *every* result and reporting a failure if *any* fails. This means we can also remove the early BMSR support check which is now covered by the error reporting. --- keepalived/vrrp/vrrp_if.c | 29 ++++++++++------------------- 1 files changed, 10 insertions(+), 19 deletions(-) diff --git a/keepalived/vrrp/vrrp_if.c b/keepalived/vrrp/vrrp_if.c index 99bd746..76065d3 100644 --- a/keepalived/vrrp/vrrp_if.c +++ b/keepalived/vrrp/vrrp_if.c @@ -127,6 +127,7 @@ static void if_mii_dump(const uint16_t mii_regs[32], unsigned phy_id) } */ + /* return -1 in case of failure */ static int if_mii_status(const int fd) { @@ -139,17 +140,18 @@ if_mii_status(const int fd) /* Reset MII registers */ memset(mii_regs, 0, sizeof (mii_regs)); - for (mii_reg = 0; mii_reg < 32; mii_reg++) - mii_regs[mii_reg] = if_mii_read(fd, phy_id, mii_reg); + for (mii_reg = 0; mii_reg < 32; mii_reg++) { + int ret = if_mii_read(fd, phy_id, mii_reg); + if (ret < 0) { + log_message(LOG_ERR, "No MII transceiver present for %s !!!", + ifr.ifr_name); + return -1; + } + mii_regs[mii_reg] = ret; + } // if_mii_dump(mii_regs, phy_id); - if (mii_regs[0] == 0xffff) { - log_message(LOG_ERR, "No MII transceiver present for %s !!!", - ifr.ifr_name); - return -1; - } - bmsr = mii_regs[1]; /* @@ -186,17 +188,6 @@ if_mii_probe(const char *ifname) return -1; } - /* check if the driver reports BMSR using the MII interface, as we - * will need this and we already know that some don't support it. - */ - phy_id = data[0]; /* save it in case it is overwritten */ - data[1] = 1; - if (ioctl(fd, SIOCGMIIREG, &ifr) < 0) { - close(fd); - return -1; - } - data[0] = phy_id; - /* Dump the MII transceiver */ status = if_mii_status(fd); close(fd); -- 1.6.0.4