From 864a1b44e1937a42753648644a812f70f9500a73 Mon Sep 17 00:00:00 2001 From: Manuel Messner Date: Tue, 7 Feb 2017 03:14:12 +0100 Subject: src: add TCP option matching This patch enables nft to match against TCP options. Currently these TCP options are supported: * End of Option List (eol) * No-Operation (noop) * Maximum Segment Size (maxseg) * Window Scale (window) * SACK Permitted (sack_permitted) * SACK (sack) * Timestamps (timestamp) Syntax: tcp options $option_name [$offset] $field_name Example: # count all incoming packets with a specific maximum segment size `x` # nft add rule filter input tcp option maxseg size x counter # count all incoming packets with a SACK TCP option where the third # (counted from zero) left field is greater `x`. # nft add rule filter input tcp option sack 2 left \> x counter If the offset (the `2` in the example above) is zero, it can optionally be omitted. For all non-SACK TCP options it is always zero, thus can be left out. Option names and field names are parsed from templates, similar to meta and ct options rather than via keywords to prevent adding more keywords than necessary. Signed-off-by: Manuel Messner Signed-off-by: Florian Westphal --- doc/nft.xml | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 173 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/nft.xml b/doc/nft.xml index be729a89..28258104 100644 --- a/doc/nft.xml +++ b/doc/nft.xml @@ -2363,14 +2363,182 @@ inet filter meta nfproto ipv6 output rt nexthop fd00::1 - - - bla - IPv6 extension header expressions + Extension header expressions + + Extension header expressions refer to data from variable-sized protocol headers, such as IPv6 extension headers and + TCPs options. + + + nftables currently supports matching (finding) a given ipv6 extension header or TCP option. + + + hbh + + nexthdr + hdrlength + + + + frag + + nexthdr + frag-off + more-fragments + id + + + + + rt + + nexthdr + hdrlength + type + seg-left + + + + dst + + nexthdr + hdrlength + + + + mh + + nexthdr + hdrlength + checksum + type + + + + tcp option + + eol + noop + maxseg + window + sack_permitted + sack + timestamp + + offset + tcp_option_field + + + + IPv6 extension headers + + + + + + Keyword + Description + + + + + hbh + Hop by Hop + + + rt + Routing Header + + + frag + Fragmentation header + + + dst + dst options + + + mh + Mobility Header + + + +
+ + + TCP Options + + + + + + + Keyword + Description + TCP option fields + + + + + eol + End of option list + kind + + + noop + 1 Byte TCP No-op options + kind + + + maxseg + TCP Maximum Segment Size + kind, length, size + + + window + TCP Window Scaling + kind, length, count + + + sack_permitted + TCP SACK permitted + kind, length + + + sack + TCP Selective Acknowledgement + kind, length, left, right + + + timestamp + TCP Timestamps + kind, length, tsval, tsecr + + + +
+
+ + + The offset is only used for the SACK TCP option fields left and right. + For all non-SACK TCP options it is always zero. + Offsets which equals to zero can be omitted. + + - IPv6 extension header expressions refer to data from an IPv6 packet's extension headers. + + finding TCP options + +filter input tcp option sack_permitted kind 1 counter + + + + matching IPv6 exthdr + +ip6 filter input frag more-fragments 1 counter + +
-- cgit v1.2.3