netfilter: nft_log: group is u16, snaplen u32
Subsystems (2)
Florian Westphal
maintainerPATCH 1/3 netfilter: nft_log: group is u16, snaplen u32
0edecbe17ae (netfilter: nft_log: group and qthreshold are 2^16) made the correct changes except in the nla_policy where it changed snaplen instead of group attibute.
--- net/netfilter/nft_log.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_log.c +2 -2
@@ -37,9 +37,9 @@ static void nft_log_eval(const struct nft_expr *expr, }static const struct nla_policy nft_log_policy[NFTA_LOG_MAX +1 ] = { - [NFTA_LOG_GROUP ] = { .type =NLA_U32 }, + [NFTA_LOG_GROUP ] = { .type =NLA_U16 }, [NFTA_LOG_PREFIX ] = { .type =NLA_STRING }, - [NFTA_LOG_SNAPLEN ] = { .type =NLA_U16 }, + [NFTA_LOG_SNAPLEN ] = { .type =NLA_U32 }, [NFTA_LOG_QTHRESHOLD ] = { .type =NLA_U16 }, };
Signature · 1 line
1.7.8.6
Florian Westphal
maintainerPATCH 2/3 expr: log: use real length when fetching attributes
NFTA_LOG_SNAPLEN is u32 and NFTA_LOG_QTHRESHOLD is u16. Without this, netlink messages from kernel fail mnl_validate step when QTHRESH or SNAPLEN was set.
Also, nft_rule_expr_log_get must update data_length, else 'nft list' doesn't show log arguments (prefix, group ..) because the netlink message decoding uses nft_rule_expr_get_u16/32 etc. which validate the length, too.
--- src/expr/log.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
src/expr/log.c +6 -2
@@ -64,12 +64,16 @@ nft_rule_expr_log_get(const struct nft_rule_expr *e, uint16_t type,switch (type) {case NFT_EXPR_LOG_PREFIX : + *data_len =strlen (log->prefix)+1 ;return log->prefix;case NFT_EXPR_LOG_GROUP : + *data_len =sizeof (log->group);return &log->group;case NFT_EXPR_LOG_SNAPLEN : + *data_len =sizeof (log->snaplen);return &log->snaplen;case NFT_EXPR_LOG_QTHRESHOLD : + *data_len =sizeof (log->qthreshold);return &log->qthreshold; }return NULL ;
@@ -91,13 +95,13 @@ static int nft_rule_expr_log_cb(const struct nlattr *attr, void *data) }break ;case NFTA_LOG_GROUP : -case NFTA_LOG_SNAPLEN : +case NFTA_LOG_QTHRESHOLD :if (mnl_attr_validate (attr,MNL_TYPE_U16 ) <0 ) {perror ("mnl_attr_validate" );return MNL_CB_ERROR ; }break ; -case NFTA_LOG_QTHRESHOLD : +case NFTA_LOG_SNAPLEN :if (mnl_attr_validate (attr,MNL_TYPE_U32 ) <0 ) {perror ("mnl_attr_validate" );return MNL_CB_ERROR ;
Signature · 1 line
1.7.8.6
Pablo Neira Ayuso
maintainerRe: [PATCH libnftables 2/3] expr: log: use real length when fetching attributes
Quoted 7 lines · Florian Westphal
NFTA_LOG_SNAPLENis u32 andNFTA_LOG_QTHRESHOLDis u16. Without this, netlink messages from kernel failmnl_validatestep when QTHRESH or SNAPLEN was set.Also,
nft_rule_expr_log_getmust updatedata_length, else 'nft list' doesn't show log arguments (prefix, group ..) because the netlink message decoding uses nft_rule_expr_get_u16/32 etc. which validate the length, too.
Also applied, thanks.
Florian Westphal
maintainerPATCH 3/3 log: s/threshold/queue-threshold/
In reply to Florian Westphalon input we expect "queue-threshold" token, so use the same name when printing the output.
--- src/statement.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
src/statement.c +1 -1
@@ -122,7 +122,7 @@ static void log_stmt_print(const struct stmt *stmt)if (stmt->log.snaplen)printf (" snaplen %u" , stmt->log.snaplen);if (stmt->log.qthreshold) -printf (" threshold %u" , stmt->log.qthreshold); +printf (" queue-threshold %u" , stmt->log.qthreshold); }static void log_stmt_destroy (struct stmt *stmt)
Signature · 1 line
1.7.8.6
Re: [PATCH nftables 3/3] log: s/threshold/queue-threshold/
Quoted 2 lines · Florian Westphal
on input we expect "queue-threshold" token, so use the same name when printing the output.
Applied, thanks.
Quoted 3 lines · Florian Westphal
0edecbe17ae(netfilter:nft_log: group and qthreshold are 2^16) made the correct changes except in thenla_policywhere it changed snaplen instead of group attibute.
Applied, thanks Florian.