icmp6.c (191340) | icmp6.c (191672) |
---|---|
1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 61 */ 62 63#include <sys/cdefs.h> | 1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 61 */ 62 63#include <sys/cdefs.h> |
64__FBSDID("$FreeBSD: head/sys/netinet6/icmp6.c 191340 2009-04-20 22:45:21Z rwatson $"); | 64__FBSDID("$FreeBSD: head/sys/netinet6/icmp6.c 191672 2009-04-29 19:19:13Z bms $"); |
65 66#include "opt_inet.h" 67#include "opt_inet6.h" 68#include "opt_ipsec.h" 69#include "opt_route.h" 70 71#include <sys/param.h> 72#include <sys/domain.h> --- 69 unchanged lines hidden (view full) --- 142 143 144void 145icmp6_init(void) 146{ 147 INIT_VNET_INET6(curvnet); 148 149 V_icmp6errpps_count = 0; | 65 66#include "opt_inet.h" 67#include "opt_inet6.h" 68#include "opt_ipsec.h" 69#include "opt_route.h" 70 71#include <sys/param.h> 72#include <sys/domain.h> --- 69 unchanged lines hidden (view full) --- 142 143 144void 145icmp6_init(void) 146{ 147 INIT_VNET_INET6(curvnet); 148 149 V_icmp6errpps_count = 0; |
150 151 mld6_init(); | |
152} 153 154static void 155icmp6_errcount(struct icmp6errstat *stat, int type, int code) 156{ 157 switch (type) { 158 case ICMP6_DST_UNREACH: 159 switch (code) { --- 264 unchanged lines hidden (view full) --- 424 425 ip6 = mtod(m, struct ip6_hdr *); 426 if (icmp6len < sizeof(struct icmp6_hdr)) { 427 ICMP6STAT_INC(icp6s_tooshort); 428 goto freeit; 429 } 430 431 /* | 150} 151 152static void 153icmp6_errcount(struct icmp6errstat *stat, int type, int code) 154{ 155 switch (type) { 156 case ICMP6_DST_UNREACH: 157 switch (code) { --- 264 unchanged lines hidden (view full) --- 422 423 ip6 = mtod(m, struct ip6_hdr *); 424 if (icmp6len < sizeof(struct icmp6_hdr)) { 425 ICMP6STAT_INC(icp6s_tooshort); 426 goto freeit; 427 } 428 429 /* |
430 * Check multicast group membership. 431 * Note: SSM filters are not applied for ICMPv6 traffic. 432 */ 433 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { 434 struct ifnet *ifp; 435 struct in6_multi *inm; 436 437 ifp = m->m_pkthdr.rcvif; 438 inm = in6m_lookup(ifp, &ip6->ip6_dst); 439 if (inm == NULL) { 440 IP6STAT_INC(ip6s_notmember); 441 in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); 442 goto freeit; 443 } 444 } 445 446 /* |
|
432 * calculate the checksum 433 */ 434#ifndef PULLDOWN_TEST 435 icmp6 = (struct icmp6_hdr *)((caddr_t)ip6 + off); 436#else 437 IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6)); 438 if (icmp6 == NULL) { 439 ICMP6STAT_INC(icp6s_tooshort); --- 170 unchanged lines hidden (view full) --- 610 case ICMP6_ECHO_REPLY: 611 icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_echoreply); 612 if (code != 0) 613 goto badcode; 614 break; 615 616 case MLD_LISTENER_QUERY: 617 case MLD_LISTENER_REPORT: | 447 * calculate the checksum 448 */ 449#ifndef PULLDOWN_TEST 450 icmp6 = (struct icmp6_hdr *)((caddr_t)ip6 + off); 451#else 452 IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6)); 453 if (icmp6 == NULL) { 454 ICMP6STAT_INC(icp6s_tooshort); --- 170 unchanged lines hidden (view full) --- 625 case ICMP6_ECHO_REPLY: 626 icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_echoreply); 627 if (code != 0) 628 goto badcode; 629 break; 630 631 case MLD_LISTENER_QUERY: 632 case MLD_LISTENER_REPORT: |
618 if (icmp6len < sizeof(struct mld_hdr)) 619 goto badlen; 620 if (icmp6->icmp6_type == MLD_LISTENER_QUERY) /* XXX: ugly... */ 621 icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mldquery); 622 else 623 icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mldreport); 624 if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) { 625 /* give up local */ 626 mld6_input(m, off); 627 m = NULL; | 633 case MLD_LISTENER_DONE: 634 case MLDV2_LISTENER_REPORT: 635 /* 636 * Drop MLD traffic which is not link-local. 637 * XXX Should we also sanity check that these messages 638 * were directed to a link-local multicast prefix? 639 */ 640 if (ip6->ip6_hlim != 1) |
628 goto freeit; | 641 goto freeit; |
629 } 630 mld6_input(n, off); | 642 if (mld_input(m, off, icmp6len) != 0) 643 return (IPPROTO_DONE); |
631 /* m stays. */ 632 break; 633 | 644 /* m stays. */ 645 break; 646 |
634 case MLD_LISTENER_DONE: 635 icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_mlddone); 636 if (icmp6len < sizeof(struct mld_hdr)) /* necessary? */ 637 goto badlen; 638 break; /* nothing to be done in kernel */ 639 640 case MLD_MTRACE_RESP: 641 case MLD_MTRACE: 642 /* XXX: these two are experimental. not officially defined. */ 643 /* XXX: per-interface statistics? */ 644 break; /* just pass it to applications */ 645 | |
646 case ICMP6_WRUREQUEST: /* ICMP6_FQDN_QUERY */ 647 { 648 enum { WRU, FQDN } mode; 649 650 if (!V_icmp6_nodeinfo) 651 break; 652 653 if (icmp6len == sizeof(struct icmp6_hdr) + 4) --- 1391 unchanged lines hidden (view full) --- 2045 if (opts) 2046 m_freem(opts); 2047 SOCKBUF_UNLOCK(&last->inp_socket->so_rcv); 2048 } else 2049 sorwakeup_locked(last->inp_socket); 2050 INP_RUNLOCK(last); 2051 } else { 2052 m_freem(m); | 647 case ICMP6_WRUREQUEST: /* ICMP6_FQDN_QUERY */ 648 { 649 enum { WRU, FQDN } mode; 650 651 if (!V_icmp6_nodeinfo) 652 break; 653 654 if (icmp6len == sizeof(struct icmp6_hdr) + 4) --- 1391 unchanged lines hidden (view full) --- 2046 if (opts) 2047 m_freem(opts); 2048 SOCKBUF_UNLOCK(&last->inp_socket->so_rcv); 2049 } else 2050 sorwakeup_locked(last->inp_socket); 2051 INP_RUNLOCK(last); 2052 } else { 2053 m_freem(m); |
2053 V_ip6stat.ip6s_delivered--; | 2054 IP6STAT_DEC(ip6s_delivered); |
2054 } 2055 return IPPROTO_DONE; 2056} 2057 2058/* 2059 * Reflect the ip6 packet back to the source. 2060 * OFF points to the icmp6 header, counted from the top of the mbuf. 2061 */ --- 155 unchanged lines hidden (view full) --- 2217 m_freem(m); 2218 return; 2219} 2220 2221void 2222icmp6_fasttimo(void) 2223{ 2224 | 2055 } 2056 return IPPROTO_DONE; 2057} 2058 2059/* 2060 * Reflect the ip6 packet back to the source. 2061 * OFF points to the icmp6 header, counted from the top of the mbuf. 2062 */ --- 155 unchanged lines hidden (view full) --- 2218 m_freem(m); 2219 return; 2220} 2221 2222void 2223icmp6_fasttimo(void) 2224{ 2225 |
2225 return; | 2226 mld_fasttimo(); |
2226} 2227 | 2227} 2228 |
2229void 2230icmp6_slowtimo(void) 2231{ 2232 2233 mld_slowtimo(); 2234} 2235 |
|
2228static const char * 2229icmp6_redirect_diag(struct in6_addr *src6, struct in6_addr *dst6, 2230 struct in6_addr *tgt6) 2231{ 2232 static char buf[1024]; 2233 char ip6bufs[INET6_ADDRSTRLEN]; 2234 char ip6bufd[INET6_ADDRSTRLEN]; 2235 char ip6buft[INET6_ADDRSTRLEN]; --- 599 unchanged lines hidden --- | 2236static const char * 2237icmp6_redirect_diag(struct in6_addr *src6, struct in6_addr *dst6, 2238 struct in6_addr *tgt6) 2239{ 2240 static char buf[1024]; 2241 char ip6bufs[INET6_ADDRSTRLEN]; 2242 char ip6bufd[INET6_ADDRSTRLEN]; 2243 char ip6buft[INET6_ADDRSTRLEN]; --- 599 unchanged lines hidden --- |