diff options
Diffstat (limited to 'net/atm/clip.c')
-rw-r--r-- | net/atm/clip.c | 462 |
1 files changed, 219 insertions, 243 deletions
diff --git a/net/atm/clip.c b/net/atm/clip.c index 3ab4e7947bab..72d852982664 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ | 3 | /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */ |
4 | 4 | ||
5 | |||
6 | #include <linux/config.h> | 5 | #include <linux/config.h> |
7 | #include <linux/string.h> | 6 | #include <linux/string.h> |
8 | #include <linux/errno.h> | 7 | #include <linux/errno.h> |
@@ -54,24 +53,24 @@ static struct net_device *clip_devs; | |||
54 | static struct atm_vcc *atmarpd; | 53 | static struct atm_vcc *atmarpd; |
55 | static struct neigh_table clip_tbl; | 54 | static struct neigh_table clip_tbl; |
56 | static struct timer_list idle_timer; | 55 | static struct timer_list idle_timer; |
57 | static int start_timer = 1; | ||
58 | |||
59 | 56 | ||
60 | static int to_atmarpd(enum atmarp_ctrl_type type,int itf,unsigned long ip) | 57 | static int to_atmarpd(enum atmarp_ctrl_type type, int itf, unsigned long ip) |
61 | { | 58 | { |
62 | struct sock *sk; | 59 | struct sock *sk; |
63 | struct atmarp_ctrl *ctrl; | 60 | struct atmarp_ctrl *ctrl; |
64 | struct sk_buff *skb; | 61 | struct sk_buff *skb; |
65 | 62 | ||
66 | DPRINTK("to_atmarpd(%d)\n",type); | 63 | DPRINTK("to_atmarpd(%d)\n", type); |
67 | if (!atmarpd) return -EUNATCH; | 64 | if (!atmarpd) |
65 | return -EUNATCH; | ||
68 | skb = alloc_skb(sizeof(struct atmarp_ctrl),GFP_ATOMIC); | 66 | skb = alloc_skb(sizeof(struct atmarp_ctrl),GFP_ATOMIC); |
69 | if (!skb) return -ENOMEM; | 67 | if (!skb) |
68 | return -ENOMEM; | ||
70 | ctrl = (struct atmarp_ctrl *) skb_put(skb,sizeof(struct atmarp_ctrl)); | 69 | ctrl = (struct atmarp_ctrl *) skb_put(skb,sizeof(struct atmarp_ctrl)); |
71 | ctrl->type = type; | 70 | ctrl->type = type; |
72 | ctrl->itf_num = itf; | 71 | ctrl->itf_num = itf; |
73 | ctrl->ip = ip; | 72 | ctrl->ip = ip; |
74 | atm_force_charge(atmarpd,skb->truesize); | 73 | atm_force_charge(atmarpd, skb->truesize); |
75 | 74 | ||
76 | sk = sk_atm(atmarpd); | 75 | sk = sk_atm(atmarpd); |
77 | skb_queue_tail(&sk->sk_receive_queue, skb); | 76 | skb_queue_tail(&sk->sk_receive_queue, skb); |
@@ -79,26 +78,24 @@ static int to_atmarpd(enum atmarp_ctrl_type type,int itf,unsigned long ip) | |||
79 | return 0; | 78 | return 0; |
80 | } | 79 | } |
81 | 80 | ||
82 | 81 | static void link_vcc(struct clip_vcc *clip_vcc, struct atmarp_entry *entry) | |
83 | static void link_vcc(struct clip_vcc *clip_vcc,struct atmarp_entry *entry) | ||
84 | { | 82 | { |
85 | DPRINTK("link_vcc %p to entry %p (neigh %p)\n",clip_vcc,entry, | 83 | DPRINTK("link_vcc %p to entry %p (neigh %p)\n", clip_vcc, entry, |
86 | entry->neigh); | 84 | entry->neigh); |
87 | clip_vcc->entry = entry; | 85 | clip_vcc->entry = entry; |
88 | clip_vcc->xoff = 0; /* @@@ may overrun buffer by one packet */ | 86 | clip_vcc->xoff = 0; /* @@@ may overrun buffer by one packet */ |
89 | clip_vcc->next = entry->vccs; | 87 | clip_vcc->next = entry->vccs; |
90 | entry->vccs = clip_vcc; | 88 | entry->vccs = clip_vcc; |
91 | entry->neigh->used = jiffies; | 89 | entry->neigh->used = jiffies; |
92 | } | 90 | } |
93 | 91 | ||
94 | |||
95 | static void unlink_clip_vcc(struct clip_vcc *clip_vcc) | 92 | static void unlink_clip_vcc(struct clip_vcc *clip_vcc) |
96 | { | 93 | { |
97 | struct atmarp_entry *entry = clip_vcc->entry; | 94 | struct atmarp_entry *entry = clip_vcc->entry; |
98 | struct clip_vcc **walk; | 95 | struct clip_vcc **walk; |
99 | 96 | ||
100 | if (!entry) { | 97 | if (!entry) { |
101 | printk(KERN_CRIT "!clip_vcc->entry (clip_vcc %p)\n",clip_vcc); | 98 | printk(KERN_CRIT "!clip_vcc->entry (clip_vcc %p)\n", clip_vcc); |
102 | return; | 99 | return; |
103 | } | 100 | } |
104 | spin_lock_bh(&entry->neigh->dev->xmit_lock); /* block clip_start_xmit() */ | 101 | spin_lock_bh(&entry->neigh->dev->xmit_lock); /* block clip_start_xmit() */ |
@@ -107,24 +104,24 @@ static void unlink_clip_vcc(struct clip_vcc *clip_vcc) | |||
107 | if (*walk == clip_vcc) { | 104 | if (*walk == clip_vcc) { |
108 | int error; | 105 | int error; |
109 | 106 | ||
110 | *walk = clip_vcc->next; /* atomic */ | 107 | *walk = clip_vcc->next; /* atomic */ |
111 | clip_vcc->entry = NULL; | 108 | clip_vcc->entry = NULL; |
112 | if (clip_vcc->xoff) | 109 | if (clip_vcc->xoff) |
113 | netif_wake_queue(entry->neigh->dev); | 110 | netif_wake_queue(entry->neigh->dev); |
114 | if (entry->vccs) | 111 | if (entry->vccs) |
115 | goto out; | 112 | goto out; |
116 | entry->expires = jiffies-1; | 113 | entry->expires = jiffies - 1; |
117 | /* force resolution or expiration */ | 114 | /* force resolution or expiration */ |
118 | error = neigh_update(entry->neigh, NULL, NUD_NONE, | 115 | error = neigh_update(entry->neigh, NULL, NUD_NONE, |
119 | NEIGH_UPDATE_F_ADMIN); | 116 | NEIGH_UPDATE_F_ADMIN); |
120 | if (error) | 117 | if (error) |
121 | printk(KERN_CRIT "unlink_clip_vcc: " | 118 | printk(KERN_CRIT "unlink_clip_vcc: " |
122 | "neigh_update failed with %d\n",error); | 119 | "neigh_update failed with %d\n", error); |
123 | goto out; | 120 | goto out; |
124 | } | 121 | } |
125 | printk(KERN_CRIT "ATMARP: unlink_clip_vcc failed (entry %p, vcc " | 122 | printk(KERN_CRIT "ATMARP: unlink_clip_vcc failed (entry %p, vcc " |
126 | "0x%p)\n",entry,clip_vcc); | 123 | "0x%p)\n", entry, clip_vcc); |
127 | out: | 124 | out: |
128 | spin_unlock_bh(&entry->neigh->dev->xmit_lock); | 125 | spin_unlock_bh(&entry->neigh->dev->xmit_lock); |
129 | } | 126 | } |
130 | 127 | ||
@@ -153,13 +150,13 @@ static int neigh_check_cb(struct neighbour *n) | |||
153 | DPRINTK("destruction postponed with ref %d\n", | 150 | DPRINTK("destruction postponed with ref %d\n", |
154 | atomic_read(&n->refcnt)); | 151 | atomic_read(&n->refcnt)); |
155 | 152 | ||
156 | while ((skb = skb_dequeue(&n->arp_queue)) != NULL) | 153 | while ((skb = skb_dequeue(&n->arp_queue)) != NULL) |
157 | dev_kfree_skb(skb); | 154 | dev_kfree_skb(skb); |
158 | 155 | ||
159 | return 0; | 156 | return 0; |
160 | } | 157 | } |
161 | 158 | ||
162 | DPRINTK("expired neigh %p\n",n); | 159 | DPRINTK("expired neigh %p\n", n); |
163 | return 1; | 160 | return 1; |
164 | } | 161 | } |
165 | 162 | ||
@@ -167,7 +164,7 @@ static void idle_timer_check(unsigned long dummy) | |||
167 | { | 164 | { |
168 | write_lock(&clip_tbl.lock); | 165 | write_lock(&clip_tbl.lock); |
169 | __neigh_for_each_release(&clip_tbl, neigh_check_cb); | 166 | __neigh_for_each_release(&clip_tbl, neigh_check_cb); |
170 | mod_timer(&idle_timer, jiffies+CLIP_CHECK_INTERVAL*HZ); | 167 | mod_timer(&idle_timer, jiffies + CLIP_CHECK_INTERVAL * HZ); |
171 | write_unlock(&clip_tbl.lock); | 168 | write_unlock(&clip_tbl.lock); |
172 | } | 169 | } |
173 | 170 | ||
@@ -177,13 +174,13 @@ static int clip_arp_rcv(struct sk_buff *skb) | |||
177 | 174 | ||
178 | DPRINTK("clip_arp_rcv\n"); | 175 | DPRINTK("clip_arp_rcv\n"); |
179 | vcc = ATM_SKB(skb)->vcc; | 176 | vcc = ATM_SKB(skb)->vcc; |
180 | if (!vcc || !atm_charge(vcc,skb->truesize)) { | 177 | if (!vcc || !atm_charge(vcc, skb->truesize)) { |
181 | dev_kfree_skb_any(skb); | 178 | dev_kfree_skb_any(skb); |
182 | return 0; | 179 | return 0; |
183 | } | 180 | } |
184 | DPRINTK("pushing to %p\n",vcc); | 181 | DPRINTK("pushing to %p\n", vcc); |
185 | DPRINTK("using %p\n",CLIP_VCC(vcc)->old_push); | 182 | DPRINTK("using %p\n", CLIP_VCC(vcc)->old_push); |
186 | CLIP_VCC(vcc)->old_push(vcc,skb); | 183 | CLIP_VCC(vcc)->old_push(vcc, skb); |
187 | return 0; | 184 | return 0; |
188 | } | 185 | } |
189 | 186 | ||
@@ -193,34 +190,38 @@ static const unsigned char llc_oui[] = { | |||
193 | 0x03, /* Ctrl: Unnumbered Information Command PDU */ | 190 | 0x03, /* Ctrl: Unnumbered Information Command PDU */ |
194 | 0x00, /* OUI: EtherType */ | 191 | 0x00, /* OUI: EtherType */ |
195 | 0x00, | 192 | 0x00, |
196 | 0x00 }; | 193 | 0x00 |
194 | }; | ||
197 | 195 | ||
198 | static void clip_push(struct atm_vcc *vcc,struct sk_buff *skb) | 196 | static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb) |
199 | { | 197 | { |
200 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); | 198 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); |
201 | 199 | ||
202 | DPRINTK("clip push\n"); | 200 | DPRINTK("clip push\n"); |
203 | if (!skb) { | 201 | if (!skb) { |
204 | DPRINTK("removing VCC %p\n",clip_vcc); | 202 | DPRINTK("removing VCC %p\n", clip_vcc); |
205 | if (clip_vcc->entry) unlink_clip_vcc(clip_vcc); | 203 | if (clip_vcc->entry) |
206 | clip_vcc->old_push(vcc,NULL); /* pass on the bad news */ | 204 | unlink_clip_vcc(clip_vcc); |
205 | clip_vcc->old_push(vcc, NULL); /* pass on the bad news */ | ||
207 | kfree(clip_vcc); | 206 | kfree(clip_vcc); |
208 | return; | 207 | return; |
209 | } | 208 | } |
210 | atm_return(vcc,skb->truesize); | 209 | atm_return(vcc, skb->truesize); |
211 | skb->dev = clip_vcc->entry ? clip_vcc->entry->neigh->dev : clip_devs; | 210 | skb->dev = clip_vcc->entry ? clip_vcc->entry->neigh->dev : clip_devs; |
212 | /* clip_vcc->entry == NULL if we don't have an IP address yet */ | 211 | /* clip_vcc->entry == NULL if we don't have an IP address yet */ |
213 | if (!skb->dev) { | 212 | if (!skb->dev) { |
214 | dev_kfree_skb_any(skb); | 213 | dev_kfree_skb_any(skb); |
215 | return; | 214 | return; |
216 | } | 215 | } |
217 | ATM_SKB(skb)->vcc = vcc; | 216 | ATM_SKB(skb)->vcc = vcc; |
218 | skb->mac.raw = skb->data; | 217 | skb->mac.raw = skb->data; |
219 | if (!clip_vcc->encap || skb->len < RFC1483LLC_LEN || memcmp(skb->data, | 218 | if (!clip_vcc->encap |
220 | llc_oui,sizeof(llc_oui))) skb->protocol = htons(ETH_P_IP); | 219 | || skb->len < RFC1483LLC_LEN |
220 | || memcmp(skb->data, llc_oui, sizeof (llc_oui))) | ||
221 | skb->protocol = htons(ETH_P_IP); | ||
221 | else { | 222 | else { |
222 | skb->protocol = ((u16 *) skb->data)[3]; | 223 | skb->protocol = ((u16 *) skb->data)[3]; |
223 | skb_pull(skb,RFC1483LLC_LEN); | 224 | skb_pull(skb, RFC1483LLC_LEN); |
224 | if (skb->protocol == htons(ETH_P_ARP)) { | 225 | if (skb->protocol == htons(ETH_P_ARP)) { |
225 | PRIV(skb->dev)->stats.rx_packets++; | 226 | PRIV(skb->dev)->stats.rx_packets++; |
226 | PRIV(skb->dev)->stats.rx_bytes += skb->len; | 227 | PRIV(skb->dev)->stats.rx_bytes += skb->len; |
@@ -235,58 +236,54 @@ static void clip_push(struct atm_vcc *vcc,struct sk_buff *skb) | |||
235 | netif_rx(skb); | 236 | netif_rx(skb); |
236 | } | 237 | } |
237 | 238 | ||
238 | |||
239 | /* | 239 | /* |
240 | * Note: these spinlocks _must_not_ block on non-SMP. The only goal is that | 240 | * Note: these spinlocks _must_not_ block on non-SMP. The only goal is that |
241 | * clip_pop is atomic with respect to the critical section in clip_start_xmit. | 241 | * clip_pop is atomic with respect to the critical section in clip_start_xmit. |
242 | */ | 242 | */ |
243 | 243 | ||
244 | 244 | static void clip_pop(struct atm_vcc *vcc, struct sk_buff *skb) | |
245 | static void clip_pop(struct atm_vcc *vcc,struct sk_buff *skb) | ||
246 | { | 245 | { |
247 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); | 246 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); |
248 | struct net_device *dev = skb->dev; | 247 | struct net_device *dev = skb->dev; |
249 | int old; | 248 | int old; |
250 | unsigned long flags; | 249 | unsigned long flags; |
251 | 250 | ||
252 | DPRINTK("clip_pop(vcc %p)\n",vcc); | 251 | DPRINTK("clip_pop(vcc %p)\n", vcc); |
253 | clip_vcc->old_pop(vcc,skb); | 252 | clip_vcc->old_pop(vcc, skb); |
254 | /* skb->dev == NULL in outbound ARP packets */ | 253 | /* skb->dev == NULL in outbound ARP packets */ |
255 | if (!dev) return; | 254 | if (!dev) |
256 | spin_lock_irqsave(&PRIV(dev)->xoff_lock,flags); | 255 | return; |
257 | if (atm_may_send(vcc,0)) { | 256 | spin_lock_irqsave(&PRIV(dev)->xoff_lock, flags); |
258 | old = xchg(&clip_vcc->xoff,0); | 257 | if (atm_may_send(vcc, 0)) { |
259 | if (old) netif_wake_queue(dev); | 258 | old = xchg(&clip_vcc->xoff, 0); |
259 | if (old) | ||
260 | netif_wake_queue(dev); | ||
260 | } | 261 | } |
261 | spin_unlock_irqrestore(&PRIV(dev)->xoff_lock,flags); | 262 | spin_unlock_irqrestore(&PRIV(dev)->xoff_lock, flags); |
262 | } | 263 | } |
263 | 264 | ||
264 | |||
265 | static void clip_neigh_destroy(struct neighbour *neigh) | 265 | static void clip_neigh_destroy(struct neighbour *neigh) |
266 | { | 266 | { |
267 | DPRINTK("clip_neigh_destroy (neigh %p)\n",neigh); | 267 | DPRINTK("clip_neigh_destroy (neigh %p)\n", neigh); |
268 | if (NEIGH2ENTRY(neigh)->vccs) | 268 | if (NEIGH2ENTRY(neigh)->vccs) |
269 | printk(KERN_CRIT "clip_neigh_destroy: vccs != NULL !!!\n"); | 269 | printk(KERN_CRIT "clip_neigh_destroy: vccs != NULL !!!\n"); |
270 | NEIGH2ENTRY(neigh)->vccs = (void *) 0xdeadbeef; | 270 | NEIGH2ENTRY(neigh)->vccs = (void *) 0xdeadbeef; |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | static void clip_neigh_solicit(struct neighbour *neigh, struct sk_buff *skb) | |
274 | static void clip_neigh_solicit(struct neighbour *neigh,struct sk_buff *skb) | ||
275 | { | 274 | { |
276 | DPRINTK("clip_neigh_solicit (neigh %p, skb %p)\n",neigh,skb); | 275 | DPRINTK("clip_neigh_solicit (neigh %p, skb %p)\n", neigh, skb); |
277 | to_atmarpd(act_need,PRIV(neigh->dev)->number,NEIGH2ENTRY(neigh)->ip); | 276 | to_atmarpd(act_need, PRIV(neigh->dev)->number, NEIGH2ENTRY(neigh)->ip); |
278 | } | 277 | } |
279 | 278 | ||
280 | 279 | static void clip_neigh_error(struct neighbour *neigh, struct sk_buff *skb) | |
281 | static void clip_neigh_error(struct neighbour *neigh,struct sk_buff *skb) | ||
282 | { | 280 | { |
283 | #ifndef CONFIG_ATM_CLIP_NO_ICMP | 281 | #ifndef CONFIG_ATM_CLIP_NO_ICMP |
284 | icmp_send(skb,ICMP_DEST_UNREACH,ICMP_HOST_UNREACH,0); | 282 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); |
285 | #endif | 283 | #endif |
286 | kfree_skb(skb); | 284 | kfree_skb(skb); |
287 | } | 285 | } |
288 | 286 | ||
289 | |||
290 | static struct neigh_ops clip_neigh_ops = { | 287 | static struct neigh_ops clip_neigh_ops = { |
291 | .family = AF_INET, | 288 | .family = AF_INET, |
292 | .solicit = clip_neigh_solicit, | 289 | .solicit = clip_neigh_solicit, |
@@ -297,7 +294,6 @@ static struct neigh_ops clip_neigh_ops = { | |||
297 | .queue_xmit = dev_queue_xmit, | 294 | .queue_xmit = dev_queue_xmit, |
298 | }; | 295 | }; |
299 | 296 | ||
300 | |||
301 | static int clip_constructor(struct neighbour *neigh) | 297 | static int clip_constructor(struct neighbour *neigh) |
302 | { | 298 | { |
303 | struct atmarp_entry *entry = NEIGH2ENTRY(neigh); | 299 | struct atmarp_entry *entry = NEIGH2ENTRY(neigh); |
@@ -305,9 +301,10 @@ static int clip_constructor(struct neighbour *neigh) | |||
305 | struct in_device *in_dev; | 301 | struct in_device *in_dev; |
306 | struct neigh_parms *parms; | 302 | struct neigh_parms *parms; |
307 | 303 | ||
308 | DPRINTK("clip_constructor (neigh %p, entry %p)\n",neigh,entry); | 304 | DPRINTK("clip_constructor (neigh %p, entry %p)\n", neigh, entry); |
309 | neigh->type = inet_addr_type(entry->ip); | 305 | neigh->type = inet_addr_type(entry->ip); |
310 | if (neigh->type != RTN_UNICAST) return -EINVAL; | 306 | if (neigh->type != RTN_UNICAST) |
307 | return -EINVAL; | ||
311 | 308 | ||
312 | rcu_read_lock(); | 309 | rcu_read_lock(); |
313 | in_dev = __in_dev_get_rcu(dev); | 310 | in_dev = __in_dev_get_rcu(dev); |
@@ -326,13 +323,13 @@ static int clip_constructor(struct neighbour *neigh) | |||
326 | neigh->ops->connected_output : neigh->ops->output; | 323 | neigh->ops->connected_output : neigh->ops->output; |
327 | entry->neigh = neigh; | 324 | entry->neigh = neigh; |
328 | entry->vccs = NULL; | 325 | entry->vccs = NULL; |
329 | entry->expires = jiffies-1; | 326 | entry->expires = jiffies - 1; |
330 | return 0; | 327 | return 0; |
331 | } | 328 | } |
332 | 329 | ||
333 | static u32 clip_hash(const void *pkey, const struct net_device *dev) | 330 | static u32 clip_hash(const void *pkey, const struct net_device *dev) |
334 | { | 331 | { |
335 | return jhash_2words(*(u32 *)pkey, dev->ifindex, clip_tbl.hash_rnd); | 332 | return jhash_2words(*(u32 *) pkey, dev->ifindex, clip_tbl.hash_rnd); |
336 | } | 333 | } |
337 | 334 | ||
338 | static struct neigh_table clip_tbl = { | 335 | static struct neigh_table clip_tbl = { |
@@ -366,7 +363,6 @@ static struct neigh_table clip_tbl = { | |||
366 | .gc_thresh3 = 1024, | 363 | .gc_thresh3 = 1024, |
367 | }; | 364 | }; |
368 | 365 | ||
369 | |||
370 | /* @@@ copy bh locking from arp.c -- need to bh-enable atm code before */ | 366 | /* @@@ copy bh locking from arp.c -- need to bh-enable atm code before */ |
371 | 367 | ||
372 | /* | 368 | /* |
@@ -376,15 +372,13 @@ static struct neigh_table clip_tbl = { | |||
376 | * clip_setentry. | 372 | * clip_setentry. |
377 | */ | 373 | */ |
378 | 374 | ||
379 | 375 | static int clip_encap(struct atm_vcc *vcc, int mode) | |
380 | static int clip_encap(struct atm_vcc *vcc,int mode) | ||
381 | { | 376 | { |
382 | CLIP_VCC(vcc)->encap = mode; | 377 | CLIP_VCC(vcc)->encap = mode; |
383 | return 0; | 378 | return 0; |
384 | } | 379 | } |
385 | 380 | ||
386 | 381 | static int clip_start_xmit(struct sk_buff *skb, struct net_device *dev) | |
387 | static int clip_start_xmit(struct sk_buff *skb,struct net_device *dev) | ||
388 | { | 382 | { |
389 | struct clip_priv *clip_priv = PRIV(dev); | 383 | struct clip_priv *clip_priv = PRIV(dev); |
390 | struct atmarp_entry *entry; | 384 | struct atmarp_entry *entry; |
@@ -392,7 +386,7 @@ static int clip_start_xmit(struct sk_buff *skb,struct net_device *dev) | |||
392 | int old; | 386 | int old; |
393 | unsigned long flags; | 387 | unsigned long flags; |
394 | 388 | ||
395 | DPRINTK("clip_start_xmit (skb %p)\n",skb); | 389 | DPRINTK("clip_start_xmit (skb %p)\n", skb); |
396 | if (!skb->dst) { | 390 | if (!skb->dst) { |
397 | printk(KERN_ERR "clip_start_xmit: skb->dst == NULL\n"); | 391 | printk(KERN_ERR "clip_start_xmit: skb->dst == NULL\n"); |
398 | dev_kfree_skb(skb); | 392 | dev_kfree_skb(skb); |
@@ -401,9 +395,9 @@ static int clip_start_xmit(struct sk_buff *skb,struct net_device *dev) | |||
401 | } | 395 | } |
402 | if (!skb->dst->neighbour) { | 396 | if (!skb->dst->neighbour) { |
403 | #if 0 | 397 | #if 0 |
404 | skb->dst->neighbour = clip_find_neighbour(skb->dst,1); | 398 | skb->dst->neighbour = clip_find_neighbour(skb->dst, 1); |
405 | if (!skb->dst->neighbour) { | 399 | if (!skb->dst->neighbour) { |
406 | dev_kfree_skb(skb); /* lost that one */ | 400 | dev_kfree_skb(skb); /* lost that one */ |
407 | clip_priv->stats.tx_dropped++; | 401 | clip_priv->stats.tx_dropped++; |
408 | return 0; | 402 | return 0; |
409 | } | 403 | } |
@@ -417,73 +411,73 @@ static int clip_start_xmit(struct sk_buff *skb,struct net_device *dev) | |||
417 | if (!entry->vccs) { | 411 | if (!entry->vccs) { |
418 | if (time_after(jiffies, entry->expires)) { | 412 | if (time_after(jiffies, entry->expires)) { |
419 | /* should be resolved */ | 413 | /* should be resolved */ |
420 | entry->expires = jiffies+ATMARP_RETRY_DELAY*HZ; | 414 | entry->expires = jiffies + ATMARP_RETRY_DELAY * HZ; |
421 | to_atmarpd(act_need,PRIV(dev)->number,entry->ip); | 415 | to_atmarpd(act_need, PRIV(dev)->number, entry->ip); |
422 | } | 416 | } |
423 | if (entry->neigh->arp_queue.qlen < ATMARP_MAX_UNRES_PACKETS) | 417 | if (entry->neigh->arp_queue.qlen < ATMARP_MAX_UNRES_PACKETS) |
424 | skb_queue_tail(&entry->neigh->arp_queue,skb); | 418 | skb_queue_tail(&entry->neigh->arp_queue, skb); |
425 | else { | 419 | else { |
426 | dev_kfree_skb(skb); | 420 | dev_kfree_skb(skb); |
427 | clip_priv->stats.tx_dropped++; | 421 | clip_priv->stats.tx_dropped++; |
428 | } | 422 | } |
429 | return 0; | 423 | return 0; |
430 | } | 424 | } |
431 | DPRINTK("neigh %p, vccs %p\n",entry,entry->vccs); | 425 | DPRINTK("neigh %p, vccs %p\n", entry, entry->vccs); |
432 | ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc; | 426 | ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc; |
433 | DPRINTK("using neighbour %p, vcc %p\n",skb->dst->neighbour,vcc); | 427 | DPRINTK("using neighbour %p, vcc %p\n", skb->dst->neighbour, vcc); |
434 | if (entry->vccs->encap) { | 428 | if (entry->vccs->encap) { |
435 | void *here; | 429 | void *here; |
436 | 430 | ||
437 | here = skb_push(skb,RFC1483LLC_LEN); | 431 | here = skb_push(skb, RFC1483LLC_LEN); |
438 | memcpy(here,llc_oui,sizeof(llc_oui)); | 432 | memcpy(here, llc_oui, sizeof(llc_oui)); |
439 | ((u16 *) here)[3] = skb->protocol; | 433 | ((u16 *) here)[3] = skb->protocol; |
440 | } | 434 | } |
441 | atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); | 435 | atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); |
442 | ATM_SKB(skb)->atm_options = vcc->atm_options; | 436 | ATM_SKB(skb)->atm_options = vcc->atm_options; |
443 | entry->vccs->last_use = jiffies; | 437 | entry->vccs->last_use = jiffies; |
444 | DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n",skb,vcc,vcc->dev); | 438 | DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev); |
445 | old = xchg(&entry->vccs->xoff,1); /* assume XOFF ... */ | 439 | old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */ |
446 | if (old) { | 440 | if (old) { |
447 | printk(KERN_WARNING "clip_start_xmit: XOFF->XOFF transition\n"); | 441 | printk(KERN_WARNING "clip_start_xmit: XOFF->XOFF transition\n"); |
448 | return 0; | 442 | return 0; |
449 | } | 443 | } |
450 | clip_priv->stats.tx_packets++; | 444 | clip_priv->stats.tx_packets++; |
451 | clip_priv->stats.tx_bytes += skb->len; | 445 | clip_priv->stats.tx_bytes += skb->len; |
452 | (void) vcc->send(vcc,skb); | 446 | vcc->send(vcc, skb); |
453 | if (atm_may_send(vcc,0)) { | 447 | if (atm_may_send(vcc, 0)) { |
454 | entry->vccs->xoff = 0; | 448 | entry->vccs->xoff = 0; |
455 | return 0; | 449 | return 0; |
456 | } | 450 | } |
457 | spin_lock_irqsave(&clip_priv->xoff_lock,flags); | 451 | spin_lock_irqsave(&clip_priv->xoff_lock, flags); |
458 | netif_stop_queue(dev); /* XOFF -> throttle immediately */ | 452 | netif_stop_queue(dev); /* XOFF -> throttle immediately */ |
459 | barrier(); | 453 | barrier(); |
460 | if (!entry->vccs->xoff) | 454 | if (!entry->vccs->xoff) |
461 | netif_start_queue(dev); | 455 | netif_start_queue(dev); |
462 | /* Oh, we just raced with clip_pop. netif_start_queue should be | 456 | /* Oh, we just raced with clip_pop. netif_start_queue should be |
463 | good enough, because nothing should really be asleep because | 457 | good enough, because nothing should really be asleep because |
464 | of the brief netif_stop_queue. If this isn't true or if it | 458 | of the brief netif_stop_queue. If this isn't true or if it |
465 | changes, use netif_wake_queue instead. */ | 459 | changes, use netif_wake_queue instead. */ |
466 | spin_unlock_irqrestore(&clip_priv->xoff_lock,flags); | 460 | spin_unlock_irqrestore(&clip_priv->xoff_lock, flags); |
467 | return 0; | 461 | return 0; |
468 | } | 462 | } |
469 | 463 | ||
470 | |||
471 | static struct net_device_stats *clip_get_stats(struct net_device *dev) | 464 | static struct net_device_stats *clip_get_stats(struct net_device *dev) |
472 | { | 465 | { |
473 | return &PRIV(dev)->stats; | 466 | return &PRIV(dev)->stats; |
474 | } | 467 | } |
475 | 468 | ||
476 | 469 | static int clip_mkip(struct atm_vcc *vcc, int timeout) | |
477 | static int clip_mkip(struct atm_vcc *vcc,int timeout) | ||
478 | { | 470 | { |
479 | struct clip_vcc *clip_vcc; | 471 | struct clip_vcc *clip_vcc; |
480 | struct sk_buff_head copy; | 472 | struct sk_buff_head copy; |
481 | struct sk_buff *skb; | 473 | struct sk_buff *skb; |
482 | 474 | ||
483 | if (!vcc->push) return -EBADFD; | 475 | if (!vcc->push) |
484 | clip_vcc = kmalloc(sizeof(struct clip_vcc),GFP_KERNEL); | 476 | return -EBADFD; |
485 | if (!clip_vcc) return -ENOMEM; | 477 | clip_vcc = kmalloc(sizeof(struct clip_vcc), GFP_KERNEL); |
486 | DPRINTK("mkip clip_vcc %p vcc %p\n",clip_vcc,vcc); | 478 | if (!clip_vcc) |
479 | return -ENOMEM; | ||
480 | DPRINTK("mkip clip_vcc %p vcc %p\n", clip_vcc, vcc); | ||
487 | clip_vcc->vcc = vcc; | 481 | clip_vcc->vcc = vcc; |
488 | vcc->user_back = clip_vcc; | 482 | vcc->user_back = clip_vcc; |
489 | set_bit(ATM_VF_IS_CLIP, &vcc->flags); | 483 | set_bit(ATM_VF_IS_CLIP, &vcc->flags); |
@@ -491,7 +485,7 @@ static int clip_mkip(struct atm_vcc *vcc,int timeout) | |||
491 | clip_vcc->xoff = 0; | 485 | clip_vcc->xoff = 0; |
492 | clip_vcc->encap = 1; | 486 | clip_vcc->encap = 1; |
493 | clip_vcc->last_use = jiffies; | 487 | clip_vcc->last_use = jiffies; |
494 | clip_vcc->idle_timeout = timeout*HZ; | 488 | clip_vcc->idle_timeout = timeout * HZ; |
495 | clip_vcc->old_push = vcc->push; | 489 | clip_vcc->old_push = vcc->push; |
496 | clip_vcc->old_pop = vcc->pop; | 490 | clip_vcc->old_pop = vcc->pop; |
497 | vcc->push = clip_push; | 491 | vcc->push = clip_push; |
@@ -501,27 +495,25 @@ static int clip_mkip(struct atm_vcc *vcc,int timeout) | |||
501 | /* re-process everything received between connection setup and MKIP */ | 495 | /* re-process everything received between connection setup and MKIP */ |
502 | while ((skb = skb_dequeue(©)) != NULL) | 496 | while ((skb = skb_dequeue(©)) != NULL) |
503 | if (!clip_devs) { | 497 | if (!clip_devs) { |
504 | atm_return(vcc,skb->truesize); | 498 | atm_return(vcc, skb->truesize); |
505 | kfree_skb(skb); | 499 | kfree_skb(skb); |
506 | } | 500 | } else { |
507 | else { | ||
508 | unsigned int len = skb->len; | 501 | unsigned int len = skb->len; |
509 | 502 | ||
510 | clip_push(vcc,skb); | 503 | clip_push(vcc, skb); |
511 | PRIV(skb->dev)->stats.rx_packets--; | 504 | PRIV(skb->dev)->stats.rx_packets--; |
512 | PRIV(skb->dev)->stats.rx_bytes -= len; | 505 | PRIV(skb->dev)->stats.rx_bytes -= len; |
513 | } | 506 | } |
514 | return 0; | 507 | return 0; |
515 | } | 508 | } |
516 | 509 | ||
517 | 510 | static int clip_setentry(struct atm_vcc *vcc, u32 ip) | |
518 | static int clip_setentry(struct atm_vcc *vcc,u32 ip) | ||
519 | { | 511 | { |
520 | struct neighbour *neigh; | 512 | struct neighbour *neigh; |
521 | struct atmarp_entry *entry; | 513 | struct atmarp_entry *entry; |
522 | int error; | 514 | int error; |
523 | struct clip_vcc *clip_vcc; | 515 | struct clip_vcc *clip_vcc; |
524 | struct flowi fl = { .nl_u = { .ip4_u = { .daddr = ip, .tos = 1 } } }; | 516 | struct flowi fl = { .nl_u = { .ip4_u = { .daddr = ip, .tos = 1}} }; |
525 | struct rtable *rt; | 517 | struct rtable *rt; |
526 | 518 | ||
527 | if (vcc->push != clip_push) { | 519 | if (vcc->push != clip_push) { |
@@ -538,28 +530,29 @@ static int clip_setentry(struct atm_vcc *vcc,u32 ip) | |||
538 | unlink_clip_vcc(clip_vcc); | 530 | unlink_clip_vcc(clip_vcc); |
539 | return 0; | 531 | return 0; |
540 | } | 532 | } |
541 | error = ip_route_output_key(&rt,&fl); | 533 | error = ip_route_output_key(&rt, &fl); |
542 | if (error) return error; | 534 | if (error) |
543 | neigh = __neigh_lookup(&clip_tbl,&ip,rt->u.dst.dev,1); | 535 | return error; |
536 | neigh = __neigh_lookup(&clip_tbl, &ip, rt->u.dst.dev, 1); | ||
544 | ip_rt_put(rt); | 537 | ip_rt_put(rt); |
545 | if (!neigh) | 538 | if (!neigh) |
546 | return -ENOMEM; | 539 | return -ENOMEM; |
547 | entry = NEIGH2ENTRY(neigh); | 540 | entry = NEIGH2ENTRY(neigh); |
548 | if (entry != clip_vcc->entry) { | 541 | if (entry != clip_vcc->entry) { |
549 | if (!clip_vcc->entry) DPRINTK("setentry: add\n"); | 542 | if (!clip_vcc->entry) |
543 | DPRINTK("setentry: add\n"); | ||
550 | else { | 544 | else { |
551 | DPRINTK("setentry: update\n"); | 545 | DPRINTK("setentry: update\n"); |
552 | unlink_clip_vcc(clip_vcc); | 546 | unlink_clip_vcc(clip_vcc); |
553 | } | 547 | } |
554 | link_vcc(clip_vcc,entry); | 548 | link_vcc(clip_vcc, entry); |
555 | } | 549 | } |
556 | error = neigh_update(neigh, llc_oui, NUD_PERMANENT, | 550 | error = neigh_update(neigh, llc_oui, NUD_PERMANENT, |
557 | NEIGH_UPDATE_F_OVERRIDE|NEIGH_UPDATE_F_ADMIN); | 551 | NEIGH_UPDATE_F_OVERRIDE | NEIGH_UPDATE_F_ADMIN); |
558 | neigh_release(neigh); | 552 | neigh_release(neigh); |
559 | return error; | 553 | return error; |
560 | } | 554 | } |
561 | 555 | ||
562 | |||
563 | static void clip_setup(struct net_device *dev) | 556 | static void clip_setup(struct net_device *dev) |
564 | { | 557 | { |
565 | dev->hard_start_xmit = clip_start_xmit; | 558 | dev->hard_start_xmit = clip_start_xmit; |
@@ -568,15 +561,14 @@ static void clip_setup(struct net_device *dev) | |||
568 | dev->type = ARPHRD_ATM; | 561 | dev->type = ARPHRD_ATM; |
569 | dev->hard_header_len = RFC1483LLC_LEN; | 562 | dev->hard_header_len = RFC1483LLC_LEN; |
570 | dev->mtu = RFC1626_MTU; | 563 | dev->mtu = RFC1626_MTU; |
571 | dev->tx_queue_len = 100; /* "normal" queue (packets) */ | 564 | dev->tx_queue_len = 100; /* "normal" queue (packets) */ |
572 | /* When using a "real" qdisc, the qdisc determines the queue */ | 565 | /* When using a "real" qdisc, the qdisc determines the queue */ |
573 | /* length. tx_queue_len is only used for the default case, */ | 566 | /* length. tx_queue_len is only used for the default case, */ |
574 | /* without any more elaborate queuing. 100 is a reasonable */ | 567 | /* without any more elaborate queuing. 100 is a reasonable */ |
575 | /* compromise between decent burst-tolerance and protection */ | 568 | /* compromise between decent burst-tolerance and protection */ |
576 | /* against memory hogs. */ | 569 | /* against memory hogs. */ |
577 | } | 570 | } |
578 | 571 | ||
579 | |||
580 | static int clip_create(int number) | 572 | static int clip_create(int number) |
581 | { | 573 | { |
582 | struct net_device *dev; | 574 | struct net_device *dev; |
@@ -585,19 +577,19 @@ static int clip_create(int number) | |||
585 | 577 | ||
586 | if (number != -1) { | 578 | if (number != -1) { |
587 | for (dev = clip_devs; dev; dev = PRIV(dev)->next) | 579 | for (dev = clip_devs; dev; dev = PRIV(dev)->next) |
588 | if (PRIV(dev)->number == number) return -EEXIST; | 580 | if (PRIV(dev)->number == number) |
589 | } | 581 | return -EEXIST; |
590 | else { | 582 | } else { |
591 | number = 0; | 583 | number = 0; |
592 | for (dev = clip_devs; dev; dev = PRIV(dev)->next) | 584 | for (dev = clip_devs; dev; dev = PRIV(dev)->next) |
593 | if (PRIV(dev)->number >= number) | 585 | if (PRIV(dev)->number >= number) |
594 | number = PRIV(dev)->number+1; | 586 | number = PRIV(dev)->number + 1; |
595 | } | 587 | } |
596 | dev = alloc_netdev(sizeof(struct clip_priv), "", clip_setup); | 588 | dev = alloc_netdev(sizeof(struct clip_priv), "", clip_setup); |
597 | if (!dev) | 589 | if (!dev) |
598 | return -ENOMEM; | 590 | return -ENOMEM; |
599 | clip_priv = PRIV(dev); | 591 | clip_priv = PRIV(dev); |
600 | sprintf(dev->name,"atm%d",number); | 592 | sprintf(dev->name, "atm%d", number); |
601 | spin_lock_init(&clip_priv->xoff_lock); | 593 | spin_lock_init(&clip_priv->xoff_lock); |
602 | clip_priv->number = number; | 594 | clip_priv->number = number; |
603 | error = register_netdev(dev); | 595 | error = register_netdev(dev); |
@@ -607,53 +599,48 @@ static int clip_create(int number) | |||
607 | } | 599 | } |
608 | clip_priv->next = clip_devs; | 600 | clip_priv->next = clip_devs; |
609 | clip_devs = dev; | 601 | clip_devs = dev; |
610 | DPRINTK("registered (net:%s)\n",dev->name); | 602 | DPRINTK("registered (net:%s)\n", dev->name); |
611 | return number; | 603 | return number; |
612 | } | 604 | } |
613 | 605 | ||
614 | 606 | static int clip_device_event(struct notifier_block *this, unsigned long event, | |
615 | static int clip_device_event(struct notifier_block *this,unsigned long event, | 607 | void *arg) |
616 | void *dev) | ||
617 | { | 608 | { |
609 | struct net_device *dev = arg; | ||
610 | |||
611 | if (event == NETDEV_UNREGISTER) { | ||
612 | neigh_ifdown(&clip_tbl, dev); | ||
613 | return NOTIFY_DONE; | ||
614 | } | ||
615 | |||
618 | /* ignore non-CLIP devices */ | 616 | /* ignore non-CLIP devices */ |
619 | if (((struct net_device *) dev)->type != ARPHRD_ATM || | 617 | if (dev->type != ARPHRD_ATM || dev->hard_start_xmit != clip_start_xmit) |
620 | ((struct net_device *) dev)->hard_start_xmit != clip_start_xmit) | ||
621 | return NOTIFY_DONE; | 618 | return NOTIFY_DONE; |
619 | |||
622 | switch (event) { | 620 | switch (event) { |
623 | case NETDEV_UP: | 621 | case NETDEV_UP: |
624 | DPRINTK("clip_device_event NETDEV_UP\n"); | 622 | DPRINTK("clip_device_event NETDEV_UP\n"); |
625 | (void) to_atmarpd(act_up,PRIV(dev)->number,0); | 623 | to_atmarpd(act_up, PRIV(dev)->number, 0); |
626 | break; | 624 | break; |
627 | case NETDEV_GOING_DOWN: | 625 | case NETDEV_GOING_DOWN: |
628 | DPRINTK("clip_device_event NETDEV_DOWN\n"); | 626 | DPRINTK("clip_device_event NETDEV_DOWN\n"); |
629 | (void) to_atmarpd(act_down,PRIV(dev)->number,0); | 627 | to_atmarpd(act_down, PRIV(dev)->number, 0); |
630 | break; | 628 | break; |
631 | case NETDEV_CHANGE: | 629 | case NETDEV_CHANGE: |
632 | case NETDEV_CHANGEMTU: | 630 | case NETDEV_CHANGEMTU: |
633 | DPRINTK("clip_device_event NETDEV_CHANGE*\n"); | 631 | DPRINTK("clip_device_event NETDEV_CHANGE*\n"); |
634 | (void) to_atmarpd(act_change,PRIV(dev)->number,0); | 632 | to_atmarpd(act_change, PRIV(dev)->number, 0); |
635 | break; | 633 | break; |
636 | case NETDEV_REBOOT: | ||
637 | case NETDEV_REGISTER: | ||
638 | case NETDEV_DOWN: | ||
639 | DPRINTK("clip_device_event %ld\n",event); | ||
640 | /* ignore */ | ||
641 | break; | ||
642 | default: | ||
643 | printk(KERN_WARNING "clip_device_event: unknown event " | ||
644 | "%ld\n",event); | ||
645 | break; | ||
646 | } | 634 | } |
647 | return NOTIFY_DONE; | 635 | return NOTIFY_DONE; |
648 | } | 636 | } |
649 | 637 | ||
650 | 638 | static int clip_inet_event(struct notifier_block *this, unsigned long event, | |
651 | static int clip_inet_event(struct notifier_block *this,unsigned long event, | 639 | void *ifa) |
652 | void *ifa) | ||
653 | { | 640 | { |
654 | struct in_device *in_dev; | 641 | struct in_device *in_dev; |
655 | 642 | ||
656 | in_dev = ((struct in_ifaddr *) ifa)->ifa_dev; | 643 | in_dev = ((struct in_ifaddr *)ifa)->ifa_dev; |
657 | if (!in_dev || !in_dev->dev) { | 644 | if (!in_dev || !in_dev->dev) { |
658 | printk(KERN_WARNING "clip_inet_event: no device\n"); | 645 | printk(KERN_WARNING "clip_inet_event: no device\n"); |
659 | return NOTIFY_DONE; | 646 | return NOTIFY_DONE; |
@@ -662,23 +649,20 @@ static int clip_inet_event(struct notifier_block *this,unsigned long event, | |||
662 | * Transitions are of the down-change-up type, so it's sufficient to | 649 | * Transitions are of the down-change-up type, so it's sufficient to |
663 | * handle the change on up. | 650 | * handle the change on up. |
664 | */ | 651 | */ |
665 | if (event != NETDEV_UP) return NOTIFY_DONE; | 652 | if (event != NETDEV_UP) |
666 | return clip_device_event(this,NETDEV_CHANGE,in_dev->dev); | 653 | return NOTIFY_DONE; |
654 | return clip_device_event(this, NETDEV_CHANGE, in_dev->dev); | ||
667 | } | 655 | } |
668 | 656 | ||
669 | 657 | ||
670 | static struct notifier_block clip_dev_notifier = { | 658 | static struct notifier_block clip_dev_notifier = { |
671 | clip_device_event, | 659 | .notifier_call = clip_device_event, |
672 | NULL, | ||
673 | 0 | ||
674 | }; | 660 | }; |
675 | 661 | ||
676 | 662 | ||
677 | 663 | ||
678 | static struct notifier_block clip_inet_notifier = { | 664 | static struct notifier_block clip_inet_notifier = { |
679 | clip_inet_event, | 665 | .notifier_call = clip_inet_event, |
680 | NULL, | ||
681 | 0 | ||
682 | }; | 666 | }; |
683 | 667 | ||
684 | 668 | ||
@@ -686,14 +670,12 @@ static struct notifier_block clip_inet_notifier = { | |||
686 | static void atmarpd_close(struct atm_vcc *vcc) | 670 | static void atmarpd_close(struct atm_vcc *vcc) |
687 | { | 671 | { |
688 | DPRINTK("atmarpd_close\n"); | 672 | DPRINTK("atmarpd_close\n"); |
689 | atmarpd = NULL; /* assumed to be atomic */ | 673 | |
690 | barrier(); | 674 | rtnl_lock(); |
691 | unregister_inetaddr_notifier(&clip_inet_notifier); | 675 | atmarpd = NULL; |
692 | unregister_netdevice_notifier(&clip_dev_notifier); | ||
693 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) | ||
694 | printk(KERN_ERR "atmarpd_close: closing with requests " | ||
695 | "pending\n"); | ||
696 | skb_queue_purge(&sk_atm(vcc)->sk_receive_queue); | 676 | skb_queue_purge(&sk_atm(vcc)->sk_receive_queue); |
677 | rtnl_unlock(); | ||
678 | |||
697 | DPRINTK("(done)\n"); | 679 | DPRINTK("(done)\n"); |
698 | module_put(THIS_MODULE); | 680 | module_put(THIS_MODULE); |
699 | } | 681 | } |
@@ -714,14 +696,14 @@ static struct atm_dev atmarpd_dev = { | |||
714 | 696 | ||
715 | static int atm_init_atmarp(struct atm_vcc *vcc) | 697 | static int atm_init_atmarp(struct atm_vcc *vcc) |
716 | { | 698 | { |
717 | if (atmarpd) return -EADDRINUSE; | 699 | rtnl_lock(); |
718 | if (start_timer) { | 700 | if (atmarpd) { |
719 | start_timer = 0; | 701 | rtnl_unlock(); |
720 | init_timer(&idle_timer); | 702 | return -EADDRINUSE; |
721 | idle_timer.expires = jiffies+CLIP_CHECK_INTERVAL*HZ; | ||
722 | idle_timer.function = idle_timer_check; | ||
723 | add_timer(&idle_timer); | ||
724 | } | 703 | } |
704 | |||
705 | mod_timer(&idle_timer, jiffies+CLIP_CHECK_INTERVAL*HZ); | ||
706 | |||
725 | atmarpd = vcc; | 707 | atmarpd = vcc; |
726 | set_bit(ATM_VF_META,&vcc->flags); | 708 | set_bit(ATM_VF_META,&vcc->flags); |
727 | set_bit(ATM_VF_READY,&vcc->flags); | 709 | set_bit(ATM_VF_READY,&vcc->flags); |
@@ -731,10 +713,7 @@ static int atm_init_atmarp(struct atm_vcc *vcc) | |||
731 | vcc->push = NULL; | 713 | vcc->push = NULL; |
732 | vcc->pop = NULL; /* crash */ | 714 | vcc->pop = NULL; /* crash */ |
733 | vcc->push_oam = NULL; /* crash */ | 715 | vcc->push_oam = NULL; /* crash */ |
734 | if (register_netdevice_notifier(&clip_dev_notifier)) | 716 | rtnl_unlock(); |
735 | printk(KERN_ERR "register_netdevice_notifier failed\n"); | ||
736 | if (register_inetaddr_notifier(&clip_inet_notifier)) | ||
737 | printk(KERN_ERR "register_inetaddr_notifier failed\n"); | ||
738 | return 0; | 717 | return 0; |
739 | } | 718 | } |
740 | 719 | ||
@@ -744,53 +723,53 @@ static int clip_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
744 | int err = 0; | 723 | int err = 0; |
745 | 724 | ||
746 | switch (cmd) { | 725 | switch (cmd) { |
747 | case SIOCMKCLIP: | 726 | case SIOCMKCLIP: |
748 | case ATMARPD_CTRL: | 727 | case ATMARPD_CTRL: |
749 | case ATMARP_MKIP: | 728 | case ATMARP_MKIP: |
750 | case ATMARP_SETENTRY: | 729 | case ATMARP_SETENTRY: |
751 | case ATMARP_ENCAP: | 730 | case ATMARP_ENCAP: |
752 | if (!capable(CAP_NET_ADMIN)) | 731 | if (!capable(CAP_NET_ADMIN)) |
753 | return -EPERM; | 732 | return -EPERM; |
754 | break; | 733 | break; |
755 | default: | 734 | default: |
756 | return -ENOIOCTLCMD; | 735 | return -ENOIOCTLCMD; |
757 | } | 736 | } |
758 | 737 | ||
759 | switch (cmd) { | 738 | switch (cmd) { |
760 | case SIOCMKCLIP: | 739 | case SIOCMKCLIP: |
761 | err = clip_create(arg); | 740 | err = clip_create(arg); |
762 | break; | 741 | break; |
763 | case ATMARPD_CTRL: | 742 | case ATMARPD_CTRL: |
764 | err = atm_init_atmarp(vcc); | 743 | err = atm_init_atmarp(vcc); |
765 | if (!err) { | 744 | if (!err) { |
766 | sock->state = SS_CONNECTED; | 745 | sock->state = SS_CONNECTED; |
767 | __module_get(THIS_MODULE); | 746 | __module_get(THIS_MODULE); |
768 | } | 747 | } |
769 | break; | 748 | break; |
770 | case ATMARP_MKIP: | 749 | case ATMARP_MKIP: |
771 | err = clip_mkip(vcc ,arg); | 750 | err = clip_mkip(vcc, arg); |
772 | break; | 751 | break; |
773 | case ATMARP_SETENTRY: | 752 | case ATMARP_SETENTRY: |
774 | err = clip_setentry(vcc, arg); | 753 | err = clip_setentry(vcc, arg); |
775 | break; | 754 | break; |
776 | case ATMARP_ENCAP: | 755 | case ATMARP_ENCAP: |
777 | err = clip_encap(vcc, arg); | 756 | err = clip_encap(vcc, arg); |
778 | break; | 757 | break; |
779 | } | 758 | } |
780 | return err; | 759 | return err; |
781 | } | 760 | } |
782 | 761 | ||
783 | static struct atm_ioctl clip_ioctl_ops = { | 762 | static struct atm_ioctl clip_ioctl_ops = { |
784 | .owner = THIS_MODULE, | 763 | .owner = THIS_MODULE, |
785 | .ioctl = clip_ioctl, | 764 | .ioctl = clip_ioctl, |
786 | }; | 765 | }; |
787 | 766 | ||
788 | #ifdef CONFIG_PROC_FS | 767 | #ifdef CONFIG_PROC_FS |
789 | 768 | ||
790 | static void svc_addr(struct seq_file *seq, struct sockaddr_atmsvc *addr) | 769 | static void svc_addr(struct seq_file *seq, struct sockaddr_atmsvc *addr) |
791 | { | 770 | { |
792 | static int code[] = { 1,2,10,6,1,0 }; | 771 | static int code[] = { 1, 2, 10, 6, 1, 0 }; |
793 | static int e164[] = { 1,8,4,6,1,0 }; | 772 | static int e164[] = { 1, 8, 4, 6, 1, 0 }; |
794 | 773 | ||
795 | if (*addr->sas_addr.pub) { | 774 | if (*addr->sas_addr.pub) { |
796 | seq_printf(seq, "%s", addr->sas_addr.pub); | 775 | seq_printf(seq, "%s", addr->sas_addr.pub); |
@@ -809,7 +788,7 @@ static void svc_addr(struct seq_file *seq, struct sockaddr_atmsvc *addr) | |||
809 | for (i = 0; fields[i]; i++) { | 788 | for (i = 0; fields[i]; i++) { |
810 | for (j = fields[i]; j; j--) | 789 | for (j = fields[i]; j; j--) |
811 | seq_printf(seq, "%02X", *prv++); | 790 | seq_printf(seq, "%02X", *prv++); |
812 | if (fields[i+1]) | 791 | if (fields[i + 1]) |
813 | seq_putc(seq, '.'); | 792 | seq_putc(seq, '.'); |
814 | } | 793 | } |
815 | } | 794 | } |
@@ -828,8 +807,7 @@ static void atmarp_info(struct seq_file *seq, struct net_device *dev, | |||
828 | svc = ((clip_vcc == SEQ_NO_VCC_TOKEN) || | 807 | svc = ((clip_vcc == SEQ_NO_VCC_TOKEN) || |
829 | (sk_atm(clip_vcc->vcc)->sk_family == AF_ATMSVC)); | 808 | (sk_atm(clip_vcc->vcc)->sk_family == AF_ATMSVC)); |
830 | 809 | ||
831 | llc = ((clip_vcc == SEQ_NO_VCC_TOKEN) || | 810 | llc = ((clip_vcc == SEQ_NO_VCC_TOKEN) || clip_vcc->encap); |
832 | clip_vcc->encap); | ||
833 | 811 | ||
834 | if (clip_vcc == SEQ_NO_VCC_TOKEN) | 812 | if (clip_vcc == SEQ_NO_VCC_TOKEN) |
835 | exp = entry->neigh->used; | 813 | exp = entry->neigh->used; |
@@ -839,10 +817,7 @@ static void atmarp_info(struct seq_file *seq, struct net_device *dev, | |||
839 | exp = (jiffies - exp) / HZ; | 817 | exp = (jiffies - exp) / HZ; |
840 | 818 | ||
841 | seq_printf(seq, "%-6s%-4s%-4s%5ld ", | 819 | seq_printf(seq, "%-6s%-4s%-4s%5ld ", |
842 | dev->name, | 820 | dev->name, svc ? "SVC" : "PVC", llc ? "LLC" : "NULL", exp); |
843 | svc ? "SVC" : "PVC", | ||
844 | llc ? "LLC" : "NULL", | ||
845 | exp); | ||
846 | 821 | ||
847 | off = scnprintf(buf, sizeof(buf) - 1, "%d.%d.%d.%d", | 822 | off = scnprintf(buf, sizeof(buf) - 1, "%d.%d.%d.%d", |
848 | NIPQUAD(entry->ip)); | 823 | NIPQUAD(entry->ip)); |
@@ -860,8 +835,7 @@ static void atmarp_info(struct seq_file *seq, struct net_device *dev, | |||
860 | } else if (!svc) { | 835 | } else if (!svc) { |
861 | seq_printf(seq, "%d.%d.%d\n", | 836 | seq_printf(seq, "%d.%d.%d\n", |
862 | clip_vcc->vcc->dev->number, | 837 | clip_vcc->vcc->dev->number, |
863 | clip_vcc->vcc->vpi, | 838 | clip_vcc->vcc->vpi, clip_vcc->vcc->vci); |
864 | clip_vcc->vcc->vci); | ||
865 | } else { | 839 | } else { |
866 | svc_addr(seq, &clip_vcc->vcc->remote); | 840 | svc_addr(seq, &clip_vcc->vcc->remote); |
867 | seq_putc(seq, '\n'); | 841 | seq_putc(seq, '\n'); |
@@ -894,7 +868,7 @@ static struct clip_vcc *clip_seq_next_vcc(struct atmarp_entry *e, | |||
894 | } | 868 | } |
895 | 869 | ||
896 | static void *clip_seq_vcc_walk(struct clip_seq_state *state, | 870 | static void *clip_seq_vcc_walk(struct clip_seq_state *state, |
897 | struct atmarp_entry *e, loff_t *pos) | 871 | struct atmarp_entry *e, loff_t * pos) |
898 | { | 872 | { |
899 | struct clip_vcc *vcc = state->vcc; | 873 | struct clip_vcc *vcc = state->vcc; |
900 | 874 | ||
@@ -911,24 +885,24 @@ static void *clip_seq_vcc_walk(struct clip_seq_state *state, | |||
911 | 885 | ||
912 | return vcc; | 886 | return vcc; |
913 | } | 887 | } |
914 | 888 | ||
915 | static void *clip_seq_sub_iter(struct neigh_seq_state *_state, | 889 | static void *clip_seq_sub_iter(struct neigh_seq_state *_state, |
916 | struct neighbour *n, loff_t *pos) | 890 | struct neighbour *n, loff_t * pos) |
917 | { | 891 | { |
918 | struct clip_seq_state *state = (struct clip_seq_state *) _state; | 892 | struct clip_seq_state *state = (struct clip_seq_state *)_state; |
919 | 893 | ||
920 | return clip_seq_vcc_walk(state, NEIGH2ENTRY(n), pos); | 894 | return clip_seq_vcc_walk(state, NEIGH2ENTRY(n), pos); |
921 | } | 895 | } |
922 | 896 | ||
923 | static void *clip_seq_start(struct seq_file *seq, loff_t *pos) | 897 | static void *clip_seq_start(struct seq_file *seq, loff_t * pos) |
924 | { | 898 | { |
925 | return neigh_seq_start(seq, pos, &clip_tbl, NEIGH_SEQ_NEIGH_ONLY); | 899 | return neigh_seq_start(seq, pos, &clip_tbl, NEIGH_SEQ_NEIGH_ONLY); |
926 | } | 900 | } |
927 | 901 | ||
928 | static int clip_seq_show(struct seq_file *seq, void *v) | 902 | static int clip_seq_show(struct seq_file *seq, void *v) |
929 | { | 903 | { |
930 | static char atm_arp_banner[] = | 904 | static char atm_arp_banner[] = |
931 | "IPitf TypeEncp Idle IP address ATM address\n"; | 905 | "IPitf TypeEncp Idle IP address ATM address\n"; |
932 | 906 | ||
933 | if (v == SEQ_START_TOKEN) { | 907 | if (v == SEQ_START_TOKEN) { |
934 | seq_puts(seq, atm_arp_banner); | 908 | seq_puts(seq, atm_arp_banner); |
@@ -939,7 +913,7 @@ static int clip_seq_show(struct seq_file *seq, void *v) | |||
939 | 913 | ||
940 | atmarp_info(seq, n->dev, NEIGH2ENTRY(n), vcc); | 914 | atmarp_info(seq, n->dev, NEIGH2ENTRY(n), vcc); |
941 | } | 915 | } |
942 | return 0; | 916 | return 0; |
943 | } | 917 | } |
944 | 918 | ||
945 | static struct seq_operations arp_seq_ops = { | 919 | static struct seq_operations arp_seq_ops = { |
@@ -988,20 +962,19 @@ static struct file_operations arp_seq_fops = { | |||
988 | 962 | ||
989 | static int __init atm_clip_init(void) | 963 | static int __init atm_clip_init(void) |
990 | { | 964 | { |
991 | neigh_table_init(&clip_tbl); | 965 | struct proc_dir_entry *p; |
966 | neigh_table_init_no_netlink(&clip_tbl); | ||
992 | 967 | ||
993 | clip_tbl_hook = &clip_tbl; | 968 | clip_tbl_hook = &clip_tbl; |
994 | register_atm_ioctl(&clip_ioctl_ops); | 969 | register_atm_ioctl(&clip_ioctl_ops); |
970 | register_netdevice_notifier(&clip_dev_notifier); | ||
971 | register_inetaddr_notifier(&clip_inet_notifier); | ||
995 | 972 | ||
996 | #ifdef CONFIG_PROC_FS | 973 | setup_timer(&idle_timer, idle_timer_check, 0); |
997 | { | ||
998 | struct proc_dir_entry *p; | ||
999 | 974 | ||
1000 | p = create_proc_entry("arp", S_IRUGO, atm_proc_root); | 975 | p = create_proc_entry("arp", S_IRUGO, atm_proc_root); |
1001 | if (p) | 976 | if (p) |
1002 | p->proc_fops = &arp_seq_fops; | 977 | p->proc_fops = &arp_seq_fops; |
1003 | } | ||
1004 | #endif | ||
1005 | 978 | ||
1006 | return 0; | 979 | return 0; |
1007 | } | 980 | } |
@@ -1012,13 +985,15 @@ static void __exit atm_clip_exit(void) | |||
1012 | 985 | ||
1013 | remove_proc_entry("arp", atm_proc_root); | 986 | remove_proc_entry("arp", atm_proc_root); |
1014 | 987 | ||
988 | unregister_inetaddr_notifier(&clip_inet_notifier); | ||
989 | unregister_netdevice_notifier(&clip_dev_notifier); | ||
990 | |||
1015 | deregister_atm_ioctl(&clip_ioctl_ops); | 991 | deregister_atm_ioctl(&clip_ioctl_ops); |
1016 | 992 | ||
1017 | /* First, stop the idle timer, so it stops banging | 993 | /* First, stop the idle timer, so it stops banging |
1018 | * on the table. | 994 | * on the table. |
1019 | */ | 995 | */ |
1020 | if (start_timer == 0) | 996 | del_timer_sync(&idle_timer); |
1021 | del_timer(&idle_timer); | ||
1022 | 997 | ||
1023 | /* Next, purge the table, so that the device | 998 | /* Next, purge the table, so that the device |
1024 | * unregister loop below does not hang due to | 999 | * unregister loop below does not hang due to |
@@ -1042,5 +1017,6 @@ static void __exit atm_clip_exit(void) | |||
1042 | 1017 | ||
1043 | module_init(atm_clip_init); | 1018 | module_init(atm_clip_init); |
1044 | module_exit(atm_clip_exit); | 1019 | module_exit(atm_clip_exit); |
1045 | 1020 | MODULE_AUTHOR("Werner Almesberger"); | |
1021 | MODULE_DESCRIPTION("Classical/IP over ATM interface"); | ||
1046 | MODULE_LICENSE("GPL"); | 1022 | MODULE_LICENSE("GPL"); |