911-kobject_add_broadcast_uevent.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. +struct sk_buff;
  7. +
  8. /* path to the userspace helper executed on an event */
  9. extern char uevent_helper[];
  10. @@ -213,6 +215,10 @@ int add_uevent_var(struct kobj_uevent_en
  11. int kobject_action_type(const char *buf, size_t count,
  12. enum kobject_action *type);
  13. +
  14. +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  15. + gfp_t allocation);
  16. +
  17. #else
  18. static inline int kobject_uevent(struct kobject *kobj,
  19. enum kobject_action action)
  20. @@ -229,6 +235,16 @@ int add_uevent_var(struct kobj_uevent_en
  21. static inline int kobject_action_type(const char *buf, size_t count,
  22. enum kobject_action *type)
  23. { return -EINVAL; }
  24. +
  25. +void kfree_skb(struct sk_buff *);
  26. +
  27. +static inline int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  28. + gfp_t allocation)
  29. +{
  30. + kfree_skb(skb);
  31. + return 0;
  32. +}
  33. +
  34. #endif
  35. #endif /* _KOBJECT_H_ */
  36. --- a/lib/kobject_uevent.c
  37. +++ b/lib/kobject_uevent.c
  38. @@ -381,6 +381,43 @@ int add_uevent_var(struct kobj_uevent_en
  39. EXPORT_SYMBOL_GPL(add_uevent_var);
  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;