1 Index: linux-2.4.35.4/net/atm/br2684.c
2 ===================================================================
3 --- linux-2.4.35.4.orig/net/atm/br2684.c
4 +++ linux-2.4.35.4/net/atm/br2684.c
5 @@ -55,36 +55,55 @@ static void skb_debug(const struct sk_bu
6 #define skb_debug(skb) do {} while (0)
9 +#define BR2684_LLC_LEN 3
10 +#define BR2684_SNAP_LEN 3
11 +#define BR2684_ETHERTYPE_LEN 2
12 +#define BR2684_PID_LEN 2
13 +#define BR2684_PAD_LEN 2
15 +static unsigned char llc_common[] = { 0xaa, 0xaa, 0x03 };
16 +static unsigned char snap_bridged[] = { 0x00, 0x80, 0xc2 };
17 +static unsigned char snap_routed[] = { 0x00, 0x00, 0x00 };
18 +static unsigned char pid_ipv4[] = { 0x00, 0x07 };
19 +static unsigned char ethertype_ipv4[] = { 0x08, 0x00 };
20 +static unsigned char ethertype_ipv6[] = { 0x86, 0xdd };
21 +static unsigned char pad_bridged[] = { 0x00, 0x00 };
23 static unsigned char llc_oui_pid_pad[] =
24 { 0xAA, 0xAA, 0x03, 0x00, 0x80, 0xC2, 0x00, 0x07, 0x00, 0x00 };
25 +static unsigned char llc_oui_ipv6[] =
26 + { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd };
27 +static unsigned char llc_oui_ipv4[] =
28 + { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00 };
32 - e_vc = BR2684_ENCAPS_VC,
33 + e_vc = BR2684_ENCAPS_VC,
34 e_llc = BR2684_ENCAPS_LLC,
38 - struct atm_vcc *atmvcc;
39 + struct atm_vcc *atmvcc;
40 struct br2684_dev *brdev;
41 /* keep old push,pop functions for chaining */
42 - void (*old_push)(struct atm_vcc *vcc,struct sk_buff *skb);
43 + void (*old_push) (struct atm_vcc * vcc, struct sk_buff * skb);
44 /* void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb); */
45 enum br2684_encaps encaps;
46 + enum br2684_payload payload;
47 struct list_head brvccs;
48 #ifdef CONFIG_ATM_BR2684_IPFILTER
49 struct br2684_filter filter;
50 -#endif /* CONFIG_ATM_BR2684_IPFILTER */
51 +#endif /* CONFIG_ATM_BR2684_IPFILTER */
52 #ifndef FASTER_VERSION
53 unsigned copies_needed, copies_failed;
54 -#endif /* FASTER_VERSION */
55 +#endif /* FASTER_VERSION */
59 struct net_device net_dev;
60 struct list_head br2684_devs;
62 - struct list_head brvccs; /* one device <=> one vcc (before xmas) */
63 + struct list_head brvccs; /* one device <=> one vcc (before xmas) */
64 struct net_device_stats stats;
67 @@ -173,24 +192,84 @@ static int br2684_xmit_vcc(struct sk_buf
71 - skb_push(skb, minheadroom);
72 - if (brvcc->encaps == e_llc)
73 - memcpy(skb->data, llc_oui_pid_pad, 10);
75 - memset(skb->data, 0, 2);
76 -#endif /* FASTER_VERSION */
78 + /* This skb_push is a problem: routed packets need less headroom than
82 +/* skb_push(skb, minheadroom); */
83 + if (brvcc->encaps == e_llc) {
85 + int actual_headroom;
90 + ((brvcc->payload == p_bridged) ?
91 + (BR2684_PID_LEN + BR2684_PAD_LEN) :
92 + BR2684_ETHERTYPE_LEN);
94 + skb_push(skb, actual_headroom);
95 + memcpy(skb->data, llc_common, BR2684_LLC_LEN);
96 + offset += BR2684_LLC_LEN;
98 + if (brvcc->payload == p_bridged) {
99 + memcpy(skb->data + offset, snap_bridged,
101 + offset += BR2684_SNAP_LEN;
102 + /* pid_ipv4 is poorly named. should probably be
105 + memcpy(skb->data + offset, pid_ipv4,
107 + offset += BR2684_PID_LEN;
108 + memcpy(skb->data + offset, pad_bridged,
110 + offset += BR2684_PAD_LEN;
111 + } else if (brvcc->payload == p_routed) {
112 + unsigned short prot =
113 + __constant_ntohs(skb->protocol);
114 + memcpy(skb->data + offset, snap_routed,
116 + offset += BR2684_SNAP_LEN;
120 + memcpy(skb->data + offset,
122 + BR2684_ETHERTYPE_LEN);
125 + memcpy(skb->data + offset,
127 + BR2684_ETHERTYPE_LEN);
130 + dev_kfree_skb(skb);
133 + offset += BR2684_ETHERTYPE_LEN;
138 + if (brvcc->payload == p_bridged)
139 + memset(skb->data, 0, 2);
141 +#endif /* FASTER_VERSION */
144 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
145 - DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
146 + DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc,
148 if (!atm_may_send(atmvcc, skb->truesize)) {
149 /* we free this here for now, because we cannot know in a higher
150 - layer whether the skb point it supplied wasn't freed yet.
153 + layer whether the skb point it supplied wasn't freed yet.
160 atomic_add(skb->truesize, &atmvcc->sk->wmem_alloc);
161 ATM_SKB(skb)->atm_options = atmvcc->atm_options;
162 brdev->stats.tx_packets++;
163 @@ -428,18 +507,39 @@ static void br2684_push(struct atm_vcc *
164 atm_return(atmvcc, skb->truesize);
165 DPRINTK("skb from brdev %p\n", brdev);
166 if (brvcc->encaps == e_llc) {
167 + /* accept packets that have "ipv[46]" in the snap header */
168 + /* 8 - 2 == sizeof(llc_oui_ipv6) - BR2684_ETHERTYPE_LEN */
169 + if (memcmp(skb->data, llc_oui_ipv6, 8 - 2) == 0) {
170 + plen = sizeof(llc_oui_ipv6);
172 + if (memcmp(skb->data + 6, ethertype_ipv6, 2) == 0)
174 + __constant_htons(ETH_P_IPV6);
175 + else if (memcmp(skb->data + 6, ethertype_ipv4, 2)
177 + skb->protocol = __constant_htons(ETH_P_IP);
179 + brdev->stats.rx_errors++;
180 + dev_kfree_skb(skb);
183 + skb_pull(skb, plen);
184 + skb->nh.raw = skb->data;
185 + skb->pkt_type = PACKET_HOST;
188 /* let us waste some time for checking the encapsulation.
189 Note, that only 7 char is checked so frames with a valid FCS
190 are also accepted (but FCS is not checked of course) */
191 - if (memcmp(skb->data, llc_oui_pid_pad, 7)) {
192 + else if (memcmp(skb->data, llc_oui_pid_pad, 7) == 0) {
193 + skb_pull(skb, plen - ETH_HLEN);
195 + eth_type_trans(skb, &brdev->net_dev);
197 brdev->stats.rx_errors++;
202 - /* Strip FCS if present */
203 - if (skb->len > 7 && skb->data[7] == 0x01)
204 - __skb_trim(skb, skb->len - 4);
206 plen = PADLEN + ETH_HLEN; /* pad, dstmac,srcmac, ethtype */
207 /* first 2 chars should be 0 */
208 @@ -448,13 +548,14 @@ static void br2684_push(struct atm_vcc *
212 + skb_pull(skb, plen - ETH_HLEN);
213 + skb->protocol = eth_type_trans(skb, &brdev->net_dev);
215 if (skb->len < plen) {
216 brdev->stats.rx_errors++;
217 dev_kfree_skb(skb); /* dev_ not needed? */
221 #ifdef FASTER_VERSION
222 /* FIXME: tcpdump shows that pointer to mac header is 2 bytes earlier,
223 than should be. What else should I set? */
224 @@ -465,30 +566,29 @@ static void br2684_push(struct atm_vcc *
225 skb->protocol = ((u16 *) skb->data)[-1];
226 #else /* some protocols might require this: */
227 skb->protocol = br_type_trans(skb, &brdev->net_dev);
228 -#endif /* CONFIG_BR2684_FAST_TRANS */
229 +#endif /* CONFIG_BR2684_FAST_TRANS */
231 - skb_pull(skb, plen - ETH_HLEN);
232 - skb->protocol = eth_type_trans(skb, &brdev->net_dev);
233 -#endif /* FASTER_VERSION */
234 + /* skb_pull(skb, plen - ETH_HLEN); */
235 + /* skb->protocol = eth_type_trans(skb, &brdev->net_dev); */
236 +#endif /* FASTER_VERSION */
237 #ifdef CONFIG_ATM_BR2684_IPFILTER
238 if (packet_fails_filter(skb->protocol, brvcc, skb)) {
239 brdev->stats.rx_dropped++;
243 -#endif /* CONFIG_ATM_BR2684_IPFILTER */
244 +#endif /* CONFIG_ATM_BR2684_IPFILTER */
245 skb->dev = &brdev->net_dev;
246 - ATM_SKB(skb)->vcc = atmvcc; /* needed ? */
247 + /* ATM_SKB(skb)->vcc = atmvcc; *//* needed ? */
248 DPRINTK("received packet's protocol: %x\n", ntohs(skb->protocol));
250 - if (!(brdev->net_dev.flags & IFF_UP)) { /* sigh, interface is down */
251 + if (!(brdev->net_dev.flags & IFF_UP)) { /* sigh, interface is down */
252 brdev->stats.rx_dropped++;
256 brdev->stats.rx_packets++;
257 brdev->stats.rx_bytes += skb->len;
258 - memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
262 @@ -525,10 +625,10 @@ Note: we do not have explicit unassign,
266 - if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO ||
267 - be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps !=
268 - BR2684_ENCAPS_VC && be.encaps != BR2684_ENCAPS_LLC) ||
269 - be.min_size != 0) {
270 + if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO
271 + || be.fcs_auto || be.has_vpiid || be.send_padding
272 + || (be.encaps != BR2684_ENCAPS_VC
273 + && be.encaps != BR2684_ENCAPS_LLC) || be.min_size != 0) {
277 @@ -554,18 +654,21 @@ Note: we do not have explicit unassign,
278 brvcc->atmvcc = atmvcc;
279 atmvcc->user_back = brvcc;
280 brvcc->encaps = (enum br2684_encaps) be.encaps;
281 + brvcc->payload = (enum br2684_payload) be.payload;
282 brvcc->old_push = atmvcc->push;
284 atmvcc->push = br2684_push;
285 skb_queue_head_init(©);
286 skb_migrate(&atmvcc->sk->receive_queue, ©);
287 while ((skb = skb_dequeue(©))) {
289 BRPRIV(skb->dev)->stats.rx_bytes -= skb->len;
290 BRPRIV(skb->dev)->stats.rx_packets--;
292 br2684_push(atmvcc, skb);
297 write_unlock_irq(&devs_lock);
300 @@ -608,12 +711,25 @@ static int br2684_create(unsigned long a
302 if (ni.ifname[0] != '\0') {
303 memcpy(brdev->net_dev.name, ni.ifname,
304 - sizeof(brdev->net_dev.name));
305 - brdev->net_dev.name[sizeof(brdev->net_dev.name) - 1] = '\0';
306 + sizeof(brdev->net_dev.name));
307 + brdev->net_dev.name[sizeof(brdev->net_dev.name) - 1] =
310 sprintf(brdev->net_dev.name, "nas%d", brdev->number);
311 DPRINTK("registered netdev %s\n", brdev->net_dev.name);
312 - ether_setup(&brdev->net_dev);
313 + if (ni.payload == p_routed) {
314 + brdev->net_dev.hard_header_len = 0;
315 + brdev->net_dev.addr_len = 0;
316 + brdev->net_dev.mtu = 1500;
318 + /* Type PPP seems most suitable */
319 + brdev->net_dev.type = ARPHRD_PPP;
320 + brdev->net_dev.flags =
321 + IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
322 + brdev->net_dev.tx_queue_len = 100;
324 + ether_setup(&brdev->net_dev);
326 brdev->mac_was_set = 0;
327 #ifdef FASTER_VERSION
328 my_eth_header = brdev->net_dev.hard_header;
329 @@ -677,12 +793,11 @@ static int br2684_ioctl(struct atm_vcc *
330 err = br2684_setfilt(atmvcc, arg);
333 -#endif /* CONFIG_ATM_BR2684_IPFILTER */
334 +#endif /* CONFIG_ATM_BR2684_IPFILTER */
339 -#ifdef CONFIG_PROC_FS
340 /* Never put more than 256 bytes in at once */
341 static int br2684_proc_engine(loff_t pos, char *buf)
343 @@ -692,52 +807,62 @@ static int br2684_proc_engine(loff_t pos
344 list_for_each(lhd, &br2684_devs) {
345 brdev = list_entry_brdev(lhd);
347 - return sprintf(buf, "dev %.16s: num=%d, mac=%02X:%02X:"
348 - "%02X:%02X:%02X:%02X (%s)\n", brdev->net_dev.name,
350 - brdev->net_dev.dev_addr[0],
351 - brdev->net_dev.dev_addr[1],
352 - brdev->net_dev.dev_addr[2],
353 - brdev->net_dev.dev_addr[3],
354 - brdev->net_dev.dev_addr[4],
355 - brdev->net_dev.dev_addr[5],
356 - brdev->mac_was_set ? "set" : "auto");
357 + return sprintf(buf,
358 + "dev %.16s: num=%d, mac=%02X:%02X:"
359 + "%02X:%02X:%02X:%02X (%s)\n",
360 + brdev->net_dev.name, brdev->number,
361 + brdev->net_dev.dev_addr[0],
362 + brdev->net_dev.dev_addr[1],
363 + brdev->net_dev.dev_addr[2],
364 + brdev->net_dev.dev_addr[3],
365 + brdev->net_dev.dev_addr[4],
366 + brdev->net_dev.dev_addr[5],
368 + mac_was_set ? "set" : "auto");
369 list_for_each(lhc, &brdev->brvccs) {
370 brvcc = list_entry_brvcc(lhc);
372 - return sprintf(buf, " vcc %d.%d.%d: encaps=%s"
373 + return sprintf(buf,
374 + " vcc %d.%d.%d: encaps=%s"
376 #ifndef FASTER_VERSION
377 - ", failed copies %u/%u"
378 -#endif /* FASTER_VERSION */
379 - "\n", brvcc->atmvcc->dev->number,
380 - brvcc->atmvcc->vpi, brvcc->atmvcc->vci,
381 - (brvcc->encaps == e_llc) ? "LLC" : "VC"
382 + ", failed copies %u/%u"
383 +#endif /* FASTER_VERSION */
385 + brvcc->atmvcc->dev->number,
386 + brvcc->atmvcc->vpi,
387 + brvcc->atmvcc->vci,
389 + e_llc) ? "LLC" : "VC",
391 + p_bridged) ? "bridged" :
393 #ifndef FASTER_VERSION
394 - , brvcc->copies_failed
395 - , brvcc->copies_needed
396 -#endif /* FASTER_VERSION */
397 + , brvcc->copies_failed,
398 + brvcc->copies_needed
399 +#endif /* FASTER_VERSION */
401 #ifdef CONFIG_ATM_BR2684_IPFILTER
402 #define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte]
403 #define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3)
404 if (brvcc->filter.netmask != 0 && pos-- == 0)
405 - return sprintf(buf, " filter=%d.%d.%d.%d/"
406 - "%d.%d.%d.%d\n", bs(prefix), bs(netmask));
407 + return sprintf(buf,
408 + " filter=%d.%d.%d.%d/"
409 + "%d.%d.%d.%d\n", bs(prefix),
413 -#endif /* CONFIG_ATM_BR2684_IPFILTER */
414 +#endif /* CONFIG_ATM_BR2684_IPFILTER */
420 static ssize_t br2684_proc_read(struct file *file, char *buf, size_t count,
425 int len = 0, x, left;
428 page = get_free_page(GFP_KERNEL);
431 @@ -746,7 +871,7 @@ static ssize_t br2684_proc_read(struct f
433 read_lock(&devs_lock);
435 - x = br2684_proc_engine(n, &((char *) page)[len]);
436 + x = br2684_proc_engine(*pos, &((char *) page)[len]);
440 @@ -761,12 +886,11 @@ static ssize_t br2684_proc_read(struct f
449 read_unlock(&devs_lock);
451 if (len > 0 && copy_to_user(buf, (char *) page, len))
454 @@ -774,23 +898,20 @@ static ssize_t br2684_proc_read(struct f
457 static struct file_operations br2684_proc_operations = {
458 - read: br2684_proc_read,
459 + read:br2684_proc_read,
462 extern struct proc_dir_entry *atm_proc_root; /* from proc.c */
463 -#endif /* CONFIG_PROC_FS */
465 /* the following avoids some spurious warnings from the compiler */
466 #define UNUSED __attribute__((unused))
468 static int __init UNUSED br2684_init(void)
470 -#ifdef CONFIG_PROC_FS
471 struct proc_dir_entry *p;
472 if ((p = create_proc_entry("br2684", 0, atm_proc_root)) == NULL)
474 p->proc_fops = &br2684_proc_operations;
475 -#endif /* CONFIG_PROC_FS */
476 br2684_ioctl_set(br2684_ioctl);
479 @@ -799,9 +920,7 @@ static void __exit UNUSED br2684_exit(vo
481 struct br2684_dev *brdev;
482 br2684_ioctl_set(NULL);
483 -#ifdef CONFIG_PROC_FS
484 remove_proc_entry("br2684", atm_proc_root);
485 -#endif /* CONFIG_PROC_FS */
486 while (!list_empty(&br2684_devs)) {
487 brdev = list_entry_brdev(br2684_devs.next);
488 unregister_netdev(&brdev->net_dev);
489 Index: linux-2.4.35.4/net/atm/common.c
490 ===================================================================
491 --- linux-2.4.35.4.orig/net/atm/common.c
492 +++ linux-2.4.35.4/net/atm/common.c
493 @@ -158,6 +158,7 @@ void br2684_ioctl_set(int (*hook)(struct
495 #ifdef CONFIG_ATM_BR2684_MODULE
496 EXPORT_SYMBOL(br2684_ioctl_set);
497 +EXPORT_SYMBOL(br2684_ioctl_hook);
501 Index: linux-2.4.35.4/include/linux/atmbr2684.h
502 ===================================================================
503 --- linux-2.4.35.4.orig/include/linux/atmbr2684.h
504 +++ linux-2.4.35.4/include/linux/atmbr2684.h
507 #include <linux/atm.h>
508 #include <linux/if.h> /* For IFNAMSIZ */
509 +#include <linux/if_ether.h> /* ETH_P_* */
512 * Type of media we're bridging (ethernet, token ring, etc) Currently only
514 #define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */
517 + * Is this VC bridged or routed?
520 +#define BR2684_PAYLOAD_ROUTED (0)
521 +#define BR2684_PAYLOAD_BRIDGED (1)
525 * This is for the ATM_NEWBACKENDIF call - these are like socket families:
526 * the first element of the structure is the backend number and the rest
527 * is per-backend specific
529 struct atm_newif_br2684 {
530 - atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
531 - int media; /* BR2684_MEDIA_* */
532 - char ifname[IFNAMSIZ];
534 + atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
535 + int media; /* BR2684_MEDIA_* */
536 + char ifname[IFNAMSIZ];
538 + int payload; /* bridged or routed */
542 @@ -68,16 +78,17 @@ struct br2684_if_spec {
543 * is per-backend specific
545 struct atm_backend_br2684 {
546 - atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
547 + atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
548 struct br2684_if_spec ifspec;
549 - int fcs_in; /* BR2684_FCSIN_* */
550 - int fcs_out; /* BR2684_FCSOUT_* */
551 - int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */
552 - int encaps; /* BR2684_ENCAPS_* */
553 - int has_vpiid; /* 1: use vpn_id - Unsupported */
555 - int send_padding; /* unsupported */
556 - int min_size; /* we will pad smaller packets than this */
557 + int fcs_in; /* BR2684_FCSIN_* */
558 + int fcs_out; /* BR2684_FCSOUT_* */
559 + int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */
560 + int encaps; /* BR2684_ENCAPS_* */
561 + int payload; /* BR2684_PAYLOAD_* */
562 + int has_vpiid; /* 1: use vpn_id - Unsupported */
564 + int send_padding; /* unsupported */
565 + int min_size; /* we will pad smaller packets than this */
569 @@ -95,7 +106,12 @@ struct br2684_filter_set {
570 struct br2684_filter filter;
573 +enum br2684_payload {
574 + p_routed = BR2684_PAYLOAD_ROUTED,
575 + p_bridged = BR2684_PAYLOAD_BRIDGED,
578 #define BR2684_SETFILT _IOW( 'a', ATMIOC_BACKEND + 0, \
579 struct br2684_filter_set)
581 -#endif /* _LINUX_ATMBR2684_H */
582 +#endif /* _LINUX_ATMBR2684_H */