[PATCH 02/10] net: export list of registered ethernet addresses

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Apr 11 00:40:37 PDT 2025


Network stack keeps an ethaddr_list of Ethernet addresses that were
registered by drivers and board code.

The list currently lacks ethernet devices for which a net_device already
existed. If a net_device is added later on, the list is consulted, but
the element is not removed.

This means ethaddr_list is "the list of registered Ethernet addresses
that were added before the relevant device has been probed". Make it more
useful by genericising it to be "the list of registered Ethernet addresses".

This introduces no functional change (only consumer is fixup code that
handles both cases already), but it allows future board code to consult
the list to check which Ethernet addresses were actually assigned.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 include/net.h |  9 +++++++++
 net/eth.c     | 11 ++---------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/net.h b/include/net.h
index b742e9499434..bc0c1edce0ce 100644
--- a/include/net.h
+++ b/include/net.h
@@ -613,4 +613,13 @@ void ifdown_all(void);
 
 extern struct class eth_class;
 
+struct eth_ethaddr {
+	struct list_head list;
+	u8 ethaddr[ETH_ALEN];
+	int ethid;
+	struct device_node *node;
+};
+
+extern struct list_head ethaddr_list;
+
 #endif /* __NET_H__ */
diff --git a/net/eth.c b/net/eth.c
index 16857ac838dd..2489ed152634 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -23,14 +23,7 @@
 
 DEFINE_DEV_CLASS(eth_class, "eth");
 
-struct eth_ethaddr {
-	struct list_head list;
-	u8 ethaddr[ETH_ALEN];
-	int ethid;
-	struct device_node *node;
-};
-
-static LIST_HEAD(ethaddr_list);
+LIST_HEAD(ethaddr_list);
 
 int eth_set_promisc(struct eth_device *edev, bool enable)
 {
@@ -102,7 +95,7 @@ void eth_register_ethaddr(int ethid, const char *ethaddr)
 	for_each_netdev(edev) {
 		if (edev->dev.id == ethid) {
 			register_preset_mac_address(edev, ethaddr);
-			return;
+			break;
 		}
 	}
 
-- 
2.39.5




More information about the barebox mailing list