From: Amin Azez <azez@ufomechanic.net>
To: Harald Welte <laforge@netfilter.org>
Cc: netfilter-devel@lists.netfilter.org, Patrick McHardy <kaber@trash.net>
Subject: Re: [PATCH 4/*] libnfnetlink fixes
Date: Mon, 12 Sep 2005 09:03:25 +0100 [thread overview]
Message-ID: <4325364D.8030406@ufomechanic.net> (raw)
In-Reply-To: <20050910090908.GD4314@rama.de.gnumonks.org>
[-- Attachment #1: Type: text/plain, Size: 640 bytes --]
Harald Welte wrote:
>On Fri, Sep 02, 2005 at 05:12:38PM +0100, Amin Azez wrote:
>
>
>>Harald Welte wrote:
>>
>>
>>
>>>On Wed, Jul 13, 2005 at 09:23:56AM +0100, Amin Azez wrote:
>>>
>>>
>>>
>>>I think this change is fine. Would you mind to re-submit the patch
>>>against current svn? Please also document the meaning of the return
>>>values, probably with a comment in the code or the header file?
>>>
>>>
>>>
>>>
>>>
>>Will do (Monday)
>>
>>thanks for the feedback.
>>
>>
>
>I haven't received an updated patch so far. Did I miss it somehow?
>
>
>
err... you must have, I sent it on 5th Sept.
Attached again.
Azez
[-- Attachment #2: libnfnetlink.c.diff --]
[-- Type: text/x-patch, Size: 1691 bytes --]
Index: src/libnfnetlink.c
===================================================================
--- src/libnfnetlink.c (revision 4254)
+++ src/libnfnetlink.c (working copy)
@@ -257,6 +257,16 @@
*
* nfnhl: libnfnetlink handle
* handler: callback function to be called for every netlink message
+ * - the callback handler should normally return 0
+ * - but may return a negative error code which will cause
+ * nfnl_listen to return immediately with the same error code
+ * - or return a postivie error code which will cause
+ * nfnl_listen to return after it has finished processing all
+ * the netlink messages in the current packet
+ * Thus a positive error code will terminate nfnl_listen "soon"
+ * without any loss of data, a negative error code will terminate
+ * nfnl_listen "very soon" and throw away data already read from
+ * the netlink socket.
* jarg: opaque argument passed on to callback
*
*/
@@ -270,6 +280,7 @@
int remain;
struct nlmsghdr *h;
struct nlmsgerr *msgerr;
+ int quit=0;
struct msghdr msg = {
(void *)&nladdr, sizeof(nladdr),
@@ -283,7 +294,7 @@
iov.iov_base = buf;
iov.iov_len = sizeof(buf);
- while (1) {
+ while (! quit) {
remain = recvmsg(nfnlh->fd, &msg, 0);
if (remain < 0) {
if (errno == EINTR)
@@ -332,6 +343,7 @@
err = handler(&nladdr, h, jarg);
if (err < 0)
return err;
+ quit |= err;
/* FIXME: why not _NEXT macros, etc.? */
//h = NLMSG_NEXT(h, remain);
@@ -348,7 +360,7 @@
}
}
- return 0;
+ return quit;
}
int nfnl_talk(struct nfnl_handle *nfnlh, struct nlmsghdr *n, pid_t peer,
next prev parent reply other threads:[~2005-09-12 8:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-12 20:37 [PATCH 4/*] libnfnetlink fixes Pablo Neira
2005-07-13 8:23 ` Amin Azez
2005-08-28 11:50 ` Harald Welte
2005-09-02 16:12 ` Amin Azez
2005-09-10 9:09 ` Harald Welte
2005-09-12 8:03 ` Amin Azez [this message]
2005-09-13 13:17 ` Harald Welte
2005-09-05 16:31 ` Amin Azez
2005-07-18 21:25 ` Harald Welte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4325364D.8030406@ufomechanic.net \
--to=azez@ufomechanic.net \
--cc=kaber@trash.net \
--cc=laforge@netfilter.org \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.