Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
lib: add uevent_next_seqnum()
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 authored and mj22226 committed Jul 30, 2023
1 parent a5f68b8 commit 4219cb5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/linux/kobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#define UEVENT_NUM_ENVP 64 /* number of env pointers */
#define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */

struct sk_buff;

#ifdef CONFIG_UEVENT_HELPER
/* path to the userspace helper executed on an event */
extern char uevent_helper[];
Expand Down Expand Up @@ -260,4 +262,7 @@ int kobject_synth_uevent(struct kobject *kobj, const char *buf, size_t count);
__printf(2, 3)
int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...);

int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
gfp_t allocation);

#endif /* _KOBJECT_H_ */
37 changes: 37 additions & 0 deletions lib/kobject_uevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,43 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
}
EXPORT_SYMBOL_GPL(add_uevent_var);

#if defined(CONFIG_NET)
int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
gfp_t allocation)
{
struct uevent_sock *ue_sk;
int err = 0;

/* send netlink message */
mutex_lock(&uevent_sock_mutex);
list_for_each_entry(ue_sk, &uevent_sock_list, list) {
struct sock *uevent_sock = ue_sk->sk;
struct sk_buff *skb2;

skb2 = skb_clone(skb, allocation);
if (!skb2)
break;

err = netlink_broadcast(uevent_sock, skb2, pid, group,
allocation);
if (err)
break;
}
mutex_unlock(&uevent_sock_mutex);

kfree_skb(skb);
return err;
}
#else
int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group,
gfp_t allocation)
{
kfree_skb(skb);
return 0;
}
#endif
EXPORT_SYMBOL_GPL(broadcast_uevent);

#if defined(CONFIG_NET)
static int uevent_net_broadcast(struct sock *usk, struct sk_buff *skb,
struct netlink_ext_ack *extack)
Expand Down

0 comments on commit 4219cb5

Please sign in to comment.