From: David Miller <davem@davemloft.net>
To: pablo@netfilter.org
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] route_bench: Filter out all responses.
Date: Sun, 20 Feb 2011 14:32:48 -0800 (PST) [thread overview]
Message-ID: <20110220.143248.260098148.davem@davemloft.net> (raw)
In-Reply-To: <4D61957F.5060905@netfilter.org>
From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Sun, 20 Feb 2011 23:28:15 +0100
> You can use:
>
> extern int mnl_socket_get_fd(const struct mnl_socket *nl);
>
> Thus, you can invoke setsockopt directly ;-).
Thank you, I didn't notice that interface.
I'll check in the following.
--------------------
route_bench: Remove knowledge of libmnl internals, not needed.
Since mnl_socket_get_fd() exists, we can use that.
Thanks to Pablo.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
route_bench.c | 13 ++-----------
1 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/route_bench.c b/route_bench.c
index 6c6b525..063b15e 100644
--- a/route_bench.c
+++ b/route_bench.c
@@ -24,16 +24,6 @@
#include <linux/rtnetlink.h>
#include <linux/filter.h>
-/* XXX Ugly knowledge of internals, but there is currently no way
- * XXX provided by the libmnl library to set socket options that are
- * XXX of level other than SOL_NETLINK. And we need to set one of
- * XXX level SOL_SOCKET to install the socket filter.
- */
-struct mnl_socket {
- int fd;
- struct sockaddr_nl addr;
-};
-
static int usage(void)
{
printf("usage: route_bench [ -o ] [ -l count ]\n");
@@ -178,7 +168,8 @@ static int do_bench(int count, in_addr_t src_addr, in_addr_t dst_addr,
portid = mnl_socket_get_portid(nl);
- err = setsockopt(nl->fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter));
+ err = setsockopt(mnl_socket_get_fd(nl), SOL_SOCKET,
+ SO_ATTACH_FILTER, &filter, sizeof(filter));
if (err) {
perror("setsockopt");
return -1;
--
1.7.4.1
prev parent reply other threads:[~2011-02-20 22:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-20 22:04 [PATCH] route_bench: Filter out all responses David Miller
2011-02-20 22:28 ` Pablo Neira Ayuso
2011-02-20 22:32 ` David Miller [this message]
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=20110220.143248.260098148.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=pablo@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.