Skip to content

Commit 8327377

Browse files
committed
packet-solutions: update the README.org
Update the README.org with links to solutions for all assignments in packet-* lessons. Some solutions point to the common/ directory, some to the packet-solutions directory. Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
1 parent 2874eb7 commit 8327377

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

packet-solutions/README.org

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,71 @@ This directory contains solutions to all the assignments in the
66
[[file:../packet01-parsing/][packet01]],
77
[[file:../packet02-rewriting/][packet02]], and
88
[[file:../packet03-redirecting/][packet03]] lessons.
9+
10+
* Table of Contents :TOC:
11+
- [[#solutions][Solutions]]
12+
- [[#packet01-packet-parsing][Packet01: packet parsing]]
13+
- [[#packet02-packet-rewriting][Packet02: packet rewriting]]
14+
- [[#packet03-redirecting-packets][Packet03: redirecting packets]]
15+
16+
* Solutions
17+
18+
** Packet01: packet parsing
19+
20+
*** Assignment 1: Fix the bounds checking error
21+
22+
See the =parse_ethhdr= function from the [[file:../common/parsing_helpers.h][parsing_helpers.h]] file.
23+
24+
*** Assignment 2: Parsing the IP header
25+
26+
See the =parse_ip6hdr= function from the [[file:../common/parsing_helpers.h][parsing_helpers.h]] file.
27+
28+
*** Assignment 3: Parsing the ICMPv6 header and reacting to it
29+
30+
See the =parse_icmp6hdr= function from the [[file:../common/parsing_helpers.h][parsing_helpers.h]]
31+
file. The sequence number should be accessed as =bpf_ntohs(icmp6h->icmp6_sequence)=
32+
as it is a 2-byte value in the network order.
33+
34+
*** Assignment 4: Adding VLAN support
35+
36+
See the =parse_ethhdr= function from the [[file:../common/parsing_helpers.h][parsing_helpers.h]] file.
37+
38+
*** Assignment 5: Adding IPv4 support
39+
40+
See the =parse_iphdr= and =parse_icmphdr= functions from the [[file:../common/parsing_helpers.h][parsing_helpers.h]] file.
41+
42+
** Packet02: packet rewriting
43+
44+
*** Assignment 1: Rewrite port numbers
45+
46+
An example XDP program can be found in the =xdp_patch_ports= section in the [[file:xdp_prog_kern_02.c][xdp_prog_kern_02.c]] file. The program will decrease by one destination port number in any TCP or UDP packet.
47+
48+
*** Assignment 2: Remove the outermost VLAN tag
49+
50+
See the =vlan_tag_pop= function from the [[file:../common/rewrite_helpers.h][rewrite_helpers.h]] file.
51+
An example XDP program can be found in the =xdp_vlan_swap= section in the [[file:xdp_prog_kern_02.c][xdp_prog_kern_02.c]] file.
52+
53+
*** Assignment 3: Add back a missing VLAN tag
54+
55+
See the =vlan_tag_push= function from the [[file:../common/rewrite_helpers.h][rewrite_helpers.h]] file.
56+
An example XDP program can be found in the =xdp_vlan_swap= section in the [[file:xdp_prog_kern_02.c][xdp_prog_kern_02.c]] file.
57+
58+
** Packet03: redirecting packets
59+
60+
*** Assignment 1: Send packets back where they came from
61+
62+
See the =xdp_icmp_echo= program in the [[file:xdp_prog_kern_03.c][xdp_prog_kern_03.c]] file.
63+
64+
*** Assignment 2: Redirect packets between two interfaces
65+
66+
See the =xdp_redirect= program in the [[file:xdp_prog_kern_03.c][xdp_prog_kern_03.c]] file.
67+
68+
*** Assignment 3: Extend to a bidirectional router
69+
70+
See the =xdp_redirect_map= program in the [[file:xdp_prog_kern_03.c][xdp_prog_kern_03.c]] file.
71+
Userspace part of the assignment is implemented in the [[file:xdp_prog_user.c][xdp_prog_user.c]] file.
72+
73+
*** Assignment 4: Use the BPF helper for routing
74+
75+
See the =xdp_router= program in the [[file:xdp_prog_kern_03.c][xdp_prog_kern_03.c]] file.
76+
Userspace part of the assignment is implemented in the [[file:xdp_prog_user.c][xdp_prog_user.c]] file.

0 commit comments

Comments
 (0)