]> err.no Git - linux-2.6/commitdiff
[NETFILTER]: ctnetlink: avoid unneccessary event message generation
authorPatrick McHardy <kaber@trash.net>
Tue, 21 Mar 2006 02:03:59 +0000 (18:03 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Mar 2006 02:03:59 +0000 (18:03 -0800)
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>
include/linux/netfilter/nfnetlink.h
net/ipv4/netfilter/ip_conntrack_netlink.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nfnetlink.c

index 934a2479f16077282264e1fd75584b17ab96f8b1..9f5b12cf489b9e53fec2ba2fbb65c30b00584572 100644 (file)
@@ -164,6 +164,7 @@ extern void nfattr_parse(struct nfattr *tb[], int maxattr,
        __res;                                                          \
 })
 
+extern int nfnetlink_has_listeners(unsigned int group);
 extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, 
                          int echo);
 extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags);
index e0b5926c76f94d0adfee4fa2a26f10bdbce33bf6..5ce2e3fc2c7f18b16452ff9838a8e34f08bbc1ba 100644 (file)
@@ -327,9 +327,10 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
                group = NFNLGRP_CONNTRACK_UPDATE;
        } else 
                return NOTIFY_DONE;
-       
-  /* FIXME: Check if there are any listeners before, don't hurt performance */
-       
+
+       if (!nfnetlink_has_listeners(group))
+               return NOTIFY_DONE;
+
        skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
        if (!skb)
                return NOTIFY_DONE;
index aef3cb41131fe7aa1827ebfbe0938fc8f233d6b0..5eadf009bb157b5a24b8100852d34d41e85d7bb8 100644 (file)
@@ -338,9 +338,10 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
                group = NFNLGRP_CONNTRACK_UPDATE;
        } else
                return NOTIFY_DONE;
-       
-  /* FIXME: Check if there are any listeners before, don't hurt performance */
-       
+
+       if (!nfnetlink_has_listeners(group))
+               return NOTIFY_DONE;
+
        skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
        if (!skb)
                return NOTIFY_DONE;
index f6063e8f0050e93778ceac0b809e75f767c8c306..b88e82a1a987461dfae03f7686bdd348cc3c6d26 100644 (file)
@@ -191,6 +191,12 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
         return 0;
 }
 
+int nfnetlink_has_listeners(unsigned int group)
+{
+       return netlink_has_listeners(nfnl, group);
+}
+EXPORT_SYMBOL_GPL(nfnetlink_has_listeners);
+
 int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
 {
        gfp_t allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;