mnl: check for NLM_F_DUMP_INTR when dumping object lists
Pablo Neira Ayuso
maintainerPATCH v3 2/2 mnl: check for NLM_F_DUMP_INTR when dumping object lists
This flag allows to detect that an update has ocurred while dumping any of the object lists. In case of interference, nft cancels the netlink socket to skip processing the remaining stale entries and it retries to obtain fresh list of objects.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
Changes from v3: Missing EINTR handling in netlink_get_setelems and netlink_dump_ruleset.
include/netlink.h | 2 ++ src/main.c | 8 ++++++- src/netlink.c | 42 ++++++++++++++++++++++++++++++----- src/rule.c | 64 +++++++++++++++++++++++++++++++---------------------- 4 files changed, 83 insertions(+), 33 deletions(-)
include/netlink.h +2 -0
@@ -137,6 +137,8 @@ extern void netlink_dump_expr(struct nft_rule_expr *nle);extern void netlink_dump_set (struct nft_set *nls);extern int netlink_batch_send (struct list_head *err_list); + +extern void netlink_restart (void );extern void netlink_abi_error (void )__noreturn ;extern int netlink_io_error (struct netlink_ctx *ctx,const struct location *loc,const char *fmt, ...);
src/main.c +7 -1
@@ -223,8 +223,14 @@ int nft_run(void *scanner, struct parser_state *state, struct list_head *msgs) ret =nft_parse (scanner, state);if (ret !=0 || state->nerrs >0 )return -1 ; +retry: + ret =nft_netlink (state, msgs); +if (ret <0 && errno ==EINTR ) { +netlink_restart (); + goto retry; + } -return nft_netlink (state, msgs); +return ret; }int main (int argc,char *const *argv)
src/netlink.c +36 -6
99 lines not on this page · raw message
src/rule.c +38 -26
120 lines not on this page · raw message
Signature · 1 line
1.7.10.4