mnl: continue monitor if errno is ESRCH
Subsystems (2)
PATCH 1/1 mnl: continue monitor if errno is ESRCH
Running the test cases in the shell directory while running nft monitor results in nft exiting with '# ERROR: No such process'. The minimal steps where I could reproduce is:
nft monitor # shell 1run-tests.sh testcases/sets/0011add_many_elements_0 # shell 2
---
Not sure if this is considered a fix or desired behaviour, but I was not expecting monitor to exit like this.
src/mnl.c | 3 +++ 1 file changed, 3 insertions(+)
src/mnl.c +3 -0
@@ -1129,7 +1129,10 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock,printf ("# ERROR: We lost some netlink events!\n" );continue ; } +fprintf (stdout,"# ERROR: %s\n" ,strerror (errno)); +if (errno ==ESRCH ) +continue ;break ; } ret =mnl_cb_run (buf, ret,0 ,0 , cb, cb_data);
Signature · 1 line
2.9.3
Pablo Neira Ayuso
maintainerQuoted 21 lines · Alexander Alemayhu
Running the test cases in the shell directory while running nft monitor results in nft exiting with '# ERROR: No such process'. The minimal steps where I could reproduce is:
nft monitor # shell 1
run-tests.shtestcases/sets/0011add_many_elements_0 # shell 2Signed-off-by Alexander Alemayhu <[email protected]>---
Not sure if this is considered a fix or desired behaviour, but I was not expecting monitor to exit like this.
src/mnl.c | 3 +++ 1 file changed, 3 insertions(+)src/mnl.c +0
-0
src/mnl.c int mnl_nft_event_listener(struct mnl_socket *nf_sock, · line 1135
Quoted 7 lines
src/mnl.c +3
-0@@ -1129,7 +1129,10 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock,printf ("# ERROR: We lost some netlink events!\n" );continue ; } +fprintf (stdout,"# ERROR: %s\n" ,strerror (errno)); +if (errno ==ESRCH ) +continue ;
It seems netlink is returning ESRCH when the number of events is high, however, it should hit ENOBUFS instead, this is strange.
Pablo Neira Ayuso
maintainerQuoted 17 lines · Pablo Neira Ayuso
Quoted 16 lines · Alexander Alemayhu
Running the test cases in the shell directory while running nft monitor results in nft exiting with '# ERROR: No such process'. The minimal steps where I could reproduce is:
nft monitor # shell 1
run-tests.shtestcases/sets/0011add_many_elements_0 # shell 2Signed-off-by Alexander Alemayhu <[email protected]>---
Not sure if this is considered a fix or desired behaviour, but I was not expecting monitor to exit like this.
src/mnl.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 15 lines
src/mnl.c int mnl_nft_event_listener(struct mnl_socket *nf_sock, · line 1135
Quoted 12 lines
src/mnl.c +3
-0@@ -1129,7 +1129,10 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock,printf ("# ERROR: We lost some netlink events!\n" );continue ; } +fprintf (stdout,"# ERROR: %s\n" ,strerror (errno)); +if (errno ==ESRCH ) +continue ;It seems netlink is returning ESRCH when the number of events is high, however, it should hit ENOBUFS instead, this is strange.
We at least need this fix from kernelspace.
Basically, the idea is to set socket error to ENOBUFS so the event listener knows that we're losing events, this is the correct way to report this in terms of netlink semantics.
Would you give it a try?
net/netfilter/nf_tables_api.c +32 -20
@@ -486,10 +486,11 @@ static int nf_tables_table_notify(const struct nft_ctx *ctx, int event) ctx->report, GFP_KERNEL); err:if (err <0 ) { -nfnetlink_set_err (ctx->net, ctx->portid,NFNLGRP_NFTABLES , - err); +if (nfnetlink_set_err (ctx->net, ctx->portid,NFNLGRP_NFTABLES , + -ENOBUFS ) >0 ) +return -ENOBUFS ; } -return err; +return 0 ; } static int nf_tables_dump_tables(struct sk_buff *skb,
@@ -1076,10 +1077,11 @@ static int nf_tables_chain_notify(const struct nft_ctx *ctx, int event) ctx->report, GFP_KERNEL); err:if (err <0 ) { -nfnetlink_set_err (ctx->net, ctx->portid,NFNLGRP_NFTABLES , - err); +if (nfnetlink_set_err (ctx->net, ctx->portid,NFNLGRP_NFTABLES , + -ENOBUFS ) >0 ) +return -ENOBUFS ; } -return err; +return 0 ; } static int nf_tables_dump_chains(struct sk_buff *skb,
@@ -1962,10 +1964,11 @@ static int nf_tables_rule_notify(const struct nft_ctx *ctx, ctx->report, GFP_KERNEL); err:if (err <0 ) { -nfnetlink_set_err (ctx->net, ctx->portid,NFNLGRP_NFTABLES , - err); +if (nfnetlink_set_err (ctx->net, ctx->portid,NFNLGRP_NFTABLES , + -ENOBUFS ) >0 ) +return -ENOBUFS ; } -return err; +return 0 ; }struct nft_rule_dump_ctx {
@@ -2722,9 +2725,12 @@ static int nf_tables_set_notify(const struct nft_ctx *ctx, err =nfnetlink_send (skb, ctx->net, portid,NFNLGRP_NFTABLES , ctx->report, gfp_flags); err: -if (err <0 ) -nfnetlink_set_err (ctx->net, portid,NFNLGRP_NFTABLES , err); -return err; +if (err <0 ) { +if (nfnetlink_set_err (ctx->net, portid,NFNLGRP_NFTABLES , + -ENOBUFS ) >0 ) +return -ENOBUFS ; + } +return 0 ; }static int nf_tables_dump_sets (struct sk_buff *skb,struct netlink_callback *cb)
@@ -3532,9 +3538,12 @@ static int nf_tables_setelem_notify(const struct nft_ctx *ctx, err =nfnetlink_send (skb, net, portid,NFNLGRP_NFTABLES , ctx->report,GFP_KERNEL ); err: -if (err <0 ) -nfnetlink_set_err (net, portid,NFNLGRP_NFTABLES , err); -return err; +if (err <0 ) { +if (nfnetlink_set_err (net, portid,NFNLGRP_NFTABLES , + -ENOBUFS ) >0 ) +return -ENOBUFS ; + } +return 0 ; } static struct nft_trans *nft_trans_elem_alloc(struct nft_ctx *ctx,
@@ -4502,9 +4511,11 @@ int nft_obj_notify(struct net *net, struct nft_table *table, err =nfnetlink_send (skb, net, portid,NFNLGRP_NFTABLES , report, gfp); err:if (err <0 ) { -nfnetlink_set_err (net, portid,NFNLGRP_NFTABLES , err); +if (nfnetlink_set_err (net, portid,NFNLGRP_NFTABLES , + -ENOBUFS ) >0 ) +return -ENOBUFS ; } -return err; +return 0 ; }EXPORT_SYMBOL_GPL (nft_obj_notify);
@@ -4569,10 +4580,11 @@ static int nf_tables_gen_notify(struct net *net, struct sk_buff *skb, int event) NFNLGRP_NFTABLES, nlmsg_report(nlh), GFP_KERNEL); err:if (err <0 ) { -nfnetlink_set_err (net,NETLINK_CB (skb).portid,NFNLGRP_NFTABLES , - err); +if (nfnetlink_set_err (net,NETLINK_CB (skb).portid, +NFNLGRP_NFTABLES , -ENOBUFS ) >0 ) +return -ENOBUFS ; } -return err; +return 0 ; } static int nf_tables_getgen(struct net *net, struct sock *nlsk,
Pablo Neira Ayuso
maintainerQuoted 34 lines · Pablo Neira Ayuso
Quoted 17 lines · Pablo Neira Ayuso
Quoted 16 lines · Alexander Alemayhu
Running the test cases in the shell directory while running nft monitor results in nft exiting with '# ERROR: No such process'. The minimal steps where I could reproduce is:
nft monitor # shell 1
run-tests.shtestcases/sets/0011add_many_elements_0 # shell 2Signed-off-by Alexander Alemayhu <[email protected]>---
Not sure if this is considered a fix or desired behaviour, but I was not expecting monitor to exit like this.
src/mnl.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 15 lines
src/mnl.c int mnl_nft_event_listener(struct mnl_socket *nf_sock, · line 1135
Quoted 12 lines
src/mnl.c +3
-0@@ -1129,7 +1129,10 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock,printf ("# ERROR: We lost some netlink events!\n" );continue ; } +fprintf (stdout,"# ERROR: %s\n" ,strerror (errno)); +if (errno ==ESRCH ) +continue ;It seems netlink is returning ESRCH when the number of events is high, however, it should hit ENOBUFS instead, this is strange.
Quoted 7 lines
We at least need this fix from kernelspace.
Basically, the idea is to set socket error to ENOBUFS so the event listener knows that we're losing events, this is the correct way to report this in terms of netlink semantics.
Would you give it a try?
Actually, this patch would be better. All return values of these notify function are ignored, so we can turned it into void.
include/net/netfilter/nf_tables.h +3 -3
@@ -988,9 +988,9 @@ struct nft_object *nf_tables_obj_lookup(const struct nft_table *table, const struct nlattr *nla, u32 objtype, u8 genmask); -int nft_obj_notify (struct net *net,struct nft_table *table, -struct nft_object *obj,u32 portid,u32 seq, -int event,int family,int report,gfp_t gfp); +void nft_obj_notify (struct net *net,struct nft_table *table, +struct nft_object *obj,u32 portid,u32 seq, +int event,int family,int report,gfp_t gfp);/** * struct nft_object_type - stateful object type
net/netfilter/nf_tables_api.c +63 -65
272 lines not on this page · raw message
Quoted 3 lines · Pablo Neira Ayuso
Actually, this patch would be better. All return values of these notify function are ignored, so we can turned it into void.
Monitor seems to work as expected and does not exit with this patch. Should all of the tests pass with this? Currently seeing
I: results: [OK] 58 [FAILED] 49 [TOTAL] 107
Thanks.
Signature · 3 lines
Mit freundlichen Grüßen Alexander Alemayhu
Pablo Neira Ayuso
maintainerQuoted 9 lines · Alexander Alemayhu
Quoted 3 lines · Pablo Neira Ayuso
Actually, this patch would be better. All return values of these notify function are ignored, so we can turned it into void.
Monitor seems to work as expected and does not exit with this patch. Should all of the tests pass with this? Currently seeing
I: results: [OK] 58 [FAILED] 49 [TOTAL] 107
Hm, I'm hitting this here:
I: results: [OK] 107 [FAILED] 0 [TOTAL] 107
Running nft git HEAD and nf.git kernel.
If you're on the same page as me, would you run some test individually to see what is breaking?
Thanks.
Quoted 6 lines · Pablo Neira Ayuso
Hm, I'm hitting this here:
I: results: [OK] 107 [FAILED] 0 [TOTAL] 107
Running nft git HEAD and nf.git kernel.
See no failures with HEAD. Suspect I misconfigured earlier, sorry for the noise.
Signature · 3 lines
Mit freundlichen Grüßen Alexander Alemayhu