[Suspend2][ 10/13] [Suspend2] Prepare/cleanup netlink connections.

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


Prepare to communicate with a userspace helper over a netlink socket and
cleanup afterwards.

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

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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/