kernel: split patches folder up into backport, pending and hack folders
[openwrt/openwrt.git] / target / linux / generic / hack-4.9 / 911-kobject_add_broadcast_uevent.patch
1 From 0d37e6edc09c99e683dd91ca0e83bbc0df8477b3 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Sun, 16 Jul 2017 16:56:10 +0200
4 Subject: lib: add uevent_next_seqnum()
5
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 ---
8 include/linux/kobject.h | 5 +++++
9 lib/kobject_uevent.c | 37 +++++++++++++++++++++++++++++++++++++
10 2 files changed, 42 insertions(+)
11
12 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
13 index a7dc9e61f433..3d6950c957cd 100644
14 --- a/include/linux/kobject.h
15 +++ b/include/linux/kobject.h
16 @@ -34,6 +34,8 @@
17
18 struct sk_buff;
19
20 +struct sk_buff;
21 +
22 #ifdef CONFIG_UEVENT_HELPER
23 /* path to the userspace helper executed on an event */
24 extern char uevent_helper[];
25 @@ -227,4 +229,7 @@ int kobject_action_type(const char *buf, size_t count,
26 int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
27 gfp_t allocation);
28
29 +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
30 + gfp_t allocation);
31 +
32 #endif /* _KOBJECT_H_ */
33 diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
34 index ac0c7cfa7292..bd13381a410f 100644
35 --- a/lib/kobject_uevent.c
36 +++ b/lib/kobject_uevent.c
37 @@ -460,6 +460,43 @@ int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
38 EXPORT_SYMBOL_GPL(broadcast_uevent);
39
40 #if defined(CONFIG_NET)
41 +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
42 + gfp_t allocation)
43 +{
44 + struct uevent_sock *ue_sk;
45 + int err = 0;
46 +
47 + /* send netlink message */
48 + mutex_lock(&uevent_sock_mutex);
49 + list_for_each_entry(ue_sk, &uevent_sock_list, list) {
50 + struct sock *uevent_sock = ue_sk->sk;
51 + struct sk_buff *skb2;
52 +
53 + skb2 = skb_clone(skb, allocation);
54 + if (!skb2)
55 + break;
56 +
57 + err = netlink_broadcast(uevent_sock, skb2, pid, group,
58 + allocation);
59 + if (err)
60 + break;
61 + }
62 + mutex_unlock(&uevent_sock_mutex);
63 +
64 + kfree_skb(skb);
65 + return err;
66 +}
67 +#else
68 +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
69 + gfp_t allocation)
70 +{
71 + kfree_skb(skb);
72 + return 0;
73 +}
74 +#endif
75 +EXPORT_SYMBOL_GPL(broadcast_uevent);
76 +
77 +#if defined(CONFIG_NET)
78 static int uevent_net_init(struct net *net)
79 {
80 struct uevent_sock *ue_sk;
81 --
82 2.11.0
83