Commit 8c90e11e authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

mISDN: Use kernel_{send,recv}msg instead of open coding

Reducing the number of direct users of sock_{recv,send}msg.
Modified version to match the latest context.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarKarsten Keil <keil@b1-systems.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eac74af9
...@@ -76,7 +76,7 @@ struct l1oip { ...@@ -76,7 +76,7 @@ struct l1oip {
struct sockaddr_in sin_local; /* local socket name */ struct sockaddr_in sin_local; /* local socket name */
struct sockaddr_in sin_remote; /* remote socket name */ struct sockaddr_in sin_remote; /* remote socket name */
struct msghdr sendmsg; /* ip message to send */ struct msghdr sendmsg; /* ip message to send */
struct iovec sendiov; /* iov for message */ struct kvec sendiov; /* iov for message */
/* frame */ /* frame */
struct l1oip_chan chan[128]; /* channel instances */ struct l1oip_chan chan[128]; /* channel instances */
......
...@@ -279,7 +279,6 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, ...@@ -279,7 +279,6 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
int multi = 0; int multi = 0;
u8 frame[len+32]; u8 frame[len+32];
struct socket *socket = NULL; struct socket *socket = NULL;
mm_segment_t oldfs;
if (debug & DEBUG_L1OIP_MSG) if (debug & DEBUG_L1OIP_MSG)
printk(KERN_DEBUG "%s: sending data to socket (len = %d)\n", printk(KERN_DEBUG "%s: sending data to socket (len = %d)\n",
...@@ -352,10 +351,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, ...@@ -352,10 +351,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
"= %d)\n", __func__, len); "= %d)\n", __func__, len);
hc->sendiov.iov_base = frame; hc->sendiov.iov_base = frame;
hc->sendiov.iov_len = len; hc->sendiov.iov_len = len;
oldfs = get_fs(); len = kernel_sendmsg(socket, &hc->sendmsg, &hc->sendiov, 1, len);
set_fs(KERNEL_DS);
len = sock_sendmsg(socket, &hc->sendmsg, len);
set_fs(oldfs);
/* give socket back */ /* give socket back */
hc->socket = socket; /* no locking required */ hc->socket = socket; /* no locking required */
...@@ -660,8 +656,6 @@ l1oip_socket_thread(void *data) ...@@ -660,8 +656,6 @@ l1oip_socket_thread(void *data)
struct l1oip *hc = (struct l1oip *)data; struct l1oip *hc = (struct l1oip *)data;
int ret = 0; int ret = 0;
struct msghdr msg; struct msghdr msg;
struct iovec iov;
mm_segment_t oldfs;
struct sockaddr_in sin_rx; struct sockaddr_in sin_rx;
unsigned char *recvbuf; unsigned char *recvbuf;
size_t recvbuf_size = 1500; size_t recvbuf_size = 1500;
...@@ -718,16 +712,12 @@ l1oip_socket_thread(void *data) ...@@ -718,16 +712,12 @@ l1oip_socket_thread(void *data)
msg.msg_namelen = sizeof(sin_rx); msg.msg_namelen = sizeof(sin_rx);
msg.msg_control = NULL; msg.msg_control = NULL;
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
/* build send message */ /* build send message */
hc->sendmsg.msg_name = &hc->sin_remote; hc->sendmsg.msg_name = &hc->sin_remote;
hc->sendmsg.msg_namelen = sizeof(hc->sin_remote); hc->sendmsg.msg_namelen = sizeof(hc->sin_remote);
hc->sendmsg.msg_control = NULL; hc->sendmsg.msg_control = NULL;
hc->sendmsg.msg_controllen = 0; hc->sendmsg.msg_controllen = 0;
hc->sendmsg.msg_iov = &hc->sendiov;
hc->sendmsg.msg_iovlen = 1;
/* give away socket */ /* give away socket */
spin_lock(&hc->socket_lock); spin_lock(&hc->socket_lock);
...@@ -739,12 +729,12 @@ l1oip_socket_thread(void *data) ...@@ -739,12 +729,12 @@ l1oip_socket_thread(void *data)
printk(KERN_DEBUG "%s: socket created and open\n", printk(KERN_DEBUG "%s: socket created and open\n",
__func__); __func__);
while (!signal_pending(current)) { while (!signal_pending(current)) {
iov.iov_base = recvbuf; struct kvec iov = {
iov.iov_len = recvbuf_size; .iov_base = recvbuf,
oldfs = get_fs(); .iov_len = sizeof(recvbuf),
set_fs(KERNEL_DS); };
recvlen = sock_recvmsg(socket, &msg, recvbuf_size, 0); recvlen = kernel_recvmsg(socket, &msg, &iov, 1,
set_fs(oldfs); sizeof(recvbuf), 0);
if (recvlen > 0) { if (recvlen > 0) {
l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen); l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
} else { } else {
......
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