提交 7175c883 编写于 作者: P Pablo Neira Ayuso 提交者: David S. Miller

netlink: allow to pass data pointer to netlink_dump_start() callback

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: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 80d326fa
...@@ -225,6 +225,7 @@ struct netlink_callback { ...@@ -225,6 +225,7 @@ struct netlink_callback {
int (*dump)(struct sk_buff * skb, int (*dump)(struct sk_buff * skb,
struct netlink_callback *cb); struct netlink_callback *cb);
int (*done)(struct netlink_callback *cb); int (*done)(struct netlink_callback *cb);
void *data;
u16 family; u16 family;
u16 min_dump_alloc; u16 min_dump_alloc;
unsigned int prev_seq, seq; 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) ...@@ -251,6 +252,7 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
struct netlink_dump_control { struct netlink_dump_control {
int (*dump)(struct sk_buff *skb, struct netlink_callback *); int (*dump)(struct sk_buff *skb, struct netlink_callback *);
int (*done)(struct netlink_callback*); int (*done)(struct netlink_callback*);
void *data;
u16 min_dump_alloc; u16 min_dump_alloc;
}; };
......
...@@ -1750,6 +1750,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, ...@@ -1750,6 +1750,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
cb->dump = control->dump; cb->dump = control->dump;
cb->done = control->done; cb->done = control->done;
cb->nlh = nlh; cb->nlh = nlh;
cb->data = control->data;
cb->min_dump_alloc = control->min_dump_alloc; cb->min_dump_alloc = control->min_dump_alloc;
atomic_inc(&skb->users); atomic_inc(&skb->users);
cb->skb = skb; cb->skb = skb;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册