From 0166e859fdd2e1cfcb15ef216cc0cca33b65ef4a Mon Sep 17 00:00:00 2001
From: Markus Gothe <markus.gothe@genexis.eu>
Date: Wed, 23 Apr 2025 22:47:04 +0200
Subject: [PATCH] netifd: refine 100-add-support-for-ecnt-lan-device.patch

Refine the patch to correctly deal with tagged VLANs on the LAN ports.

(cherry picked from commit 7c9376c25e3974a5e959b9f90dd93589ac6bf0ab)
---
 .../100-add-support-for-ecnt-lan-device.patch | 44 +++++--------------
 1 file changed, 12 insertions(+), 32 deletions(-)

diff --git a/package/network/config/netifd/patches/airoha/100-add-support-for-ecnt-lan-device.patch b/package/network/config/netifd/patches/airoha/100-add-support-for-ecnt-lan-device.patch
index 043d6d0c8a6..f620b76e5d3 100644
--- a/package/network/config/netifd/patches/airoha/100-add-support-for-ecnt-lan-device.patch
+++ b/package/network/config/netifd/patches/airoha/100-add-support-for-ecnt-lan-device.patch
@@ -1,32 +1,12 @@
-diff --git a/device.c b/device.c
-index d69be9c..2798555 100644
---- a/device.c
-+++ b/device.c
-@@ -696,6 +696,18 @@ device_find(const char *name)
- 	return avl_find_element(&devices, name, dev, avl);
- }
- 
-+static bool
-+device_is_lan_port(const char *name)
-+{
-+	int i;
-+	int n;
-+
-+	if (sscanf(name, "eth0.%d %n", &i, &n) == 1 && !name[n])
-+		return true;
-+
-+	return false;
-+}
-+
- struct device *
- __device_get(const char *name, int create, bool check_vlan)
- {
-@@ -703,7 +715,7 @@ __device_get(const char *name, int create, bool check_vlan)
- 
- 	dev = avl_find_element(&devices, name, dev, avl);
- 
--	if (!dev && check_vlan && strchr(name, '.'))
-+	if (!dev && check_vlan && !device_is_lan_port(name) && strchr(name, '.'))
- 		return get_vlan_device_chain(name, create);
- 
- 	if (name[0] == '@')
+diff -uNr a/vlan.c b/vlan.c
+--- a/vlan.c	2024-01-04 13:35:43.000000000 +0100
++++ b/vlan.c	2025-04-23 23:01:10.763035748 +0200
+@@ -260,7 +260,7 @@
+ 	if (!buf)
+ 		return NULL;
+ 
+-	s = split_vlan(buf);
++	s = split_vlan(strncmp(buf, "eth0.", 5) ? buf : buf + 5);
+ 	dev = __device_get(buf, create, false);
+ 	if (!dev || !s)
+ 		goto out;
-- 
GitLab