911-kobject_add_broadcast_uevent.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --- a/include/linux/kobject.h
  2. +++ b/include/linux/kobject.h
  3. @@ -32,6 +32,8 @@
  4. #define UEVENT_NUM_ENVP 32 /* number of env pointers */
  5. #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
  6. +struct sk_buff;
  7. +
  8. #ifdef CONFIG_UEVENT_HELPER
  9. /* path to the userspace helper executed on an event */
  10. extern char uevent_helper[];
  11. @@ -239,4 +241,7 @@ int add_uevent_var(struct kobj_uevent_en
  12. int kobject_action_type(const char *buf, size_t count,
  13. enum kobject_action *type);
  14. +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  15. + gfp_t allocation);
  16. +
  17. #endif /* _KOBJECT_H_ */
  18. --- a/lib/kobject_uevent.c
  19. +++ b/lib/kobject_uevent.c
  20. @@ -423,6 +423,43 @@ int add_uevent_var(struct kobj_uevent_en
  21. EXPORT_SYMBOL_GPL(add_uevent_var);
  22. #if defined(CONFIG_NET)
  23. +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  24. + gfp_t allocation)
  25. +{
  26. + struct uevent_sock *ue_sk;
  27. + int err = 0;
  28. +
  29. + /* send netlink message */
  30. + mutex_lock(&uevent_sock_mutex);
  31. + list_for_each_entry(ue_sk, &uevent_sock_list, list) {
  32. + struct sock *uevent_sock = ue_sk->sk;
  33. + struct sk_buff *skb2;
  34. +
  35. + skb2 = skb_clone(skb, allocation);
  36. + if (!skb2)
  37. + break;
  38. +
  39. + err = netlink_broadcast(uevent_sock, skb2, pid, group,
  40. + allocation);
  41. + if (err)
  42. + break;
  43. + }
  44. + mutex_unlock(&uevent_sock_mutex);
  45. +
  46. + kfree_skb(skb);
  47. + return err;
  48. +}
  49. +#else
  50. +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  51. + gfp_t allocation)
  52. +{
  53. + kfree_skb(skb);
  54. + return 0;
  55. +}
  56. +#endif
  57. +EXPORT_SYMBOL_GPL(broadcast_uevent);
  58. +
  59. +#if defined(CONFIG_NET)
  60. static int uevent_net_init(struct net *net)
  61. {
  62. struct uevent_sock *ue_sk;