@@ -28,12 +28,16 @@ interface it came from. This functionality can be used to implement load
2828balancers, to send simple ICMP replies, etc. We will use this functionality in
2929the Assignment 1 to implement a simple ICMP echo server.
3030
31- Note that in all our assignments below we are using the =skb= (i.e.,
32- =xdpgeneric=) mode to load programs. We are doing this because =veth= devices
33- won't deliver redirected/retransmitted XDP frames unless there is an XDP
34- program attached to the receiving side of the target =veth= interface. Physical
35- hardware will likely behave the same. XDP maintainers are currently working on
36- fixing this behaviour upstream.
31+ Note that in order to the transmit and/or redirect functionality to work, *all*
32+ involved devices should have an attached XDP program, including both veth
33+ peers. We have to do this because =veth= devices won't deliver
34+ redirected/retransmitted XDP frames unless there is an XDP program attached to
35+ the receiving side of the target =veth= interface. Physical hardware will
36+ likely behave the same. XDP maintainers are currently working on fixing this
37+ behaviour upstream. See the
38+ [[https://www.netdevconf.org/0x13/session.html?talk-veth-xdp][Veth XDP: XDP for containers]]
39+ talk which describes the reasons behind this problem. (The =xdpgeneric= mode
40+ may be used without this limitation.)
3741
3842** Redirecting packets to other interfaces
3943
@@ -82,10 +86,14 @@ only a small part of the packet is changing, the Incremental Internet Checksum
8286checksum.
8387
8488To test the echo server create a new environment with both address families
85- supported and load the XDP program:
89+ supported and load the XDP program. Note that we also need to load a dummy
90+ =xdp_pass= program for the peer device as well, as explained in the
91+ [[#sending-packets-back-to-the-interface-they-came-from][Sending packets back to the interface they came from]]
92+ section.
8693#+begin_src sh
8794$ t setup -n test --legacy-ip
88- $ sudo ./xdp_loader -d test --skb -F --progsec xdp_icmp_echo
95+ $ t exec -n test -- ./xdp_loader -d veth0 -F --progsec xdp_pass
96+ $ t load -n test -- -F --progsec xdp_icmp_echo
8997#+end_src
9098Ping the host and use the =xdp_stat= program to check that the ICMP echo server
9199actually returned =XDP_TX=. Repeat for both address families (you can pass
@@ -122,9 +130,13 @@ Env 1 Env 2
122130 veth0 (MAC=X1) <----------- veth1 (MAC=Y1)
123131#+end_src
124132Setup the two environments, patch the =xdp_redirect= program accordingly, and
125- attach it to the =right= interface. To test load the program, enter the right
126- environment, and ping the inner interface of the left environment (your IPv6
127- address may be different):
133+ attach it to the =right= interface. Don't forget to attach a dummy program to
134+ the left inner interface like this:
135+ #+begin_src sh
136+ $ t exec -n left -- ./xdp_loader -d veth0 -F --progsec xdp_pass
137+ #+end_src
138+ To test load the program, enter the right environment, and ping the inner
139+ interface of the left environment (your IPv6 address may be different):
128140#+begin_src sh
129141$ t enter -n right
130142$ ping fc00:dead:cafe:10::2
@@ -173,8 +185,13 @@ the =xdp_prog_user.c= program.
173185To test the code, configure environment as in the Assignment 2 and install the
174186=xdp_redirect_map= program on both interfaces:
175187#+begin_src sh
176- $ sudo ./xdp_loader -d left -F --progsec xdp_redirect_map --skb
177- $ sudo ./xdp_loader -d right -F --progsec xdp_redirect_map --skb
188+ $ t load -n left -- -F --progsec xdp_redirect_map
189+ $ t load -n right -- -F --progsec xdp_redirect_map
190+ #+end_src
191+ Don't forget about dummy programs for inner interfaces:
192+ #+begin_src sh
193+ $ t exec -n left -- ./xdp_loader -d veth0 -F --progsec xdp_pass
194+ $ t exec -n right -- ./xdp_loader -d veth0 -F --progsec xdp_pass
178195#+end_src
179196Configure parameters for both interfaces using the new =xdp_prog_user= helper.
180197For simplicity there is a new special helper, =t set_redirect_map=, which will
@@ -258,17 +275,16 @@ $ t setup -n uno --legacy-ip
258275$ t setup -n dos --legacy-ip
259276$ t setup -n tres --legacy-ip
260277
261- $ sudo sysctl net.ipv4.conf.uno.forwarding=1
262- $ sudo sysctl net.ipv4.conf.dos.forwarding=1
263- $ sudo sysctl net.ipv4.conf.tres.forwarding=1
278+ $ sudo sysctl net.ipv4.conf.all.forwarding=1
279+ $ sudo sysctl net.ipv6.conf.all.forwarding=1
264280
265- $ sudo sysctl net.ipv6.conf. uno.forwarding=1
266- $ sudo sysctl net.ipv6.conf. dos.forwarding=1
267- $ sudo sysctl net.ipv6.conf. tres.forwarding=1
281+ $ t load -n uno -- -F --progsec xdp_router
282+ $ t load -n dos -- -F --progsec xdp_router
283+ $ t load -n tres -- -F --progsec xdp_router
268284
269- $ sudo ./xdp_loader -d uno --progsec xdp_router --skb -F
270- $ sudo ./xdp_loader -d dos --progsec xdp_router --skb -F
271- $ sudo ./xdp_loader -d tres --progsec xdp_router --skb -F
285+ $ t exec -n uno -- ./xdp_loader -d veth0 -F --progsec xdp_pass
286+ $ t exec -n dos -- ./xdp_loader -d veth0 -F --progsec xdp_pass
287+ $ t exec -n tres -- ./xdp_loader -d veth0 -F --progsec xdp_pass
272288
273289$ sudo ./xdp_prog_user -d uno
274290$ sudo ./xdp_prog_user -d dos
0 commit comments