From: Pablo Neira Ayuso Subject: [PATCH 2/2 nft] doc: nft: document log, reject, counter, meta, limit, nat and queue statements Date: Thu, 8 Sep 2016 23:12:22 +0200 Message-ID: <1473369142-21765-2-git-send-email-pablo@netfilter.org> References: <1473369142-21765-1-git-send-email-pablo@netfilter.org> To: netfilter-devel@vger.kernel.org Return-path: Received: from mail.us.es ([193.147.175.20]:44038 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754251AbcIHVMd (ORCPT ); Thu, 8 Sep 2016 17:12:33 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 681DF1E11B4 for ; Thu, 8 Sep 2016 23:12:29 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 4F0A9114D62 for ; Thu, 8 Sep 2016 23:12:29 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id CEBF0100A5F for ; Thu, 8 Sep 2016 23:12:26 +0200 (CEST) In-Reply-To: <1473369142-21765-1-git-send-email-pablo@netfilter.org> Sender: netfilter-devel-owner@vger.kernel.org List-ID: This patch adds the missing documentation for the aforementioned statements. This is based on original work from Shivani Bhardwaj. Signed-off-by: Pablo Neira Ayuso --- doc/nft.xml | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 454 insertions(+), 3 deletions(-) diff --git a/doc/nft.xml b/doc/nft.xml index e6e8583..dbb36e0 100644 --- a/doc/nft.xml +++ b/doc/nft.xml @@ -2203,36 +2203,487 @@ filter input iif eth0 drop Log statement + + log + prefix + string + level + syslog-level + + + log + group + nflog_group + prefix + string + queue-threshold + value + snaplen + size + - + + The log statement enables logging of matching packets. When this statement is used from a rule, the Linux kernel will print some information on all matching packets, such as header fields, via the kernel log (where it can be read with dmesg(1) or read in the syslog). If the group number is specified, the Linux kernel will pass the packet to nfnetlink_log which will multicast the packet through a netlink socket to the specified multicast group. One or more userspace processes may subscribe to the group to receive the packets. This is a non-terminating statement, so the rule evaluation continues after the packet is logged. + + + + log statement options + + + + + + + Keyword + Description + Type + + + + + prefix + Prefix log messages + string + + + syslog-level + Syslog level of logging + string: emerg, alert, crit, err, warn [default], notice, info, debug + + + group + NFLOG group to send messages to + unsigned integer (16 bit) + + + snaplen + Length of packet payload to include in netlink message + unsigned integer (32 bit) + + + queue-threshold + Number of packets to queue inside the kernel before sending them to userspace + unsigned integer (32 bit) + + + +
+
+ Reject statement + + reject + with + + icmp + icmp6 + icmpx + + type + + icmp_type + icmp6_type + icmpx_type + + + + reject + with + tcp + reset + + + + A reject statement is used to send back an error packet in response to the matched packet otherwise it is equivalent to drop so it is a terminating statement, ending rule traversal. This statement is only valid in the input, forward and output chains, and user-defined chains which are only called from those chains. + + reject statement (ip) + + + + + + + Keyword + Description + Type + + + + + icmp_type + ICMP response to be sent to the host + unsigned integer (8 bit), net-unreachable, host-unreachable, prot-unreachable, port-unreachable [default], net-prohibited, host-prohibited, admin-prohibited + + + +
+ + reject statement (ip6) + + + + + + + Keyword + Description + Type + + + + + icmp6_type + ICMP6 response to be sent to the host + unsigned integer (8 bit), no-route, admin-prohibited, addr-unreachable, port-unreachable [default], policy-fail, reject-route + + + +
+ + reject statement (inet) + + + + + + + Keyword + Description + Type + + + + + icmpx_type + ICMP response to be sent to the host + unsigned integer (8 bit), port-unreachable [default], admin-prohibited, no-route, host-unreachable + + + +
Counter statement + A counter statement sets the hit count of packets along with the number of bytes. + + + counter + packets + number + + bytes + number + + + + Meta statement + A meta statement sets the value of a meta expression. + The existing meta fields are: priority, mark, pkttype, nftrace. + + + meta + + mark + priority + pkttype + nftrace + + set + value + + + + A meta statement sets meta data associated with a packet. + + + + Meta statement types + + + + + + + Keyword + Description + Value + + + + + priority + TC packet priority + tc_handle + + + mark + Packet mark + mark + + + pkttype + packet type + pkt_type + + + nftrace + ruleset packet tracing on/off. Use monitor trace command to watch traces + 0, 1 + + + +
+
+ +
Limit statement + + limit + rate + over + packet_number + / + + second + minute + hour + day + + burst packet_number packets + + + limit + rate + over + byte_number + + bytes + kbytes + mbytes + + / + + second + minute + hour + day + week + + burst byte_number bytes + + + A limit statement matches at a limited rate using a token bucket filter. A rule using this statement will match until this limit is reached. It can be used in combination with the log statement to give limited logging. The over keyword, that is optional, makes it match over the specified rate. + + + limit statement values + + + + + + + Keyword + Description + Type + + + + + packet_number + Number of packets + unsigned integer (32 bit) + + + byte_number + Number of bytes + unsigned integer (32 bit) + + + +
- - NAT statement + + NAT statements + + + snat + to + + address + mapping + + :port + persistent, random, fully-random + + + dnat + to + + address + mapping + + :port + persistent, random, fully-random + + + + The nat statements are only valid from nat chain types. + + The snat statement is only valid in the postrouting and input hooks, and non-base chains which are only called from those chains. It specifies that the source address of the packet should be modified. The dnat statement is only valid in the prerouting and output chains, and non-base chains which are only called from those chains. It specifies that the destination address of the packet should be modified. All future packets in this connection will also be mangled, and rules should cease being examined. + + + + NAT statement values + + + + + + + Expression + Description + Type + + + + + address + Specifies that the source/destination address of the packet should be modified + ipv4_addr, ipv6_addr, eg. abcd::1234 + + + port + Specifies that the source/destination address of the packet should be modified + port number (16 bits) + + + mapping + Specifies a list of tuples that relates any arbitrary expression key with address value + mapping expression, eg. meta mark map { 10 : 192.168.1.2, 20 : 192.168.1.3 } + + + +
+ + NAT statement flags + + + + + + Flag + Description + + + + + persistent + Gives a client the same source-/destination-address for each connection. + + + random + If used then port mapping will be randomized using a random seeded MD5 hash mix using source and destination address and destination port. + + + fully-random + If used then port mapping is generated based on a 32-bit pseudo-random algorithm suitable for simulation. + + + +
+
Queue statement + This statement passes the packet to userspace using the nfnetlink_queue handler. The packet is put into the queue identified by its 16-bit queue number. Userspace can inspect and modify the packet if desired. Userspace must then drop or reinject the packet into the kernel. Please see libnetfilter_queue documentation for details. + + + + queue + num + queue_number + bypass + + + queue + num + queue_number_from - queue_number_to + bypass,fanout + + + + + queue statement values + + + + + + + Value + Description + Type + + + + + queue_number + Sets queue number, default is 0. + unsigned integer (16 bit) + + + queue_number_from + Sets initial queue in the range if fanout is used. + unsigned integer (16 bit) + + + queue_number_to + Sets closing queue in the range if fanout is used. + unsigned integer (16 bit) + + + +
+ + queue statement flags + + + + + + Flag + Description + + + + + bypass + Let packets go through is userspace application cannot back off. Before using this flag, read libnetfilter_queue documentation for performance tuning recomendations. + + + fanout + Distribute packets between several queues. + + + +
-- 2.1.4