aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJorge Boncompte [DTI2] <jorge@dti2.net>2011-11-21 10:25:58 +0000
committerDavid S. Miller <davem@davemloft.net>2011-11-22 16:15:49 -0500
commit40ba84993d66469d336099c5af74c3da5b73e28d (patch)
tree3935df24cbdc9faab02e42342d24b48f5b0c0b11 /net
parentatm: Introduce vcc_process_recv_queue (diff)
downloadlinux-dev-40ba84993d66469d336099c5af74c3da5b73e28d.tar.xz
linux-dev-40ba84993d66469d336099c5af74c3da5b73e28d.zip
atm: Allow MSG_PEEK for atm sockets
Now that the vcc backends do the right thing with respect the receive queue on registration, allow MSK_PEEK for atm sockets. This allows a userspace program to inspect the packets and decide what backend to use to handle them. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/atm/common.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/net/atm/common.c b/net/atm/common.c
index 0b4c58fe3919..b4b44dbed645 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -522,8 +522,11 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
if (sock->state != SS_CONNECTED)
return -ENOTCONN;
- if (flags & ~MSG_DONTWAIT) /* only handle MSG_DONTWAIT */
+
+ /* only handle MSG_DONTWAIT and MSG_PEEK */
+ if (flags & ~(MSG_DONTWAIT | MSG_PEEK))
return -EOPNOTSUPP;
+
vcc = ATM_SD(sock);
if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
test_bit(ATM_VF_CLOSE, &vcc->flags) ||
@@ -544,8 +547,13 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
if (error)
return error;
sock_recv_ts_and_drops(msg, sk, skb);
- pr_debug("%d -= %d\n", atomic_read(&sk->sk_rmem_alloc), skb->truesize);
- atm_return(vcc, skb->truesize);
+
+ if (!(flags & MSG_PEEK)) {
+ pr_debug("%d -= %d\n", atomic_read(&sk->sk_rmem_alloc),
+ skb->truesize);
+ atm_return(vcc, skb->truesize);
+ }
+
skb_free_datagram(sk, skb);
return copied;
}