911-kobject_add_broadcast_uevent.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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,4 +215,7 @@ 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. +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  14. + gfp_t allocation);
  15. +
  16. #endif /* _KOBJECT_H_ */
  17. --- a/lib/kobject_uevent.c
  18. +++ b/lib/kobject_uevent.c
  19. @@ -382,6 +382,43 @@ int add_uevent_var(struct kobj_uevent_en
  20. EXPORT_SYMBOL_GPL(add_uevent_var);
  21. #if defined(CONFIG_NET)
  22. +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  23. + gfp_t allocation)
  24. +{
  25. + struct uevent_sock *ue_sk;
  26. + int err = 0;
  27. +
  28. + /* send netlink message */
  29. + mutex_lock(&uevent_sock_mutex);
  30. + list_for_each_entry(ue_sk, &uevent_sock_list, list) {
  31. + struct sock *uevent_sock = ue_sk->sk;
  32. + struct sk_buff *skb2;
  33. +
  34. + skb2 = skb_clone(skb, allocation);
  35. + if (!skb2)
  36. + break;
  37. +
  38. + err = netlink_broadcast(uevent_sock, skb2, pid, group,
  39. + allocation);
  40. + if (err)
  41. + break;
  42. + }
  43. + mutex_unlock(&uevent_sock_mutex);
  44. +
  45. + kfree_skb(skb);
  46. + return err;
  47. +}
  48. +#else
  49. +int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
  50. + gfp_t allocation)
  51. +{
  52. + kfree_skb(skb);
  53. + return 0;
  54. +}
  55. +#endif
  56. +EXPORT_SYMBOL_GPL(broadcast_uevent);
  57. +
  58. +#if defined(CONFIG_NET)
  59. static int uevent_net_init(struct net *net)
  60. {
  61. struct uevent_sock *ue_sk;