1616#include <linux/init.h>
1717
1818static struct sk_buff_head loopback_queue ;
19+ #define ROSE_LOOPBACK_LIMIT 1000
1920static struct timer_list loopback_timer ;
2021
2122static void rose_set_loopback_timer (void );
@@ -35,29 +36,27 @@ static int rose_loopback_running(void)
3536
3637int rose_loopback_queue (struct sk_buff * skb , struct rose_neigh * neigh )
3738{
38- struct sk_buff * skbn ;
39+ struct sk_buff * skbn = NULL ;
3940
40- skbn = skb_clone (skb , GFP_ATOMIC );
41+ if (skb_queue_len (& loopback_queue ) < ROSE_LOOPBACK_LIMIT )
42+ skbn = skb_clone (skb , GFP_ATOMIC );
4143
42- kfree_skb (skb );
43-
44- if (skbn != NULL ) {
44+ if (skbn ) {
45+ consume_skb (skb );
4546 skb_queue_tail (& loopback_queue , skbn );
4647
4748 if (!rose_loopback_running ())
4849 rose_set_loopback_timer ();
50+ } else {
51+ kfree_skb (skb );
4952 }
5053
5154 return 1 ;
5255}
5356
54-
5557static void rose_set_loopback_timer (void )
5658{
57- del_timer (& loopback_timer );
58-
59- loopback_timer .expires = jiffies + 10 ;
60- add_timer (& loopback_timer );
59+ mod_timer (& loopback_timer , jiffies + 10 );
6160}
6261
6362static void rose_loopback_timer (struct timer_list * unused )
@@ -68,8 +67,12 @@ static void rose_loopback_timer(struct timer_list *unused)
6867 struct sock * sk ;
6968 unsigned short frametype ;
7069 unsigned int lci_i , lci_o ;
70+ int count ;
7171
72- while ((skb = skb_dequeue (& loopback_queue )) != NULL ) {
72+ for (count = 0 ; count < ROSE_LOOPBACK_LIMIT ; count ++ ) {
73+ skb = skb_dequeue (& loopback_queue );
74+ if (!skb )
75+ return ;
7376 if (skb -> len < ROSE_MIN_LEN ) {
7477 kfree_skb (skb );
7578 continue ;
@@ -106,6 +109,8 @@ static void rose_loopback_timer(struct timer_list *unused)
106109 kfree_skb (skb );
107110 }
108111 }
112+ if (!skb_queue_empty (& loopback_queue ))
113+ mod_timer (& loopback_timer , jiffies + 1 );
109114}
110115
111116void __exit rose_loopback_clear (void )
0 commit comments