Commit 40ba84993d66469d336099c5af74c3da5b73e28d

Authored by Jorge Boncompte [DTI2]
Committed by David S. Miller
1 parent 4e55f57858

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>

Showing 1 changed file with 11 additions and 3 deletions Side-by-side Diff

... ... @@ -522,8 +522,11 @@
522 522  
523 523 if (sock->state != SS_CONNECTED)
524 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 528 return -EOPNOTSUPP;
  529 +
527 530 vcc = ATM_SD(sock);
528 531 if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
529 532 test_bit(ATM_VF_CLOSE, &vcc->flags) ||
... ... @@ -544,8 +547,13 @@
544 547 if (error)
545 548 return error;
546 549 sock_recv_ts_and_drops(msg, sk, skb);
547   - pr_debug("%d -= %d\n", atomic_read(&sk->sk_rmem_alloc), skb->truesize);
548   - atm_return(vcc, skb->truesize);
  550 +
  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 557 skb_free_datagram(sk, skb);
550 558 return copied;
551 559 }