I'm not a C/C++ developer. Well this is very far away from my memory. I changed the following line:

+      error = netdev_linux_get_ethtool(name, miimon);
to
+      error = netdev_linux_get_ethtool(&name, &miimon);

as it looks like we're sending adresses to functions instead of the values. This should work and it
passed the "make check".

Correct me if I'm wrong please!

Dave

On 09/25/2016 12:06 PM, David Hill wrote:
From 2748f6325facb7d5d880d620041e2f11767abe0c Mon Sep 17 00:00:00 2001
From: David Hill <dh...@redhat.com>
Date: Tue, 30 Aug 2016 15:13:31 -0400
Subject: [PATCH 1/1] netdev-linux.c - Trying to use miimon and on failure failback to ethtool

Some network drivers might return true to SIOCGMIIPHY and an error on SIOCGMIIREG, this patch will simply fallback to ethtool if this happens and failover should still happen on an OVS using such nics.

Signed-off-by: David Hill <dh...@redhat.com>

---
lib/netdev-linux.c | 50 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index efc9527..05aa91f 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -1426,6 +1426,33 @@ netdev_linux_do_miimon(const char *name, int cmd, const char *cmd_name,
 }

 static int
+netdev_linux_get_ethtool(const char *name, bool *miimon)
+{
+    struct mii_ioctl_data data;
+    int error;
+
+    *miimon = false;
+
+    struct ethtool_cmd ecmd;
+    VLOG_DBG_RL(&rl, "%s: failed to query MII, falling back to ethtool",
+                    name);
+
+    COVERAGE_INC(netdev_get_ethtool);
+    memset(&ecmd, 0, sizeof ecmd);
+    error = netdev_linux_do_ethtool(name, &ecmd, ETHTOOL_GLINK,
+                                        "ETHTOOL_GLINK");
+    if (!error) {
+        struct ethtool_value eval;
+        memcpy(&eval, &ecmd, sizeof eval);
+        *miimon = !!eval.data;
+    } else {
+        VLOG_WARN_RL(&rl, "%s: ethtool link status failed", name);
+    }
+
+    return error;
+}
+
+static int
 netdev_linux_get_miimon(const char *name, bool *miimon)
 {
     struct mii_ioctl_data data;
@@ -1443,28 +1470,11 @@ netdev_linux_get_miimon(const char *name, bool *miimon)
         if (!error) {
             *miimon = !!(data.val_out & BMSR_LSTATUS);
-        } else {
-            VLOG_WARN_RL(&rl, "%s: failed to query MII", name);
-        }
-    } else {
-        struct ethtool_cmd ecmd;
-
- VLOG_DBG_RL(&rl, "%s: failed to query MII, falling back to ethtool",
-                    name);
-
-        COVERAGE_INC(netdev_get_ethtool);
-        memset(&ecmd, 0, sizeof ecmd);
-        error = netdev_linux_do_ethtool(name, &ecmd, ETHTOOL_GLINK,
-                                        "ETHTOOL_GLINK");
-        if (!error) {
-            struct ethtool_value eval;
-
-            memcpy(&eval, &ecmd, sizeof eval);
-            *miimon = !!eval.data;
-        } else {
-            VLOG_WARN_RL(&rl, "%s: ethtool link status failed", name);
         }
     }
+    if (error) {
+      error = netdev_linux_get_ethtool(&name, &miimon);
+    }

     return error;
 }
--
2.7.4


_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to