small fixes
cover small fixes
Hi,
Here's three small patches which fix some issue with the examples provided in the code.
BR,
--
Eric
PATCH 1/3 examples: delete payload code in nft-chain-add
'make check' was not working due to the fact that 'libnftables/payload.h' was not present. As the payload related code was commented, the "I've got an axe" solution was to remove all payload related code. This is done in this patch.
--- examples/nft-rule-add.c | 25 ------------------------- 1 file changed, 25 deletions(-)
examples/nft-rule-add.c +0 -25
@@ -21,7 +21,6 @@#include <libmnl/libmnl.h> #include <libnftables/rule.h> #include <libnftables/expr.h> -#include <libnftables/payload.h> #include <linux/netfilter_ipv4/ipt_LOG.h> #include <linux/netfilter/xt_iprange.h>
@@ -93,29 +92,6 @@ static void add_expr_match(struct nft_rule *r)#define field_sizeof (t, f) (sizeof(((t *)NULL)->f)) -static void add_payload2 (struct nft_rule_expr *e) -{ -nft_rule_expr_set_u32 (e,NFT_EXPR_PAYLOAD_BASE , -NFT_PAYLOAD_NETWORK_HEADER ); -nft_rule_expr_set_u32 (e,NFT_EXPR_PAYLOAD_DREG ,NFT_REG_1 ); -nft_rule_expr_set_u32 (e,NFT_EXPR_PAYLOAD_OFFSET , - offsetof(struct iphdr , protocol)); -nft_rule_expr_set_u32 (e,NFT_EXPR_PAYLOAD_LEN ,1 ); -} - -static void add_payload (struct nft_rule *r) -{ -struct nft_rule_expr *expr; - - expr =nft_rule_expr_alloc ("payload" ); -if (expr ==NULL ) -return ; - -add_payload2 (expr); - -nft_rule_add_expr (r, expr); -} -int main (int argc,char *argv[]) {struct mnl_socket *nl;
@@ -153,7 +129,6 @@ int main(int argc, char *argv[])add_expr_match (r);add_expr_target (r); -// add_payload(r); char tmp[1024 ];nft_rule_snprintf (tmp,sizeof (tmp), r,0 ,0 );
Signature · 1 line
1.7.10.4
PATCH 2/3 nft-events: add newline to output
In reply to Eric LeblondThis patch adds a new line to messages to be sure that they are printed to the shell as soon as they occur. This also fixes the display of output.
--- examples/nft-events.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
examples/nft-events.c +3 -3
@@ -39,7 +39,7 @@ static int table_cb(const struct nlmsghdr *nlh, int type) }nft_table_snprintf (buf,sizeof (buf), t,NFT_TABLE_O_DEFAULT ,0 ); -printf ("[%s]\t%s" , type ==NFT_MSG_NEWTABLE ?"NEW" :"DEL" , buf); +printf ("[%s]\t%s\n" , type ==NFT_MSG_NEWTABLE ?"NEW" :"DEL" , buf); err_free:nft_table_free (t);
@@ -64,7 +64,7 @@ static int rule_cb(const struct nlmsghdr *nlh, int type) }nft_rule_snprintf (buf,sizeof (buf), t,NFT_RULE_O_DEFAULT ,0 ); -printf ("[%s]\t%s" , type ==NFT_MSG_NEWRULE ?"NEW" :"DEL" , buf); +printf ("[%s]\t%s\n" , type ==NFT_MSG_NEWRULE ?"NEW" :"DEL" , buf); err_free:nft_rule_free (t);
@@ -89,7 +89,7 @@ static int chain_cb(const struct nlmsghdr *nlh, int type) }nft_chain_snprintf (buf,sizeof (buf), t,NFT_CHAIN_O_DEFAULT ,0 ); -printf ("[%s]\t%s" , type ==NFT_MSG_NEWCHAIN ?"NEW" :"DEL" , buf); +printf ("[%s]\t%s\n" , type ==NFT_MSG_NEWCHAIN ?"NEW" :"DEL" , buf); err_free:nft_chain_free (t);
Signature · 1 line
1.7.10.4
PATCH 3/3 expr: fix display of dreg expression
In reply to Eric Leblond--- src/expr/immediate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/expr/immediate.c +1 -1
@@ -335,7 +335,7 @@ nft_rule_expr_immediate_snprintf_default(char *buf, size_t len,int size = len, offset =0 , ret;struct nft_expr_immediate *imm = (struct nft_expr_immediate *)e->data; - ret =snprintf (buf, len,"dreg=%u" , imm->dreg); + ret =snprintf (buf, len,"dreg=%u " , imm->dreg);SNPRINTF_BUFFER_SIZE (ret, size, len, offset);if (e->flags & (1 <<NFT_EXPR_IMM_DATA )) {
Signature · 1 line
1.7.10.4
2013/6/4 Eric Leblond <[email protected]>:
Quoted 6 lines
Hi,
Here's three small patches which fix some issue with the examples provided in the code.
Hi Eric,
I also saw that issues. Thanks.
Regards.
--
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso
maintainerRe: [libnftables PATCH 1/3] examples: delete payload code in nft-chain-add
In reply to Eric LeblondQuoted 2 lines · Eric Leblond
'make check' was not working due to the fact that
'libnftables/payload.h' was not present.
Oops, that file was dead lying on my filesystem, applied a fix for this.
Quoted 3 lines
As the payload related code was commented, the "I've got an axe" solution was to remove all payload related code. This is done in this patch.
I prefered to keep the payload example, so apply a different fix. Thanks for the spots anyway.
Re: [libnftables PATCH 2/3] nft-events: add newline to output
In reply to Eric LeblondQuoted 3 lines · Eric Leblond
This patch adds a new line to messages to be sure that they are printed to the shell as soon as they occur. This also fixes the display of output.
Applied, thanks Eric.
Pablo Neira Ayuso
maintainerRe: [libnftables PATCH 3/3] expr: fix display of dreg expression
In reply to Eric LeblondAlso applied, thanks Eric.