[Suspend2][ 05/13] [Suspend2] Send netlink message to userspace helper.

From: Nigel Cunningham
Date: Tue Jun 27 2006 - 01:02:59 EST


Send a netlink message to a userspace helper.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

kernel/power/netlink.c | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/kernel/power/netlink.c b/kernel/power/netlink.c
index c8c543a..696009d 100644
--- a/kernel/power/netlink.c
+++ b/kernel/power/netlink.c
@@ -79,3 +79,39 @@ static void suspend_notify_userspace(voi
read_unlock(&tasklist_lock);
}

+DECLARE_WORK(suspend_notify_userspace_work, suspend_notify_userspace, NULL);
+
+void suspend_send_netlink_message(struct user_helper_data *uhd,
+ int type, void* params, size_t len)
+{
+ struct sk_buff *skb;
+ struct nlmsghdr *nlh;
+ void *dest;
+
+ skb = suspend_get_skb(uhd);
+ if (!skb) {
+ printk("suspend_netlink: Can't allocate skb!\n");
+ return;
+ }
+
+ /* NLMSG_PUT contains a hidden goto nlmsg_failure */
+ nlh = NLMSG_PUT(skb, 0, uhd->sock_seq, type, len);
+ uhd->sock_seq++;
+
+ dest = NLMSG_DATA(nlh);
+ if (params && len > 0)
+ memcpy(dest, params, len);
+
+ netlink_unicast(uhd->nl, skb, uhd->pid, 0);
+
+ /* We may be in an interrupt context so defer waking up userspace */
+ suspend_notify_userspace_work.data = uhd;
+ schedule_work(&suspend_notify_userspace_work);
+
+ return;
+
+nlmsg_failure:
+ if (skb)
+ put_skb(uhd, skb);
+}
+

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/