parser: fix typo
PATCH 1/2 parser: fix typo
Separator was misspelled as "seperator" in a symbol name.
--- src/parser_bison.y | 74 +++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 37 deletions(-)
src/parser_bison.y +37 -37
@@ -699,7 +699,7 @@ input : /* empty */ } ; -stmt_seperator : NEWLINE +stmt_separator : NEWLINE | SEMICOLON ;
@@ -707,7 +707,7 @@ opt_newline : NEWLINE | /* empty */ ; -common_block : INCLUDE QUOTED_STRING stmt_seperator +common_block : INCLUDE QUOTED_STRING stmt_separator { if (scanner_include_file(scanner, $2, &@$) < 0) { xfree($2);
@@ -715,7 +715,7 @@ common_block : INCLUDE QUOTED_STRING stmt_seperator } xfree($2); } - | DEFINE identifier '=' initializer_expr stmt_seperator + | DEFINE identifier '=' initializer_expr stmt_separator { struct scope *scope = current_scope(state);
@@ -728,7 +728,7 @@ common_block : INCLUDE QUOTED_STRING stmt_seperator symbol_bind(scope, $2, $4); xfree($2); } - | error stmt_seperator + | error stmt_separator { if (++state->nerrs == max_errors) YYABORT;
@@ -737,8 +737,8 @@ common_block : INCLUDE QUOTED_STRING stmt_seperator ; line : common_block { $$ = NULL; } - | stmt_seperator { $$ = NULL; } - | base_cmd stmt_seperator { $$ = $1; } + | stmt_separator { $$ = NULL; } + | base_cmd stmt_separator { $$ = $1; } | base_cmd TOKEN_EOF { /*
@@ -851,7 +851,7 @@ add_cmd : TABLE table_spec { $$ = cmd_alloc(CMD_ADD, CMD_OBJ_QUOTA, &$2, &@$, $3); } - | CT STRING obj_spec ct_obj_alloc '{' ct_block '}' stmt_seperator + | CT STRING obj_spec ct_obj_alloc '{' ct_block '}' stmt_separator { struct error_record *erec; int type;
@@ -930,7 +930,7 @@ create_cmd : TABLE table_spec { $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_QUOTA, &$2, &@$, $3); } - | CT STRING obj_spec ct_obj_alloc '{' ct_block '}' stmt_seperator + | CT STRING obj_spec ct_obj_alloc '{' ct_block '}' stmt_separator { struct error_record *erec; int type;
@@ -1238,11 +1238,11 @@ table_options : FLAGS STRING table_block : /* empty */ { $$ = $<table>-1; } | table_block common_block - | table_block stmt_seperator - | table_block table_options stmt_seperator + | table_block stmt_separator + | table_block table_options stmt_separator | table_block CHAIN chain_identifier chain_block_alloc '{' chain_block '}' - stmt_seperator + stmt_separator { $4->location = @3; handle_merge(&$4->handle, &$3);
@@ -1253,7 +1253,7 @@ table_block : /* empty */ { $$ = $<table>-1; } } | table_block SET set_identifier set_block_alloc '{' set_block '}' - stmt_seperator + stmt_separator { $4->location = @3; handle_merge(&$4->handle, &$3);
@@ -1263,7 +1263,7 @@ table_block : /* empty */ { $$ = $<table>-1; } } | table_block MAP set_identifier map_block_alloc '{' map_block '}' - stmt_seperator + stmt_separator { $4->location = @3; handle_merge(&$4->handle, &$3);
@@ -1273,7 +1273,7 @@ table_block : /* empty */ { $$ = $<table>-1; } } | table_block COUNTER obj_identifier obj_block_alloc '{' counter_block '}' - stmt_seperator + stmt_separator { $4->location = @3; $4->type = NFT_OBJECT_COUNTER;
@@ -1284,7 +1284,7 @@ table_block : /* empty */ { $$ = $<table>-1; } } | table_block QUOTA obj_identifier obj_block_alloc '{' quota_block '}' - stmt_seperator + stmt_separator { $4->location = @3; $4->type = NFT_OBJECT_QUOTA;
@@ -1293,7 +1293,7 @@ table_block : /* empty */ { $$ = $<table>-1; } list_add_tail(&$4->list, &$1->objs); $$ = $1; } - | table_block CT ct_obj_kind obj_identifier obj_block_alloc '{' ct_block '}' stmt_seperator + | table_block CT ct_obj_kind obj_identifier obj_block_alloc '{' ct_block '}' stmt_separator { struct error_record *erec; int type;
@@ -1322,10 +1322,10 @@ chain_block_alloc : /* empty */ chain_block : /* empty */ { $$ = $<chain>-1; } | chain_block common_block - | chain_block stmt_seperator - | chain_block hook_spec stmt_seperator - | chain_block policy_spec stmt_seperator - | chain_block rule stmt_seperator + | chain_block stmt_separator + | chain_block hook_spec stmt_separator + | chain_block policy_spec stmt_separator + | chain_block rule stmt_separator { list_add_tail(&$2->list, &$1->rules); $$ = $1;
@@ -1340,23 +1340,23 @@ set_block_alloc : /* empty */ set_block : /* empty */ { $$ = $<set>-1; } | set_block common_block - | set_block stmt_seperator - | set_block TYPE data_type stmt_seperator + | set_block stmt_separator + | set_block TYPE data_type stmt_separator { $1->keytype = $3; $$ = $1; } - | set_block FLAGS set_flag_list stmt_seperator + | set_block FLAGS set_flag_list stmt_separator { $1->flags = $3; $$ = $1; } - | set_block TIMEOUT time_spec stmt_seperator + | set_block TIMEOUT time_spec stmt_separator { $1->timeout = $3 * 1000; $$ = $1; } - | set_block GC_INTERVAL time_spec stmt_seperator + | set_block GC_INTERVAL time_spec stmt_separator { $1->gc_int = $3 * 1000; $$ = $1;
@@ -1366,7 +1366,7 @@ set_block : /* empty */ { $$ = $<set>-1; } $1->init = $4; $$ = $1; } - | set_block set_mechanism stmt_seperator + | set_block set_mechanism stmt_separator ; set_block_expr : set_expr
@@ -1393,10 +1393,10 @@ map_block_alloc : /* empty */ map_block : /* empty */ { $$ = $<set>-1; } | map_block common_block - | map_block stmt_seperator + | map_block stmt_separator | map_block TYPE data_type COLON data_type - stmt_seperator + stmt_separator { $1->keytype = $3; $1->datatype = $5;
@@ -1405,7 +1405,7 @@ map_block : /* empty */ { $$ = $<set>-1; } } | map_block TYPE data_type COLON COUNTER - stmt_seperator + stmt_separator { $1->keytype = $3; $1->objtype = NFT_OBJECT_COUNTER;
@@ -1414,14 +1414,14 @@ map_block : /* empty */ { $$ = $<set>-1; } } | map_block TYPE data_type COLON QUOTA - stmt_seperator + stmt_separator { $1->keytype = $3; $1->objtype = NFT_OBJECT_QUOTA; $1->flags |= NFT_SET_OBJECT; $$ = $1; } - | map_block FLAGS set_flag_list stmt_seperator + | map_block FLAGS set_flag_list stmt_separator { $1->flags |= $3; $$ = $1;
@@ -1431,7 +1431,7 @@ map_block : /* empty */ { $$ = $<set>-1; } $1->init = $4; $$ = $1; } - | map_block set_mechanism stmt_seperator + | map_block set_mechanism stmt_separator ; set_mechanism : POLICY set_policy_spec
@@ -1489,7 +1489,7 @@ obj_block_alloc : /* empty */ counter_block : /* empty */ { $$ = $<obj>-1; } | counter_block common_block - | counter_block stmt_seperator + | counter_block stmt_separator | counter_block counter_config { $1->counter = *$2;
@@ -1499,7 +1499,7 @@ counter_block : /* empty */ { $$ = $<obj>-1; } quota_block : /* empty */ { $$ = $<obj>-1; } | quota_block common_block - | quota_block stmt_seperator + | quota_block stmt_separator | quota_block quota_config { $1->quota = *$2;
@@ -1509,7 +1509,7 @@ quota_block : /* empty */ { $$ = $<obj>-1; } ct_block : /* empty */ { $$ = $<obj>-1; } | ct_block common_block - | ct_block stmt_seperator + | ct_block stmt_separator | ct_block ct_config { $$ = $1;
@@ -2717,7 +2717,7 @@ ct_l4protoname : TCP { $$ = IPPROTO_TCP; } | UDP { $$ = IPPROTO_UDP; } ; -ct_config : TYPE QUOTED_STRING PROTOCOL ct_l4protoname stmt_seperator +ct_config : TYPE QUOTED_STRING PROTOCOL ct_l4protoname stmt_separator { struct ct_helper *ct; int ret;
@@ -2732,7 +2732,7 @@ ct_config : TYPE QUOTED_STRING PROTOCOL ct_l4protoname stmt_seperator ct->l4proto = $4; } - | L3PROTOCOL family_spec_explicit stmt_seperator + | L3PROTOCOL family_spec_explicit stmt_separator { $<obj>0->ct_helper.l3proto = $2; }
Signature · 1 line
2.14.1
PATCH 2/2 src: limit stateful object support
This patch adds support for a new type of stateful object: limit. Creation, deletion and listing operations are supported.
--- include/linux/netfilter/nf_tables.h | 3 +- include/rule.h | 13 +++++ include/statement.h | 1 + src/evaluate.c | 5 ++ src/netlink.c | 19 +++++++ src/parser_bison.y | 101 ++++++++++++++++++++++++++++++++++-- src/rule.c | 43 ++++++++++++++- src/scanner.l | 1 + src/statement.c | 3 +- 9 files changed, 183 insertions(+), 6 deletions(-)
include/linux/netfilter/nf_tables.h +2 -1
@@ -1278,7 +1278,8 @@ enum nft_ct_helper_attributes {#define NFT_OBJECT_COUNTER 1#define NFT_OBJECT_QUOTA 2#define NFT_OBJECT_CT_HELPER 3 -#define __NFT_OBJECT_MAX 4 +#define NFT_OBJECT_LIMIT 4 +#define __NFT_OBJECT_MAX 5#define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1)/**
include/rule.h +13 -0
@@ -272,6 +272,14 @@ struct ct_helper {uint8_t l4proto; }; +struct limit { +uint64_t rate; +uint64_t unit; +uint32_t burst; +uint32_t type; +uint32_t flags; +}; +/** * struct obj - nftables stateful object statement *
@@ -291,6 +299,7 @@ struct obj {struct counter counter;struct quota quota;struct ct_helper ct_helper; +struct limit limit; }; };
@@ -357,6 +366,8 @@ enum cmd_ops {* @CMD_OBJ_COUNTERS: multiple counters * @CMD_OBJ_QUOTA: quota * @CMD_OBJ_QUOTAS: multiple quotas +* @CMD_OBJ_LIMIT: limit +* @CMD_OBJ_LIMITS: multiple limits */ enum cmd_obj {CMD_OBJ_INVALID ,
@@ -381,6 +392,8 @@ enum cmd_obj {CMD_OBJ_QUOTAS ,CMD_OBJ_CT_HELPER ,CMD_OBJ_CT_HELPERS , +CMD_OBJ_LIMIT , + CMD_OBJ_LIMITS, }; struct export {
include/statement.h +1 -0
@@ -325,5 +325,6 @@ extern void stmt_list_free(struct list_head *list);extern void stmt_print (const struct stmt *stmt,struct output_ctx *octx);const char *get_rate (uint64_t byte_rate,uint64_t *rate); +const char *get_unit (uint64_t u);#endif /* NFTABLES_STATEMENT_H */
src/evaluate.c +5 -0
@@ -2997,6 +2997,7 @@ static int cmd_evaluate_add(struct eval_ctx *ctx, struct cmd *cmd)case CMD_OBJ_COUNTER :case CMD_OBJ_QUOTA :case CMD_OBJ_CT_HELPER : +case CMD_OBJ_LIMIT :return 0 ;default :BUG ("invalid command object type %u\n" , cmd->obj);
@@ -3022,6 +3023,7 @@ static int cmd_evaluate_delete(struct eval_ctx *ctx, struct cmd *cmd)case CMD_OBJ_COUNTER :case CMD_OBJ_QUOTA :case CMD_OBJ_CT_HELPER : +case CMD_OBJ_LIMIT :return 0 ;default :BUG ("invalid command object type %u\n" , cmd->obj);
@@ -3111,9 +3113,12 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_COUNTER );case CMD_OBJ_CT_HELPER :return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_CT_HELPER ); +case CMD_OBJ_LIMIT : +return cmd_evaluate_list_obj (ctx, cmd,NFT_OBJECT_LIMIT );case CMD_OBJ_COUNTERS :case CMD_OBJ_QUOTAS :case CMD_OBJ_CT_HELPERS : +case CMD_OBJ_LIMITS :case CMD_OBJ_SETS :if (cmd->handle.table ==NULL )return 0 ;
src/netlink.c +19 -0
@@ -328,6 +328,13 @@ alloc_nftnl_obj(const struct handle *h, struct obj *obj)nftnl_obj_set_u16 (nlo,NFTNL_OBJ_CT_HELPER_L3PROTO , obj->ct_helper.l3proto);break ; +case NFT_OBJECT_LIMIT : +nftnl_obj_set_u64 (nlo,NFTNL_OBJ_LIMIT_RATE , obj->limit.rate); +nftnl_obj_set_u64 (nlo,NFTNL_OBJ_LIMIT_UNIT , obj->limit.unit); +nftnl_obj_set_u32 (nlo,NFTNL_OBJ_LIMIT_BURST , obj->limit.burst); +nftnl_obj_set_u32 (nlo,NFTNL_OBJ_LIMIT_TYPE , obj->limit.type); +nftnl_obj_set_u32 (nlo,NFTNL_OBJ_LIMIT_FLAGS , obj->limit.flags); +break ;default :BUG ("Unknown type %d\n" , obj->type);break ;
@@ -1743,6 +1750,18 @@ static struct obj *netlink_delinearize_obj(struct netlink_ctx *ctx, obj->ct_helper.l3proto =nftnl_obj_get_u16 (nlo,NFTNL_OBJ_CT_HELPER_L3PROTO ); obj->ct_helper.l4proto =nftnl_obj_get_u8 (nlo,NFTNL_OBJ_CT_HELPER_L4PROTO );break ; +case NFT_OBJECT_LIMIT : + obj->limit.rate = +nftnl_obj_get_u64 (nlo,NFTNL_OBJ_LIMIT_RATE ); + obj->limit.unit = +nftnl_obj_get_u64 (nlo,NFTNL_OBJ_LIMIT_UNIT ); + obj->limit.burst = +nftnl_obj_get_u32 (nlo,NFTNL_OBJ_LIMIT_BURST ); + obj->limit.type = +nftnl_obj_get_u32 (nlo,NFTNL_OBJ_LIMIT_TYPE ); + obj->limit.flags = +nftnl_obj_get_u32 (nlo,NFTNL_OBJ_LIMIT_FLAGS ); +break ; } obj->type = type;
src/parser_bison.y +98 -3
179 lines not on this page · raw message
src/rule.c +42 -1
89 lines not on this page · raw message
src/scanner.l +1 -0
@@ -300,6 +300,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "counters" { return COUNTERS; } "quotas" { return QUOTAS; } +"limits" { return LIMITS; } "log" { return LOG; } "prefix" { return PREFIX; }
src/statement.c +2 -1
@@ -175,6 +175,7 @@ static const char *objref_type[NFT_OBJECT_MAX + 1] = { [NFT_OBJECT_COUNTER] = "counter", [NFT_OBJECT_QUOTA] = "quota", [NFT_OBJECT_CT_HELPER] = "cthelper", + [NFT_OBJECT_LIMIT] = "limit", };static const char *objref_type_name (uint32_t type)
@@ -286,7 +287,7 @@ struct stmt *log_stmt_alloc(const struct location *loc)return stmt_alloc (loc, &log_stmt_ops); } -static const char *get_unit (uint64_t u) +const char *get_unit (uint64_t u) {switch (u) {case 1 :return "second" ;
Signature · 1 line
2.14.1
Re: [PATCH nft 2/2] src: limit stateful object support
Maybe the commit title is confusing, since "limit" seems the typical imperative mood instead of a noun.
Pablo, should I resend the patches with a better title?
Pablo Neira Ayuso
maintainerRe: [PATCH nft 2/2] src: limit stateful object support
Quoted 4 lines · Pablo M. Bermudo Garay
Maybe the commit title is confusing, since "limit" seems the typical imperative mood instead of a noun.
Pablo, should I resend the patches with a better title?
No - unless I find anything more relevant that triggers a v2 - I can mangle it here. Please tell me what title you want and I'll mangle this before applying.
Thanks.
Re: [PATCH nft 2/2] src: limit stateful object support
2017-08-23 23:51 GMT+02:00 Pablo Neira Ayuso <[email protected]>:
Quoted 11 lines · Pablo M. Bermudo Garay
Quoted 4 lines
Maybe the commit title is confusing, since "limit" seems the typical imperative mood instead of a noun.
Pablo, should I resend the patches with a better title?
No - unless I find anything more relevant that triggers a v2 - I can mangle it here. Please tell me what title you want and I'll mangle this before applying.
Thanks.
I think that something like "src: add stateful object support for limit" is fine for both libnftnl and nft commits.
Thanks.
Quoted 1 line · Pablo M. Bermudo Garay
Separator was misspelled as "seperator" in a symbol name.
Applied this one, thanks!