netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jorge Boncompte [DTI2]" <jorge@dti2.net>
To: netdev@vger.kernel.org, linux-atm-general@lists.sourceforge.net
Cc: "Jorge Boncompte [DTI2]" <jorge@dti2.net>
Subject: [PATCH 5/5] atm: Allow MSG_PEEK for atm sockets
Date: Mon, 21 Nov 2011 21:25:58 +0100	[thread overview]
Message-ID: <1321907158-27857-6-git-send-email-jorge@dti2.net> (raw)
In-Reply-To: <1321907158-27857-1-git-send-email-jorge@dti2.net>

From: "Jorge Boncompte [DTI2]" <jorge@dti2.net>

    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>
---
 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 0b4c58f..b4b44db 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;
 }
-- 
1.7.7.1

  parent reply	other threads:[~2011-11-21 20:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-21 20:25 [PATCH net-next 0/5] atm: cleanups and MSK_PEEK for atm sockets Jorge Boncompte [DTI2]
2011-11-21 20:25 ` [PATCH 1/5] atm: br2684: Do not move counters backwards Jorge Boncompte [DTI2]
2011-11-21 20:25 ` [PATCH 2/5] atm: clip: Don't " Jorge Boncompte [DTI2]
2011-11-21 20:25 ` [PATCH 3/5] atm: clip: move clip_devs check to clip_push Jorge Boncompte [DTI2]
2011-11-21 20:25 ` [PATCH 4/5] atm: Introduce vcc_process_recv_queue Jorge Boncompte [DTI2]
2011-11-21 20:25 ` Jorge Boncompte [DTI2] [this message]
2011-11-22 21:16 ` [PATCH net-next 0/5] atm: cleanups and MSK_PEEK for atm sockets David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321907158-27857-6-git-send-email-jorge@dti2.net \
    --to=jorge@dti2.net \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).