diff options
author | Jorge Boncompte [DTI2] <jorge@dti2.net> | 2011-11-21 05:25:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-22 16:15:49 -0500 |
commit | 40ba84993d66469d336099c5af74c3da5b73e28d (patch) | |
tree | 3935df24cbdc9faab02e42342d24b48f5b0c0b11 /net/atm/common.c | |
parent | 4e55f5785825f18b1eb6c5cc5a9717e276925805 (diff) |
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/atm/common.c')
-rw-r--r-- | net/atm/common.c | 14 |
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, | |||
522 | 522 | ||
523 | if (sock->state != SS_CONNECTED) | 523 | if (sock->state != SS_CONNECTED) |
524 | return -ENOTCONN; | 524 | return -ENOTCONN; |
525 | if (flags & ~MSG_DONTWAIT) /* only handle MSG_DONTWAIT */ | 525 | |
526 | /* only handle MSG_DONTWAIT and MSG_PEEK */ | ||
527 | if (flags & ~(MSG_DONTWAIT | MSG_PEEK)) | ||
526 | return -EOPNOTSUPP; | 528 | return -EOPNOTSUPP; |
529 | |||
527 | vcc = ATM_SD(sock); | 530 | vcc = ATM_SD(sock); |
528 | if (test_bit(ATM_VF_RELEASED, &vcc->flags) || | 531 | if (test_bit(ATM_VF_RELEASED, &vcc->flags) || |
529 | test_bit(ATM_VF_CLOSE, &vcc->flags) || | 532 | test_bit(ATM_VF_CLOSE, &vcc->flags) || |
@@ -544,8 +547,13 @@ int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | |||
544 | if (error) | 547 | if (error) |
545 | return error; | 548 | return error; |
546 | sock_recv_ts_and_drops(msg, sk, skb); | 549 | sock_recv_ts_and_drops(msg, sk, skb); |
547 | pr_debug("%d -= %d\n", atomic_read(&sk->sk_rmem_alloc), skb->truesize); | 550 | |
548 | atm_return(vcc, skb->truesize); | 551 | if (!(flags & MSG_PEEK)) { |
552 | pr_debug("%d -= %d\n", atomic_read(&sk->sk_rmem_alloc), | ||
553 | skb->truesize); | ||
554 | atm_return(vcc, skb->truesize); | ||
555 | } | ||
556 | |||
549 | skb_free_datagram(sk, skb); | 557 | skb_free_datagram(sk, skb); |
550 | return copied; | 558 | return copied; |
551 | } | 559 | } |