Commit 3dc40393 authored by Frank Seidel's avatar Frank Seidel Committed by David S. Miller

mISDN: Add allocation of recvbuf[1500] at run time to reduce stack size

Before: 1656 bytes on i386, now 164.
Modified by Andreas Eversberg <andreas@eversberg.eu>
Signed-off-by: default avatarFrank Seidel <frank@f-seidel.de>
Signed-off-by: default avatarAndreas Eversberg <andreas@eversberg.eu>
Signed-off-by: default avatarKarsten Keil <keil@b1-systems.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5b277b86
...@@ -663,18 +663,28 @@ l1oip_socket_thread(void *data) ...@@ -663,18 +663,28 @@ l1oip_socket_thread(void *data)
struct iovec iov; struct iovec iov;
mm_segment_t oldfs; mm_segment_t oldfs;
struct sockaddr_in sin_rx; struct sockaddr_in sin_rx;
unsigned char recvbuf[1500]; unsigned char *recvbuf;
size_t recvbuf_size = 1500;
int recvlen; int recvlen;
struct socket *socket = NULL; struct socket *socket = NULL;
DECLARE_COMPLETION(wait); DECLARE_COMPLETION(wait);
/* allocate buffer memory */
recvbuf = kmalloc(recvbuf_size, GFP_KERNEL);
if (!recvbuf) {
printk(KERN_ERR "%s: Failed to alloc recvbuf.\n", __func__);
ret = -ENOMEM;
goto fail;
}
/* make daemon */ /* make daemon */
allow_signal(SIGTERM); allow_signal(SIGTERM);
/* create socket */ /* create socket */
if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &socket)) { if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &socket)) {
printk(KERN_ERR "%s: Failed to create socket.\n", __func__); printk(KERN_ERR "%s: Failed to create socket.\n", __func__);
return -EIO; ret = -EIO;
goto fail;
} }
/* set incoming address */ /* set incoming address */
...@@ -730,10 +740,10 @@ l1oip_socket_thread(void *data) ...@@ -730,10 +740,10 @@ l1oip_socket_thread(void *data)
__func__); __func__);
while (!signal_pending(current)) { while (!signal_pending(current)) {
iov.iov_base = recvbuf; iov.iov_base = recvbuf;
iov.iov_len = sizeof(recvbuf); iov.iov_len = recvbuf_size;
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
recvlen = sock_recvmsg(socket, &msg, sizeof(recvbuf), 0); recvlen = sock_recvmsg(socket, &msg, recvbuf_size, 0);
set_fs(oldfs); set_fs(oldfs);
if (recvlen > 0) { if (recvlen > 0) {
l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen); l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
...@@ -760,6 +770,9 @@ l1oip_socket_thread(void *data) ...@@ -760,6 +770,9 @@ l1oip_socket_thread(void *data)
__func__); __func__);
fail: fail:
/* free recvbuf */
kfree(recvbuf);
/* close socket */ /* close socket */
if (socket) if (socket)
sock_release(socket); sock_release(socket);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment