[kernel] refresh 2.6.37 patches
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-2.6.37 / 911-kobject_add_broadcast_uevent.patch
1 --- a/include/linux/kobject.h
2 +++ b/include/linux/kobject.h
3 @@ -31,6 +31,8 @@
4 #define UEVENT_NUM_ENVP 32 /* number of env pointers */
5 #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
6
7 +struct sk_buff;
8 +
9 /* path to the userspace helper executed on an event */
10 extern char uevent_helper[];
11
12 @@ -215,6 +217,10 @@ int add_uevent_var(struct kobj_uevent_en
13
14 int kobject_action_type(const char *buf, size_t count,
15 enum kobject_action *type);
16 +
17 +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
18 + gfp_t allocation);
19 +
20 #else
21 static inline int kobject_uevent(struct kobject *kobj,
22 enum kobject_action action)
23 @@ -231,6 +237,16 @@ static inline int add_uevent_var(struct
24 static inline int kobject_action_type(const char *buf, size_t count,
25 enum kobject_action *type)
26 { return -EINVAL; }
27 +
28 +void kfree_skb(struct sk_buff *);
29 +
30 +static inline int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
31 + gfp_t allocation)
32 +{
33 + kfree_skb(skb);
34 + return 0;
35 +}
36 +
37 #endif
38
39 #endif /* _KOBJECT_H_ */
40 --- a/lib/kobject_uevent.c
41 +++ b/lib/kobject_uevent.c
42 @@ -377,6 +377,43 @@ int add_uevent_var(struct kobj_uevent_en
43 EXPORT_SYMBOL_GPL(add_uevent_var);
44
45 #if defined(CONFIG_NET)
46 +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
47 + gfp_t allocation)
48 +{
49 + struct uevent_sock *ue_sk;
50 + int err = 0;
51 +
52 + /* send netlink message */
53 + mutex_lock(&uevent_sock_mutex);
54 + list_for_each_entry(ue_sk, &uevent_sock_list, list) {
55 + struct sock *uevent_sock = ue_sk->sk;
56 + struct sk_buff *skb2;
57 +
58 + skb2 = skb_clone(skb, allocation);
59 + if (!skb2)
60 + break;
61 +
62 + err = netlink_broadcast(uevent_sock, skb2, pid, group,
63 + allocation);
64 + if (err)
65 + break;
66 + }
67 + mutex_unlock(&uevent_sock_mutex);
68 +
69 + kfree_skb(skb);
70 + return err;
71 +}
72 +#else
73 +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
74 + gfp_t allocation)
75 +{
76 + kfree_skb(skb);
77 + return 0;
78 +}
79 +#endif
80 +EXPORT_SYMBOL_GPL(broadcast_uevent);
81 +
82 +#if defined(CONFIG_NET)
83 static int uevent_net_init(struct net *net)
84 {
85 struct uevent_sock *ue_sk;