Prepare to communicate with a userspace helper over a netlink socket and
cleanup afterwards.
Signed-off-by: Nigel Cunningham <[email protected]>
kernel/power/netlink.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/kernel/power/netlink.c b/kernel/power/netlink.c
index c5b4bea..7b75f4f 100644
--- a/kernel/power/netlink.c
+++ b/kernel/power/netlink.c
@@ -257,3 +257,36 @@ static void suspend_netlink_input(struct
} while (uhd->nl && uhd->nl->sk_receive_queue.qlen);
}
+static int netlink_prepare(struct user_helper_data *uhd)
+{
+ uhd->next = uhd_list;
+ uhd_list = uhd;
+
+ uhd->sock_seq = 0x42c0ffee;
+ uhd->nl = netlink_kernel_create(uhd->netlink_id, 0,
+ suspend_netlink_input, THIS_MODULE);
+ if (!uhd->nl) {
+ printk("Failed to allocate netlink socket for %s.\n",
+ uhd->name);
+ return -ENOMEM;
+ }
+
+ suspend_fill_skb_pool(uhd);
+
+ return 0;
+}
+
+void suspend_netlink_close(struct user_helper_data *uhd)
+{
+ if (uhd->nl) {
+ sock_release(uhd->nl->sk_socket);
+ uhd->nl = NULL;
+ }
+
+ while (uhd->emerg_skbs) {
+ struct sk_buff *next = uhd->emerg_skbs->next;
+ kfree_skb(uhd->emerg_skbs);
+ uhd->emerg_skbs = next;
+ }
+}
+
--
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]