Switch to the rt2x00 rt2500 pci version
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.24 / 601-br2684-routed-support.patch
1 diff -Nur linux-2.6.24.2/include/linux/atmbr2684.h linux-2.6.24.2-copy/include/linux/atmbr2684.h
2 --- linux-2.6.24.2/include/linux/atmbr2684.h 2008-02-11 05:51:11.000000000 +0000
3 +++ linux-2.6.24.2-copy/include/linux/atmbr2684.h 2008-03-27 01:08:42.000000000 +0000
4 @@ -14,6 +14,9 @@
5 #define BR2684_MEDIA_FDDI (3)
6 #define BR2684_MEDIA_802_6 (4) /* 802.6 */
7
8 + /* used only at device creation: */
9 +#define BR2684_FLAG_ROUTED (1<<16) /* payload is routed, not bridged */
10 +
11 /*
12 * Is there FCS inbound on this VC? This currently isn't supported.
13 */
14 @@ -36,15 +39,22 @@
15 #define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */
16
17 /*
18 + * Is this VC bridged or routed?
19 + */
20 +
21 +#define BR2684_PAYLOAD_ROUTED (0)
22 +#define BR2684_PAYLOAD_BRIDGED (1)
23 +
24 +/*
25 * This is for the ATM_NEWBACKENDIF call - these are like socket families:
26 * the first element of the structure is the backend number and the rest
27 * is per-backend specific
28 */
29 struct atm_newif_br2684 {
30 - atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
31 - int media; /* BR2684_MEDIA_* */
32 - char ifname[IFNAMSIZ];
33 - int mtu;
34 + atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
35 + int media; /* BR2684_MEDIA_*, flags in upper bits */
36 + char ifname[IFNAMSIZ];
37 + int mtu;
38 };
39
40 /*
41 @@ -55,10 +65,10 @@
42 #define BR2684_FIND_BYNUM (1)
43 #define BR2684_FIND_BYIFNAME (2)
44 struct br2684_if_spec {
45 - int method; /* BR2684_FIND_* */
46 + int method; /* BR2684_FIND_* */
47 union {
48 - char ifname[IFNAMSIZ];
49 - int devnum;
50 + char ifname[IFNAMSIZ];
51 + int devnum;
52 } spec;
53 };
54
55 @@ -68,16 +78,16 @@
56 * is per-backend specific
57 */
58 struct atm_backend_br2684 {
59 - atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
60 + atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
61 struct br2684_if_spec ifspec;
62 - int fcs_in; /* BR2684_FCSIN_* */
63 - int fcs_out; /* BR2684_FCSOUT_* */
64 - int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */
65 - int encaps; /* BR2684_ENCAPS_* */
66 - int has_vpiid; /* 1: use vpn_id - Unsupported */
67 - __u8 vpn_id[7];
68 - int send_padding; /* unsupported */
69 - int min_size; /* we will pad smaller packets than this */
70 + int fcs_in; /* BR2684_FCSIN_* */
71 + int fcs_out; /* BR2684_FCSOUT_* */
72 + int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */
73 + int encaps; /* BR2684_ENCAPS_* */
74 + int has_vpiid; /* 1: use vpn_id - Unsupported */
75 + __u8 vpn_id[7];
76 + int send_padding; /* unsupported */
77 + int min_size; /* we will pad smaller packets than this */
78 };
79
80 /*
81 @@ -86,8 +96,8 @@
82 * efficient per-if in/out filters, this support will be removed
83 */
84 struct br2684_filter {
85 - __be32 prefix; /* network byte order */
86 - __be32 netmask; /* 0 = disable filter */
87 + __be32 prefix; /* network byte order */
88 + __be32 netmask; /* 0 = disable filter */
89 };
90
91 struct br2684_filter_set {
92 @@ -95,7 +105,13 @@
93 struct br2684_filter filter;
94 };
95
96 +enum br2684_payload {
97 + p_routed = BR2684_PAYLOAD_ROUTED,
98 + p_bridged = BR2684_PAYLOAD_BRIDGED,
99 +};
100 +
101 #define BR2684_SETFILT _IOW( 'a', ATMIOC_BACKEND + 0, \
102 struct br2684_filter_set)
103
104 #endif /* _LINUX_ATMBR2684_H */
105 +
106 diff -Nur linux-2.6.24.2/net/atm/br2684.c linux-2.6.24.2-copy/net/atm/br2684.c
107 --- linux-2.6.24.2/net/atm/br2684.c 2008-02-11 05:51:11.000000000 +0000
108 +++ linux-2.6.24.2-copy/net/atm/br2684.c 2008-03-27 03:24:17.000000000 +0000
109 @@ -1,8 +1,10 @@
110 /*
111 -Experimental ethernet netdevice using ATM AAL5 as underlying carrier
112 -(RFC1483 obsoleted by RFC2684) for Linux 2.4
113 -Author: Marcell GAL, 2000, XDSL Ltd, Hungary
114 -*/
115 + * Ethernet netdevice using ATM AAL5 as underlying carrier
116 + * (RFC1483 obsoleted by RFC2684) for Linux
117 + *
118 + * Authors: Marcell GAL, 2000, XDSL Ltd, Hungary
119 + * Eric Kinzie, 2006-2007, US Naval Research Laboratory
120 + */
121
122 #include <linux/module.h>
123 #include <linux/init.h>
124 @@ -39,21 +41,35 @@
125 #define skb_debug(skb) do {} while (0)
126 #endif
127
128 +#define BR2684_ETHERTYPE_LEN 2
129 +#define BR2684_PAD_LEN 2
130 +
131 +#define LLC 0xaa, 0xaa, 0x03
132 +#define SNAP_BRIDGED 0x00, 0x80, 0xc2
133 +#define SNAP_ROUTED 0x00, 0x00, 0x00
134 +#define PID_ETHERNET 0x00, 0x07
135 +#define ETHERTYPE_IPV4 0x08, 0x00
136 +#define ETHERTYPE_IPV6 0x86, 0xdd
137 +#define PAD_BRIDGED 0x00, 0x00
138 +
139 +static unsigned char ethertype_ipv4[] = { ETHERTYPE_IPV4 };
140 +static unsigned char ethertype_ipv6[] = { ETHERTYPE_IPV6 };
141 static unsigned char llc_oui_pid_pad[] =
142 - { 0xAA, 0xAA, 0x03, 0x00, 0x80, 0xC2, 0x00, 0x07, 0x00, 0x00 };
143 -#define PADLEN (2)
144 + { LLC, SNAP_BRIDGED, PID_ETHERNET, PAD_BRIDGED };
145 +static unsigned char llc_oui_ipv4[] = { LLC, SNAP_ROUTED, ETHERTYPE_IPV4 };
146 +static unsigned char llc_oui_ipv6[] = { LLC, SNAP_ROUTED, ETHERTYPE_IPV6 };
147
148 enum br2684_encaps {
149 - e_vc = BR2684_ENCAPS_VC,
150 + e_vc = BR2684_ENCAPS_VC,
151 e_llc = BR2684_ENCAPS_LLC,
152 };
153
154 struct br2684_vcc {
155 - struct atm_vcc *atmvcc;
156 + struct atm_vcc *atmvcc;
157 struct net_device *device;
158 - /* keep old push,pop functions for chaining */
159 - void (*old_push)(struct atm_vcc *vcc,struct sk_buff *skb);
160 - /* void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb); */
161 + /* keep old push, pop functions for chaining */
162 + void (*old_push) (struct atm_vcc * vcc, struct sk_buff * skb);
163 + /* void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); */
164 enum br2684_encaps encaps;
165 struct list_head brvccs;
166 #ifdef CONFIG_ATM_BR2684_IPFILTER
167 @@ -66,9 +82,10 @@
168 struct net_device *net_dev;
169 struct list_head br2684_devs;
170 int number;
171 - struct list_head brvccs; /* one device <=> one vcc (before xmas) */
172 + struct list_head brvccs; /* one device <=> one vcc (before xmas) */
173 struct net_device_stats stats;
174 int mac_was_set;
175 + enum br2684_payload payload;
176 };
177
178 /*
179 @@ -84,7 +101,7 @@
180
181 static inline struct br2684_dev *BRPRIV(const struct net_device *net_dev)
182 {
183 - return (struct br2684_dev *) net_dev->priv;
184 + return (struct br2684_dev *)net_dev->priv;
185 }
186
187 static inline struct net_device *list_entry_brdev(const struct list_head *le)
188 @@ -94,7 +111,7 @@
189
190 static inline struct br2684_vcc *BR2684_VCC(const struct atm_vcc *atmvcc)
191 {
192 - return (struct br2684_vcc *) (atmvcc->user_back);
193 + return (struct br2684_vcc *)(atmvcc->user_back);
194 }
195
196 static inline struct br2684_vcc *list_entry_brvcc(const struct list_head *le)
197 @@ -132,10 +149,11 @@
198 * otherwise false
199 */
200 static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
201 - struct br2684_vcc *brvcc)
202 + struct br2684_vcc *brvcc)
203 {
204 struct atm_vcc *atmvcc;
205 int minheadroom = (brvcc->encaps == e_llc) ? 10 : 2;
206 +
207 if (skb_headroom(skb) < minheadroom) {
208 struct sk_buff *skb2 = skb_realloc_headroom(skb, minheadroom);
209 brvcc->copies_needed++;
210 @@ -146,23 +164,48 @@
211 }
212 skb = skb2;
213 }
214 - skb_push(skb, minheadroom);
215 - if (brvcc->encaps == e_llc)
216 - skb_copy_to_linear_data(skb, llc_oui_pid_pad, 10);
217 - else
218 - memset(skb->data, 0, 2);
219 +
220 + if (brvcc->encaps == e_llc) {
221 + if (brdev->payload == p_bridged) {
222 + skb_push(skb, sizeof(llc_oui_pid_pad));
223 + skb_copy_to_linear_data(skb, llc_oui_pid_pad,
224 + sizeof(llc_oui_pid_pad));
225 + } else if (brdev->payload == p_routed) {
226 + unsigned short prot = ntohs(skb->protocol);
227 +
228 + skb_push(skb, sizeof(llc_oui_ipv4));
229 + switch (prot) {
230 + case ETH_P_IP:
231 + skb_copy_to_linear_data(skb, llc_oui_ipv4,
232 + sizeof(llc_oui_ipv4));
233 + break;
234 + case ETH_P_IPV6:
235 + skb_copy_to_linear_data(skb, llc_oui_ipv6,
236 + sizeof(llc_oui_ipv6));
237 + break;
238 + default:
239 + dev_kfree_skb(skb);
240 + return 0;
241 + }
242 + }
243 + } else {
244 + skb_push(skb, 2);
245 + if (brdev->payload == p_bridged)
246 + memset(skb->data, 0, 2);
247 + }
248 skb_debug(skb);
249
250 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
251 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
252 if (!atm_may_send(atmvcc, skb->truesize)) {
253 - /* we free this here for now, because we cannot know in a higher
254 - layer whether the skb point it supplied wasn't freed yet.
255 - now, it always is.
256 - */
257 + /*
258 + * We free this here for now, because we cannot know in a higher
259 + * layer whether the skb pointer it supplied wasn't freed yet.
260 + * Now, it always is.
261 + */
262 dev_kfree_skb(skb);
263 return 0;
264 - }
265 + }
266 atomic_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc);
267 ATM_SKB(skb)->atm_options = atmvcc->atm_options;
268 brdev->stats.tx_packets++;
269 @@ -172,10 +215,9 @@
270 }
271
272 static inline struct br2684_vcc *pick_outgoing_vcc(struct sk_buff *skb,
273 - struct br2684_dev *brdev)
274 + struct br2684_dev *brdev)
275 {
276 - return list_empty(&brdev->brvccs) ? NULL :
277 - list_entry_brvcc(brdev->brvccs.next); /* 1 vcc/dev right now */
278 + return list_empty(&brdev->brvccs) ? NULL : list_entry_brvcc(brdev->brvccs.next); /* 1 vcc/dev right now */
279 }
280
281 static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
282 @@ -199,11 +241,10 @@
283 /*
284 * We should probably use netif_*_queue() here, but that
285 * involves added complication. We need to walk before
286 - * we can run
287 + * we can run.
288 + *
289 + * Don't free here! this pointer might be no longer valid!
290 */
291 - /* don't free here! this pointer might be no longer valid!
292 - dev_kfree_skb(skb);
293 - */
294 brdev->stats.tx_errors++;
295 brdev->stats.tx_fifo_errors++;
296 }
297 @@ -217,12 +258,11 @@
298 return &BRPRIV(dev)->stats;
299 }
300
301 -
302 /*
303 * We remember when the MAC gets set, so we don't override it later with
304 * the ESI of the ATM card of the first VC
305 */
306 -static int (*my_eth_mac_addr)(struct net_device *, void *);
307 +static int (*my_eth_mac_addr) (struct net_device *, void *);
308 static int br2684_mac_addr(struct net_device *dev, void *p)
309 {
310 int err = my_eth_mac_addr(dev, p);
311 @@ -233,7 +273,7 @@
312
313 #ifdef CONFIG_ATM_BR2684_IPFILTER
314 /* this IOCTL is experimental. */
315 -static int br2684_setfilt(struct atm_vcc *atmvcc, void __user *arg)
316 +static int br2684_setfilt(struct atm_vcc *atmvcc, void __user * arg)
317 {
318 struct br2684_vcc *brvcc;
319 struct br2684_filter_set fs;
320 @@ -243,13 +283,12 @@
321 if (fs.ifspec.method != BR2684_FIND_BYNOTHING) {
322 /*
323 * This is really a per-vcc thing, but we can also search
324 - * by device
325 + * by device.
326 */
327 struct br2684_dev *brdev;
328 read_lock(&devs_lock);
329 brdev = BRPRIV(br2684_find_dev(&fs.ifspec));
330 - if (brdev == NULL || list_empty(&brdev->brvccs) ||
331 - brdev->brvccs.next != brdev->brvccs.prev) /* >1 VCC */
332 + if (brdev == NULL || list_empty(&brdev->brvccs) || brdev->brvccs.next != brdev->brvccs.prev) /* >1 VCC */
333 brvcc = NULL;
334 else
335 brvcc = list_entry_brvcc(brdev->brvccs.next);
336 @@ -267,15 +306,16 @@
337 packet_fails_filter(__be16 type, struct br2684_vcc *brvcc, struct sk_buff *skb)
338 {
339 if (brvcc->filter.netmask == 0)
340 - return 0; /* no filter in place */
341 + return 0; /* no filter in place */
342 if (type == htons(ETH_P_IP) &&
343 - (((struct iphdr *) (skb->data))->daddr & brvcc->filter.
344 + (((struct iphdr *)(skb->data))->daddr & brvcc->filter.
345 netmask) == brvcc->filter.prefix)
346 return 0;
347 if (type == htons(ETH_P_ARP))
348 return 0;
349 - /* TODO: we should probably filter ARPs too.. don't want to have
350 - * them returning values that don't make sense, or is that ok?
351 + /*
352 + * TODO: we should probably filter ARPs too.. don't want to have
353 + * them returning values that don't make sense, or is that ok?
354 */
355 return 1; /* drop */
356 }
357 @@ -299,7 +339,6 @@
358 struct br2684_vcc *brvcc = BR2684_VCC(atmvcc);
359 struct net_device *net_dev = brvcc->device;
360 struct br2684_dev *brdev = BRPRIV(net_dev);
361 - int plen = sizeof(llc_oui_pid_pad) + ETH_HLEN;
362
363 pr_debug("br2684_push\n");
364
365 @@ -320,35 +359,58 @@
366 atm_return(atmvcc, skb->truesize);
367 pr_debug("skb from brdev %p\n", brdev);
368 if (brvcc->encaps == e_llc) {
369 - /* let us waste some time for checking the encapsulation.
370 - Note, that only 7 char is checked so frames with a valid FCS
371 - are also accepted (but FCS is not checked of course) */
372 - if (memcmp(skb->data, llc_oui_pid_pad, 7)) {
373 +
374 + if (skb->len > 7 && skb->data[7] == 0x01)
375 + __skb_trim(skb, skb->len - 4);
376 +
377 + /* accept packets that have "ipv[46]" in the snap header */
378 + if ((skb->len >= (sizeof(llc_oui_ipv4)))
379 + &&
380 + (memcmp
381 + (skb->data, llc_oui_ipv4,
382 + sizeof(llc_oui_ipv4) - BR2684_ETHERTYPE_LEN) == 0)) {
383 + if (memcmp
384 + (skb->data + 6, ethertype_ipv6,
385 + sizeof(ethertype_ipv6)) == 0)
386 + skb->protocol = __constant_htons(ETH_P_IPV6);
387 + else if (memcmp
388 + (skb->data + 6, ethertype_ipv4,
389 + sizeof(ethertype_ipv4)) == 0)
390 + skb->protocol = __constant_htons(ETH_P_IP);
391 + else {
392 + brdev->stats.rx_errors++;
393 + dev_kfree_skb(skb);
394 + return;
395 + }
396 + skb_pull(skb, sizeof(llc_oui_ipv4));
397 + skb_reset_network_header(skb);
398 + skb->pkt_type = PACKET_HOST;
399 + /*
400 + * Let us waste some time for checking the encapsulation.
401 + * Note, that only 7 char is checked so frames with a valid FCS
402 + * are also accepted (but FCS is not checked of course).
403 + */
404 + } else if ((skb->len >= sizeof(llc_oui_pid_pad)) &&
405 + (memcmp(skb->data, llc_oui_pid_pad, 7) == 0)) {
406 + skb_pull(skb, sizeof(llc_oui_pid_pad));
407 + skb->protocol = eth_type_trans(skb, net_dev);
408 + } else {
409 brdev->stats.rx_errors++;
410 dev_kfree_skb(skb);
411 return;
412 }
413
414 - /* Strip FCS if present */
415 - if (skb->len > 7 && skb->data[7] == 0x01)
416 - __skb_trim(skb, skb->len - 4);
417 } else {
418 - plen = PADLEN + ETH_HLEN; /* pad, dstmac,srcmac, ethtype */
419 /* first 2 chars should be 0 */
420 if (*((u16 *) (skb->data)) != 0) {
421 brdev->stats.rx_errors++;
422 dev_kfree_skb(skb);
423 return;
424 }
425 - }
426 - if (skb->len < plen) {
427 - brdev->stats.rx_errors++;
428 - dev_kfree_skb(skb); /* dev_ not needed? */
429 - return;
430 + skb_pull(skb, BR2684_PAD_LEN + ETH_HLEN); /* pad, dstmac, srcmac, ethtype */
431 + skb->protocol = eth_type_trans(skb, net_dev);
432 }
433
434 - skb_pull(skb, plen - ETH_HLEN);
435 - skb->protocol = eth_type_trans(skb, net_dev);
436 #ifdef CONFIG_ATM_BR2684_IPFILTER
437 if (unlikely(packet_fails_filter(skb->protocol, brvcc, skb))) {
438 brdev->stats.rx_dropped++;
439 @@ -372,11 +434,12 @@
440 netif_rx(skb);
441 }
442
443 -static int br2684_regvcc(struct atm_vcc *atmvcc, void __user *arg)
444 +/*
445 + * Assign a vcc to a dev
446 + * Note: we do not have explicit unassign, but look at _push()
447 + */
448 +static int br2684_regvcc(struct atm_vcc *atmvcc, void __user * arg)
449 {
450 -/* assign a vcc to a dev
451 -Note: we do not have explicit unassign, but look at _push()
452 -*/
453 int err;
454 struct br2684_vcc *brvcc;
455 struct sk_buff *skb;
456 @@ -395,7 +458,7 @@
457 net_dev = br2684_find_dev(&be.ifspec);
458 if (net_dev == NULL) {
459 printk(KERN_ERR
460 - "br2684: tried to attach to non-existant device\n");
461 + "br2684: tried to attach to non-existant device\n");
462 err = -ENXIO;
463 goto error;
464 }
465 @@ -411,13 +474,15 @@
466 }
467 if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO ||
468 be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps !=
469 - BR2684_ENCAPS_VC && be.encaps != BR2684_ENCAPS_LLC) ||
470 - be.min_size != 0) {
471 + BR2684_ENCAPS_VC
472 + && be.encaps !=
473 + BR2684_ENCAPS_LLC)
474 + || be.min_size != 0) {
475 err = -EINVAL;
476 goto error;
477 }
478 - pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, be.encaps,
479 - brvcc);
480 + pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc,
481 + be.encaps, brvcc);
482 if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) {
483 unsigned char *esi = atmvcc->dev->esi;
484 if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5])
485 @@ -430,7 +495,7 @@
486 brvcc->device = net_dev;
487 brvcc->atmvcc = atmvcc;
488 atmvcc->user_back = brvcc;
489 - brvcc->encaps = (enum br2684_encaps) be.encaps;
490 + brvcc->encaps = (enum br2684_encaps)be.encaps;
491 brvcc->old_push = atmvcc->push;
492 barrier();
493 atmvcc->push = br2684_push;
494 @@ -461,7 +526,7 @@
495 }
496 __module_get(THIS_MODULE);
497 return 0;
498 - error:
499 + error:
500 write_unlock_irq(&devs_lock);
501 kfree(brvcc);
502 return err;
503 @@ -482,25 +547,52 @@
504 INIT_LIST_HEAD(&brdev->brvccs);
505 }
506
507 -static int br2684_create(void __user *arg)
508 +static void br2684_setup_routed(struct net_device *netdev)
509 +{
510 + struct br2684_dev *brdev = BRPRIV(netdev);
511 + brdev->net_dev = netdev;
512 +
513 + netdev->hard_header_len = 0;
514 + my_eth_mac_addr = netdev->set_mac_address;
515 + netdev->set_mac_address = br2684_mac_addr;
516 + netdev->hard_start_xmit = br2684_start_xmit;
517 + netdev->get_stats = br2684_get_stats;
518 + netdev->addr_len = 0;
519 + netdev->mtu = 1500;
520 + netdev->type = ARPHRD_PPP;
521 + netdev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
522 + netdev->tx_queue_len = 100;
523 + INIT_LIST_HEAD(&brdev->brvccs);
524 +}
525 +
526 +static int br2684_create(void __user * arg)
527 {
528 int err;
529 struct net_device *netdev;
530 struct br2684_dev *brdev;
531 struct atm_newif_br2684 ni;
532 + enum br2684_payload payload;
533
534 pr_debug("br2684_create\n");
535
536 if (copy_from_user(&ni, arg, sizeof ni)) {
537 return -EFAULT;
538 }
539 +
540 + if (ni.media & BR2684_FLAG_ROUTED)
541 + payload = p_routed;
542 + else
543 + payload = p_bridged;
544 + ni.media &= 0xffff; /* strip flags */
545 +
546 if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) {
547 return -EINVAL;
548 }
549
550 netdev = alloc_netdev(sizeof(struct br2684_dev),
551 ni.ifname[0] ? ni.ifname : "nas%d",
552 - br2684_setup);
553 + (payload == p_routed) ?
554 + br2684_setup_routed : br2684_setup);
555 if (!netdev)
556 return -ENOMEM;
557
558 @@ -516,6 +608,7 @@
559 }
560
561 write_lock_irq(&devs_lock);
562 + brdev->payload = payload;
563 brdev->number = list_empty(&br2684_devs) ? 1 :
564 BRPRIV(list_entry_brdev(br2684_devs.prev))->number + 1;
565 list_add_tail(&brdev->br2684_devs, &br2684_devs);
566 @@ -528,16 +621,16 @@
567 * -ENOIOCTLCMD for any unrecognized ioctl
568 */
569 static int br2684_ioctl(struct socket *sock, unsigned int cmd,
570 - unsigned long arg)
571 + unsigned long arg)
572 {
573 struct atm_vcc *atmvcc = ATM_SD(sock);
574 void __user *argp = (void __user *)arg;
575 + atm_backend_t b;
576
577 int err;
578 - switch(cmd) {
579 + switch (cmd) {
580 case ATM_SETBACKEND:
581 - case ATM_NEWBACKENDIF: {
582 - atm_backend_t b;
583 + case ATM_NEWBACKENDIF:
584 err = get_user(b, (atm_backend_t __user *) argp);
585 if (err)
586 return -EFAULT;
587 @@ -549,7 +642,6 @@
588 return br2684_regvcc(atmvcc, argp);
589 else
590 return br2684_create(argp);
591 - }
592 #ifdef CONFIG_ATM_BR2684_IPFILTER
593 case BR2684_SETFILT:
594 if (atmvcc->push != br2684_push)
595 @@ -557,6 +649,7 @@
596 if (!capable(CAP_NET_ADMIN))
597 return -EPERM;
598 err = br2684_setfilt(atmvcc, argp);
599 +
600 return err;
601 #endif /* CONFIG_ATM_BR2684_IPFILTER */
602 }
603 @@ -564,24 +657,25 @@
604 }
605
606 static struct atm_ioctl br2684_ioctl_ops = {
607 - .owner = THIS_MODULE,
608 - .ioctl = br2684_ioctl,
609 + .owner = THIS_MODULE,
610 + .ioctl = br2684_ioctl,
611 };
612
613 -
614 #ifdef CONFIG_PROC_FS
615 -static void *br2684_seq_start(struct seq_file *seq, loff_t *pos)
616 +static void *br2684_seq_start(struct seq_file *seq, loff_t * pos)
617 + __acquires(devs_lock)
618 {
619 read_lock(&devs_lock);
620 return seq_list_start(&br2684_devs, *pos);
621 }
622
623 -static void *br2684_seq_next(struct seq_file *seq, void *v, loff_t *pos)
624 +static void *br2684_seq_next(struct seq_file *seq, void *v, loff_t * pos)
625 {
626 return seq_list_next(v, &br2684_devs, pos);
627 }
628
629 static void br2684_seq_stop(struct seq_file *seq, void *v)
630 + __releases(devs_lock)
631 {
632 read_unlock(&devs_lock);
633 }
634 @@ -589,7 +683,7 @@
635 static int br2684_seq_show(struct seq_file *seq, void *v)
636 {
637 const struct br2684_dev *brdev = list_entry(v, struct br2684_dev,
638 - br2684_devs);
639 + br2684_devs);
640 const struct net_device *net_dev = brdev->net_dev;
641 const struct br2684_vcc *brvcc;
642 DECLARE_MAC_BUF(mac);
643 @@ -601,21 +695,19 @@
644 brdev->mac_was_set ? "set" : "auto");
645
646 list_for_each_entry(brvcc, &brdev->brvccs, brvccs) {
647 - seq_printf(seq, " vcc %d.%d.%d: encaps=%s"
648 - ", failed copies %u/%u"
649 - "\n", brvcc->atmvcc->dev->number,
650 - brvcc->atmvcc->vpi, brvcc->atmvcc->vci,
651 - (brvcc->encaps == e_llc) ? "LLC" : "VC"
652 - , brvcc->copies_failed
653 - , brvcc->copies_needed
654 - );
655 + seq_printf(seq, " vcc %d.%d.%d: encaps=%s payload=%s"
656 + ", failed copies %u/%u"
657 + "\n", brvcc->atmvcc->dev->number,
658 + brvcc->atmvcc->vpi, brvcc->atmvcc->vci,
659 + (brvcc->encaps == e_llc) ? "LLC" : "VC",
660 + (brdev->payload == p_bridged) ? "bridged" : "routed",
661 + brvcc->copies_failed, brvcc->copies_needed);
662 #ifdef CONFIG_ATM_BR2684_IPFILTER
663 #define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte]
664 #define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3)
665 - if (brvcc->filter.netmask != 0)
666 - seq_printf(seq, " filter=%d.%d.%d.%d/"
667 - "%d.%d.%d.%d\n",
668 - bs(prefix), bs(netmask));
669 + if (brvcc->filter.netmask != 0)
670 + seq_printf(seq, " filter=%d.%d.%d.%d/"
671 + "%d.%d.%d.%d\n", bs(prefix), bs(netmask));
672 #undef bs
673 #undef b1
674 #endif /* CONFIG_ATM_BR2684_IPFILTER */
675 @@ -625,9 +717,9 @@
676
677 static const struct seq_operations br2684_seq_ops = {
678 .start = br2684_seq_start,
679 - .next = br2684_seq_next,
680 - .stop = br2684_seq_stop,
681 - .show = br2684_seq_show,
682 + .next = br2684_seq_next,
683 + .stop = br2684_seq_stop,
684 + .show = br2684_seq_show,
685 };
686
687 static int br2684_proc_open(struct inode *inode, struct file *file)
688 @@ -636,26 +728,28 @@
689 }
690
691 static const struct file_operations br2684_proc_ops = {
692 - .owner = THIS_MODULE,
693 - .open = br2684_proc_open,
694 - .read = seq_read,
695 - .llseek = seq_lseek,
696 + .owner = THIS_MODULE,
697 + .open = br2684_proc_open,
698 + .read = seq_read,
699 + .llseek = seq_lseek,
700 .release = seq_release,
701 };
702
703 extern struct proc_dir_entry *atm_proc_root; /* from proc.c */
704 -#endif
705 +#endif /* CONFIG_PROC_FS */
706
707 static int __init br2684_init(void)
708 {
709 #ifdef CONFIG_PROC_FS
710 struct proc_dir_entry *p;
711 +
712 if ((p = create_proc_entry("br2684", 0, atm_proc_root)) == NULL)
713 - return -ENOMEM;
714 - p->proc_fops = &br2684_proc_ops;
715 + return -ENOMEM;
716 + p->proc_fops = &br2684_proc_ops;
717 #endif
718 - register_atm_ioctl(&br2684_ioctl_ops);
719 - return 0;
720 + register_atm_ioctl(&br2684_ioctl_ops);
721 + return 0;
722 +
723 }
724
725 static void __exit br2684_exit(void)
726 @@ -689,3 +783,4 @@
727 MODULE_AUTHOR("Marcell GAL");
728 MODULE_DESCRIPTION("RFC2684 bridged protocols over ATM/AAL5");
729 MODULE_LICENSE("GPL");
730 +
This page took 0.077129 seconds and 5 git commands to generate.