aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm/br2684.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/atm/br2684.c')
-rw-r--r--net/atm/br2684.c222
1 files changed, 114 insertions, 108 deletions
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index d9bb2a16b7cb..5c8a0dcb1045 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -1,9 +1,10 @@
1/* 1/*
2Ethernet netdevice using ATM AAL5 as underlying carrier 2 * Ethernet netdevice using ATM AAL5 as underlying carrier
3(RFC1483 obsoleted by RFC2684) for Linux 3 * (RFC1483 obsoleted by RFC2684) for Linux
4Authors: Marcell GAL, 2000, XDSL Ltd, Hungary 4 *
5 Eric Kinzie, 2006-2007, US Naval Research Laboratory 5 * Authors: Marcell GAL, 2000, XDSL Ltd, Hungary
6*/ 6 * Eric Kinzie, 2006-2007, US Naval Research Laboratory
7 */
7 8
8#include <linux/module.h> 9#include <linux/module.h>
9#include <linux/init.h> 10#include <linux/init.h>
@@ -51,28 +52,24 @@ static void skb_debug(const struct sk_buff *skb)
51#define ETHERTYPE_IPV6 0x86, 0xdd 52#define ETHERTYPE_IPV6 0x86, 0xdd
52#define PAD_BRIDGED 0x00, 0x00 53#define PAD_BRIDGED 0x00, 0x00
53 54
54static unsigned char ethertype_ipv4[] = 55static unsigned char ethertype_ipv4[] = { ETHERTYPE_IPV4 };
55 { ETHERTYPE_IPV4 }; 56static unsigned char ethertype_ipv6[] = { ETHERTYPE_IPV6 };
56static unsigned char ethertype_ipv6[] =
57 { ETHERTYPE_IPV6 };
58static unsigned char llc_oui_pid_pad[] = 57static unsigned char llc_oui_pid_pad[] =
59 { LLC, SNAP_BRIDGED, PID_ETHERNET, PAD_BRIDGED }; 58 { LLC, SNAP_BRIDGED, PID_ETHERNET, PAD_BRIDGED };
60static unsigned char llc_oui_ipv4[] = 59static unsigned char llc_oui_ipv4[] = { LLC, SNAP_ROUTED, ETHERTYPE_IPV4 };
61 { LLC, SNAP_ROUTED, ETHERTYPE_IPV4 }; 60static unsigned char llc_oui_ipv6[] = { LLC, SNAP_ROUTED, ETHERTYPE_IPV6 };
62static unsigned char llc_oui_ipv6[] =
63 { LLC, SNAP_ROUTED, ETHERTYPE_IPV6 };
64 61
65enum br2684_encaps { 62enum br2684_encaps {
66 e_vc = BR2684_ENCAPS_VC, 63 e_vc = BR2684_ENCAPS_VC,
67 e_llc = BR2684_ENCAPS_LLC, 64 e_llc = BR2684_ENCAPS_LLC,
68}; 65};
69 66
70struct br2684_vcc { 67struct br2684_vcc {
71 struct atm_vcc *atmvcc; 68 struct atm_vcc *atmvcc;
72 struct net_device *device; 69 struct net_device *device;
73 /* keep old push,pop functions for chaining */ 70 /* keep old push, pop functions for chaining */
74 void (*old_push)(struct atm_vcc *vcc,struct sk_buff *skb); 71 void (*old_push) (struct atm_vcc * vcc, struct sk_buff * skb);
75 /* void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb); */ 72 /* void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); */
76 enum br2684_encaps encaps; 73 enum br2684_encaps encaps;
77 struct list_head brvccs; 74 struct list_head brvccs;
78#ifdef CONFIG_ATM_BR2684_IPFILTER 75#ifdef CONFIG_ATM_BR2684_IPFILTER
@@ -85,7 +82,7 @@ struct br2684_dev {
85 struct net_device *net_dev; 82 struct net_device *net_dev;
86 struct list_head br2684_devs; 83 struct list_head br2684_devs;
87 int number; 84 int number;
88 struct list_head brvccs; /* one device <=> one vcc (before xmas) */ 85 struct list_head brvccs; /* one device <=> one vcc (before xmas) */
89 struct net_device_stats stats; 86 struct net_device_stats stats;
90 int mac_was_set; 87 int mac_was_set;
91 enum br2684_payload payload; 88 enum br2684_payload payload;
@@ -104,7 +101,7 @@ static LIST_HEAD(br2684_devs);
104 101
105static inline struct br2684_dev *BRPRIV(const struct net_device *net_dev) 102static inline struct br2684_dev *BRPRIV(const struct net_device *net_dev)
106{ 103{
107 return (struct br2684_dev *) net_dev->priv; 104 return (struct br2684_dev *)net_dev->priv;
108} 105}
109 106
110static inline struct net_device *list_entry_brdev(const struct list_head *le) 107static inline struct net_device *list_entry_brdev(const struct list_head *le)
@@ -114,7 +111,7 @@ static inline struct net_device *list_entry_brdev(const struct list_head *le)
114 111
115static inline struct br2684_vcc *BR2684_VCC(const struct atm_vcc *atmvcc) 112static inline struct br2684_vcc *BR2684_VCC(const struct atm_vcc *atmvcc)
116{ 113{
117 return (struct br2684_vcc *) (atmvcc->user_back); 114 return (struct br2684_vcc *)(atmvcc->user_back);
118} 115}
119 116
120static inline struct br2684_vcc *list_entry_brvcc(const struct list_head *le) 117static inline struct br2684_vcc *list_entry_brvcc(const struct list_head *le)
@@ -152,7 +149,7 @@ static struct net_device *br2684_find_dev(const struct br2684_if_spec *s)
152 * otherwise false 149 * otherwise false
153 */ 150 */
154static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev, 151static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
155 struct br2684_vcc *brvcc) 152 struct br2684_vcc *brvcc)
156{ 153{
157 struct atm_vcc *atmvcc; 154 struct atm_vcc *atmvcc;
158 int minheadroom = (brvcc->encaps == e_llc) ? 10 : 2; 155 int minheadroom = (brvcc->encaps == e_llc) ? 10 : 2;
@@ -171,21 +168,24 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
171 if (brvcc->encaps == e_llc) { 168 if (brvcc->encaps == e_llc) {
172 if (brdev->payload == p_bridged) { 169 if (brdev->payload == p_bridged) {
173 skb_push(skb, sizeof(llc_oui_pid_pad)); 170 skb_push(skb, sizeof(llc_oui_pid_pad));
174 skb_copy_to_linear_data(skb, llc_oui_pid_pad, sizeof(llc_oui_pid_pad)); 171 skb_copy_to_linear_data(skb, llc_oui_pid_pad,
172 sizeof(llc_oui_pid_pad));
175 } else if (brdev->payload == p_routed) { 173 } else if (brdev->payload == p_routed) {
176 unsigned short prot = ntohs(skb->protocol); 174 unsigned short prot = ntohs(skb->protocol);
177 175
178 skb_push(skb, sizeof(llc_oui_ipv4)); 176 skb_push(skb, sizeof(llc_oui_ipv4));
179 switch (prot) { 177 switch (prot) {
180 case ETH_P_IP: 178 case ETH_P_IP:
181 skb_copy_to_linear_data(skb, llc_oui_ipv4, sizeof(llc_oui_ipv4)); 179 skb_copy_to_linear_data(skb, llc_oui_ipv4,
182 break; 180 sizeof(llc_oui_ipv4));
183 case ETH_P_IPV6: 181 break;
184 skb_copy_to_linear_data(skb, llc_oui_ipv6, sizeof(llc_oui_ipv6)); 182 case ETH_P_IPV6:
185 break; 183 skb_copy_to_linear_data(skb, llc_oui_ipv6,
186 default: 184 sizeof(llc_oui_ipv6));
187 dev_kfree_skb(skb); 185 break;
188 return 0; 186 default:
187 dev_kfree_skb(skb);
188 return 0;
189 } 189 }
190 } 190 }
191 } else { 191 } else {
@@ -198,13 +198,14 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
198 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; 198 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
199 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); 199 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
200 if (!atm_may_send(atmvcc, skb->truesize)) { 200 if (!atm_may_send(atmvcc, skb->truesize)) {
201 /* we free this here for now, because we cannot know in a higher 201 /*
202 layer whether the skb point it supplied wasn't freed yet. 202 * We free this here for now, because we cannot know in a higher
203 now, it always is. 203 * layer whether the skb pointer it supplied wasn't freed yet.
204 */ 204 * Now, it always is.
205 */
205 dev_kfree_skb(skb); 206 dev_kfree_skb(skb);
206 return 0; 207 return 0;
207 } 208 }
208 atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); 209 atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc);
209 ATM_SKB(skb)->atm_options = atmvcc->atm_options; 210 ATM_SKB(skb)->atm_options = atmvcc->atm_options;
210 brdev->stats.tx_packets++; 211 brdev->stats.tx_packets++;
@@ -214,10 +215,9 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
214} 215}
215 216
216static inline struct br2684_vcc *pick_outgoing_vcc(struct sk_buff *skb, 217static inline struct br2684_vcc *pick_outgoing_vcc(struct sk_buff *skb,
217 struct br2684_dev *brdev) 218 struct br2684_dev *brdev)
218{ 219{
219 return list_empty(&brdev->brvccs) ? NULL : 220 return list_empty(&brdev->brvccs) ? NULL : list_entry_brvcc(brdev->brvccs.next); /* 1 vcc/dev right now */
220 list_entry_brvcc(brdev->brvccs.next); /* 1 vcc/dev right now */
221} 221}
222 222
223static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev) 223static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -241,11 +241,10 @@ static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
241 /* 241 /*
242 * We should probably use netif_*_queue() here, but that 242 * We should probably use netif_*_queue() here, but that
243 * involves added complication. We need to walk before 243 * involves added complication. We need to walk before
244 * we can run 244 * we can run.
245 *
246 * Don't free here! this pointer might be no longer valid!
245 */ 247 */
246 /* don't free here! this pointer might be no longer valid!
247 dev_kfree_skb(skb);
248 */
249 brdev->stats.tx_errors++; 248 brdev->stats.tx_errors++;
250 brdev->stats.tx_fifo_errors++; 249 brdev->stats.tx_fifo_errors++;
251 } 250 }
@@ -259,12 +258,11 @@ static struct net_device_stats *br2684_get_stats(struct net_device *dev)
259 return &BRPRIV(dev)->stats; 258 return &BRPRIV(dev)->stats;
260} 259}
261 260
262
263/* 261/*
264 * We remember when the MAC gets set, so we don't override it later with 262 * We remember when the MAC gets set, so we don't override it later with
265 * the ESI of the ATM card of the first VC 263 * the ESI of the ATM card of the first VC
266 */ 264 */
267static int (*my_eth_mac_addr)(struct net_device *, void *); 265static int (*my_eth_mac_addr) (struct net_device *, void *);
268static int br2684_mac_addr(struct net_device *dev, void *p) 266static int br2684_mac_addr(struct net_device *dev, void *p)
269{ 267{
270 int err = my_eth_mac_addr(dev, p); 268 int err = my_eth_mac_addr(dev, p);
@@ -275,7 +273,7 @@ static int br2684_mac_addr(struct net_device *dev, void *p)
275 273
276#ifdef CONFIG_ATM_BR2684_IPFILTER 274#ifdef CONFIG_ATM_BR2684_IPFILTER
277/* this IOCTL is experimental. */ 275/* this IOCTL is experimental. */
278static int br2684_setfilt(struct atm_vcc *atmvcc, void __user *arg) 276static int br2684_setfilt(struct atm_vcc *atmvcc, void __user * arg)
279{ 277{
280 struct br2684_vcc *brvcc; 278 struct br2684_vcc *brvcc;
281 struct br2684_filter_set fs; 279 struct br2684_filter_set fs;
@@ -285,13 +283,12 @@ static int br2684_setfilt(struct atm_vcc *atmvcc, void __user *arg)
285 if (fs.ifspec.method != BR2684_FIND_BYNOTHING) { 283 if (fs.ifspec.method != BR2684_FIND_BYNOTHING) {
286 /* 284 /*
287 * This is really a per-vcc thing, but we can also search 285 * This is really a per-vcc thing, but we can also search
288 * by device 286 * by device.
289 */ 287 */
290 struct br2684_dev *brdev; 288 struct br2684_dev *brdev;
291 read_lock(&devs_lock); 289 read_lock(&devs_lock);
292 brdev = BRPRIV(br2684_find_dev(&fs.ifspec)); 290 brdev = BRPRIV(br2684_find_dev(&fs.ifspec));
293 if (brdev == NULL || list_empty(&brdev->brvccs) || 291 if (brdev == NULL || list_empty(&brdev->brvccs) || brdev->brvccs.next != brdev->brvccs.prev) /* >1 VCC */
294 brdev->brvccs.next != brdev->brvccs.prev) /* >1 VCC */
295 brvcc = NULL; 292 brvcc = NULL;
296 else 293 else
297 brvcc = list_entry_brvcc(brdev->brvccs.next); 294 brvcc = list_entry_brvcc(brdev->brvccs.next);
@@ -309,15 +306,16 @@ static inline int
309packet_fails_filter(__be16 type, struct br2684_vcc *brvcc, struct sk_buff *skb) 306packet_fails_filter(__be16 type, struct br2684_vcc *brvcc, struct sk_buff *skb)
310{ 307{
311 if (brvcc->filter.netmask == 0) 308 if (brvcc->filter.netmask == 0)
312 return 0; /* no filter in place */ 309 return 0; /* no filter in place */
313 if (type == htons(ETH_P_IP) && 310 if (type == htons(ETH_P_IP) &&
314 (((struct iphdr *) (skb->data))->daddr & brvcc->filter. 311 (((struct iphdr *)(skb->data))->daddr & brvcc->filter.
315 netmask) == brvcc->filter.prefix) 312 netmask) == brvcc->filter.prefix)
316 return 0; 313 return 0;
317 if (type == htons(ETH_P_ARP)) 314 if (type == htons(ETH_P_ARP))
318 return 0; 315 return 0;
319 /* TODO: we should probably filter ARPs too.. don't want to have 316 /*
320 * them returning values that don't make sense, or is that ok? 317 * TODO: we should probably filter ARPs too.. don't want to have
318 * them returning values that don't make sense, or is that ok?
321 */ 319 */
322 return 1; /* drop */ 320 return 1; /* drop */
323} 321}
@@ -367,10 +365,17 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
367 365
368 /* accept packets that have "ipv[46]" in the snap header */ 366 /* accept packets that have "ipv[46]" in the snap header */
369 if ((skb->len >= (sizeof(llc_oui_ipv4))) 367 if ((skb->len >= (sizeof(llc_oui_ipv4)))
370 && (memcmp(skb->data, llc_oui_ipv4, sizeof(llc_oui_ipv4) - BR2684_ETHERTYPE_LEN) == 0)) { 368 &&
371 if (memcmp(skb->data + 6, ethertype_ipv6, sizeof(ethertype_ipv6)) == 0) 369 (memcmp
370 (skb->data, llc_oui_ipv4,
371 sizeof(llc_oui_ipv4) - BR2684_ETHERTYPE_LEN) == 0)) {
372 if (memcmp
373 (skb->data + 6, ethertype_ipv6,
374 sizeof(ethertype_ipv6)) == 0)
372 skb->protocol = __constant_htons(ETH_P_IPV6); 375 skb->protocol = __constant_htons(ETH_P_IPV6);
373 else if (memcmp(skb->data + 6, ethertype_ipv4, sizeof(ethertype_ipv4)) == 0) 376 else if (memcmp
377 (skb->data + 6, ethertype_ipv4,
378 sizeof(ethertype_ipv4)) == 0)
374 skb->protocol = __constant_htons(ETH_P_IP); 379 skb->protocol = __constant_htons(ETH_P_IP);
375 else { 380 else {
376 brdev->stats.rx_errors++; 381 brdev->stats.rx_errors++;
@@ -380,12 +385,13 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
380 skb_pull(skb, sizeof(llc_oui_ipv4)); 385 skb_pull(skb, sizeof(llc_oui_ipv4));
381 skb_reset_network_header(skb); 386 skb_reset_network_header(skb);
382 skb->pkt_type = PACKET_HOST; 387 skb->pkt_type = PACKET_HOST;
383 388 /*
384 /* let us waste some time for checking the encapsulation. 389 * Let us waste some time for checking the encapsulation.
385 Note, that only 7 char is checked so frames with a valid FCS 390 * Note, that only 7 char is checked so frames with a valid FCS
386 are also accepted (but FCS is not checked of course) */ 391 * are also accepted (but FCS is not checked of course).
392 */
387 } else if ((skb->len >= sizeof(llc_oui_pid_pad)) && 393 } else if ((skb->len >= sizeof(llc_oui_pid_pad)) &&
388 (memcmp(skb->data, llc_oui_pid_pad, 7) == 0)) { 394 (memcmp(skb->data, llc_oui_pid_pad, 7) == 0)) {
389 skb_pull(skb, sizeof(llc_oui_pid_pad)); 395 skb_pull(skb, sizeof(llc_oui_pid_pad));
390 skb->protocol = eth_type_trans(skb, net_dev); 396 skb->protocol = eth_type_trans(skb, net_dev);
391 } else { 397 } else {
@@ -401,7 +407,7 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
401 dev_kfree_skb(skb); 407 dev_kfree_skb(skb);
402 return; 408 return;
403 } 409 }
404 skb_pull(skb, BR2684_PAD_LEN + ETH_HLEN); /* pad, dstmac, srcmac, ethtype */ 410 skb_pull(skb, BR2684_PAD_LEN + ETH_HLEN); /* pad, dstmac, srcmac, ethtype */
405 skb->protocol = eth_type_trans(skb, net_dev); 411 skb->protocol = eth_type_trans(skb, net_dev);
406 } 412 }
407 413
@@ -428,11 +434,12 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
428 netif_rx(skb); 434 netif_rx(skb);
429} 435}
430 436
431static int br2684_regvcc(struct atm_vcc *atmvcc, void __user *arg) 437/*
438 * Assign a vcc to a dev
439 * Note: we do not have explicit unassign, but look at _push()
440 */
441static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
432{ 442{
433/* assign a vcc to a dev
434Note: we do not have explicit unassign, but look at _push()
435*/
436 int err; 443 int err;
437 struct br2684_vcc *brvcc; 444 struct br2684_vcc *brvcc;
438 struct sk_buff *skb; 445 struct sk_buff *skb;
@@ -451,7 +458,7 @@ Note: we do not have explicit unassign, but look at _push()
451 net_dev = br2684_find_dev(&be.ifspec); 458 net_dev = br2684_find_dev(&be.ifspec);
452 if (net_dev == NULL) { 459 if (net_dev == NULL) {
453 printk(KERN_ERR 460 printk(KERN_ERR
454 "br2684: tried to attach to non-existant device\n"); 461 "br2684: tried to attach to non-existant device\n");
455 err = -ENXIO; 462 err = -ENXIO;
456 goto error; 463 goto error;
457 } 464 }
@@ -467,13 +474,15 @@ Note: we do not have explicit unassign, but look at _push()
467 } 474 }
468 if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO || 475 if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO ||
469 be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps != 476 be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps !=
470 BR2684_ENCAPS_VC && be.encaps != BR2684_ENCAPS_LLC) || 477 BR2684_ENCAPS_VC
471 be.min_size != 0) { 478 && be.encaps !=
479 BR2684_ENCAPS_LLC)
480 || be.min_size != 0) {
472 err = -EINVAL; 481 err = -EINVAL;
473 goto error; 482 goto error;
474 } 483 }
475 pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, be.encaps, 484 pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc,
476 brvcc); 485 be.encaps, brvcc);
477 if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) { 486 if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) {
478 unsigned char *esi = atmvcc->dev->esi; 487 unsigned char *esi = atmvcc->dev->esi;
479 if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5]) 488 if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5])
@@ -486,7 +495,7 @@ Note: we do not have explicit unassign, but look at _push()
486 brvcc->device = net_dev; 495 brvcc->device = net_dev;
487 brvcc->atmvcc = atmvcc; 496 brvcc->atmvcc = atmvcc;
488 atmvcc->user_back = brvcc; 497 atmvcc->user_back = brvcc;
489 brvcc->encaps = (enum br2684_encaps) be.encaps; 498 brvcc->encaps = (enum br2684_encaps)be.encaps;
490 brvcc->old_push = atmvcc->push; 499 brvcc->old_push = atmvcc->push;
491 barrier(); 500 barrier();
492 atmvcc->push = br2684_push; 501 atmvcc->push = br2684_push;
@@ -517,7 +526,7 @@ Note: we do not have explicit unassign, but look at _push()
517 } 526 }
518 __module_get(THIS_MODULE); 527 __module_get(THIS_MODULE);
519 return 0; 528 return 0;
520 error: 529 error:
521 write_unlock_irq(&devs_lock); 530 write_unlock_irq(&devs_lock);
522 kfree(brvcc); 531 kfree(brvcc);
523 return err; 532 return err;
@@ -556,7 +565,7 @@ static void br2684_setup_routed(struct net_device *netdev)
556 INIT_LIST_HEAD(&brdev->brvccs); 565 INIT_LIST_HEAD(&brdev->brvccs);
557} 566}
558 567
559static int br2684_create(void __user *arg) 568static int br2684_create(void __user * arg)
560{ 569{
561 int err; 570 int err;
562 struct net_device *netdev; 571 struct net_device *netdev;
@@ -574,7 +583,7 @@ static int br2684_create(void __user *arg)
574 payload = p_routed; 583 payload = p_routed;
575 else 584 else
576 payload = p_bridged; 585 payload = p_bridged;
577 ni.media &= 0xffff; /* strip flags */ 586 ni.media &= 0xffff; /* strip flags */
578 587
579 if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) { 588 if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) {
580 return -EINVAL; 589 return -EINVAL;
@@ -583,7 +592,7 @@ static int br2684_create(void __user *arg)
583 netdev = alloc_netdev(sizeof(struct br2684_dev), 592 netdev = alloc_netdev(sizeof(struct br2684_dev),
584 ni.ifname[0] ? ni.ifname : "nas%d", 593 ni.ifname[0] ? ni.ifname : "nas%d",
585 (payload == p_routed) ? 594 (payload == p_routed) ?
586 br2684_setup_routed : br2684_setup); 595 br2684_setup_routed : br2684_setup);
587 if (!netdev) 596 if (!netdev)
588 return -ENOMEM; 597 return -ENOMEM;
589 598
@@ -612,16 +621,16 @@ static int br2684_create(void __user *arg)
612 * -ENOIOCTLCMD for any unrecognized ioctl 621 * -ENOIOCTLCMD for any unrecognized ioctl
613 */ 622 */
614static int br2684_ioctl(struct socket *sock, unsigned int cmd, 623static int br2684_ioctl(struct socket *sock, unsigned int cmd,
615 unsigned long arg) 624 unsigned long arg)
616{ 625{
617 struct atm_vcc *atmvcc = ATM_SD(sock); 626 struct atm_vcc *atmvcc = ATM_SD(sock);
618 void __user *argp = (void __user *)arg; 627 void __user *argp = (void __user *)arg;
628 atm_backend_t b;
619 629
620 int err; 630 int err;
621 switch(cmd) { 631 switch (cmd) {
622 case ATM_SETBACKEND: 632 case ATM_SETBACKEND:
623 case ATM_NEWBACKENDIF: { 633 case ATM_NEWBACKENDIF:
624 atm_backend_t b;
625 err = get_user(b, (atm_backend_t __user *) argp); 634 err = get_user(b, (atm_backend_t __user *) argp);
626 if (err) 635 if (err)
627 return -EFAULT; 636 return -EFAULT;
@@ -633,7 +642,6 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
633 return br2684_regvcc(atmvcc, argp); 642 return br2684_regvcc(atmvcc, argp);
634 else 643 else
635 return br2684_create(argp); 644 return br2684_create(argp);
636 }
637#ifdef CONFIG_ATM_BR2684_IPFILTER 645#ifdef CONFIG_ATM_BR2684_IPFILTER
638 case BR2684_SETFILT: 646 case BR2684_SETFILT:
639 if (atmvcc->push != br2684_push) 647 if (atmvcc->push != br2684_push)
@@ -641,6 +649,7 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
641 if (!capable(CAP_NET_ADMIN)) 649 if (!capable(CAP_NET_ADMIN))
642 return -EPERM; 650 return -EPERM;
643 err = br2684_setfilt(atmvcc, argp); 651 err = br2684_setfilt(atmvcc, argp);
652
644 return err; 653 return err;
645#endif /* CONFIG_ATM_BR2684_IPFILTER */ 654#endif /* CONFIG_ATM_BR2684_IPFILTER */
646 } 655 }
@@ -648,19 +657,18 @@ static int br2684_ioctl(struct socket *sock, unsigned int cmd,
648} 657}
649 658
650static struct atm_ioctl br2684_ioctl_ops = { 659static struct atm_ioctl br2684_ioctl_ops = {
651 .owner = THIS_MODULE, 660 .owner = THIS_MODULE,
652 .ioctl = br2684_ioctl, 661 .ioctl = br2684_ioctl,
653}; 662};
654 663
655
656#ifdef CONFIG_PROC_FS 664#ifdef CONFIG_PROC_FS
657static void *br2684_seq_start(struct seq_file *seq, loff_t *pos) 665static void *br2684_seq_start(struct seq_file *seq, loff_t * pos)
658{ 666{
659 read_lock(&devs_lock); 667 read_lock(&devs_lock);
660 return seq_list_start(&br2684_devs, *pos); 668 return seq_list_start(&br2684_devs, *pos);
661} 669}
662 670
663static void *br2684_seq_next(struct seq_file *seq, void *v, loff_t *pos) 671static void *br2684_seq_next(struct seq_file *seq, void *v, loff_t * pos)
664{ 672{
665 return seq_list_next(v, &br2684_devs, pos); 673 return seq_list_next(v, &br2684_devs, pos);
666} 674}
@@ -673,7 +681,7 @@ static void br2684_seq_stop(struct seq_file *seq, void *v)
673static int br2684_seq_show(struct seq_file *seq, void *v) 681static int br2684_seq_show(struct seq_file *seq, void *v)
674{ 682{
675 const struct br2684_dev *brdev = list_entry(v, struct br2684_dev, 683 const struct br2684_dev *brdev = list_entry(v, struct br2684_dev,
676 br2684_devs); 684 br2684_devs);
677 const struct net_device *net_dev = brdev->net_dev; 685 const struct net_device *net_dev = brdev->net_dev;
678 const struct br2684_vcc *brvcc; 686 const struct br2684_vcc *brvcc;
679 DECLARE_MAC_BUF(mac); 687 DECLARE_MAC_BUF(mac);
@@ -686,20 +694,18 @@ static int br2684_seq_show(struct seq_file *seq, void *v)
686 694
687 list_for_each_entry(brvcc, &brdev->brvccs, brvccs) { 695 list_for_each_entry(brvcc, &brdev->brvccs, brvccs) {
688 seq_printf(seq, " vcc %d.%d.%d: encaps=%s payload=%s" 696 seq_printf(seq, " vcc %d.%d.%d: encaps=%s payload=%s"
689 ", failed copies %u/%u" 697 ", failed copies %u/%u"
690 "\n", brvcc->atmvcc->dev->number, 698 "\n", brvcc->atmvcc->dev->number,
691 brvcc->atmvcc->vpi, brvcc->atmvcc->vci, 699 brvcc->atmvcc->vpi, brvcc->atmvcc->vci,
692 (brvcc->encaps == e_llc) ? "LLC" : "VC", 700 (brvcc->encaps == e_llc) ? "LLC" : "VC",
693 (brdev->payload == p_bridged) ? "bridged" : "routed", 701 (brdev->payload == p_bridged) ? "bridged" : "routed",
694 brvcc->copies_failed, 702 brvcc->copies_failed, brvcc->copies_needed);
695 brvcc->copies_needed);
696#ifdef CONFIG_ATM_BR2684_IPFILTER 703#ifdef CONFIG_ATM_BR2684_IPFILTER
697#define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte] 704#define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte]
698#define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3) 705#define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3)
699 if (brvcc->filter.netmask != 0) 706 if (brvcc->filter.netmask != 0)
700 seq_printf(seq, " filter=%d.%d.%d.%d/" 707 seq_printf(seq, " filter=%d.%d.%d.%d/"
701 "%d.%d.%d.%d\n", 708 "%d.%d.%d.%d\n", bs(prefix), bs(netmask));
702 bs(prefix), bs(netmask));
703#undef bs 709#undef bs
704#undef b1 710#undef b1
705#endif /* CONFIG_ATM_BR2684_IPFILTER */ 711#endif /* CONFIG_ATM_BR2684_IPFILTER */
@@ -709,9 +715,9 @@ static int br2684_seq_show(struct seq_file *seq, void *v)
709 715
710static const struct seq_operations br2684_seq_ops = { 716static const struct seq_operations br2684_seq_ops = {
711 .start = br2684_seq_start, 717 .start = br2684_seq_start,
712 .next = br2684_seq_next, 718 .next = br2684_seq_next,
713 .stop = br2684_seq_stop, 719 .stop = br2684_seq_stop,
714 .show = br2684_seq_show, 720 .show = br2684_seq_show,
715}; 721};
716 722
717static int br2684_proc_open(struct inode *inode, struct file *file) 723static int br2684_proc_open(struct inode *inode, struct file *file)
@@ -720,15 +726,15 @@ static int br2684_proc_open(struct inode *inode, struct file *file)
720} 726}
721 727
722static const struct file_operations br2684_proc_ops = { 728static const struct file_operations br2684_proc_ops = {
723 .owner = THIS_MODULE, 729 .owner = THIS_MODULE,
724 .open = br2684_proc_open, 730 .open = br2684_proc_open,
725 .read = seq_read, 731 .read = seq_read,
726 .llseek = seq_lseek, 732 .llseek = seq_lseek,
727 .release = seq_release, 733 .release = seq_release,
728}; 734};
729 735
730extern struct proc_dir_entry *atm_proc_root; /* from proc.c */ 736extern struct proc_dir_entry *atm_proc_root; /* from proc.c */
731#endif 737#endif /* CONFIG_PROC_FS */
732 738
733static int __init br2684_init(void) 739static int __init br2684_init(void)
734{ 740{