Skip to content

Commit c3e071e

Browse files
committed
packet03: Add README
This just explains what the assignments should do, and directs the student to figure out how to do it by themselves. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
1 parent 740f78d commit c3e071e

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

packet03-redirecting/README.org

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# -*- fill-column: 76; -*-
2+
#+TITLE: Tutorial: Packet03 - redirecting packets
3+
#+OPTIONS: ^:nil
4+
5+
Now that you have come this far, you know how to parse packet data, and how
6+
to modify packets. These are two of the main components of a packet
7+
processing system, but there is one additional component that is missing:
8+
How to redirect packets and transmit them back out onto the network.
9+
10+
This lesson will cover this aspect of packet processing. Unfortunately, we
11+
have not had time to complete it yet. So if you've made it this far,
12+
congratulations, you are at the end of the tutorial for now!
13+
14+
If you do feel up to a challenge, the headings below should give you a hint
15+
about what to do in this lesson; but you will have to find guidance and
16+
examples elsewhere. For instance, you could take a look at the [[https://elixir.bootlin.com/linux/latest/source/samples/bpf][examples in
17+
the kernel source tree]].
18+
19+
Bonus points for sending a pull request with extensions of this tutorial
20+
document when you're done :)
21+
22+
* Table of Contents :TOC:
23+
- [[#assignments][Assignments]]
24+
- [[#assignment-1-send-packets-back-where-they-came-from][Assignment 1: Send packets back where they came from]]
25+
- [[#assignment-2-redirect-packets-between-two-interfaces][Assignment 2: Redirect packets between two interfaces]]
26+
- [[#assignment-3-extend-to-a-bidirectional-router][Assignment 3: Extend to a bidirectional router]]
27+
- [[#assignment-4-use-the-bpf-helper-for-routing][Assignment 4: Use the BPF helper for routing]]
28+
29+
* Assignments
30+
31+
** Assignment 1: Send packets back where they came from
32+
Just swap destination and source MAC addresses, and use =XDP_TX= to send the
33+
packet back where it came from.
34+
35+
** Assignment 2: Redirect packets between two interfaces
36+
Manually setup a redirect map, perform the necessary Ethernet header
37+
rewrite, and make the packet go from one interface to another. You'll need
38+
two interfaces (i.e., two test environments) to do this.
39+
40+
** Assignment 3: Extend to a bidirectional router
41+
For this you'll need to install redirect packets on both interfaces and make
42+
packets be redirected both ways. See if you can get a ping between the two
43+
inner interfaces to work.
44+
45+
** Assignment 4: Use the BPF helper for routing
46+
After completing Assignment 3, you'll have hard-coded a redirect between two
47+
interfaces. But wouldn't it be better to dynamically lookup where each
48+
packet should go? Fortunately, the kernel already has this functionality, in
49+
the form of a routing table. There's a BPF helper that allows XDP programs
50+
to do lookups in the kernel routing table, and use this information to
51+
redirect packets. In this assignment, extend your forwarding program to use
52+
this facility for full redirection.
53+

0 commit comments

Comments
 (0)