Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198586
b: refs/heads/master
c: dcda138
h: refs/heads/master
v: v3
  • Loading branch information
Sjur Braendeland authored and David S. Miller committed May 24, 2010
1 parent 602a620 commit e398f6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a9a8f1070d8733b37418b3a2d58df4e771b61f88
refs/heads/master: dcda138d2f27e32bd0d6250cc42839b0d70bb4b8
47 changes: 18 additions & 29 deletions trunk/net/caif/caif_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,53 +292,42 @@ static void caif_check_flow_release(struct sock *sk)
caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_ON_REQ);
}
}

/*
* Copied from sock.c:sock_queue_rcv_skb(), and added check that user buffer
* has sufficient size.
* Copied from unix_dgram_recvmsg, but removed credit checks,
* changed locking, address handling and added MSG_TRUNC.
*/

static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *m, size_t buf_len, int flags)
struct msghdr *m, size_t len, int flags)

{
struct sock *sk = sock->sk;
struct sk_buff *skb;
int ret = 0;
int len;
int ret;
int copylen;

if (unlikely(!buf_len))
return -EINVAL;
ret = -EOPNOTSUPP;
if (m->msg_flags&MSG_OOB)
goto read_error;

skb = skb_recv_datagram(sk, flags, 0 , &ret);
if (!skb)
goto read_error;

len = skb->len;

if (skb && skb->len > buf_len && !(flags & MSG_PEEK)) {
len = buf_len;
/*
* Push skb back on receive queue if buffer too small.
* This has a built-in race where multi-threaded receive
* may get packet in wrong order, but multiple read does
* not really guarantee ordered delivery anyway.
* Let's optimize for speed without taking locks.
*/

skb_queue_head(&sk->sk_receive_queue, skb);
ret = -EMSGSIZE;
goto read_error;
copylen = skb->len;
if (len < copylen) {
m->msg_flags |= MSG_TRUNC;
copylen = len;
}

ret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, len);
ret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, copylen);
if (ret)
goto read_error;
goto out_free;

ret = (flags & MSG_TRUNC) ? skb->len : copylen;
out_free:
skb_free_datagram(sk, skb);

caif_check_flow_release(sk);

return len;
return ret;

read_error:
return ret;
Expand Down

0 comments on commit e398f6c

Please sign in to comment.