#define __NFT_OUTPUT_NOTSUPP UINT_MAX
+/* internal marker, not used by the kernel. */
+#define NFT_NEVER_TIMEOUT UINT64_MAX
+
#endif /* NFTABLES_NFTABLES_H */
}
if (expr->timeout) {
nft_print(octx, " timeout ");
- time_print(expr->timeout, octx);
+ if (expr->timeout == NFT_NEVER_TIMEOUT)
+ nft_print(octx, "never");
+ else
+ time_print(expr->timeout, octx);
}
- if (!nft_output_stateless(octx) && expr->expiration) {
+ if (!nft_output_stateless(octx) &&
+ expr->timeout != NFT_NEVER_TIMEOUT &&
+ expr->expiration) {
nft_print(octx, " expires ");
time_print(expr->expiration, octx);
}
break;
}
- if (elem->timeout)
- nftnl_set_elem_set_u64(nlse, NFTNL_SET_ELEM_TIMEOUT,
- elem->timeout);
+ if (elem->timeout) {
+ uint64_t timeout = elem->timeout;
+
+ if (elem->timeout == NFT_NEVER_TIMEOUT)
+ timeout = 0;
+
+ nftnl_set_elem_set_u64(nlse, NFTNL_SET_ELEM_TIMEOUT, timeout);
+ }
if (elem->expiration)
nftnl_set_elem_set_u64(nlse, NFTNL_SET_ELEM_EXPIRATION,
elem->expiration);
expr = set_elem_expr_alloc(&netlink_location, key);
expr->flags |= EXPR_F_KERNEL;
- if (nftnl_set_elem_is_set(nlse, NFTNL_SET_ELEM_TIMEOUT))
+ if (nftnl_set_elem_is_set(nlse, NFTNL_SET_ELEM_TIMEOUT)) {
expr->timeout = nftnl_set_elem_get_u64(nlse, NFTNL_SET_ELEM_TIMEOUT);
+ if (expr->timeout == 0)
+ expr->timeout = NFT_NEVER_TIMEOUT;
+ }
+
if (nftnl_set_elem_is_set(nlse, NFTNL_SET_ELEM_EXPIRATION))
expr->expiration = nftnl_set_elem_get_u64(nlse, NFTNL_SET_ELEM_EXPIRATION);
if (nftnl_set_elem_is_set(nlse, NFTNL_SET_ELEM_USERDATA))
%type <string> identifier type_identifier string comment_spec
%destructor { free_const($$); } identifier type_identifier string comment_spec
-%type <val> time_spec time_spec_or_num_s quota_used
+%type <val> time_spec time_spec_or_num_s set_elem_time_spec quota_used
%type <expr> data_type_expr data_type_atom_expr
%destructor { expr_free($$); } data_type_expr data_type_atom_expr
| set_elem_options set_elem_option
;
-set_elem_option : TIMEOUT time_spec
+set_elem_time_spec : STRING
+ {
+ struct error_record *erec;
+ uint64_t res;
+
+ if (!strcmp("never", $1)) {
+ free_const($1);
+ $$ = NFT_NEVER_TIMEOUT;
+ break;
+ }
+
+ erec = time_parse(&@1, $1, &res);
+ free_const($1);
+ if (erec != NULL) {
+ erec_queue(erec, state->msgs);
+ YYERROR;
+ }
+ $$ = res;
+ }
+ ;
+
+set_elem_option : TIMEOUT time_spec
{
$<expr>0->timeout = $2;
}
}
;
-set_elem_expr_option : TIMEOUT time_spec
+set_elem_expr_option : TIMEOUT set_elem_time_spec
{
$<expr>0->timeout = $2;
}