From 3c0186c6138cdc6c98685192448824200907bb8f Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Mon, 14 Apr 2025 01:16:54 +0200
Subject: [PATCH] gluon-core: use single conduit interface for DSA topology

As explained in issue #3479, asisgning the same role over interfaces
using different conduit interfaces can lead the network setup rendered
in an dysfunctional state.

As a stop-gap solution, use the same conduit interface for all devices
with the problematic topology.

Link: https://github.com/freifunk-gluon/gluon/issues/3479

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 .../luasrc/lib/gluon/upgrade/205-dsa-conduit  | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100755 package/gluon-core/luasrc/lib/gluon/upgrade/205-dsa-conduit

diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/205-dsa-conduit b/package/gluon-core/luasrc/lib/gluon/upgrade/205-dsa-conduit
new file mode 100755
index 000000000..90a3115a2
--- /dev/null
+++ b/package/gluon-core/luasrc/lib/gluon/upgrade/205-dsa-conduit
@@ -0,0 +1,38 @@
+#!/usr/bin/lua
+
+local uci = require('simple-uci').cursor()
+local platform = require 'gluon.platform'
+
+-- This is a workaround to result in a configuration where all ports
+-- on the DSA switch are connected to the same CPU interface.
+--
+-- See Gluon issue #3479 for details.
+-- https://github.com/freifunk-gluon/gluon/issues/3479
+
+if not platform.match('ipq806x', 'generic', {
+	'netgear,r7800',
+	'tplink,c2600',
+}) then
+	return
+end
+
+
+local ports = {
+	'lan1',
+	'lan2',
+	'lan3',
+	'lan4',
+	'wan',
+}
+local cpu_conduit = 'eth0'
+
+for _, port in ipairs(ports) do
+	local section_name = 'port_' .. port
+
+	uci:section('network', 'device', section_name, {
+		name = port,
+		conduit = cpu_conduit,
+	})
+end
+
+uci:save('network')
-- 
GitLab