From dc6ca0ca4174595ab0b6e5e821488aec7d60bbd2 Mon Sep 17 00:00:00 2001
From: Markus Gothe <markus.gothe@genexis.eu>
Date: Thu, 23 Jan 2025 14:12:06 +0100
Subject: [PATCH] Fix detection of 'ae_wan' WAN-interface.

---
 econet/econet.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/econet/econet.c b/econet/econet.c
index 94a7958..72c4f36 100644
--- a/econet/econet.c
+++ b/econet/econet.c
@@ -67,15 +67,11 @@ int econet_eth_get_stats(const char *ifname, struct eth_stats *stats)
 		/* Check and fetch stats if the Interface belongs to hsgmii_lan driver */
 		if (!hsgmii_lan_prvt_get_port_statistics(ifname, stats, NULL)) {
 			return 0;
-		}
-		libethernet_err("invalid port name: %s\n", ifname);
-		return -1;
-	}
-
-	if (!strcmp(ifname, "ae_wan")) {
-		/* Check and fetch rstats if the Interface belongs to ae_wan driver */
-		if (!ae_wan_prvt_get_port_statistics(stats, NULL)) {
-			return 0;
+		} else if (!strcmp(ifname, "ae_wan")) {
+			/* Check and fetch rstats if the Interface belongs to ae_wan driver */
+			if (!ae_wan_prvt_get_port_statistics(stats, NULL)) {
+				return 0;
+			}
 		}
 
 		libethernet_err("error reading stats for interface %s\n", ifname);
@@ -100,16 +96,11 @@ int econet_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rstats)
 		/* Check and fetch rstats if the Interface belongs to hsgmii_lan driver */
 		if (!hsgmii_lan_prvt_get_port_statistics(ifname, NULL, rstats)) {
 			return 0;
-		}
-
-		libethernet_err("invalid port name: %s\n", ifname);
-		return -1;
-	}
-
-	if (!strcmp(ifname, "ae_wan")) {
-		/* Check and fetch rstats if the Interface belongs to ae_wan driver */
-		if (!ae_wan_prvt_get_port_statistics(NULL, rstats)) {
-			return 0;
+		} else if (!strcmp(ifname, "ae_wan")) {
+			/* Check and fetch rstats if the Interface belongs to ae_wan driver */
+			if (!ae_wan_prvt_get_port_statistics(NULL, rstats)) {
+				return 0;
+			}
 		}
 
 		libethernet_err("error reading rmon stats for interface %s\n", ifname);
-- 
GitLab