diff options
author | Patrick McHardy <kaber@trash.net> | 2006-03-20 21:03:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-20 21:03:59 -0500 |
commit | a24276924875802853b5bdc12c56d29f1c1bbc79 (patch) | |
tree | 5725689bf434004143ae875bbfee3d3d29ddcdb0 /net | |
parent | c4b885139203d37f76662c37ae645fe8e0f4e4e5 (diff) |
[NETFILTER]: ctnetlink: avoid unneccessary event message generation
Avoid unneccessary event message generation by checking for netlink
listeners before building a message.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/netfilter/ip_conntrack_netlink.c | 7 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 7 | ||||
-rw-r--r-- | net/netfilter/nfnetlink.c | 6 |
3 files changed, 14 insertions, 6 deletions
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index e0b5926c76f9..5ce2e3fc2c7f 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c | |||
@@ -327,9 +327,10 @@ static int ctnetlink_conntrack_event(struct notifier_block *this, | |||
327 | group = NFNLGRP_CONNTRACK_UPDATE; | 327 | group = NFNLGRP_CONNTRACK_UPDATE; |
328 | } else | 328 | } else |
329 | return NOTIFY_DONE; | 329 | return NOTIFY_DONE; |
330 | 330 | ||
331 | /* FIXME: Check if there are any listeners before, don't hurt performance */ | 331 | if (!nfnetlink_has_listeners(group)) |
332 | 332 | return NOTIFY_DONE; | |
333 | |||
333 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); | 334 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); |
334 | if (!skb) | 335 | if (!skb) |
335 | return NOTIFY_DONE; | 336 | return NOTIFY_DONE; |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index aef3cb41131f..5eadf009bb15 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -338,9 +338,10 @@ static int ctnetlink_conntrack_event(struct notifier_block *this, | |||
338 | group = NFNLGRP_CONNTRACK_UPDATE; | 338 | group = NFNLGRP_CONNTRACK_UPDATE; |
339 | } else | 339 | } else |
340 | return NOTIFY_DONE; | 340 | return NOTIFY_DONE; |
341 | 341 | ||
342 | /* FIXME: Check if there are any listeners before, don't hurt performance */ | 342 | if (!nfnetlink_has_listeners(group)) |
343 | 343 | return NOTIFY_DONE; | |
344 | |||
344 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); | 345 | skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); |
345 | if (!skb) | 346 | if (!skb) |
346 | return NOTIFY_DONE; | 347 | return NOTIFY_DONE; |
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c index f6063e8f0050..b88e82a1a987 100644 --- a/net/netfilter/nfnetlink.c +++ b/net/netfilter/nfnetlink.c | |||
@@ -191,6 +191,12 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys, | |||
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | 193 | ||
194 | int nfnetlink_has_listeners(unsigned int group) | ||
195 | { | ||
196 | return netlink_has_listeners(nfnl, group); | ||
197 | } | ||
198 | EXPORT_SYMBOL_GPL(nfnetlink_has_listeners); | ||
199 | |||
194 | int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) | 200 | int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) |
195 | { | 201 | { |
196 | gfp_t allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; | 202 | gfp_t allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; |