All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] atm: cleanups and MSK_PEEK for atm sockets
@ 2011-11-21 20:25 Jorge Boncompte [DTI2]
  2011-11-21 20:25 ` [PATCH 1/5] atm: br2684: Do not move counters backwards Jorge Boncompte [DTI2]
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jorge Boncompte [DTI2] @ 2011-11-21 20:25 UTC (permalink / raw)
  To: netdev, linux-atm-general; +Cc: Jorge Boncompte [DTI2]

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

    This series does some cleanup and introduces MSG_PEEK support for ATM
sockets.

Jorge Boncompte [DTI2] (5):
  atm: br2684: Do not move counters backwards
  atm: clip: Don't move counters backwards
  atm: clip: move clip_devs check to clip_push
  atm: Introduce vcc_process_recv_queue
  atm: Allow MSG_PEEK for atm sockets

 net/atm/br2684.c  |   27 +++++----------------------
 net/atm/clip.c    |   34 +++++++++-------------------------
 net/atm/common.c  |   34 +++++++++++++++++++++++++++++++---
 net/atm/common.h  |    1 +
 net/atm/pppoatm.c |    4 ++++
 5 files changed, 50 insertions(+), 50 deletions(-)

-- 
1.7.7.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] atm: br2684: Do not move counters backwards
  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 ` Jorge Boncompte [DTI2]
  2011-11-21 20:25 ` [PATCH 2/5] atm: clip: Don't " Jorge Boncompte [DTI2]
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jorge Boncompte [DTI2] @ 2011-11-21 20:25 UTC (permalink / raw)
  To: netdev, linux-atm-general; +Cc: Jorge Boncompte [DTI2]

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

    This snippet has caused several bugs in the past, and I don't see the
point on substracting the skb len from netdev stats.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
---
 net/atm/br2684.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index d07223c..81cf33b 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -557,15 +557,8 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
 	skb_queue_splice_init(rq, &queue);
 	spin_unlock_irqrestore(&rq->lock, flags);
 
-	skb_queue_walk_safe(&queue, skb, tmp) {
-		struct net_device *dev;
-
+	skb_queue_walk_safe(&queue, skb, tmp)
 		br2684_push(atmvcc, skb);
-		dev = skb->dev;
-
-		dev->stats.rx_bytes -= skb->len;
-		dev->stats.rx_packets--;
-	}
 
 	/* initialize netdev carrier state */
 	if (atmvcc->dev->signal == ATM_PHY_SIG_LOST)
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] atm: clip: Don't move counters backwards
  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 ` Jorge Boncompte [DTI2]
  2011-11-21 20:25 ` [PATCH 3/5] atm: clip: move clip_devs check to clip_push Jorge Boncompte [DTI2]
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jorge Boncompte [DTI2] @ 2011-11-21 20:25 UTC (permalink / raw)
  To: netdev, linux-atm-general; +Cc: Jorge Boncompte [DTI2]

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

    I don't see the point on substracting the skb len from the netdev stats.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
---
 net/atm/clip.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/net/atm/clip.c b/net/atm/clip.c
index 8523940..3cb9470 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -484,16 +484,8 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout)
 		if (!clip_devs) {
 			atm_return(vcc, skb->truesize);
 			kfree_skb(skb);
-		} else {
-			struct net_device *dev = skb->dev;
-			unsigned int len = skb->len;
-
-			skb_get(skb);
+		} else
 			clip_push(vcc, skb);
-			dev->stats.rx_packets--;
-			dev->stats.rx_bytes -= len;
-			kfree_skb(skb);
-		}
 	}
 	return 0;
 }
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] atm: clip: move clip_devs check to clip_push
  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 ` Jorge Boncompte [DTI2]
  2011-11-21 20:25 ` [PATCH 4/5] atm: Introduce vcc_process_recv_queue Jorge Boncompte [DTI2]
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jorge Boncompte [DTI2] @ 2011-11-21 20:25 UTC (permalink / raw)
  To: netdev, linux-atm-general; +Cc: Jorge Boncompte [DTI2]

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

    This will allow further cleanup.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
---
 net/atm/clip.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/atm/clip.c b/net/atm/clip.c
index 3cb9470..521b45b 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -189,6 +189,13 @@ static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb)
 	struct clip_vcc *clip_vcc = CLIP_VCC(vcc);
 
 	pr_debug("\n");
+
+	if (!clip_devs) {
+		atm_return(vcc, skb->truesize);
+		kfree_skb(skb);
+		return;
+	}
+
 	if (!skb) {
 		pr_debug("removing VCC %p\n", clip_vcc);
 		if (clip_vcc->entry)
@@ -480,13 +487,9 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout)
 	spin_unlock_irqrestore(&rq->lock, flags);
 
 	/* re-process everything received between connection setup and MKIP */
-	skb_queue_walk_safe(&queue, skb, tmp) {
-		if (!clip_devs) {
-			atm_return(vcc, skb->truesize);
-			kfree_skb(skb);
-		} else
-			clip_push(vcc, skb);
-	}
+	skb_queue_walk_safe(&queue, skb, tmp)
+		clip_push(vcc, skb);
+
 	return 0;
 }
 
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] atm: Introduce vcc_process_recv_queue
  2011-11-21 20:25 [PATCH net-next 0/5] atm: cleanups and MSK_PEEK for atm sockets Jorge Boncompte [DTI2]
                   ` (2 preceding siblings ...)
  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 ` Jorge Boncompte [DTI2]
  2011-11-21 20:25 ` [PATCH 5/5] atm: Allow MSG_PEEK for atm sockets Jorge Boncompte [DTI2]
  2011-11-22 21:16 ` [PATCH net-next 0/5] atm: cleanups and MSK_PEEK " David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jorge Boncompte [DTI2] @ 2011-11-21 20:25 UTC (permalink / raw)
  To: netdev, linux-atm-general; +Cc: Jorge Boncompte [DTI2]

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

    This function moves the implementation found in the clip and br2684
modules to common code, correctly unlinks the skb from the queue before
pushing it and makes pppoatm use it.

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
---
 net/atm/br2684.c  |   20 +++++---------------
 net/atm/clip.c    |   13 +------------
 net/atm/common.c  |   20 ++++++++++++++++++++
 net/atm/common.h  |    1 +
 net/atm/pppoatm.c |    4 ++++
 5 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 81cf33b..53b0aa1 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -489,15 +489,11 @@ free_skb:
  */
 static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
 {
-	struct sk_buff_head queue;
-	int err;
 	struct br2684_vcc *brvcc;
-	struct sk_buff *skb, *tmp;
-	struct sk_buff_head *rq;
 	struct br2684_dev *brdev;
 	struct net_device *net_dev;
 	struct atm_backend_br2684 be;
-	unsigned long flags;
+	int err;
 
 	if (copy_from_user(&be, arg, sizeof be))
 		return -EFAULT;
@@ -550,16 +546,6 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
 	atmvcc->push = br2684_push;
 	atmvcc->pop = br2684_pop;
 
-	__skb_queue_head_init(&queue);
-	rq = &sk_atm(atmvcc)->sk_receive_queue;
-
-	spin_lock_irqsave(&rq->lock, flags);
-	skb_queue_splice_init(rq, &queue);
-	spin_unlock_irqrestore(&rq->lock, flags);
-
-	skb_queue_walk_safe(&queue, skb, tmp)
-		br2684_push(atmvcc, skb);
-
 	/* initialize netdev carrier state */
 	if (atmvcc->dev->signal == ATM_PHY_SIG_LOST)
 		netif_carrier_off(net_dev);
@@ -567,6 +553,10 @@ static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
 		netif_carrier_on(net_dev);
 
 	__module_get(THIS_MODULE);
+
+	/* re-process everything received between connection setup and
+	   backend setup */
+	vcc_process_recv_queue(atmvcc);
 	return 0;
 
 error:
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 521b45b..3d2ac66 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -455,10 +455,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
 
 static int clip_mkip(struct atm_vcc *vcc, int timeout)
 {
-	struct sk_buff_head *rq, queue;
 	struct clip_vcc *clip_vcc;
-	struct sk_buff *skb, *tmp;
-	unsigned long flags;
 
 	if (!vcc->push)
 		return -EBADFD;
@@ -479,16 +476,8 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout)
 	vcc->push = clip_push;
 	vcc->pop = clip_pop;
 
-	__skb_queue_head_init(&queue);
-	rq = &sk_atm(vcc)->sk_receive_queue;
-
-	spin_lock_irqsave(&rq->lock, flags);
-	skb_queue_splice_init(rq, &queue);
-	spin_unlock_irqrestore(&rq->lock, flags);
-
 	/* re-process everything received between connection setup and MKIP */
-	skb_queue_walk_safe(&queue, skb, tmp)
-		clip_push(vcc, skb);
+	vcc_process_recv_queue(vcc);
 
 	return 0;
 }
diff --git a/net/atm/common.c b/net/atm/common.c
index 14ff9fe..0b4c58f 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -214,6 +214,26 @@ void vcc_release_async(struct atm_vcc *vcc, int reply)
 }
 EXPORT_SYMBOL(vcc_release_async);
 
+void vcc_process_recv_queue(struct atm_vcc *vcc)
+{
+	struct sk_buff_head queue, *rq;
+	struct sk_buff *skb, *tmp;
+	unsigned long flags;
+
+	__skb_queue_head_init(&queue);
+	rq = &sk_atm(vcc)->sk_receive_queue;
+
+	spin_lock_irqsave(&rq->lock, flags);
+	skb_queue_splice_init(rq, &queue);
+	spin_unlock_irqrestore(&rq->lock, flags);
+
+	skb_queue_walk_safe(&queue, skb, tmp) {
+		__skb_unlink(skb, &queue);
+		vcc->push(vcc, skb);
+	}
+}
+EXPORT_SYMBOL(vcc_process_recv_queue);
+
 void atm_dev_signal_change(struct atm_dev *dev, char signal)
 {
 	pr_debug("%s signal=%d dev=%p number=%d dev->signal=%d\n",
diff --git a/net/atm/common.h b/net/atm/common.h
index f48a76b..cc3c2da 100644
--- a/net/atm/common.h
+++ b/net/atm/common.h
@@ -24,6 +24,7 @@ int vcc_setsockopt(struct socket *sock, int level, int optname,
 		   char __user *optval, unsigned int optlen);
 int vcc_getsockopt(struct socket *sock, int level, int optname,
 		   char __user *optval, int __user *optlen);
+void vcc_process_recv_queue(struct atm_vcc *vcc);
 
 int atmpvc_init(void);
 void atmpvc_exit(void);
diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c
index db4a11c..df35d9a 100644
--- a/net/atm/pppoatm.c
+++ b/net/atm/pppoatm.c
@@ -303,6 +303,10 @@ static int pppoatm_assign_vcc(struct atm_vcc *atmvcc, void __user *arg)
 	atmvcc->push = pppoatm_push;
 	atmvcc->pop = pppoatm_pop;
 	__module_get(THIS_MODULE);
+
+	/* re-process everything received between connection setup and
+	   backend setup */
+	vcc_process_recv_queue(atmvcc);
 	return 0;
 }
 
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] atm: Allow MSG_PEEK for atm sockets
  2011-11-21 20:25 [PATCH net-next 0/5] atm: cleanups and MSK_PEEK for atm sockets Jorge Boncompte [DTI2]
                   ` (3 preceding siblings ...)
  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]
  2011-11-22 21:16 ` [PATCH net-next 0/5] atm: cleanups and MSK_PEEK " David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jorge Boncompte [DTI2] @ 2011-11-21 20:25 UTC (permalink / raw)
  To: netdev, linux-atm-general; +Cc: Jorge Boncompte [DTI2]

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 0/5] atm: cleanups and MSK_PEEK for atm sockets
  2011-11-21 20:25 [PATCH net-next 0/5] atm: cleanups and MSK_PEEK for atm sockets Jorge Boncompte [DTI2]
                   ` (4 preceding siblings ...)
  2011-11-21 20:25 ` [PATCH 5/5] atm: Allow MSG_PEEK for atm sockets Jorge Boncompte [DTI2]
@ 2011-11-22 21:16 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2011-11-22 21:16 UTC (permalink / raw)
  To: jorge; +Cc: netdev, linux-atm-general

From: "Jorge Boncompte [DTI2]" <jorge@dti2.net>
Date: Mon, 21 Nov 2011 21:25:53 +0100

>     This series does some cleanup and introduces MSG_PEEK support for ATM
> sockets.

Applied, thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-22 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 5/5] atm: Allow MSG_PEEK for atm sockets Jorge Boncompte [DTI2]
2011-11-22 21:16 ` [PATCH net-next 0/5] atm: cleanups and MSK_PEEK " David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.