netlink: allow to pass data pointer to netlink_dump_start() callback
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 24 Feb 2012 14:30:16 +0000 (14:30 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 26 Feb 2012 19:10:44 +0000 (14:10 -0500)
This patch allows you to pass a data pointer that can be
accessed from the dump callback.

Netfilter is going to use this patch to provide filtered dumps
to user-space. This is specifically interesting in ctnetlink that
may handle lots of conntrack entries. We can save precious
cycles by skipping the conversion to TLV format of conntrack
entries that are not interesting for user-space.

More specifically, ctnetlink will include one operation to allow
to filter the dumping of conntrack entries by ctmark values.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netlink.h
net/netlink/af_netlink.c

index 1f8c1a95f57c42086d062022d3f0df2d467f79fa..a2092f582a784f6df9443f6a773cff660288a9a7 100644 (file)
@@ -225,6 +225,7 @@ struct netlink_callback {
        int                     (*dump)(struct sk_buff * skb,
                                        struct netlink_callback *cb);
        int                     (*done)(struct netlink_callback *cb);
+       void                    *data;
        u16                     family;
        u16                     min_dump_alloc;
        unsigned int            prev_seq, seq;
@@ -251,6 +252,7 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
 struct netlink_dump_control {
        int (*dump)(struct sk_buff *skb, struct netlink_callback *);
        int (*done)(struct netlink_callback*);
+       void *data;
        u16 min_dump_alloc;
 };
 
index ab74845876d28224f1ef1ec9af2b15dbb2e60278..32bb75324e76d0141c99df87449f3013b5c5a060 100644 (file)
@@ -1750,6 +1750,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
        cb->dump = control->dump;
        cb->done = control->done;
        cb->nlh = nlh;
+       cb->data = control->data;
        cb->min_dump_alloc = control->min_dump_alloc;
        atomic_inc(&skb->users);
        cb->skb = skb;
This page took 0.02983 seconds and 5 git commands to generate.