History

netfilter: nf_tables: zero timeout means element never times out

This patch uses zero as timeout marker for those elements that never expire when the element is created. If userspace provides no timeout for an element, then the default set timeout applies. However, if no default set timeout is specified and timeout flag is set on, then timeout extension is allocated and timeout is set to zero to allow for future updates. Use of zero a never timeout marker has been suggested by Phil Sutter. Note that, in older kernels, it is already possible to define elements that never expire by declaring a set with the set timeout flag set on and no global set timeout, in this case, new element with no explicit timeout never expire do not allocate the timeout extension, hence, they never expire. This approach makes it complicated to accomodate element timeout update, because element extensions do not support reallocations. Therefore, allocate the timeout extension and use the new marker for this case, but do not expose it to userspace to retain backward compatibility in the set listing.

Pablo Neira Ayuso committed 2 years ago

Commit 8bfb74a1 parent 4c5daea4 files · +31 −20Browse files

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

Unified · Split

include/uapi/linux/netfilter/nf_tables.h+1−1
@@ -436,7 +436,7 @@ enum nft_set_elem_flags { · 435 unmodified lines
436 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)436 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)
437 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)437 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)
438 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32)438 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32)
439 * @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64)439 * @NFTA_SET_ELEM_TIMEOUT: timeout value, zero means never times out (NLA_U64)
440 * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64)440 * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64)
441 * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY)441 * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY)
442 * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)442 * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)