Force reset on decompression error
[linux-2.6/tcp-comp.git] / net / decnet / dn_dev.c
blobfbafa9780def5a472e0f6d7adc2982633e1a4c2f
1 /*
2 * DECnet An implementation of the DECnet protocol suite for the LINUX
3 * operating system. DECnet is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * DECnet Device Layer
8 * Authors: Steve Whitehouse <SteveW@ACM.org>
9 * Eduardo Marcelo Serrat <emserrat@geocities.com>
11 * Changes:
12 * Steve Whitehouse : Devices now see incoming frames so they
13 * can mark on who it came from.
14 * Steve Whitehouse : Fixed bug in creating neighbours. Each neighbour
15 * can now have a device specific setup func.
16 * Steve Whitehouse : Added /proc/sys/net/decnet/conf/<dev>/
17 * Steve Whitehouse : Fixed bug which sometimes killed timer
18 * Steve Whitehouse : Multiple ifaddr support
19 * Steve Whitehouse : SIOCGIFCONF is now a compile time option
20 * Steve Whitehouse : /proc/sys/net/decnet/conf/<sys>/forwarding
21 * Steve Whitehouse : Removed timer1 - it's a user space issue now
22 * Patrick Caulfield : Fixed router hello message format
23 * Steve Whitehouse : Got rid of constant sizes for blksize for
24 * devices. All mtu based now.
27 #include <linux/capability.h>
28 #include <linux/module.h>
29 #include <linux/moduleparam.h>
30 #include <linux/init.h>
31 #include <linux/net.h>
32 #include <linux/netdevice.h>
33 #include <linux/proc_fs.h>
34 #include <linux/seq_file.h>
35 #include <linux/timer.h>
36 #include <linux/string.h>
37 #include <linux/if_addr.h>
38 #include <linux/if_arp.h>
39 #include <linux/if_ether.h>
40 #include <linux/skbuff.h>
41 #include <linux/sysctl.h>
42 #include <linux/notifier.h>
43 #include <asm/uaccess.h>
44 #include <asm/system.h>
45 #include <net/neighbour.h>
46 #include <net/dst.h>
47 #include <net/flow.h>
48 #include <net/fib_rules.h>
49 #include <net/netlink.h>
50 #include <net/dn.h>
51 #include <net/dn_dev.h>
52 #include <net/dn_route.h>
53 #include <net/dn_neigh.h>
54 #include <net/dn_fib.h>
56 #define DN_IFREQ_SIZE (sizeof(struct ifreq) - sizeof(struct sockaddr) + sizeof(struct sockaddr_dn))
58 static char dn_rt_all_end_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x04,0x00,0x00};
59 static char dn_rt_all_rt_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x03,0x00,0x00};
60 static char dn_hiord[ETH_ALEN] = {0xAA,0x00,0x04,0x00,0x00,0x00};
61 static unsigned char dn_eco_version[3] = {0x02,0x00,0x00};
63 extern struct neigh_table dn_neigh_table;
66 * decnet_address is kept in network order.
68 __le16 decnet_address = 0;
70 static DEFINE_RWLOCK(dndev_lock);
71 static struct net_device *decnet_default_device;
72 static BLOCKING_NOTIFIER_HEAD(dnaddr_chain);
74 static struct dn_dev *dn_dev_create(struct net_device *dev, int *err);
75 static void dn_dev_delete(struct net_device *dev);
76 static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa);
78 static int dn_eth_up(struct net_device *);
79 static void dn_eth_down(struct net_device *);
80 static void dn_send_brd_hello(struct net_device *dev, struct dn_ifaddr *ifa);
81 static void dn_send_ptp_hello(struct net_device *dev, struct dn_ifaddr *ifa);
83 static struct dn_dev_parms dn_dev_list[] = {
85 .type = ARPHRD_ETHER, /* Ethernet */
86 .mode = DN_DEV_BCAST,
87 .state = DN_DEV_S_RU,
88 .t2 = 1,
89 .t3 = 10,
90 .name = "ethernet",
91 .ctl_name = NET_DECNET_CONF_ETHER,
92 .up = dn_eth_up,
93 .down = dn_eth_down,
94 .timer3 = dn_send_brd_hello,
97 .type = ARPHRD_IPGRE, /* DECnet tunneled over GRE in IP */
98 .mode = DN_DEV_BCAST,
99 .state = DN_DEV_S_RU,
100 .t2 = 1,
101 .t3 = 10,
102 .name = "ipgre",
103 .ctl_name = NET_DECNET_CONF_GRE,
104 .timer3 = dn_send_brd_hello,
106 #if 0
108 .type = ARPHRD_X25, /* Bog standard X.25 */
109 .mode = DN_DEV_UCAST,
110 .state = DN_DEV_S_DS,
111 .t2 = 1,
112 .t3 = 120,
113 .name = "x25",
114 .ctl_name = NET_DECNET_CONF_X25,
115 .timer3 = dn_send_ptp_hello,
117 #endif
118 #if 0
120 .type = ARPHRD_PPP, /* DECnet over PPP */
121 .mode = DN_DEV_BCAST,
122 .state = DN_DEV_S_RU,
123 .t2 = 1,
124 .t3 = 10,
125 .name = "ppp",
126 .ctl_name = NET_DECNET_CONF_PPP,
127 .timer3 = dn_send_brd_hello,
129 #endif
131 .type = ARPHRD_DDCMP, /* DECnet over DDCMP */
132 .mode = DN_DEV_UCAST,
133 .state = DN_DEV_S_DS,
134 .t2 = 1,
135 .t3 = 120,
136 .name = "ddcmp",
137 .ctl_name = NET_DECNET_CONF_DDCMP,
138 .timer3 = dn_send_ptp_hello,
141 .type = ARPHRD_LOOPBACK, /* Loopback interface - always last */
142 .mode = DN_DEV_BCAST,
143 .state = DN_DEV_S_RU,
144 .t2 = 1,
145 .t3 = 10,
146 .name = "loopback",
147 .ctl_name = NET_DECNET_CONF_LOOPBACK,
148 .timer3 = dn_send_brd_hello,
152 #define DN_DEV_LIST_SIZE (sizeof(dn_dev_list)/sizeof(struct dn_dev_parms))
154 #define DN_DEV_PARMS_OFFSET(x) ((int) ((char *) &((struct dn_dev_parms *)0)->x))
156 #ifdef CONFIG_SYSCTL
158 static int min_t2[] = { 1 };
159 static int max_t2[] = { 60 }; /* No max specified, but this seems sensible */
160 static int min_t3[] = { 1 };
161 static int max_t3[] = { 8191 }; /* Must fit in 16 bits when multiplied by BCT3MULT or T3MULT */
163 static int min_priority[1];
164 static int max_priority[] = { 127 }; /* From DECnet spec */
166 static int dn_forwarding_proc(ctl_table *, int, struct file *,
167 void __user *, size_t *, loff_t *);
168 static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen,
169 void __user *oldval, size_t __user *oldlenp,
170 void __user *newval, size_t newlen);
172 static struct dn_dev_sysctl_table {
173 struct ctl_table_header *sysctl_header;
174 ctl_table dn_dev_vars[5];
175 ctl_table dn_dev_dev[2];
176 ctl_table dn_dev_conf_dir[2];
177 ctl_table dn_dev_proto_dir[2];
178 ctl_table dn_dev_root_dir[2];
179 } dn_dev_sysctl = {
180 NULL,
183 .ctl_name = NET_DECNET_CONF_DEV_FORWARDING,
184 .procname = "forwarding",
185 .data = (void *)DN_DEV_PARMS_OFFSET(forwarding),
186 .maxlen = sizeof(int),
187 .mode = 0644,
188 .proc_handler = dn_forwarding_proc,
189 .strategy = dn_forwarding_sysctl,
192 .ctl_name = NET_DECNET_CONF_DEV_PRIORITY,
193 .procname = "priority",
194 .data = (void *)DN_DEV_PARMS_OFFSET(priority),
195 .maxlen = sizeof(int),
196 .mode = 0644,
197 .proc_handler = proc_dointvec_minmax,
198 .strategy = sysctl_intvec,
199 .extra1 = &min_priority,
200 .extra2 = &max_priority
203 .ctl_name = NET_DECNET_CONF_DEV_T2,
204 .procname = "t2",
205 .data = (void *)DN_DEV_PARMS_OFFSET(t2),
206 .maxlen = sizeof(int),
207 .mode = 0644,
208 .proc_handler = proc_dointvec_minmax,
209 .strategy = sysctl_intvec,
210 .extra1 = &min_t2,
211 .extra2 = &max_t2
214 .ctl_name = NET_DECNET_CONF_DEV_T3,
215 .procname = "t3",
216 .data = (void *)DN_DEV_PARMS_OFFSET(t3),
217 .maxlen = sizeof(int),
218 .mode = 0644,
219 .proc_handler = proc_dointvec_minmax,
220 .strategy = sysctl_intvec,
221 .extra1 = &min_t3,
222 .extra2 = &max_t3
227 .ctl_name = 0,
228 .procname = "",
229 .mode = 0555,
230 .child = dn_dev_sysctl.dn_dev_vars
231 }, {0}},
233 .ctl_name = NET_DECNET_CONF,
234 .procname = "conf",
235 .mode = 0555,
236 .child = dn_dev_sysctl.dn_dev_dev
237 }, {0}},
239 .ctl_name = NET_DECNET,
240 .procname = "decnet",
241 .mode = 0555,
242 .child = dn_dev_sysctl.dn_dev_conf_dir
243 }, {0}},
245 .ctl_name = CTL_NET,
246 .procname = "net",
247 .mode = 0555,
248 .child = dn_dev_sysctl.dn_dev_proto_dir
249 }, {0}}
252 static void dn_dev_sysctl_register(struct net_device *dev, struct dn_dev_parms *parms)
254 struct dn_dev_sysctl_table *t;
255 int i;
257 t = kmemdup(&dn_dev_sysctl, sizeof(*t), GFP_KERNEL);
258 if (t == NULL)
259 return;
261 for(i = 0; i < ARRAY_SIZE(t->dn_dev_vars) - 1; i++) {
262 long offset = (long)t->dn_dev_vars[i].data;
263 t->dn_dev_vars[i].data = ((char *)parms) + offset;
266 if (dev) {
267 t->dn_dev_dev[0].procname = dev->name;
268 t->dn_dev_dev[0].ctl_name = dev->ifindex;
269 } else {
270 t->dn_dev_dev[0].procname = parms->name;
271 t->dn_dev_dev[0].ctl_name = parms->ctl_name;
274 t->dn_dev_dev[0].child = t->dn_dev_vars;
275 t->dn_dev_conf_dir[0].child = t->dn_dev_dev;
276 t->dn_dev_proto_dir[0].child = t->dn_dev_conf_dir;
277 t->dn_dev_root_dir[0].child = t->dn_dev_proto_dir;
278 t->dn_dev_vars[0].extra1 = (void *)dev;
280 t->sysctl_header = register_sysctl_table(t->dn_dev_root_dir);
281 if (t->sysctl_header == NULL)
282 kfree(t);
283 else
284 parms->sysctl = t;
287 static void dn_dev_sysctl_unregister(struct dn_dev_parms *parms)
289 if (parms->sysctl) {
290 struct dn_dev_sysctl_table *t = parms->sysctl;
291 parms->sysctl = NULL;
292 unregister_sysctl_table(t->sysctl_header);
293 kfree(t);
297 static int dn_forwarding_proc(ctl_table *table, int write,
298 struct file *filep,
299 void __user *buffer,
300 size_t *lenp, loff_t *ppos)
302 #ifdef CONFIG_DECNET_ROUTER
303 struct net_device *dev = table->extra1;
304 struct dn_dev *dn_db;
305 int err;
306 int tmp, old;
308 if (table->extra1 == NULL)
309 return -EINVAL;
311 dn_db = dev->dn_ptr;
312 old = dn_db->parms.forwarding;
314 err = proc_dointvec(table, write, filep, buffer, lenp, ppos);
316 if ((err >= 0) && write) {
317 if (dn_db->parms.forwarding < 0)
318 dn_db->parms.forwarding = 0;
319 if (dn_db->parms.forwarding > 2)
320 dn_db->parms.forwarding = 2;
322 * What an ugly hack this is... its works, just. It
323 * would be nice if sysctl/proc were just that little
324 * bit more flexible so I don't have to write a special
325 * routine, or suffer hacks like this - SJW
327 tmp = dn_db->parms.forwarding;
328 dn_db->parms.forwarding = old;
329 if (dn_db->parms.down)
330 dn_db->parms.down(dev);
331 dn_db->parms.forwarding = tmp;
332 if (dn_db->parms.up)
333 dn_db->parms.up(dev);
336 return err;
337 #else
338 return -EINVAL;
339 #endif
342 static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen,
343 void __user *oldval, size_t __user *oldlenp,
344 void __user *newval, size_t newlen)
346 #ifdef CONFIG_DECNET_ROUTER
347 struct net_device *dev = table->extra1;
348 struct dn_dev *dn_db;
349 int value;
351 if (table->extra1 == NULL)
352 return -EINVAL;
354 dn_db = dev->dn_ptr;
356 if (newval && newlen) {
357 if (newlen != sizeof(int))
358 return -EINVAL;
360 if (get_user(value, (int __user *)newval))
361 return -EFAULT;
362 if (value < 0)
363 return -EINVAL;
364 if (value > 2)
365 return -EINVAL;
367 if (dn_db->parms.down)
368 dn_db->parms.down(dev);
369 dn_db->parms.forwarding = value;
370 if (dn_db->parms.up)
371 dn_db->parms.up(dev);
374 return 0;
375 #else
376 return -EINVAL;
377 #endif
380 #else /* CONFIG_SYSCTL */
381 static void dn_dev_sysctl_unregister(struct dn_dev_parms *parms)
384 static void dn_dev_sysctl_register(struct net_device *dev, struct dn_dev_parms *parms)
388 #endif /* CONFIG_SYSCTL */
390 static inline __u16 mtu2blksize(struct net_device *dev)
392 u32 blksize = dev->mtu;
393 if (blksize > 0xffff)
394 blksize = 0xffff;
396 if (dev->type == ARPHRD_ETHER ||
397 dev->type == ARPHRD_PPP ||
398 dev->type == ARPHRD_IPGRE ||
399 dev->type == ARPHRD_LOOPBACK)
400 blksize -= 2;
402 return (__u16)blksize;
405 static struct dn_ifaddr *dn_dev_alloc_ifa(void)
407 struct dn_ifaddr *ifa;
409 ifa = kzalloc(sizeof(*ifa), GFP_KERNEL);
411 return ifa;
414 static __inline__ void dn_dev_free_ifa(struct dn_ifaddr *ifa)
416 kfree(ifa);
419 static void dn_dev_del_ifa(struct dn_dev *dn_db, struct dn_ifaddr **ifap, int destroy)
421 struct dn_ifaddr *ifa1 = *ifap;
422 unsigned char mac_addr[6];
423 struct net_device *dev = dn_db->dev;
425 ASSERT_RTNL();
427 *ifap = ifa1->ifa_next;
429 if (dn_db->dev->type == ARPHRD_ETHER) {
430 if (ifa1->ifa_local != dn_eth2dn(dev->dev_addr)) {
431 dn_dn2eth(mac_addr, ifa1->ifa_local);
432 dev_mc_delete(dev, mac_addr, ETH_ALEN, 0);
436 dn_ifaddr_notify(RTM_DELADDR, ifa1);
437 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_DOWN, ifa1);
438 if (destroy) {
439 dn_dev_free_ifa(ifa1);
441 if (dn_db->ifa_list == NULL)
442 dn_dev_delete(dn_db->dev);
446 static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa)
448 struct net_device *dev = dn_db->dev;
449 struct dn_ifaddr *ifa1;
450 unsigned char mac_addr[6];
452 ASSERT_RTNL();
454 /* Check for duplicates */
455 for(ifa1 = dn_db->ifa_list; ifa1; ifa1 = ifa1->ifa_next) {
456 if (ifa1->ifa_local == ifa->ifa_local)
457 return -EEXIST;
460 if (dev->type == ARPHRD_ETHER) {
461 if (ifa->ifa_local != dn_eth2dn(dev->dev_addr)) {
462 dn_dn2eth(mac_addr, ifa->ifa_local);
463 dev_mc_add(dev, mac_addr, ETH_ALEN, 0);
467 ifa->ifa_next = dn_db->ifa_list;
468 dn_db->ifa_list = ifa;
470 dn_ifaddr_notify(RTM_NEWADDR, ifa);
471 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_UP, ifa);
473 return 0;
476 static int dn_dev_set_ifa(struct net_device *dev, struct dn_ifaddr *ifa)
478 struct dn_dev *dn_db = dev->dn_ptr;
479 int rv;
481 if (dn_db == NULL) {
482 int err;
483 dn_db = dn_dev_create(dev, &err);
484 if (dn_db == NULL)
485 return err;
488 ifa->ifa_dev = dn_db;
490 if (dev->flags & IFF_LOOPBACK)
491 ifa->ifa_scope = RT_SCOPE_HOST;
493 rv = dn_dev_insert_ifa(dn_db, ifa);
494 if (rv)
495 dn_dev_free_ifa(ifa);
496 return rv;
500 int dn_dev_ioctl(unsigned int cmd, void __user *arg)
502 char buffer[DN_IFREQ_SIZE];
503 struct ifreq *ifr = (struct ifreq *)buffer;
504 struct sockaddr_dn *sdn = (struct sockaddr_dn *)&ifr->ifr_addr;
505 struct dn_dev *dn_db;
506 struct net_device *dev;
507 struct dn_ifaddr *ifa = NULL, **ifap = NULL;
508 int ret = 0;
510 if (copy_from_user(ifr, arg, DN_IFREQ_SIZE))
511 return -EFAULT;
512 ifr->ifr_name[IFNAMSIZ-1] = 0;
514 #ifdef CONFIG_KMOD
515 dev_load(ifr->ifr_name);
516 #endif
518 switch(cmd) {
519 case SIOCGIFADDR:
520 break;
521 case SIOCSIFADDR:
522 if (!capable(CAP_NET_ADMIN))
523 return -EACCES;
524 if (sdn->sdn_family != AF_DECnet)
525 return -EINVAL;
526 break;
527 default:
528 return -EINVAL;
531 rtnl_lock();
533 if ((dev = __dev_get_by_name(ifr->ifr_name)) == NULL) {
534 ret = -ENODEV;
535 goto done;
538 if ((dn_db = dev->dn_ptr) != NULL) {
539 for (ifap = &dn_db->ifa_list; (ifa=*ifap) != NULL; ifap = &ifa->ifa_next)
540 if (strcmp(ifr->ifr_name, ifa->ifa_label) == 0)
541 break;
544 if (ifa == NULL && cmd != SIOCSIFADDR) {
545 ret = -EADDRNOTAVAIL;
546 goto done;
549 switch(cmd) {
550 case SIOCGIFADDR:
551 *((__le16 *)sdn->sdn_nodeaddr) = ifa->ifa_local;
552 goto rarok;
554 case SIOCSIFADDR:
555 if (!ifa) {
556 if ((ifa = dn_dev_alloc_ifa()) == NULL) {
557 ret = -ENOBUFS;
558 break;
560 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
561 } else {
562 if (ifa->ifa_local == dn_saddr2dn(sdn))
563 break;
564 dn_dev_del_ifa(dn_db, ifap, 0);
567 ifa->ifa_local = ifa->ifa_address = dn_saddr2dn(sdn);
569 ret = dn_dev_set_ifa(dev, ifa);
571 done:
572 rtnl_unlock();
574 return ret;
575 rarok:
576 if (copy_to_user(arg, ifr, DN_IFREQ_SIZE))
577 ret = -EFAULT;
578 goto done;
581 struct net_device *dn_dev_get_default(void)
583 struct net_device *dev;
584 read_lock(&dndev_lock);
585 dev = decnet_default_device;
586 if (dev) {
587 if (dev->dn_ptr)
588 dev_hold(dev);
589 else
590 dev = NULL;
592 read_unlock(&dndev_lock);
593 return dev;
596 int dn_dev_set_default(struct net_device *dev, int force)
598 struct net_device *old = NULL;
599 int rv = -EBUSY;
600 if (!dev->dn_ptr)
601 return -ENODEV;
602 write_lock(&dndev_lock);
603 if (force || decnet_default_device == NULL) {
604 old = decnet_default_device;
605 decnet_default_device = dev;
606 rv = 0;
608 write_unlock(&dndev_lock);
609 if (old)
610 dev_put(old);
611 return rv;
614 static void dn_dev_check_default(struct net_device *dev)
616 write_lock(&dndev_lock);
617 if (dev == decnet_default_device) {
618 decnet_default_device = NULL;
619 } else {
620 dev = NULL;
622 write_unlock(&dndev_lock);
623 if (dev)
624 dev_put(dev);
627 static struct dn_dev *dn_dev_by_index(int ifindex)
629 struct net_device *dev;
630 struct dn_dev *dn_dev = NULL;
631 dev = dev_get_by_index(ifindex);
632 if (dev) {
633 dn_dev = dev->dn_ptr;
634 dev_put(dev);
637 return dn_dev;
640 static const struct nla_policy dn_ifa_policy[IFA_MAX+1] = {
641 [IFA_ADDRESS] = { .type = NLA_U16 },
642 [IFA_LOCAL] = { .type = NLA_U16 },
643 [IFA_LABEL] = { .type = NLA_STRING,
644 .len = IFNAMSIZ - 1 },
647 static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
649 struct nlattr *tb[IFA_MAX+1];
650 struct dn_dev *dn_db;
651 struct ifaddrmsg *ifm;
652 struct dn_ifaddr *ifa, **ifap;
653 int err;
655 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
656 if (err < 0)
657 goto errout;
659 err = -ENODEV;
660 ifm = nlmsg_data(nlh);
661 if ((dn_db = dn_dev_by_index(ifm->ifa_index)) == NULL)
662 goto errout;
664 err = -EADDRNOTAVAIL;
665 for (ifap = &dn_db->ifa_list; (ifa = *ifap); ifap = &ifa->ifa_next) {
666 if (tb[IFA_LOCAL] &&
667 nla_memcmp(tb[IFA_LOCAL], &ifa->ifa_local, 2))
668 continue;
670 if (tb[IFA_LABEL] && nla_strcmp(tb[IFA_LABEL], ifa->ifa_label))
671 continue;
673 dn_dev_del_ifa(dn_db, ifap, 1);
674 return 0;
677 errout:
678 return err;
681 static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
683 struct nlattr *tb[IFA_MAX+1];
684 struct net_device *dev;
685 struct dn_dev *dn_db;
686 struct ifaddrmsg *ifm;
687 struct dn_ifaddr *ifa;
688 int err;
690 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
691 if (err < 0)
692 return err;
694 if (tb[IFA_LOCAL] == NULL)
695 return -EINVAL;
697 ifm = nlmsg_data(nlh);
698 if ((dev = __dev_get_by_index(ifm->ifa_index)) == NULL)
699 return -ENODEV;
701 if ((dn_db = dev->dn_ptr) == NULL) {
702 int err;
703 dn_db = dn_dev_create(dev, &err);
704 if (!dn_db)
705 return err;
708 if ((ifa = dn_dev_alloc_ifa()) == NULL)
709 return -ENOBUFS;
711 if (tb[IFA_ADDRESS] == NULL)
712 tb[IFA_ADDRESS] = tb[IFA_LOCAL];
714 ifa->ifa_local = nla_get_le16(tb[IFA_LOCAL]);
715 ifa->ifa_address = nla_get_le16(tb[IFA_ADDRESS]);
716 ifa->ifa_flags = ifm->ifa_flags;
717 ifa->ifa_scope = ifm->ifa_scope;
718 ifa->ifa_dev = dn_db;
720 if (tb[IFA_LABEL])
721 nla_strlcpy(ifa->ifa_label, tb[IFA_LABEL], IFNAMSIZ);
722 else
723 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
725 err = dn_dev_insert_ifa(dn_db, ifa);
726 if (err)
727 dn_dev_free_ifa(ifa);
729 return err;
732 static inline size_t dn_ifaddr_nlmsg_size(void)
734 return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
735 + nla_total_size(IFNAMSIZ) /* IFA_LABEL */
736 + nla_total_size(2) /* IFA_ADDRESS */
737 + nla_total_size(2); /* IFA_LOCAL */
740 static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
741 u32 pid, u32 seq, int event, unsigned int flags)
743 struct ifaddrmsg *ifm;
744 struct nlmsghdr *nlh;
746 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), flags);
747 if (nlh == NULL)
748 return -EMSGSIZE;
750 ifm = nlmsg_data(nlh);
751 ifm->ifa_family = AF_DECnet;
752 ifm->ifa_prefixlen = 16;
753 ifm->ifa_flags = ifa->ifa_flags | IFA_F_PERMANENT;
754 ifm->ifa_scope = ifa->ifa_scope;
755 ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
757 if (ifa->ifa_address)
758 NLA_PUT_LE16(skb, IFA_ADDRESS, ifa->ifa_address);
759 if (ifa->ifa_local)
760 NLA_PUT_LE16(skb, IFA_LOCAL, ifa->ifa_local);
761 if (ifa->ifa_label[0])
762 NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label);
764 return nlmsg_end(skb, nlh);
766 nla_put_failure:
767 nlmsg_cancel(skb, nlh);
768 return -EMSGSIZE;
771 static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa)
773 struct sk_buff *skb;
774 int err = -ENOBUFS;
776 skb = alloc_skb(dn_ifaddr_nlmsg_size(), GFP_KERNEL);
777 if (skb == NULL)
778 goto errout;
780 err = dn_nl_fill_ifaddr(skb, ifa, 0, 0, event, 0);
781 if (err < 0) {
782 /* -EMSGSIZE implies BUG in dn_ifaddr_nlmsg_size() */
783 WARN_ON(err == -EMSGSIZE);
784 kfree_skb(skb);
785 goto errout;
787 err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
788 errout:
789 if (err < 0)
790 rtnl_set_sk_err(RTNLGRP_DECnet_IFADDR, err);
793 static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
795 int idx, dn_idx = 0, skip_ndevs, skip_naddr;
796 struct net_device *dev;
797 struct dn_dev *dn_db;
798 struct dn_ifaddr *ifa;
800 skip_ndevs = cb->args[0];
801 skip_naddr = cb->args[1];
803 idx = 0;
804 for_each_netdev(dev) {
805 if (idx < skip_ndevs)
806 goto cont;
807 else if (idx > skip_ndevs) {
808 /* Only skip over addresses for first dev dumped
809 * in this iteration (idx == skip_ndevs) */
810 skip_naddr = 0;
813 if ((dn_db = dev->dn_ptr) == NULL)
814 goto cont;
816 for (ifa = dn_db->ifa_list, dn_idx = 0; ifa;
817 ifa = ifa->ifa_next, dn_idx++) {
818 if (dn_idx < skip_naddr)
819 continue;
821 if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
822 cb->nlh->nlmsg_seq, RTM_NEWADDR,
823 NLM_F_MULTI) < 0)
824 goto done;
826 cont:
827 idx++;
829 done:
830 cb->args[0] = idx;
831 cb->args[1] = dn_idx;
833 return skb->len;
836 static int dn_dev_get_first(struct net_device *dev, __le16 *addr)
838 struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
839 struct dn_ifaddr *ifa;
840 int rv = -ENODEV;
841 if (dn_db == NULL)
842 goto out;
843 ifa = dn_db->ifa_list;
844 if (ifa != NULL) {
845 *addr = ifa->ifa_local;
846 rv = 0;
848 out:
849 return rv;
853 * Find a default address to bind to.
855 * This is one of those areas where the initial VMS concepts don't really
856 * map onto the Linux concepts, and since we introduced multiple addresses
857 * per interface we have to cope with slightly odd ways of finding out what
858 * "our address" really is. Mostly it's not a problem; for this we just guess
859 * a sensible default. Eventually the routing code will take care of all the
860 * nasties for us I hope.
862 int dn_dev_bind_default(__le16 *addr)
864 struct net_device *dev;
865 int rv;
866 dev = dn_dev_get_default();
867 last_chance:
868 if (dev) {
869 read_lock(&dev_base_lock);
870 rv = dn_dev_get_first(dev, addr);
871 read_unlock(&dev_base_lock);
872 dev_put(dev);
873 if (rv == 0 || dev == &loopback_dev)
874 return rv;
876 dev = &loopback_dev;
877 dev_hold(dev);
878 goto last_chance;
881 static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa)
883 struct endnode_hello_message *msg;
884 struct sk_buff *skb = NULL;
885 __le16 *pktlen;
886 struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
888 if ((skb = dn_alloc_skb(NULL, sizeof(*msg), GFP_ATOMIC)) == NULL)
889 return;
891 skb->dev = dev;
893 msg = (struct endnode_hello_message *)skb_put(skb,sizeof(*msg));
895 msg->msgflg = 0x0D;
896 memcpy(msg->tiver, dn_eco_version, 3);
897 dn_dn2eth(msg->id, ifa->ifa_local);
898 msg->iinfo = DN_RT_INFO_ENDN;
899 msg->blksize = dn_htons(mtu2blksize(dev));
900 msg->area = 0x00;
901 memset(msg->seed, 0, 8);
902 memcpy(msg->neighbor, dn_hiord, ETH_ALEN);
904 if (dn_db->router) {
905 struct dn_neigh *dn = (struct dn_neigh *)dn_db->router;
906 dn_dn2eth(msg->neighbor, dn->addr);
909 msg->timer = dn_htons((unsigned short)dn_db->parms.t3);
910 msg->mpd = 0x00;
911 msg->datalen = 0x02;
912 memset(msg->data, 0xAA, 2);
914 pktlen = (__le16 *)skb_push(skb,2);
915 *pktlen = dn_htons(skb->len - 2);
917 skb_reset_network_header(skb);
919 dn_rt_finish_output(skb, dn_rt_all_rt_mcast, msg->id);
923 #define DRDELAY (5 * HZ)
925 static int dn_am_i_a_router(struct dn_neigh *dn, struct dn_dev *dn_db, struct dn_ifaddr *ifa)
927 /* First check time since device went up */
928 if ((jiffies - dn_db->uptime) < DRDELAY)
929 return 0;
931 /* If there is no router, then yes... */
932 if (!dn_db->router)
933 return 1;
935 /* otherwise only if we have a higher priority or.. */
936 if (dn->priority < dn_db->parms.priority)
937 return 1;
939 /* if we have equal priority and a higher node number */
940 if (dn->priority != dn_db->parms.priority)
941 return 0;
943 if (dn_ntohs(dn->addr) < dn_ntohs(ifa->ifa_local))
944 return 1;
946 return 0;
949 static void dn_send_router_hello(struct net_device *dev, struct dn_ifaddr *ifa)
951 int n;
952 struct dn_dev *dn_db = dev->dn_ptr;
953 struct dn_neigh *dn = (struct dn_neigh *)dn_db->router;
954 struct sk_buff *skb;
955 size_t size;
956 unsigned char *ptr;
957 unsigned char *i1, *i2;
958 __le16 *pktlen;
959 char *src;
961 if (mtu2blksize(dev) < (26 + 7))
962 return;
964 n = mtu2blksize(dev) - 26;
965 n /= 7;
967 if (n > 32)
968 n = 32;
970 size = 2 + 26 + 7 * n;
972 if ((skb = dn_alloc_skb(NULL, size, GFP_ATOMIC)) == NULL)
973 return;
975 skb->dev = dev;
976 ptr = skb_put(skb, size);
978 *ptr++ = DN_RT_PKT_CNTL | DN_RT_PKT_ERTH;
979 *ptr++ = 2; /* ECO */
980 *ptr++ = 0;
981 *ptr++ = 0;
982 dn_dn2eth(ptr, ifa->ifa_local);
983 src = ptr;
984 ptr += ETH_ALEN;
985 *ptr++ = dn_db->parms.forwarding == 1 ?
986 DN_RT_INFO_L1RT : DN_RT_INFO_L2RT;
987 *((__le16 *)ptr) = dn_htons(mtu2blksize(dev));
988 ptr += 2;
989 *ptr++ = dn_db->parms.priority; /* Priority */
990 *ptr++ = 0; /* Area: Reserved */
991 *((__le16 *)ptr) = dn_htons((unsigned short)dn_db->parms.t3);
992 ptr += 2;
993 *ptr++ = 0; /* MPD: Reserved */
994 i1 = ptr++;
995 memset(ptr, 0, 7); /* Name: Reserved */
996 ptr += 7;
997 i2 = ptr++;
999 n = dn_neigh_elist(dev, ptr, n);
1001 *i2 = 7 * n;
1002 *i1 = 8 + *i2;
1004 skb_trim(skb, (27 + *i2));
1006 pktlen = (__le16 *)skb_push(skb, 2);
1007 *pktlen = dn_htons(skb->len - 2);
1009 skb_reset_network_header(skb);
1011 if (dn_am_i_a_router(dn, dn_db, ifa)) {
1012 struct sk_buff *skb2 = skb_copy(skb, GFP_ATOMIC);
1013 if (skb2) {
1014 dn_rt_finish_output(skb2, dn_rt_all_end_mcast, src);
1018 dn_rt_finish_output(skb, dn_rt_all_rt_mcast, src);
1021 static void dn_send_brd_hello(struct net_device *dev, struct dn_ifaddr *ifa)
1023 struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
1025 if (dn_db->parms.forwarding == 0)
1026 dn_send_endnode_hello(dev, ifa);
1027 else
1028 dn_send_router_hello(dev, ifa);
1031 static void dn_send_ptp_hello(struct net_device *dev, struct dn_ifaddr *ifa)
1033 int tdlen = 16;
1034 int size = dev->hard_header_len + 2 + 4 + tdlen;
1035 struct sk_buff *skb = dn_alloc_skb(NULL, size, GFP_ATOMIC);
1036 int i;
1037 unsigned char *ptr;
1038 char src[ETH_ALEN];
1040 if (skb == NULL)
1041 return ;
1043 skb->dev = dev;
1044 skb_push(skb, dev->hard_header_len);
1045 ptr = skb_put(skb, 2 + 4 + tdlen);
1047 *ptr++ = DN_RT_PKT_HELO;
1048 *((__le16 *)ptr) = ifa->ifa_local;
1049 ptr += 2;
1050 *ptr++ = tdlen;
1052 for(i = 0; i < tdlen; i++)
1053 *ptr++ = 0252;
1055 dn_dn2eth(src, ifa->ifa_local);
1056 dn_rt_finish_output(skb, dn_rt_all_rt_mcast, src);
1059 static int dn_eth_up(struct net_device *dev)
1061 struct dn_dev *dn_db = dev->dn_ptr;
1063 if (dn_db->parms.forwarding == 0)
1064 dev_mc_add(dev, dn_rt_all_end_mcast, ETH_ALEN, 0);
1065 else
1066 dev_mc_add(dev, dn_rt_all_rt_mcast, ETH_ALEN, 0);
1068 dn_db->use_long = 1;
1070 return 0;
1073 static void dn_eth_down(struct net_device *dev)
1075 struct dn_dev *dn_db = dev->dn_ptr;
1077 if (dn_db->parms.forwarding == 0)
1078 dev_mc_delete(dev, dn_rt_all_end_mcast, ETH_ALEN, 0);
1079 else
1080 dev_mc_delete(dev, dn_rt_all_rt_mcast, ETH_ALEN, 0);
1083 static void dn_dev_set_timer(struct net_device *dev);
1085 static void dn_dev_timer_func(unsigned long arg)
1087 struct net_device *dev = (struct net_device *)arg;
1088 struct dn_dev *dn_db = dev->dn_ptr;
1089 struct dn_ifaddr *ifa;
1091 if (dn_db->t3 <= dn_db->parms.t2) {
1092 if (dn_db->parms.timer3) {
1093 for(ifa = dn_db->ifa_list; ifa; ifa = ifa->ifa_next) {
1094 if (!(ifa->ifa_flags & IFA_F_SECONDARY))
1095 dn_db->parms.timer3(dev, ifa);
1098 dn_db->t3 = dn_db->parms.t3;
1099 } else {
1100 dn_db->t3 -= dn_db->parms.t2;
1103 dn_dev_set_timer(dev);
1106 static void dn_dev_set_timer(struct net_device *dev)
1108 struct dn_dev *dn_db = dev->dn_ptr;
1110 if (dn_db->parms.t2 > dn_db->parms.t3)
1111 dn_db->parms.t2 = dn_db->parms.t3;
1113 dn_db->timer.data = (unsigned long)dev;
1114 dn_db->timer.function = dn_dev_timer_func;
1115 dn_db->timer.expires = jiffies + (dn_db->parms.t2 * HZ);
1117 add_timer(&dn_db->timer);
1120 struct dn_dev *dn_dev_create(struct net_device *dev, int *err)
1122 int i;
1123 struct dn_dev_parms *p = dn_dev_list;
1124 struct dn_dev *dn_db;
1126 for(i = 0; i < DN_DEV_LIST_SIZE; i++, p++) {
1127 if (p->type == dev->type)
1128 break;
1131 *err = -ENODEV;
1132 if (i == DN_DEV_LIST_SIZE)
1133 return NULL;
1135 *err = -ENOBUFS;
1136 if ((dn_db = kzalloc(sizeof(struct dn_dev), GFP_ATOMIC)) == NULL)
1137 return NULL;
1139 memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms));
1140 smp_wmb();
1141 dev->dn_ptr = dn_db;
1142 dn_db->dev = dev;
1143 init_timer(&dn_db->timer);
1145 dn_db->uptime = jiffies;
1147 dn_db->neigh_parms = neigh_parms_alloc(dev, &dn_neigh_table);
1148 if (!dn_db->neigh_parms) {
1149 dev->dn_ptr = NULL;
1150 kfree(dn_db);
1151 return NULL;
1154 if (dn_db->parms.up) {
1155 if (dn_db->parms.up(dev) < 0) {
1156 neigh_parms_release(&dn_neigh_table, dn_db->neigh_parms);
1157 dev->dn_ptr = NULL;
1158 kfree(dn_db);
1159 return NULL;
1163 dn_dev_sysctl_register(dev, &dn_db->parms);
1165 dn_dev_set_timer(dev);
1167 *err = 0;
1168 return dn_db;
1173 * This processes a device up event. We only start up
1174 * the loopback device & ethernet devices with correct
1175 * MAC addreses automatically. Others must be started
1176 * specifically.
1178 * FIXME: How should we configure the loopback address ? If we could dispense
1179 * with using decnet_address here and for autobind, it will be one less thing
1180 * for users to worry about setting up.
1183 void dn_dev_up(struct net_device *dev)
1185 struct dn_ifaddr *ifa;
1186 __le16 addr = decnet_address;
1187 int maybe_default = 0;
1188 struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr;
1190 if ((dev->type != ARPHRD_ETHER) && (dev->type != ARPHRD_LOOPBACK))
1191 return;
1194 * Need to ensure that loopback device has a dn_db attached to it
1195 * to allow creation of neighbours against it, even though it might
1196 * not have a local address of its own. Might as well do the same for
1197 * all autoconfigured interfaces.
1199 if (dn_db == NULL) {
1200 int err;
1201 dn_db = dn_dev_create(dev, &err);
1202 if (dn_db == NULL)
1203 return;
1206 if (dev->type == ARPHRD_ETHER) {
1207 if (memcmp(dev->dev_addr, dn_hiord, 4) != 0)
1208 return;
1209 addr = dn_eth2dn(dev->dev_addr);
1210 maybe_default = 1;
1213 if (addr == 0)
1214 return;
1216 if ((ifa = dn_dev_alloc_ifa()) == NULL)
1217 return;
1219 ifa->ifa_local = ifa->ifa_address = addr;
1220 ifa->ifa_flags = 0;
1221 ifa->ifa_scope = RT_SCOPE_UNIVERSE;
1222 strcpy(ifa->ifa_label, dev->name);
1224 dn_dev_set_ifa(dev, ifa);
1227 * Automagically set the default device to the first automatically
1228 * configured ethernet card in the system.
1230 if (maybe_default) {
1231 dev_hold(dev);
1232 if (dn_dev_set_default(dev, 0))
1233 dev_put(dev);
1237 static void dn_dev_delete(struct net_device *dev)
1239 struct dn_dev *dn_db = dev->dn_ptr;
1241 if (dn_db == NULL)
1242 return;
1244 del_timer_sync(&dn_db->timer);
1245 dn_dev_sysctl_unregister(&dn_db->parms);
1246 dn_dev_check_default(dev);
1247 neigh_ifdown(&dn_neigh_table, dev);
1249 if (dn_db->parms.down)
1250 dn_db->parms.down(dev);
1252 dev->dn_ptr = NULL;
1254 neigh_parms_release(&dn_neigh_table, dn_db->neigh_parms);
1255 neigh_ifdown(&dn_neigh_table, dev);
1257 if (dn_db->router)
1258 neigh_release(dn_db->router);
1259 if (dn_db->peer)
1260 neigh_release(dn_db->peer);
1262 kfree(dn_db);
1265 void dn_dev_down(struct net_device *dev)
1267 struct dn_dev *dn_db = dev->dn_ptr;
1268 struct dn_ifaddr *ifa;
1270 if (dn_db == NULL)
1271 return;
1273 while((ifa = dn_db->ifa_list) != NULL) {
1274 dn_dev_del_ifa(dn_db, &dn_db->ifa_list, 0);
1275 dn_dev_free_ifa(ifa);
1278 dn_dev_delete(dev);
1281 void dn_dev_init_pkt(struct sk_buff *skb)
1283 return;
1286 void dn_dev_veri_pkt(struct sk_buff *skb)
1288 return;
1291 void dn_dev_hello(struct sk_buff *skb)
1293 return;
1296 void dn_dev_devices_off(void)
1298 struct net_device *dev;
1300 rtnl_lock();
1301 for_each_netdev(dev)
1302 dn_dev_down(dev);
1303 rtnl_unlock();
1307 void dn_dev_devices_on(void)
1309 struct net_device *dev;
1311 rtnl_lock();
1312 for_each_netdev(dev) {
1313 if (dev->flags & IFF_UP)
1314 dn_dev_up(dev);
1316 rtnl_unlock();
1319 int register_dnaddr_notifier(struct notifier_block *nb)
1321 return blocking_notifier_chain_register(&dnaddr_chain, nb);
1324 int unregister_dnaddr_notifier(struct notifier_block *nb)
1326 return blocking_notifier_chain_unregister(&dnaddr_chain, nb);
1329 #ifdef CONFIG_PROC_FS
1330 static inline int is_dn_dev(struct net_device *dev)
1332 return dev->dn_ptr != NULL;
1335 static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
1337 int i;
1338 struct net_device *dev;
1340 read_lock(&dev_base_lock);
1342 if (*pos == 0)
1343 return SEQ_START_TOKEN;
1345 i = 1;
1346 for_each_netdev(dev) {
1347 if (!is_dn_dev(dev))
1348 continue;
1350 if (i++ == *pos)
1351 return dev;
1354 return NULL;
1357 static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1359 struct net_device *dev;
1361 ++*pos;
1363 dev = (struct net_device *)v;
1364 if (v == SEQ_START_TOKEN)
1365 dev = net_device_entry(&dev_base_head);
1367 for_each_netdev_continue(dev) {
1368 if (!is_dn_dev(dev))
1369 continue;
1371 return dev;
1374 return NULL;
1377 static void dn_dev_seq_stop(struct seq_file *seq, void *v)
1379 read_unlock(&dev_base_lock);
1382 static char *dn_type2asc(char type)
1384 switch(type) {
1385 case DN_DEV_BCAST:
1386 return "B";
1387 case DN_DEV_UCAST:
1388 return "U";
1389 case DN_DEV_MPOINT:
1390 return "M";
1393 return "?";
1396 static int dn_dev_seq_show(struct seq_file *seq, void *v)
1398 if (v == SEQ_START_TOKEN)
1399 seq_puts(seq, "Name Flags T1 Timer1 T3 Timer3 BlkSize Pri State DevType Router Peer\n");
1400 else {
1401 struct net_device *dev = v;
1402 char peer_buf[DN_ASCBUF_LEN];
1403 char router_buf[DN_ASCBUF_LEN];
1404 struct dn_dev *dn_db = dev->dn_ptr;
1406 seq_printf(seq, "%-8s %1s %04u %04u %04lu %04lu"
1407 " %04hu %03d %02x %-10s %-7s %-7s\n",
1408 dev->name ? dev->name : "???",
1409 dn_type2asc(dn_db->parms.mode),
1410 0, 0,
1411 dn_db->t3, dn_db->parms.t3,
1412 mtu2blksize(dev),
1413 dn_db->parms.priority,
1414 dn_db->parms.state, dn_db->parms.name,
1415 dn_db->router ? dn_addr2asc(dn_ntohs(*(__le16 *)dn_db->router->primary_key), router_buf) : "",
1416 dn_db->peer ? dn_addr2asc(dn_ntohs(*(__le16 *)dn_db->peer->primary_key), peer_buf) : "");
1418 return 0;
1421 static const struct seq_operations dn_dev_seq_ops = {
1422 .start = dn_dev_seq_start,
1423 .next = dn_dev_seq_next,
1424 .stop = dn_dev_seq_stop,
1425 .show = dn_dev_seq_show,
1428 static int dn_dev_seq_open(struct inode *inode, struct file *file)
1430 return seq_open(file, &dn_dev_seq_ops);
1433 static const struct file_operations dn_dev_seq_fops = {
1434 .owner = THIS_MODULE,
1435 .open = dn_dev_seq_open,
1436 .read = seq_read,
1437 .llseek = seq_lseek,
1438 .release = seq_release,
1441 #endif /* CONFIG_PROC_FS */
1443 static int __initdata addr[2];
1444 module_param_array(addr, int, NULL, 0444);
1445 MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node");
1447 void __init dn_dev_init(void)
1449 if (addr[0] > 63 || addr[0] < 0) {
1450 printk(KERN_ERR "DECnet: Area must be between 0 and 63");
1451 return;
1454 if (addr[1] > 1023 || addr[1] < 0) {
1455 printk(KERN_ERR "DECnet: Node must be between 0 and 1023");
1456 return;
1459 decnet_address = dn_htons((addr[0] << 10) | addr[1]);
1461 dn_dev_devices_on();
1463 rtnl_register(PF_DECnet, RTM_NEWADDR, dn_nl_newaddr, NULL);
1464 rtnl_register(PF_DECnet, RTM_DELADDR, dn_nl_deladdr, NULL);
1465 rtnl_register(PF_DECnet, RTM_GETADDR, NULL, dn_nl_dump_ifaddr);
1467 proc_net_fops_create("decnet_dev", S_IRUGO, &dn_dev_seq_fops);
1469 #ifdef CONFIG_SYSCTL
1471 int i;
1472 for(i = 0; i < DN_DEV_LIST_SIZE; i++)
1473 dn_dev_sysctl_register(NULL, &dn_dev_list[i]);
1475 #endif /* CONFIG_SYSCTL */
1478 void __exit dn_dev_cleanup(void)
1480 #ifdef CONFIG_SYSCTL
1482 int i;
1483 for(i = 0; i < DN_DEV_LIST_SIZE; i++)
1484 dn_dev_sysctl_unregister(&dn_dev_list[i]);
1486 #endif /* CONFIG_SYSCTL */
1488 proc_net_remove("decnet_dev");
1490 dn_dev_devices_off();