]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
atm: Introduce vcc_process_recv_queue
authorJorge Boncompte [DTI2] <jorge@dti2.net>
Mon, 21 Nov 2011 10:25:57 +0000 (10:25 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 22 Nov 2011 21:15:42 +0000 (16:15 -0500)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/atm/br2684.c
net/atm/clip.c
net/atm/common.c
net/atm/common.h
net/atm/pppoatm.c

index 81cf33b1527de0f4a0e72aeb289aba26e96ac8f8..53b0aa14a1e628f89059c2beb3ca02089ffd0a88 100644 (file)
@@ -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:
index e2de7c548b3a51544416b2b3fd48ce53ac757b4c..11439a7f67825fe554b9ca711204f547e7147e54 100644 (file)
@@ -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;
 }
index 14ff9fe399896c024630c3bced79de195cd5dd54..0b4c58fe39191b58bb6d627313e60087130a23a1 100644 (file)
@@ -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",
index f48a76b6cdf48845a5834800f6716113c9c95914..cc3c2dae4d793427259e614acfec579d42f0c2a1 100644 (file)
@@ -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);
index db4a11c61d15c08462623975d027d1bbb81fa4a2..df35d9a3b5fe91672cf0890d49566ae96e1f11e5 100644 (file)
@@ -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;
 }