On Wed, May 29, 2019 at 12:04:53AM -0700, [email protected] wrote:
> On Tue, May 28, 2019 at 09:20 PM, Gary Lin wrote:
> 
> > 
> > On Tue, May 28, 2019 at 07:32:33PM -0700, [email protected] wrote:
> > 
> >> Hi all,
> >> What kind of network topology should I set up to make xdp_redirect_map.py
> >> runnable and what user-case this example represent for?
> > 
> > The script does nothing really meaningful but demostrates how to use
> > XDP_REDIRECT.
> > 
> > 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.
> > 
> > Cheers,
> > 
> > Gary Lin
> > 
> > 
> >> PS: I have the same question about xdp_macswap_count.py too
> >> 
> >> Thanks for helping me!
> >> Forrest
> >> 
> >> 
> >> 
> > 
> > 
> 
> 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.
> 
Sorry, my memory betrayed me. Those two scripts swap the mac, not IP.
As I said, xdp_redirect_map.py is a demo script, so it doesn't care if
the packets are dropped in Machine B or not. In the real world, users
of XDP_REDIRECT usually modify the IP address or prepend a header
with bpf_xdp_adjust_head(), so that those packets can be passed further.

> 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?
> 
AFAIK, the frame checksum is calculated by the network card, so we don't
have to do the calculation.

Cheers,

Gary Lin

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#1694): https://lists.iovisor.org/g/iovisor-dev/message/1694
Mute This Topic: https://lists.iovisor.org/mt/31829746/21656
Group Owner: [email protected]
Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to