Re: how to set environment to run example?

Forrest Chen

On Tue, May 28, 2019 at 09:20 PM, Gary Lin wrote:
On Tue, May 28, 2019 at 07:32:33PM -0700, forrest0579@... wrote:
Hi all,
What kind of network topology should I set up to make runnable and what user-case this example represent for?
The script does nothing really meaningful but demostrates how to use

It redirects all traffic from one network interface to another, so you
need a machine with at least two XDP-enabled network interfaces. When you
send a packet from eth0 of Machine B to eth0 of Machine A, the script
swaps the src IP and dst IP of the incoming packets and sends them out
through eth1 of Machine A, so the packets will flow like this:

(Machine A) (Machine B)
[ eth0 ]<------[ eth0 ]
| ^
v |
[ eth1 ] ---------+

The script also counts the number of packet processed per second as a
rough performance measurement for XDP_REDIRECT, so you can generate a
huge volume of traffic with the programs like trafgen in Machine B to
do the test.


Gary Lin

PS: I have the same question about too

Thanks for helping me!

These two examples swap mac instead of IP address.
And as an effect with the given topology, the egress package from MachineA-eth1 has dst mac of MachineB-eth0 and src mac of MachineA-eth0, dst IP of MachineA and src IP of MachineB. Assume that due to the dst mac, the package finally delivered back to MachineB, but the dst IP does not match the IP in MachineB.  I have no idea in which kind of topology the package could be consumed.

Another question, after swap mac, shouldn't we re-calculate the l2 csum? or if I modify that field like src/dst IP/Port, how can I re-calculate these csum? Does BPF_FUNC_csum_diff helper function work for this?



Join { to automatically receive all group messages.