* @chain: chain name (chains and rules only)
* @set: set name (sets only)
* @handle: rule handle (rules only)
+ * @position: rule position (rules only)
*/
struct handle {
uint32_t family;
const char *chain;
const char *set;
uint64_t handle;
+ uint64_t position;
};
extern void handle_merge(struct handle *dst, const struct handle *src);
nlh = nft_table_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE,
nft_rule_attr_get_u32(nlr, NFT_RULE_ATTR_FAMILY),
- NLM_F_APPEND|NLM_F_ACK|NLM_F_CREATE, seq);
+ flags|NLM_F_ACK|NLM_F_CREATE, seq);
nft_rule_nlmsg_build_payload(nlh, nlr);
return mnl_talk(nf_sock, nlh, nlh->nlmsg_len, NULL, NULL);
nft_rule_attr_set_str(nlr, NFT_RULE_ATTR_CHAIN, h->chain);
if (h->handle)
nft_rule_attr_set_u64(nlr, NFT_RULE_ATTR_HANDLE, h->handle);
+ if (h->position)
+ nft_rule_attr_set_u64(nlr, NFT_RULE_ATTR_POSITION, h->position);
return nlr;
}
h.table = xstrdup(nft_rule_attr_get_str(nlr, NFT_RULE_ATTR_TABLE));
h.chain = xstrdup(nft_rule_attr_get_str(nlr, NFT_RULE_ATTR_CHAIN));
h.handle = nft_rule_attr_get_u64(nlr, NFT_RULE_ATTR_HANDLE);
+ if (nft_rule_attr_is_set(nlr, NFT_RULE_ATTR_POSITION))
+ h.position = nft_rule_attr_get_u64(nlr, NFT_RULE_ATTR_POSITION);
pctx->rule = rule_alloc(&internal_location, &h);
pctx->table = table_lookup(&h);
%token SNAT "snat"
%token DNAT "dnat"
+%token POSITION "position"
+
%type <string> identifier string
%destructor { xfree($$); } identifier string
%destructor { handle_free(&$$); } table_spec tables_spec chain_spec chain_identifier ruleid_spec
%type <handle> set_spec set_identifier
%destructor { handle_free(&$$); } set_spec set_identifier
-%type <val> handle_spec family_spec
+%type <val> handle_spec family_spec position_spec
%type <table> table_block_alloc table_block
%destructor { table_free($$); } table_block_alloc
}
;
-ruleid_spec : chain_spec handle_spec
+position_spec : /* empty */
+ {
+ $$ = 0;
+ }
+ | POSITION NUM
+ {
+ $$ = $2;
+ }
+ ;
+
+ruleid_spec : chain_spec handle_spec position_spec
{
$$ = $1;
$$.handle = $2;
+ $$.position = $3;
}
;
dst->set = xstrdup(src->set);
if (dst->handle == 0)
dst->handle = src->handle;
+ if (dst->position == 0)
+ dst->position = src->position;
}
struct set *set_alloc(const struct location *loc)
"flush" { return FLUSH; }
"rename" { return RENAME; }
+"position" { return POSITION; }
+
"counter" { return COUNTER; }
"packets" { return PACKETS; }
"bytes" { return BYTES; }