driver-core: skip uevent generation when nobody is listening
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 5 Dec 2011 18:12:47 +0000 (19:12 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 10 Dec 2011 00:23:50 +0000 (16:23 -0800)
Most network namespaces unlikely have listeners to uevents, and should
benefit from skipping all the string copies.

Cc: Eric Biederman <ebiederm@xmission.com>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
lib/kobject_uevent.c

index ad72a03..e66e9b6 100644 (file)
@@ -259,6 +259,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                struct sk_buff *skb;
                size_t len;
 
+               if (!netlink_has_listeners(uevent_sock, 1))
+                       continue;
+
                /* allocate message with the maximum possible size */
                len = strlen(action_string) + strlen(devpath) + 2;
                skb = alloc_skb(len + env->buflen, GFP_KERNEL);