Add port mirror support to UCI

Albrecht Lohöfener albrechtloh at gmx.de
Sun Apr 19 06:06:53 PDT 2026


Hi all,

with an increasing number of DSA drivers supporting Ethernet port 
mirroring (I have a RTL8380M based switch), I would like to discuss 
adding native support for this in OpenWrt.

Currently, mirroring can be configured via tc, e.g. lan1 mirrored to lan4:

tc qdisc add dev lan1 clsact
tc filter add dev lan1 ingress matchall \
     action mirred egress mirror dev lan4
tc filter add dev lan1 egress matchall \
     action mirred egress mirror dev lan4

While functional, this approach:
* is not integrated with UCI
* is not persistent in /etc/config/network
* is not user friendly

I have put together a first draft implementation:
https://github.com/openwrt/openwrt/pull/22988

The proposed solution follows a similar design to the qos-scripts 
package. It introduces a new configuration file at 
/etc/config/port-mirror along with a corresponding set of scripts. 
However, I’m not sure whether a standalone port-mirror-scripts approach 
is the right direction, or if it would be more appropriate to integrate 
port mirroring directly into netifd.

I’d appreciate feedback on the overall approach and guidance on how this 
feature should ideally be integrated into OpenWrt.

---
# Example UCI commands
uci set port-mirror.example=mirror
uci set port-mirror.example.enabled='1'
uci set port-mirror.example.source='lan1'
uci set port-mirror.example.target='lan4'
uci set port-mirror.example.ingress='1'
uci set port-mirror.example.egress='1'
uci commit port-mirror
/etc/init.d/port-mirror reload

---
# Example file /etc/config/port-mirror
config mirror 'example'
	option enabled '1'
	option source 'lan1'
	option target 'lan4'
	option ingress '1'
	option egress '1'


Best regards,
Albrecht



More information about the openwrt-devel mailing list