History

netfilter: nftables: add catch-all set element support

This patch extends the set infrastructure to add a special catch-all set element. If the lookup fails to find an element (or range) in the set, then the catch-all element is selected. Users can specify a mapping, expression(s) and timeout to be attached to the catch-all element. This patch adds a catchall list to the set, this list might contain more than one single catch-all element (e.g. in case that the catch-all element is removed and a new one is added in the same transaction). However, most of the time, there will be either one element or no elements at all in this list. The catch-all element is identified via NFT_SET_ELEM_CATCHALL flag and such special element has no NFTA_SET_ELEM_KEY attribute. There is a new nft_set_elem_catchall object that stores a reference to the dummy catch-all element (catchall->elem) whose layout is the same of the set element type to reuse the existing set element codebase. The set size does not apply to the catch-all element, users can define a catch-all element even if the set is full. The check for valid set element flags hava been updates to report EOPNOTSUPP in case userspace requests flags that are not supported when using new userspace nftables and old kernel.

Pablo Neira Ayuso committed 5 years ago

Commit aaa31041 parent 97c976d8 files · +465 −63Browse files

Showing the changes to include/uapi (1 of 8 files). Show all

Unified · Split

include/uapi/linux/netfilter/nf_tables.h+2−0
@@ -398,9 +398,11 @@ enum nft_set_attributes { · 397 unmodified lines
398 * enum nft_set_elem_flags - nf_tables set element flags398 * enum nft_set_elem_flags - nf_tables set element flags
399 *399 *
400 * @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval400 * @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval
401 * @NFT_SET_ELEM_CATCHALL: special catch-all element
401 */402 */
402enum nft_set_elem_flags {403enum nft_set_elem_flags {
403 NFT_SET_ELEM_INTERVAL_END = 0x1,404 NFT_SET_ELEM_INTERVAL_END = 0x1,
405 NFT_SET_ELEM_CATCHALL = 0x2,
404};406};
405 407
406/**408/**