Track and print rule source in drop prints
[flowspec-xdp] / README.md
1 FlowSpec -> XDP Conversion Utility
2 ==================================
3
4 This utility allows you to convert flowspec rules (exctracted from a local BIRD instance with birdc)
5 to an XDP program. It currently supports the entire flowspec grammar, however does not implement
6 community parsing to detect actions due to BIRD limitations.
7
8 `install.sh` provides a simple example script which will compile and install a generated XDP program
9 from the rules in bird's `flowspec4` and `flowspec6` routing tables. It will drop any packets which
10 match any flowspec filter.
11
12 `genrules.py` will accept birdc output on stdin and generate a rules.h file which is included in
13 xdp.c to check individual rules. The specific behavior of some less-common parsing options can be
14 controlled by parameters to `genrules.py` -
15  * --8021q can be either "drop-vlan", "accept-vlan" or "parse-vlan" to either drop all traffic with
16    a VLAN tag, accept all traffic with a VLAN tag (without comparing it against any flowspec rules),
17    or parse VLAN traffic and compare it against flowspec rules just like any other traffic.
18  * If --8021q is set to "parse-vlan", --require-8021q can be set to a specific VLAN tag, and all
19    traffic with different VLAN tags is dropped.
20  * --ihl can be set to "drop-options", "accept-options", or "parse-options" to drop all traffic with
21    extra IPv4 option fields, accept all traffic with extra IPv4 options fields (without comparing it
22    to any flowspec rules), or parse IPv4 traffic with option fields like normal.
23  * --v6frag can be set to "drop-frags","ignore","parse-frags","ignore-parse-if-rule" to:
24    * drop all IPv6 fragments,
25    * ignore IPv6 fragments, matching only the IPv6 header but no ICMP/TCP/UDP options,
26    * parse IPv6 fragments, matching ICMP/TCP/UDP options if relevant (eg often only in the first
27      fragment), or
28    * ignore IPv6 fragments as above, unless a flow6 rule specifies the "fragment" keyword, in which
29      case parse all IPv6 fragments as above for all rules.
30
31 Note that if all of the above options are set to their "drop" variant, the parsing can avoid all
32 offset calculation, using static offsets for all fields.
33
34 Drop counts are tracked in XDP per-CPU arrays, and can be viewed with `dropcount.sh`.