2 * Neighbour Discovery for IPv6
3 * Linux INET6 implementation
6 * Pedro Roque <roque@di.fc.ul.pt>
7 * Mike Shaver <shaver@ingenia.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
18 * Lars Fenneberg : fixed MTU setting on receipt
21 * Janos Farkas : kmalloc failure checks
22 * Alexey Kuznetsov : state machine reworked
23 * and moved to net/core.
24 * Pekka Savola : RFC2461 validation
25 * YOSHIFUJI Hideaki @USAGI : Verify ND options properly
28 /* Set to 3 to get tracing... */
31 #define ND_PRINTK(fmt, args...) do { if (net_ratelimit()) { printk(fmt, ## args); } } while(0)
32 #define ND_NOPRINTK(x...) do { ; } while(0)
33 #define ND_PRINTK0 ND_PRINTK
34 #define ND_PRINTK1 ND_NOPRINTK
35 #define ND_PRINTK2 ND_NOPRINTK
36 #define ND_PRINTK3 ND_NOPRINTK
39 #define ND_PRINTK1 ND_PRINTK
43 #define ND_PRINTK2 ND_PRINTK
47 #define ND_PRINTK3 ND_PRINTK
50 #include <linux/module.h>
51 #include <linux/config.h>
52 #include <linux/errno.h>
53 #include <linux/types.h>
54 #include <linux/socket.h>
55 #include <linux/sockios.h>
56 #include <linux/sched.h>
57 #include <linux/net.h>
58 #include <linux/in6.h>
59 #include <linux/route.h>
60 #include <linux/init.h>
62 #include <linux/sysctl.h>
65 #include <linux/if_arp.h>
66 #include <linux/ipv6.h>
67 #include <linux/icmpv6.h>
73 #include <net/protocol.h>
74 #include <net/ndisc.h>
75 #include <net/ip6_route.h>
76 #include <net/addrconf.h>
80 #include <net/ip6_checksum.h>
81 #include <linux/proc_fs.h>
83 #include <linux/netfilter.h>
84 #include <linux/netfilter_ipv6.h>
86 static struct socket *ndisc_socket;
88 static u32 ndisc_hash(const void *pkey, const struct net_device *dev);
89 static int ndisc_constructor(struct neighbour *neigh);
90 static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb);
91 static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb);
92 static int pndisc_constructor(struct pneigh_entry *n);
93 static void pndisc_destructor(struct pneigh_entry *n);
94 static void pndisc_redo(struct sk_buff *skb);
96 static struct neigh_ops ndisc_generic_ops = {
98 .solicit = ndisc_solicit,
99 .error_report = ndisc_error_report,
100 .output = neigh_resolve_output,
101 .connected_output = neigh_connected_output,
102 .hh_output = dev_queue_xmit,
103 .queue_xmit = dev_queue_xmit,
106 static struct neigh_ops ndisc_hh_ops = {
108 .solicit = ndisc_solicit,
109 .error_report = ndisc_error_report,
110 .output = neigh_resolve_output,
111 .connected_output = neigh_resolve_output,
112 .hh_output = dev_queue_xmit,
113 .queue_xmit = dev_queue_xmit,
117 static struct neigh_ops ndisc_direct_ops = {
119 .output = dev_queue_xmit,
120 .connected_output = dev_queue_xmit,
121 .hh_output = dev_queue_xmit,
122 .queue_xmit = dev_queue_xmit,
125 struct neigh_table nd_tbl = {
127 .entry_size = sizeof(struct neighbour) + sizeof(struct in6_addr),
128 .key_len = sizeof(struct in6_addr),
130 .constructor = ndisc_constructor,
131 .pconstructor = pndisc_constructor,
132 .pdestructor = pndisc_destructor,
133 .proxy_redo = pndisc_redo,
137 .base_reachable_time = 30 * HZ,
138 .retrans_time = 1 * HZ,
139 .gc_staletime = 60 * HZ,
140 .reachable_time = 30 * HZ,
141 .delay_probe_time = 5 * HZ,
145 .anycast_delay = 1 * HZ,
146 .proxy_delay = (8 * HZ) / 10,
149 .gc_interval = 30 * HZ,
156 struct ndisc_options {
157 struct nd_opt_hdr *nd_opt_array[7];
158 struct nd_opt_hdr *nd_opt_piend;
161 #define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR]
162 #define nd_opts_tgt_lladdr nd_opt_array[ND_OPT_TARGET_LL_ADDR]
163 #define nd_opts_pi nd_opt_array[ND_OPT_PREFIX_INFO]
164 #define nd_opts_pi_end nd_opt_piend
165 #define nd_opts_rh nd_opt_array[ND_OPT_REDIRECT_HDR]
166 #define nd_opts_mtu nd_opt_array[ND_OPT_MTU]
168 #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7)
170 static u8 *ndisc_fill_option(u8 *opt, int type, void *data, int data_len)
172 int space = NDISC_OPT_SPACE(data_len);
176 memcpy(opt+2, data, data_len);
179 if ((space -= data_len) > 0)
180 memset(opt, 0, space);
184 static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
185 struct nd_opt_hdr *end)
188 if (!cur || !end || cur >= end)
190 type = cur->nd_opt_type;
192 cur = ((void *)cur) + (cur->nd_opt_len << 3);
193 } while(cur < end && cur->nd_opt_type != type);
194 return (cur <= end && cur->nd_opt_type == type ? cur : NULL);
197 static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
198 struct ndisc_options *ndopts)
200 struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)opt;
202 if (!nd_opt || opt_len < 0 || !ndopts)
204 memset(ndopts, 0, sizeof(*ndopts));
207 if (opt_len < sizeof(struct nd_opt_hdr))
209 l = nd_opt->nd_opt_len << 3;
210 if (opt_len < l || l == 0)
212 switch (nd_opt->nd_opt_type) {
213 case ND_OPT_SOURCE_LL_ADDR:
214 case ND_OPT_TARGET_LL_ADDR:
216 case ND_OPT_REDIRECT_HDR:
217 if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
218 ND_PRINTK2(KERN_WARNING
219 "%s(): duplicated ND6 option found: type=%d\n",
221 nd_opt->nd_opt_type);
223 ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
226 case ND_OPT_PREFIX_INFO:
227 ndopts->nd_opts_pi_end = nd_opt;
228 if (ndopts->nd_opt_array[nd_opt->nd_opt_type] == 0)
229 ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
233 * Unknown options must be silently ignored,
234 * to accommodate future extension to the protocol.
236 ND_PRINTK2(KERN_NOTICE
237 "%s(): ignored unsupported option; type=%d, len=%d\n",
239 nd_opt->nd_opt_type, nd_opt->nd_opt_len);
242 nd_opt = ((void *)nd_opt) + l;
247 int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir)
251 case ARPHRD_IEEE802: /* Not sure. Check it later. --ANK */
253 ipv6_eth_mc_map(addr, buf);
255 case ARPHRD_IEEE802_TR:
256 ipv6_tr_mc_map(addr,buf);
259 ipv6_arcnet_mc_map(addr, buf);
263 memcpy(buf, dev->broadcast, dev->addr_len);
270 static u32 ndisc_hash(const void *pkey, const struct net_device *dev)
274 hash_val = *(u32*)(pkey + sizeof(struct in6_addr) - 4);
275 hash_val ^= (hash_val>>16);
276 hash_val ^= hash_val>>8;
277 hash_val ^= hash_val>>3;
278 hash_val = (hash_val^dev->ifindex)&NEIGH_HASHMASK;
283 static int ndisc_constructor(struct neighbour *neigh)
285 struct in6_addr *addr = (struct in6_addr*)&neigh->primary_key;
286 struct net_device *dev = neigh->dev;
287 struct inet6_dev *in6_dev = in6_dev_get(dev);
288 int is_multicast = ipv6_addr_is_multicast(addr);
293 if (in6_dev->nd_parms)
294 neigh->parms = in6_dev->nd_parms;
296 neigh->type = is_multicast ? RTN_MULTICAST : RTN_UNICAST;
297 if (dev->hard_header == NULL) {
298 neigh->nud_state = NUD_NOARP;
299 neigh->ops = &ndisc_direct_ops;
300 neigh->output = neigh->ops->queue_xmit;
303 neigh->nud_state = NUD_NOARP;
304 ndisc_mc_map(addr, neigh->ha, dev, 1);
305 } else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
306 neigh->nud_state = NUD_NOARP;
307 memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
308 if (dev->flags&IFF_LOOPBACK)
309 neigh->type = RTN_LOCAL;
310 } else if (dev->flags&IFF_POINTOPOINT) {
311 neigh->nud_state = NUD_NOARP;
312 memcpy(neigh->ha, dev->broadcast, dev->addr_len);
314 if (dev->hard_header_cache)
315 neigh->ops = &ndisc_hh_ops;
317 neigh->ops = &ndisc_generic_ops;
318 if (neigh->nud_state&NUD_VALID)
319 neigh->output = neigh->ops->connected_output;
321 neigh->output = neigh->ops->output;
323 in6_dev_put(in6_dev);
327 static int pndisc_constructor(struct pneigh_entry *n)
329 struct in6_addr *addr = (struct in6_addr*)&n->key;
330 struct in6_addr maddr;
331 struct net_device *dev = n->dev;
333 if (dev == NULL || __in6_dev_get(dev) == NULL)
335 addrconf_addr_solict_mult(addr, &maddr);
336 ipv6_dev_mc_inc(dev, &maddr);
340 static void pndisc_destructor(struct pneigh_entry *n)
342 struct in6_addr *addr = (struct in6_addr*)&n->key;
343 struct in6_addr maddr;
344 struct net_device *dev = n->dev;
346 if (dev == NULL || __in6_dev_get(dev) == NULL)
348 addrconf_addr_solict_mult(addr, &maddr);
349 ipv6_dev_mc_dec(dev, &maddr);
353 * Send a Neighbour Advertisement
356 static inline void ndisc_flow_init(struct flowi *fl, u8 type,
357 struct in6_addr *saddr, struct in6_addr *daddr)
359 memset(fl, 0, sizeof(*fl));
360 ipv6_addr_copy(&fl->fl6_src, saddr);
361 ipv6_addr_copy(&fl->fl6_dst, daddr);
362 fl->proto = IPPROTO_ICMPV6;
363 fl->fl_icmp_type = type;
364 fl->fl_icmp_code = 0;
367 static void inline ndisc_update(struct neighbour *neigh,
368 u8 *lladdr, u32 flags)
371 write_lock_bh(&neigh->lock);
372 notify = __neigh_update(neigh, lladdr, NUD_STALE, flags);
374 if (notify > 0 && neigh->parms->app_probes) {
375 write_unlock_bh(&neigh->lock);
376 neigh_app_notify(neigh);
379 write_unlock_bh(&neigh->lock);
382 static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
383 struct in6_addr *daddr, struct in6_addr *solicited_addr,
384 int router, int solicited, int override, int inc_opt)
386 struct in6_addr tmpaddr;
387 struct inet6_ifaddr *ifp;
388 struct inet6_dev *idev;
390 struct dst_entry* dst;
391 struct sock *sk = ndisc_socket->sk;
392 struct in6_addr *src_addr;
398 len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
400 /* for anycast or proxy, solicited_addr != src_addr */
401 ifp = ipv6_get_ifaddr(solicited_addr, dev, 1);
403 src_addr = solicited_addr;
406 if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr))
411 ndisc_flow_init(&fl, NDISC_NEIGHBOUR_ADVERTISEMENT, src_addr, daddr);
413 dst = ndisc_dst_alloc(dev, neigh, daddr, ip6_output);
417 err = xfrm_lookup(&dst, &fl, NULL, 0);
425 len += NDISC_OPT_SPACE(dev->addr_len);
430 skb = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev) + dst->header_len + 64,
435 "ICMPv6 NA: %s() failed to allocate an skb.\n",
441 skb_reserve(skb, LL_RESERVED_SPACE(dev));
442 ip6_nd_hdr(sk, skb, dev, src_addr, daddr, IPPROTO_ICMPV6, len);
444 msg = (struct nd_msg *)skb_put(skb, len);
445 skb->h.raw = (unsigned char*)msg;
447 msg->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT;
448 msg->icmph.icmp6_code = 0;
449 msg->icmph.icmp6_cksum = 0;
451 msg->icmph.icmp6_unused = 0;
452 msg->icmph.icmp6_router = router;
453 msg->icmph.icmp6_solicited = solicited;
454 msg->icmph.icmp6_override = !!override;
456 /* Set the target address. */
457 ipv6_addr_copy(&msg->target, solicited_addr);
460 ndisc_fill_option(msg->opt, ND_OPT_TARGET_LL_ADDR, dev->dev_addr, dev->addr_len);
463 msg->icmph.icmp6_cksum = csum_ipv6_magic(src_addr, daddr, len,
465 csum_partial((__u8 *) msg,
469 idev = in6_dev_get(dst->dev);
470 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS);
471 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output);
473 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS);
474 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
477 if (likely(idev != NULL))
481 void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
482 struct in6_addr *solicit,
483 struct in6_addr *daddr, struct in6_addr *saddr)
486 struct dst_entry* dst;
487 struct inet6_dev *idev;
488 struct sock *sk = ndisc_socket->sk;
491 struct in6_addr addr_buf;
497 if (ipv6_get_lladdr(dev, &addr_buf))
502 ndisc_flow_init(&fl, NDISC_NEIGHBOUR_SOLICITATION, saddr, daddr);
504 dst = ndisc_dst_alloc(dev, neigh, daddr, ip6_output);
508 err = xfrm_lookup(&dst, &fl, NULL, 0);
514 len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
515 send_llinfo = dev->addr_len && !ipv6_addr_any(saddr);
517 len += NDISC_OPT_SPACE(dev->addr_len);
519 skb = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev) + dst->header_len + 64,
523 "ICMPv6 NA: %s() failed to allocate an skb.\n",
529 skb_reserve(skb, LL_RESERVED_SPACE(dev));
530 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
532 msg = (struct nd_msg *)skb_put(skb, len);
533 skb->h.raw = (unsigned char*)msg;
534 msg->icmph.icmp6_type = NDISC_NEIGHBOUR_SOLICITATION;
535 msg->icmph.icmp6_code = 0;
536 msg->icmph.icmp6_cksum = 0;
537 msg->icmph.icmp6_unused = 0;
539 /* Set the target address. */
540 ipv6_addr_copy(&msg->target, solicit);
543 ndisc_fill_option(msg->opt, ND_OPT_SOURCE_LL_ADDR, dev->dev_addr, dev->addr_len);
546 msg->icmph.icmp6_cksum = csum_ipv6_magic(&skb->nh.ipv6h->saddr,
549 csum_partial((__u8 *) msg,
553 idev = in6_dev_get(dst->dev);
554 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS);
555 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output);
557 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTNEIGHBORSOLICITS);
558 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
561 if (likely(idev != NULL))
565 void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
566 struct in6_addr *daddr)
569 struct dst_entry* dst;
570 struct inet6_dev *idev;
571 struct sock *sk = ndisc_socket->sk;
573 struct icmp6hdr *hdr;
578 ndisc_flow_init(&fl, NDISC_ROUTER_SOLICITATION, saddr, daddr);
580 dst = ndisc_dst_alloc(dev, NULL, daddr, ip6_output);
584 err = xfrm_lookup(&dst, &fl, NULL, 0);
590 len = sizeof(struct icmp6hdr);
592 len += NDISC_OPT_SPACE(dev->addr_len);
594 skb = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev) + dst->header_len + 64,
598 "ICMPv6 RS: %s() failed to allocate an skb.\n",
604 skb_reserve(skb, LL_RESERVED_SPACE(dev));
605 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
607 hdr = (struct icmp6hdr *)skb_put(skb, len);
608 skb->h.raw = (unsigned char*)hdr;
609 hdr->icmp6_type = NDISC_ROUTER_SOLICITATION;
611 hdr->icmp6_cksum = 0;
612 hdr->icmp6_unused = 0;
614 opt = (u8*) (hdr + 1);
617 ndisc_fill_option(opt, ND_OPT_SOURCE_LL_ADDR, dev->dev_addr, dev->addr_len);
620 hdr->icmp6_cksum = csum_ipv6_magic(&skb->nh.ipv6h->saddr, daddr, len,
622 csum_partial((__u8 *) hdr, len, 0));
626 idev = in6_dev_get(dst->dev);
627 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS);
628 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output);
630 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTROUTERSOLICITS);
631 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
634 if (likely(idev != NULL))
639 static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
642 * "The sender MUST return an ICMP
643 * destination unreachable"
645 dst_link_failure(skb);
649 /* Called with locked neigh: either read or both */
651 static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
653 struct in6_addr *saddr = NULL;
654 struct in6_addr mcaddr;
655 struct net_device *dev = neigh->dev;
656 struct in6_addr *target = (struct in6_addr *)&neigh->primary_key;
657 int probes = atomic_read(&neigh->probes);
659 if (skb && ipv6_chk_addr(&skb->nh.ipv6h->saddr, dev, 1))
660 saddr = &skb->nh.ipv6h->saddr;
662 if ((probes -= neigh->parms->ucast_probes) < 0) {
663 if (!(neigh->nud_state & NUD_VALID)) {
664 ND_PRINTK1(KERN_DEBUG
665 "%s(): trying to ucast probe in NUD_INVALID: "
666 "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
670 ndisc_send_ns(dev, neigh, target, target, saddr);
671 } else if ((probes -= neigh->parms->app_probes) < 0) {
676 addrconf_addr_solict_mult(target, &mcaddr);
677 ndisc_send_ns(dev, NULL, target, &mcaddr, saddr);
681 static void ndisc_recv_ns(struct sk_buff *skb)
683 struct nd_msg *msg = (struct nd_msg *)skb->h.raw;
684 struct in6_addr *saddr = &skb->nh.ipv6h->saddr;
685 struct in6_addr *daddr = &skb->nh.ipv6h->daddr;
688 u32 ndoptlen = skb->tail - msg->opt;
689 struct ndisc_options ndopts;
690 struct net_device *dev = skb->dev;
691 struct inet6_ifaddr *ifp;
692 struct inet6_dev *idev = NULL;
693 struct neighbour *neigh;
694 int dad = ipv6_addr_any(saddr);
697 if (ipv6_addr_is_multicast(&msg->target)) {
698 ND_PRINTK2(KERN_WARNING
699 "ICMPv6 NS: multicast target address");
705 * DAD has to be destined for solicited node multicast address.
708 !(daddr->s6_addr32[0] == htonl(0xff020000) &&
709 daddr->s6_addr32[1] == htonl(0x00000000) &&
710 daddr->s6_addr32[2] == htonl(0x00000001) &&
711 daddr->s6_addr [12] == 0xff )) {
712 ND_PRINTK2(KERN_WARNING
713 "ICMPv6 NS: bad DAD packet (wrong destination)\n");
717 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
718 ND_PRINTK2(KERN_WARNING
719 "ICMPv6 NS: invalid ND options\n");
723 if (ndopts.nd_opts_src_lladdr) {
724 lladdr = (u8*)(ndopts.nd_opts_src_lladdr + 1);
725 lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
726 if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len)) {
727 ND_PRINTK2(KERN_WARNING
728 "ICMPv6 NS: invalid link-layer address length\n");
733 * If the IP source address is the unspecified address,
734 * there MUST NOT be source link-layer address option
738 ND_PRINTK2(KERN_WARNING
739 "ICMPv6 NS: bad DAD packet (link-layer address option)\n");
744 inc = ipv6_addr_is_multicast(daddr);
746 if ((ifp = ipv6_get_ifaddr(&msg->target, dev, 1)) != NULL) {
747 if (ifp->flags & IFA_F_TENTATIVE) {
748 /* Address is tentative. If the source
749 is unspecified address, it is someone
750 does DAD, otherwise we ignore solicitations
751 until DAD timer expires.
755 if (dev->type == ARPHRD_IEEE802_TR) {
756 unsigned char *sadr = skb->mac.raw;
757 if (((sadr[8] ^ dev->dev_addr[0]) & 0x7f) == 0 &&
758 sadr[9] == dev->dev_addr[1] &&
759 sadr[10] == dev->dev_addr[2] &&
760 sadr[11] == dev->dev_addr[3] &&
761 sadr[12] == dev->dev_addr[4] &&
762 sadr[13] == dev->dev_addr[5]) {
763 /* looped-back to us */
767 addrconf_dad_failure(ifp);
773 idev = in6_dev_get(dev);
775 /* XXX: count this drop? */
779 if (ipv6_chk_acast_addr(dev, &msg->target) ||
780 (idev->cnf.forwarding &&
781 pneigh_lookup(&nd_tbl, &msg->target, dev, 0))) {
782 if (skb->stamp.tv_sec != LOCALLY_ENQUEUED &&
783 skb->pkt_type != PACKET_HOST &&
785 idev->nd_parms->proxy_delay != 0) {
787 * for anycast or proxy,
788 * sender should delay its response
789 * by a random time between 0 and
790 * MAX_ANYCAST_DELAY_TIME seconds.
791 * (RFC2461) -- yoshfuji
793 struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
795 pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
803 struct in6_addr maddr;
805 ipv6_addr_all_nodes(&maddr);
806 #ifdef CONFIG_IPV6_NDISC_NEW
807 ndisc_send_na(dev, NULL, &maddr, &msg->target,
808 idev->cnf.forwarding, 0, ifp && inc, inc);
810 ndisc_send_na(dev, NULL, &maddr, &msg->target,
811 idev->cnf.forwarding, 0, ifp != NULL, inc);
817 nd_tbl.stats.rcv_probes_mcast++;
819 nd_tbl.stats.rcv_probes_ucast++;
822 * update / create cache entry
823 * for the source address
825 #ifdef CONFIG_IPV6_NDISC_NEW
826 neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, !inc || lladdr || !skb->dev->addr_len);
828 ndisc_update(neigh, lladdr, NEIGH_UPDATE_F_IP6NS);
829 ndisc_send_na(dev, neigh, saddr, &msg->target,
830 idev->cnf.forwarding, 1, (ifp && inc) , inc);
831 neigh_release(neigh);
834 neigh = neigh_event_ns(&nd_tbl, lladdr, saddr, dev);
836 if (neigh || !dev->hard_header) {
837 ndisc_send_na(dev, neigh, saddr, &msg->target,
838 idev->cnf.forwarding, 1, ifp != NULL, 1);
840 neigh_release(neigh);
853 static void ndisc_recv_na(struct sk_buff *skb)
855 struct nd_msg *msg = (struct nd_msg *)skb->h.raw;
856 struct in6_addr *saddr = &skb->nh.ipv6h->saddr;
857 struct in6_addr *daddr = &skb->nh.ipv6h->daddr;
860 u32 ndoptlen = skb->tail - msg->opt;
861 struct ndisc_options ndopts;
862 struct net_device *dev = skb->dev;
863 struct inet6_ifaddr *ifp;
864 struct neighbour *neigh;
866 if (skb->len < sizeof(struct nd_msg)) {
867 ND_PRINTK2(KERN_WARNING
868 "ICMPv6 NA: packet too short\n");
872 if (ipv6_addr_is_multicast(&msg->target)) {
873 ND_PRINTK2(KERN_WARNING
874 "ICMPv6 NA: target address is multicast.\n");
878 if (ipv6_addr_is_multicast(daddr) &&
879 msg->icmph.icmp6_solicited) {
880 ND_PRINTK2(KERN_WARNING
881 "ICMPv6 NA: solicited NA is multicasted.\n");
885 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
886 ND_PRINTK2(KERN_WARNING
887 "ICMPv6 NS: invalid ND option\n");
890 if (ndopts.nd_opts_tgt_lladdr) {
891 lladdr = (u8*)(ndopts.nd_opts_tgt_lladdr + 1);
892 lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
893 if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len)) {
894 ND_PRINTK2(KERN_WARNING
895 "ICMPv6 NA: invalid link-layer address length\n");
898 } else if (ipv6_addr_is_multicast(daddr)) {
899 ND_PRINTK2(KERN_WARNING
900 "ICMPv6 NA: multicasted NA missing target link-layer address\n");
904 if ((ifp = ipv6_get_ifaddr(&msg->target, dev, 1))) {
905 if (ifp->flags & IFA_F_TENTATIVE) {
906 addrconf_dad_failure(ifp);
909 /* What should we make now? The advertisement
910 is invalid, but ndisc specs say nothing
911 about it. It could be misconfiguration, or
912 an smart proxy agent tries to help us :-)
914 ND_PRINTK1(KERN_WARNING
915 "ICMPv6 NA: someone advertises our address on %s!\n",
916 ifp->idev->dev->name);
920 neigh = neigh_lookup(&nd_tbl, &msg->target, dev);
923 #ifdef CONFIG_IPV6_NDISC_NEW
927 write_lock_bh(&neigh->lock);
928 if (!(neigh->nud_state & ~NUD_FAILED))
931 was_router = neigh->flags & NTF_ROUTER;
933 notify = __neigh_update(neigh, lladdr,
934 msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
935 (NEIGH_UPDATE_F_IP6NA|
936 (msg->icmph.icmp6_override ? NEIGH_UPDATE_F_OVERRIDE : 0) |
937 (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0)));
939 if (was_router && !(neigh->flags & NTF_ROUTER)) {
941 * Change: router to host
944 rt = rt6_get_dflt_router(saddr, dev);
946 /* Mark as expired (may be in use elsewhere) */
947 rt->rt6i_expires = jiffies - 1;
948 ip6_del_rt(rt, NULL, NULL);
952 if (neigh->flags & NTF_ROUTER) {
953 if (msg->icmph.icmp6_router == 0) {
955 * Change: router to host
958 rt = rt6_get_dflt_router(saddr, dev);
960 ip6_del_rt(rt, NULL, NULL);
963 if (msg->icmph.icmp6_router)
964 neigh->flags |= NTF_ROUTER;
967 neigh_update(neigh, lladdr,
968 msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
969 msg->icmph.icmp6_override, 1);
971 #ifdef CONFIG_IPV6_NDISC_NEW
974 if (notify > 0 && neigh->parms->app_probes) {
975 write_unlock_bh(&neigh->lock);
976 neigh_app_notify(neigh);
979 write_unlock_bh(&neigh->lock);
981 neigh_release(neigh);
985 static void ndisc_recv_rs(struct sk_buff *skb)
987 struct rs_msg *rs_msg = (struct rs_msg *) skb->h.raw;
988 unsigned long ndoptlen = skb->len - sizeof(*rs_msg);
989 struct neighbour *neigh;
990 struct inet6_dev *idev;
991 struct in6_addr *saddr = &skb->nh.ipv6h->saddr;
992 struct ndisc_options ndopts;
996 if (skb->len < sizeof(*rs_msg))
999 idev = in6_dev_get(skb->dev);
1001 if (net_ratelimit())
1002 ND_PRINTK1("ICMP6 RS: can't find in6 device\n");
1006 /* Don't accept RS if we're not in router mode */
1007 if (!idev->cnf.forwarding || idev->cnf.accept_ra)
1011 * Don't update NCE if src = ::;
1012 * this implies that the source node has no ip address assigned yet.
1014 if (ipv6_addr_any(saddr))
1017 /* Parse ND options */
1018 if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) {
1019 if (net_ratelimit())
1020 ND_PRINTK2("ICMP6 NS: invalid ND option, ignored\n");
1024 if (ndopts.nd_opts_src_lladdr) {
1025 lladdr = (u8 *)(ndopts.nd_opts_src_lladdr + 1);
1026 lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
1027 if (lladdrlen != NDISC_OPT_SPACE(skb->dev->addr_len))
1031 neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
1033 #ifdef CONFIG_IPV6_NDISC_NEW
1034 ndisc_update(neigh, lladdr, NEIGH_UPDATE_F_IP6RS);
1036 neigh_update(neigh, lladdr, NUD_STALE, 1, 1);
1038 neigh_release(neigh);
1044 static void ndisc_router_discovery(struct sk_buff *skb)
1046 struct ra_msg *ra_msg = (struct ra_msg *) skb->h.raw;
1047 struct neighbour *neigh;
1048 struct inet6_dev *in6_dev;
1049 struct rt6_info *rt;
1051 struct ndisc_options ndopts;
1054 __u8 * opt = (__u8 *)(ra_msg + 1);
1056 optlen = (skb->tail - skb->h.raw) - sizeof(struct ra_msg);
1058 if (!(ipv6_addr_type(&skb->nh.ipv6h->saddr) & IPV6_ADDR_LINKLOCAL)) {
1059 ND_PRINTK2(KERN_WARNING
1060 "ICMPv6 RA: source address is not link-local.\n");
1064 ND_PRINTK2(KERN_WARNING
1065 "ICMPv6 RA: packet too short\n");
1070 * set the RA_RECV flag in the interface
1073 in6_dev = in6_dev_get(skb->dev);
1074 if (in6_dev == NULL) {
1076 "ICMPv6 RA: can't find inet6 device for %s.\n",
1080 if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_ra) {
1081 in6_dev_put(in6_dev);
1085 if (!ndisc_parse_options(opt, optlen, &ndopts)) {
1086 in6_dev_put(in6_dev);
1087 ND_PRINTK2(KERN_WARNING
1088 "ICMP6 RA: invalid ND options\n");
1092 if (in6_dev->if_flags & IF_RS_SENT) {
1094 * flag that an RA was received after an RS was sent
1095 * out on this interface.
1097 in6_dev->if_flags |= IF_RA_RCVD;
1101 * Remember the managed/otherconf flags from most recently
1102 * received RA message (RFC 2462) -- yoshfuji
1104 in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
1106 (ra_msg->icmph.icmp6_addrconf_managed ?
1107 IF_RA_MANAGED : 0) |
1108 (ra_msg->icmph.icmp6_addrconf_other ?
1109 IF_RA_OTHERCONF : 0);
1111 lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);
1113 rt = rt6_get_dflt_router(&skb->nh.ipv6h->saddr, skb->dev);
1115 if (rt && lifetime == 0) {
1116 ip6_del_rt(rt, NULL, NULL);
1120 if (rt == NULL && lifetime) {
1121 ND_PRINTK3(KERN_DEBUG
1122 "ICMPv6 RA: adding default router.\n");
1124 rt = rt6_add_dflt_router(&skb->nh.ipv6h->saddr, skb->dev);
1127 "ICMPv6 RA: %s() failed to add default route.\n",
1129 in6_dev_put(in6_dev);
1133 neigh = rt->rt6i_nexthop;
1134 if (neigh == NULL) {
1136 "ICMPv6 RA: %s() got default router without neighbour.\n",
1138 dst_release(&rt->u.dst);
1139 in6_dev_put(in6_dev);
1142 neigh->flags |= NTF_ROUTER;
1145 * If we where using an "all destinations on link" route
1149 rt6_purge_dflt_routers(RTF_ALLONLINK);
1153 fib6_update_expiry(rt, lifetime);
1155 if (ra_msg->icmph.icmp6_hop_limit)
1156 in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
1159 * Update Reachable Time and Retrans Timer
1162 if (in6_dev->nd_parms) {
1163 unsigned long rtime = ntohl(ra_msg->retrans_timer);
1165 if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
1166 rtime = (rtime*HZ)/1000;
1169 in6_dev->nd_parms->retrans_time = rtime;
1170 in6_dev->tstamp = jiffies;
1171 inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
1174 rtime = ntohl(ra_msg->reachable_time);
1175 if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
1176 rtime = (rtime*HZ)/1000;
1181 if (rtime != in6_dev->nd_parms->base_reachable_time) {
1182 in6_dev->nd_parms->base_reachable_time = rtime;
1183 in6_dev->nd_parms->gc_staletime = 3 * rtime;
1184 in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime);
1185 in6_dev->tstamp = jiffies;
1186 inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
1195 if (rt && (neigh = rt->rt6i_nexthop) != NULL) {
1198 if (ndopts.nd_opts_src_lladdr) {
1199 lladdr = (u8*)((ndopts.nd_opts_src_lladdr)+1);
1200 lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
1201 if (lladdrlen != NDISC_OPT_SPACE(skb->dev->addr_len)) {
1202 ND_PRINTK2(KERN_WARNING
1203 "ICMPv6 RA: invalid link-layer address length\n");
1207 #ifdef CONFIG_IPV6_NDISC_NEW
1208 ndisc_update(neigh, lladdr, NEIGH_UPDATE_F_IP6RA);
1210 neigh_update(neigh, lladdr, NUD_STALE, 1, 1);
1214 if (ndopts.nd_opts_pi) {
1215 struct nd_opt_hdr *p;
1216 for (p = ndopts.nd_opts_pi;
1218 p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
1219 addrconf_prefix_rcv(skb->dev, (u8*)p, (p->nd_opt_len) << 3);
1223 if (ndopts.nd_opts_mtu) {
1226 memcpy(&mtu, ((u8*)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
1229 if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
1230 ND_PRINTK2(KERN_WARNING
1231 "ICMPv6 RA: invalid mtu: %d\n",
1233 } else if (in6_dev->cnf.mtu6 != mtu) {
1234 in6_dev->cnf.mtu6 = mtu;
1237 rt->u.dst.metrics[RTAX_MTU-1] = mtu;
1239 rt6_mtu_change(skb->dev, mtu);
1243 if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
1244 ND_PRINTK2(KERN_WARNING
1245 "ICMPv6 RA: invalid RA options");
1249 dst_release(&rt->u.dst);
1250 in6_dev_put(in6_dev);
1253 static void ndisc_redirect_rcv(struct sk_buff *skb)
1255 struct inet6_dev *in6_dev;
1256 struct icmp6hdr *icmph;
1257 struct in6_addr *dest;
1258 struct in6_addr *target; /* new first hop to destination */
1259 struct neighbour *neigh;
1261 struct ndisc_options ndopts;
1266 if (!(ipv6_addr_type(&skb->nh.ipv6h->saddr) & IPV6_ADDR_LINKLOCAL)) {
1267 ND_PRINTK2(KERN_WARNING
1268 "ICMPv6 Redirect: source address is not link-local.\n");
1272 optlen = skb->tail - skb->h.raw;
1273 optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr);
1276 ND_PRINTK2(KERN_WARNING
1277 "ICMPv6 Redirect: packet too short\n");
1281 icmph = (struct icmp6hdr *) skb->h.raw;
1282 target = (struct in6_addr *) (icmph + 1);
1285 if (ipv6_addr_is_multicast(dest)) {
1286 ND_PRINTK2(KERN_WARNING
1287 "ICMPv6 Redirect: destination address is multicast.\n");
1291 if (ipv6_addr_cmp(dest, target) == 0) {
1293 } else if (!(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
1294 ND_PRINTK2(KERN_WARNING
1295 "ICMPv6 Redirect: target address is not link-local.\n");
1299 in6_dev = in6_dev_get(skb->dev);
1302 if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_redirects) {
1303 in6_dev_put(in6_dev);
1308 * The IP source address of the Redirect MUST be the same as the current
1309 * first-hop router for the specified ICMP Destination Address.
1312 if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) {
1313 ND_PRINTK2(KERN_WARNING
1314 "ICMPv6 Redirect: invalid ND options\n");
1315 in6_dev_put(in6_dev);
1318 if (ndopts.nd_opts_tgt_lladdr) {
1319 lladdr = (u8*)(ndopts.nd_opts_tgt_lladdr + 1);
1320 lladdrlen = ndopts.nd_opts_tgt_lladdr->nd_opt_len << 3;
1321 if (lladdrlen != NDISC_OPT_SPACE(skb->dev->addr_len)) {
1322 ND_PRINTK2(KERN_WARNING
1323 "ICMPv6 Redirect: invalid link-layer address length\n");
1324 in6_dev_put(in6_dev);
1328 /* passed validation tests */
1331 We install redirect only if nexthop state is valid.
1334 neigh = __neigh_lookup(&nd_tbl, target, skb->dev, 1);
1336 #ifdef CONFIG_IPV6_NDISC_NEW
1337 rt6_redirect(dest, &skb->nh.ipv6h->saddr, neigh, lladdr, on_link);
1339 if (neigh->nud_state&NUD_VALID) {
1340 if (!rt6_redirect(dest, &skb->nh.ipv6h->saddr, neigh, NULL, on_link))
1341 neigh_update(neigh, lladdr, NUD_STALE, 1, 1);
1343 write_lock_bh(&neigh->lock);
1344 __neigh_event_send(neigh, NULL);
1345 write_unlock_bh(&neigh->lock);
1348 neigh_release(neigh);
1350 in6_dev_put(in6_dev);
1353 void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1354 struct in6_addr *target)
1356 struct sock *sk = ndisc_socket->sk;
1357 int len = sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr);
1358 struct sk_buff *buff;
1359 struct icmp6hdr *icmph;
1360 struct in6_addr saddr_buf;
1361 struct in6_addr *addrp;
1362 struct net_device *dev;
1363 struct rt6_info *rt;
1364 struct dst_entry *dst;
1365 struct inet6_dev *idev;
1374 if (ipv6_get_lladdr(dev, &saddr_buf)) {
1375 ND_PRINTK2(KERN_WARNING
1376 "ICMPv6 Redirect: no link-local address on %s\n",
1381 ndisc_flow_init(&fl, NDISC_REDIRECT, &saddr_buf, &skb->nh.ipv6h->saddr);
1383 rt = rt6_lookup(&skb->nh.ipv6h->saddr, NULL, dev->ifindex, 1);
1388 err = xfrm_lookup(&dst, &fl, NULL, 0);
1394 rt = (struct rt6_info *) dst;
1396 if (rt->rt6i_flags & RTF_GATEWAY) {
1397 ND_PRINTK2(KERN_WARNING
1398 "ICMPv6 Redirect: destination is not a neighbour.\n");
1402 if (!xrlim_allow(dst, 1*HZ)) {
1407 if (dev->addr_len) {
1408 if (neigh->nud_state&NUD_VALID) {
1409 len += NDISC_OPT_SPACE(dev->addr_len);
1411 /* If nexthop is not valid, do not redirect!
1412 We will make it later, when will be sure,
1420 rd_len = min_t(unsigned int,
1421 IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8);
1425 buff = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev) + dst->header_len + 64,
1429 "ICMPv6 Redirect: %s() failed to allocate an skb.\n",
1437 skb_reserve(buff, LL_RESERVED_SPACE(dev));
1438 ip6_nd_hdr(sk, buff, dev, &saddr_buf, &skb->nh.ipv6h->saddr,
1439 IPPROTO_ICMPV6, len);
1441 icmph = (struct icmp6hdr *)skb_put(buff, len);
1442 buff->h.raw = (unsigned char*)icmph;
1444 memset(icmph, 0, sizeof(struct icmp6hdr));
1445 icmph->icmp6_type = NDISC_REDIRECT;
1448 * copy target and destination addresses
1451 addrp = (struct in6_addr *)(icmph + 1);
1452 ipv6_addr_copy(addrp, target);
1454 ipv6_addr_copy(addrp, &skb->nh.ipv6h->daddr);
1456 opt = (u8*) (addrp + 1);
1459 * include target_address option
1463 opt = ndisc_fill_option(opt, ND_OPT_TARGET_LL_ADDR, neigh->ha, dev->addr_len);
1466 * build redirect option and copy skb over to the new packet.
1470 *(opt++) = ND_OPT_REDIRECT_HDR;
1471 *(opt++) = (rd_len >> 3);
1474 memcpy(opt, skb->nh.ipv6h, rd_len - 8);
1476 icmph->icmp6_cksum = csum_ipv6_magic(&saddr_buf, &skb->nh.ipv6h->saddr,
1477 len, IPPROTO_ICMPV6,
1478 csum_partial((u8 *) icmph, len, 0));
1481 idev = in6_dev_get(dst->dev);
1482 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS);
1483 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, buff, NULL, dst->dev, dst_output);
1485 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTREDIRECTS);
1486 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
1489 if (likely(idev != NULL))
1493 static void pndisc_redo(struct sk_buff *skb)
1499 int ndisc_rcv(struct sk_buff *skb)
1503 if (!pskb_may_pull(skb, skb->len))
1506 msg = (struct nd_msg *) skb->h.raw;
1508 __skb_push(skb, skb->data-skb->h.raw);
1510 if (skb->nh.ipv6h->hop_limit != 255) {
1511 ND_PRINTK2(KERN_WARNING
1512 "ICMPv6 NDISC: invalid hop-limit: %d\n",
1513 skb->nh.ipv6h->hop_limit);
1517 if (msg->icmph.icmp6_code != 0) {
1518 ND_PRINTK2(KERN_WARNING
1519 "ICMPv6 NDISC: invalid ICMPv6 code: %d\n",
1520 msg->icmph.icmp6_code);
1524 switch (msg->icmph.icmp6_type) {
1525 case NDISC_NEIGHBOUR_SOLICITATION:
1529 case NDISC_NEIGHBOUR_ADVERTISEMENT:
1533 case NDISC_ROUTER_SOLICITATION:
1537 case NDISC_ROUTER_ADVERTISEMENT:
1538 ndisc_router_discovery(skb);
1541 case NDISC_REDIRECT:
1542 ndisc_redirect_rcv(skb);
1549 static int ndisc_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
1551 struct net_device *dev = ptr;
1554 case NETDEV_CHANGEADDR:
1555 neigh_changeaddr(&nd_tbl, dev);
1559 neigh_ifdown(&nd_tbl, dev);
1562 case NETDEV_UNREGISTER:
1572 static struct notifier_block ndisc_netdev_notifier = {
1573 .notifier_call = ndisc_netdev_event,
1576 #ifdef CONFIG_SYSCTL
1577 int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, struct file * filp, void __user *buffer, size_t *lenp, loff_t *ppos)
1579 struct net_device *dev = ctl->extra1;
1580 struct inet6_dev *idev;
1582 if (write && dev && (idev = in6_dev_get(dev)) != NULL) {
1583 idev->tstamp = jiffies;
1584 inet6_ifinfo_notify(RTM_NEWLINK, idev);
1587 return proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
1591 int __init ndisc_init(struct net_proto_family *ops)
1593 struct ipv6_pinfo *np;
1597 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &ndisc_socket);
1600 "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n",
1602 ndisc_socket = NULL; /* For safety. */
1606 sk = ndisc_socket->sk;
1608 sk->sk_allocation = GFP_ATOMIC;
1609 np->hop_limit = 255;
1610 /* Do not loopback ndisc messages */
1612 sk->sk_prot->unhash(sk);
1615 * Initialize the neighbour table
1618 neigh_table_init(&nd_tbl);
1620 #ifdef CONFIG_SYSCTL
1621 neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH,
1622 "ipv6", &ndisc_ifinfo_sysctl_change);
1625 register_netdevice_notifier(&ndisc_netdev_notifier);
1629 void ndisc_cleanup(void)
1631 #ifdef CONFIG_SYSCTL
1632 neigh_sysctl_unregister(&nd_tbl.parms);
1634 neigh_table_clear(&nd_tbl);
1635 sock_release(ndisc_socket);
1636 ndisc_socket = NULL; /* For safety. */