Packet Mirroring with XDP
There are several ways to achieve packet mirroring in Linux, but I had thought that XDP alone could not implement packet mirroring. In other words, I believed it required combining with other features like TC. After some experimentation, I found that packet mirroring can be achieved using the devmap broadcast feature (simultaneous transmission to all devmap entries). The code is available at xdp_mirror.py. The overall architecture looks like this. There are 3 hosts (h1-3) and a gateway (gw) connecting them....