* [PATCH nft] mnl: check for NLM_F_DUMP_INTR when dumping object lists
@ 2014-07-04 10:32 Pablo Neira Ayuso
2014-07-05 17:18 ` Patrick McHardy
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2014-07-04 10:32 UTC (permalink / raw)
To: netfilter-devel; +Cc: kaber
This flag allows to detect that an update has ocurred while dumping
any of the object lists.
<cmdline>:1:1-17: Error: Could not receive rules from kernel: Interrupted system call
list table filter
^^^^^^^^^^^^^^^^^
Basically, the user has to retry to make sure that it saves the current
rule-set.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/mnl.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/mnl.c b/src/mnl.c
index a816106..d3c91b4 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -363,6 +363,9 @@ static int rule_cb(const struct nlmsghdr *nlh, void *data)
struct nft_rule_list *nlr_list = data;
struct nft_rule *r;
+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+ return MNL_CB_ERROR;
+
r = nft_rule_alloc();
if (r == NULL)
memory_allocation_error();
@@ -474,6 +477,9 @@ static int chain_cb(const struct nlmsghdr *nlh, void *data)
struct nft_chain_list *nlc_list = data;
struct nft_chain *c;
+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+ return MNL_CB_ERROR;
+
c = nft_chain_alloc();
if (c == NULL)
memory_allocation_error();
@@ -603,6 +609,9 @@ static int table_cb(const struct nlmsghdr *nlh, void *data)
struct nft_table_list *nlt_list = data;
struct nft_table *t;
+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+ return MNL_CB_ERROR;
+
t = nft_table_alloc();
if (t == NULL)
memory_allocation_error();
@@ -736,6 +745,9 @@ static int set_cb(const struct nlmsghdr *nlh, void *data)
struct nft_set_list *nls_list = data;
struct nft_set *s;
+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+ return MNL_CB_ERROR;
+
s = nft_set_alloc();
if (s == NULL)
memory_allocation_error();
@@ -839,6 +851,9 @@ int mnl_nft_setelem_delete(struct mnl_socket *nf_sock, struct nft_set *nls,
static int set_elem_cb(const struct nlmsghdr *nlh, void *data)
{
+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+ return MNL_CB_ERROR;
+
nft_set_elems_nlmsg_parse(nlh, data);
return MNL_CB_OK;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nft] mnl: check for NLM_F_DUMP_INTR when dumping object lists
2014-07-04 10:32 [PATCH nft] mnl: check for NLM_F_DUMP_INTR when dumping object lists Pablo Neira Ayuso
@ 2014-07-05 17:18 ` Patrick McHardy
2014-07-06 8:54 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Patrick McHardy @ 2014-07-05 17:18 UTC (permalink / raw)
To: Pablo Neira Ayuso, netfilter-devel
On 4. Juli 2014 12:32:22 MESZ, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>This flag allows to detect that an update has ocurred while dumping
>any of the object lists.
>
><cmdline>:1:1-17: Error: Could not receive rules from kernel:
>Interrupted system call
>list table filter
>^^^^^^^^^^^^^^^^^
>
>Basically, the user has to retry to make sure that it saves the current
>rule-set.
Shouldn't we automatically handle this? Transient failure is really bad for many reasons.
>
>Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
>---
> src/mnl.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
>diff --git a/src/mnl.c b/src/mnl.c
>index a816106..d3c91b4 100644
>--- a/src/mnl.c
>+++ b/src/mnl.c
>@@ -363,6 +363,9 @@ static int rule_cb(const struct nlmsghdr *nlh, void
>*data)
> struct nft_rule_list *nlr_list = data;
> struct nft_rule *r;
>
>+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
>+ return MNL_CB_ERROR;
>+
> r = nft_rule_alloc();
> if (r == NULL)
> memory_allocation_error();
>@@ -474,6 +477,9 @@ static int chain_cb(const struct nlmsghdr *nlh,
>void *data)
> struct nft_chain_list *nlc_list = data;
> struct nft_chain *c;
>
>+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
>+ return MNL_CB_ERROR;
>+
> c = nft_chain_alloc();
> if (c == NULL)
> memory_allocation_error();
>@@ -603,6 +609,9 @@ static int table_cb(const struct nlmsghdr *nlh,
>void *data)
> struct nft_table_list *nlt_list = data;
> struct nft_table *t;
>
>+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
>+ return MNL_CB_ERROR;
>+
> t = nft_table_alloc();
> if (t == NULL)
> memory_allocation_error();
>@@ -736,6 +745,9 @@ static int set_cb(const struct nlmsghdr *nlh, void
>*data)
> struct nft_set_list *nls_list = data;
> struct nft_set *s;
>
>+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
>+ return MNL_CB_ERROR;
>+
> s = nft_set_alloc();
> if (s == NULL)
> memory_allocation_error();
>@@ -839,6 +851,9 @@ int mnl_nft_setelem_delete(struct mnl_socket
>*nf_sock, struct nft_set *nls,
>
> static int set_elem_cb(const struct nlmsghdr *nlh, void *data)
> {
>+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
>+ return MNL_CB_ERROR;
>+
> nft_set_elems_nlmsg_parse(nlh, data);
> return MNL_CB_OK;
> }
--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH nft] mnl: check for NLM_F_DUMP_INTR when dumping object lists
2014-07-05 17:18 ` Patrick McHardy
@ 2014-07-06 8:54 ` Pablo Neira Ayuso
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2014-07-06 8:54 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netfilter-devel
On Sat, Jul 05, 2014 at 07:18:51PM +0200, Patrick McHardy wrote:
> On 4. Juli 2014 12:32:22 MESZ, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> >This flag allows to detect that an update has ocurred while dumping
> >any of the object lists.
> >
> ><cmdline>:1:1-17: Error: Could not receive rules from kernel:
> >Interrupted system call
> >list table filter
> >^^^^^^^^^^^^^^^^^
> >
> >Basically, the user has to retry to make sure that it saves the current
> >rule-set.
>
> Shouldn't we automatically handle this? Transient failure is really
> bad for many reasons.
OK, I'm going to extend this so it indefinitely retries until it
fetches the entire rule-set. Thanks Patrick.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-06 8:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-04 10:32 [PATCH nft] mnl: check for NLM_F_DUMP_INTR when dumping object lists Pablo Neira Ayuso
2014-07-05 17:18 ` Patrick McHardy
2014-07-06 8:54 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).