#!/bin/sh
#creds https://biot.com/switches/testing/mirroring
sniffPort=wan
mirrorPort=lan0
#Turn on the mirror port
ip link set up dev ${mirrorPort}
#Add the clsact queue discipline. This qdisc lets us attach the matchall filter
tc qdisc add dev ${sniffPort} clsact
# enable hw tc offload.
ethtool -K ${sniffPort} hw-tc-offload on
#Mirror all packets inbound on sniffPort (ingress) to mirrorPort. Note the skip_sw flag, meaning this command will not fall back on mirroring via the CPU if the hardware offload fails
tc filter add dev ${sniffPort} ingress matchall skip_sw action mirred egress mirror dev ${mirrorPort}
#Mirror all packets going out of snifPort (egress) to mirrorPort
tc filter add dev ${sniffPort} egress matchall skip_sw action mirred egress mirror dev ${mirrorPort}
REF : https://patchwork.ozlabs.org/project/netdev/patch/20160704073411.17633-1-amir@vadai.me/
I have modified to use the skip_sw flags by enabling the hardware offload, no more kernel error, but still silent with tcpdump...
root@ultra:~# tc -s -p qdisc ls dev wan
qdisc noqueue 0: root refcnt 2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
qdisc clsact ffff: parent ffff:fff1
Sent 199423 bytes 1345 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
root@ultra:~# tc -s -p qdisc ls dev lan0
qdisc noqueue 0: root refcnt 2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0