[nftables] netlink: add helper function for socket callback modification
Patrick McHardy
netfilter-cvslog-bounces at lists.netfilter.org
Wed Apr 1 07:43:48 CEST 2009
Gitweb: http://git.netfilter.org/cgi-bin/gitweb.cgi?p=nftables.git;a=commit;h=f5b8b54cf41ca5bf47242d516e6f94623fc6132b
commit f5b8b54cf41ca5bf47242d516e6f94623fc6132b
Author: Patrick McHardy <kaber at trash.net>
AuthorDate: Tue Mar 31 04:07:25 2009 +0200
Commit: Patrick McHardy <kaber at trash.net>
CommitDate: Tue Mar 31 04:07:25 2009 +0200
netlink: add helper function for socket callback modification
Signed-off-by: Patrick McHardy <kaber at trash.net>
via f5b8b54cf41ca5bf47242d516e6f94623fc6132b (commit)
from 3fb11ad7718f28949c73e5f5c01a6548fb86125b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f5b8b54cf41ca5bf47242d516e6f94623fc6132b
Author: Patrick McHardy <kaber at trash.net>
Date: Tue Mar 31 04:07:25 2009 +0200
netlink: add helper function for socket callback modification
Signed-off-by: Patrick McHardy <kaber at trash.net>
-----------------------------------------------------------------------
src/netlink.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
Signed-off-by: Patrick McHardy <kaber at trash.net>
diff --git a/src/netlink.c b/src/netlink.c
index 4700cd7..734b07e 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -40,6 +40,11 @@ static void __exit netlink_close_sock(void)
nl_socket_free(nf_sock);
}
+static void netlink_set_callback(nl_recvmsg_msg_cb_t func, void *arg)
+{
+ nl_socket_modify_cb(nf_sock, NL_CB_VALID, NL_CB_CUSTOM, func, arg);
+}
+
void netlink_dump_object(struct nl_object *obj)
{
struct nl_dump_params params = {
@@ -213,8 +218,7 @@ int netlink_get_rule(struct netlink_ctx *ctx, const struct handle *h)
nlr = alloc_nft_rule(h);
nfnl_nft_rule_query(nf_sock, nlr, 0);
- nl_socket_modify_cb(nf_sock, NL_CB_VALID, NL_CB_CUSTOM,
- netlink_get_rule_cb, ctx);
+ netlink_set_callback(netlink_get_rule_cb, ctx);
err = nl_recvmsgs_default(nf_sock);
nfnl_nft_rule_put(nlr);
@@ -347,8 +351,7 @@ int netlink_get_chain(struct netlink_ctx *ctx, const struct handle *h)
nlc = alloc_nft_chain(h);
nfnl_nft_chain_query(nf_sock, nlc, 0);
- nl_socket_modify_cb(nf_sock, NL_CB_VALID, NL_CB_CUSTOM,
- netlink_get_chain_cb, ctx);
+ netlink_set_callback(netlink_get_chain_cb, ctx);
err = nl_recvmsgs_default(nf_sock);
nfnl_nft_chain_put(nlc);
@@ -452,8 +455,7 @@ int netlink_get_table(struct netlink_ctx *ctx, const struct handle *h)
nlt = alloc_nft_table(h);
nfnl_nft_table_query(nf_sock, nlt, 0);
- nl_socket_modify_cb(nf_sock, NL_CB_VALID, NL_CB_CUSTOM,
- netlink_get_table_cb, ctx);
+ netlink_set_callback(netlink_get_table_cb, ctx);
err = nl_recvmsgs_default(nf_sock);
nfnl_nft_table_put(nlt);
More information about the netfilter-cvslog
mailing list