netfilter: nf_tables: consolidate timeout extension for elements
Expiration and timeout are stored in separated set element extensions, but they are tightly coupled. Consolidate them in a single extension to simplify and prepare for set element updates. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
@@ -687,7 +687,6 @@ void nf_tables_destroy_set(const struct nft_ctx *ctx, struct nft_set *set);
|
||||
* @NFT_SET_EXT_DATA: mapping data
|
||||
* @NFT_SET_EXT_FLAGS: element flags
|
||||
* @NFT_SET_EXT_TIMEOUT: element timeout
|
||||
* @NFT_SET_EXT_EXPIRATION: element expiration time
|
||||
* @NFT_SET_EXT_USERDATA: user data associated with the element
|
||||
* @NFT_SET_EXT_EXPRESSIONS: expressions associated with the element
|
||||
* @NFT_SET_EXT_OBJREF: stateful object reference associated with element
|
||||
@@ -699,7 +698,6 @@ enum nft_set_extensions {
|
||||
NFT_SET_EXT_DATA,
|
||||
NFT_SET_EXT_FLAGS,
|
||||
NFT_SET_EXT_TIMEOUT,
|
||||
NFT_SET_EXT_EXPIRATION,
|
||||
NFT_SET_EXT_USERDATA,
|
||||
NFT_SET_EXT_EXPRESSIONS,
|
||||
NFT_SET_EXT_OBJREF,
|
||||
@@ -811,16 +809,16 @@ static inline u8 *nft_set_ext_flags(const struct nft_set_ext *ext)
|
||||
return nft_set_ext(ext, NFT_SET_EXT_FLAGS);
|
||||
}
|
||||
|
||||
static inline u64 *nft_set_ext_timeout(const struct nft_set_ext *ext)
|
||||
struct nft_timeout {
|
||||
u64 timeout;
|
||||
u64 expiration;
|
||||
};
|
||||
|
||||
static inline struct nft_timeout *nft_set_ext_timeout(const struct nft_set_ext *ext)
|
||||
{
|
||||
return nft_set_ext(ext, NFT_SET_EXT_TIMEOUT);
|
||||
}
|
||||
|
||||
static inline u64 *nft_set_ext_expiration(const struct nft_set_ext *ext)
|
||||
{
|
||||
return nft_set_ext(ext, NFT_SET_EXT_EXPIRATION);
|
||||
}
|
||||
|
||||
static inline struct nft_userdata *nft_set_ext_userdata(const struct nft_set_ext *ext)
|
||||
{
|
||||
return nft_set_ext(ext, NFT_SET_EXT_USERDATA);
|
||||
@@ -834,8 +832,8 @@ static inline struct nft_set_elem_expr *nft_set_ext_expr(const struct nft_set_ex
|
||||
static inline bool __nft_set_elem_expired(const struct nft_set_ext *ext,
|
||||
u64 tstamp)
|
||||
{
|
||||
return nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION) &&
|
||||
time_after_eq64(tstamp, READ_ONCE(*nft_set_ext_expiration(ext)));
|
||||
return nft_set_ext_exists(ext, NFT_SET_EXT_TIMEOUT) &&
|
||||
time_after_eq64(tstamp, READ_ONCE(nft_set_ext_timeout(ext)->expiration));
|
||||
}
|
||||
|
||||
static inline bool nft_set_elem_expired(const struct nft_set_ext *ext)
|
||||
|
||||
Reference in New Issue
Block a user