raw_ip6.c (185370) | raw_ip6.c (185435) |
---|---|
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 --- 46 unchanged lines hidden (view full) --- 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * SUCH DAMAGE. 58 * 59 * @(#)raw_ip.c 8.2 (Berkeley) 1/4/94 60 */ 61 62#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 --- 46 unchanged lines hidden (view full) --- 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * SUCH DAMAGE. 58 * 59 * @(#)raw_ip.c 8.2 (Berkeley) 1/4/94 60 */ 61 62#include <sys/cdefs.h> |
63__FBSDID("$FreeBSD: head/sys/netinet6/raw_ip6.c 185370 2008-11-27 12:04:35Z bz $"); | 63__FBSDID("$FreeBSD: head/sys/netinet6/raw_ip6.c 185435 2008-11-29 14:32:14Z bz $"); |
64 65#include "opt_ipsec.h" 66#include "opt_inet6.h" 67 68#include <sys/param.h> 69#include <sys/errno.h> | 64 65#include "opt_ipsec.h" 66#include "opt_inet6.h" 67 68#include <sys/param.h> 69#include <sys/errno.h> |
70#include <sys/jail.h> |
|
70#include <sys/lock.h> 71#include <sys/malloc.h> 72#include <sys/mbuf.h> 73#include <sys/priv.h> 74#include <sys/proc.h> 75#include <sys/protosw.h> 76#include <sys/signalvar.h> 77#include <sys/socket.h> --- 79 unchanged lines hidden (view full) --- 157 m_freem(m); 158 return (IPPROTO_DONE); 159 } 160 161 init_sin6(&fromsa, m); /* general init */ 162 163 INP_INFO_RLOCK(&V_ripcbinfo); 164 LIST_FOREACH(in6p, &V_ripcb, inp_list) { | 71#include <sys/lock.h> 72#include <sys/malloc.h> 73#include <sys/mbuf.h> 74#include <sys/priv.h> 75#include <sys/proc.h> 76#include <sys/protosw.h> 77#include <sys/signalvar.h> 78#include <sys/socket.h> --- 79 unchanged lines hidden (view full) --- 158 m_freem(m); 159 return (IPPROTO_DONE); 160 } 161 162 init_sin6(&fromsa, m); /* general init */ 163 164 INP_INFO_RLOCK(&V_ripcbinfo); 165 LIST_FOREACH(in6p, &V_ripcb, inp_list) { |
166 /* XXX inp locking */ |
|
165 if ((in6p->in6p_vflag & INP_IPV6) == 0) 166 continue; 167 if (in6p->in6p_ip6_nxt && 168 in6p->in6p_ip6_nxt != proto) 169 continue; 170 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) && 171 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst)) 172 continue; 173 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) && 174 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src)) 175 continue; | 167 if ((in6p->in6p_vflag & INP_IPV6) == 0) 168 continue; 169 if (in6p->in6p_ip6_nxt && 170 in6p->in6p_ip6_nxt != proto) 171 continue; 172 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) && 173 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst)) 174 continue; 175 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) && 176 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src)) 177 continue; |
178 if (jailed(in6p->inp_cred)) { 179 if (!prison_check_ip6(in6p->inp_cred, &ip6->ip6_dst)) 180 continue; 181 } |
|
176 INP_RLOCK(in6p); 177 if (in6p->in6p_cksum != -1) { 178 V_rip6stat.rip6s_isum++; 179 if (in6_cksum(m, proto, *offp, 180 m->m_pkthdr.len - *offp)) { 181 INP_RUNLOCK(in6p); 182 V_rip6stat.rip6s_badsum++; 183 continue; --- 212 unchanged lines hidden (view full) --- 396 * Source address selection. 397 */ 398 if ((in6a = in6_selectsrc(dstsock, optp, in6p, NULL, so->so_cred, 399 &oifp, &error)) == NULL) { 400 if (error == 0) 401 error = EADDRNOTAVAIL; 402 goto bad; 403 } | 182 INP_RLOCK(in6p); 183 if (in6p->in6p_cksum != -1) { 184 V_rip6stat.rip6s_isum++; 185 if (in6_cksum(m, proto, *offp, 186 m->m_pkthdr.len - *offp)) { 187 INP_RUNLOCK(in6p); 188 V_rip6stat.rip6s_badsum++; 189 continue; --- 212 unchanged lines hidden (view full) --- 402 * Source address selection. 403 */ 404 if ((in6a = in6_selectsrc(dstsock, optp, in6p, NULL, so->so_cred, 405 &oifp, &error)) == NULL) { 406 if (error == 0) 407 error = EADDRNOTAVAIL; 408 goto bad; 409 } |
410 if (jailed(in6p->inp_cred)) 411 if (prison_getip6(in6p->inp_cred, in6a) != 0) { 412 error = EPERM; 413 goto bad; 414 } |
|
404 ip6->ip6_src = *in6a; 405 406 if (oifp && scope_ambiguous) { 407 /* 408 * Application should provide a proper zone ID or the use of 409 * default zone IDs should be enabled. Unfortunately, some 410 * applications do not behave as it should, so we need a 411 * workaround. Even if an appropriate ID is not determined --- 246 unchanged lines hidden (view full) --- 658 struct ifaddr *ia = NULL; 659 int error = 0; 660 661 inp = sotoinpcb(so); 662 KASSERT(inp != NULL, ("rip6_bind: inp == NULL")); 663 664 if (nam->sa_len != sizeof(*addr)) 665 return (EINVAL); | 415 ip6->ip6_src = *in6a; 416 417 if (oifp && scope_ambiguous) { 418 /* 419 * Application should provide a proper zone ID or the use of 420 * default zone IDs should be enabled. Unfortunately, some 421 * applications do not behave as it should, so we need a 422 * workaround. Even if an appropriate ID is not determined --- 246 unchanged lines hidden (view full) --- 669 struct ifaddr *ia = NULL; 670 int error = 0; 671 672 inp = sotoinpcb(so); 673 KASSERT(inp != NULL, ("rip6_bind: inp == NULL")); 674 675 if (nam->sa_len != sizeof(*addr)) 676 return (EINVAL); |
677 if (!prison_check_ip6(td->td_ucred, &addr->sin6_addr)) 678 return (EADDRNOTAVAIL); |
|
666 if (TAILQ_EMPTY(&V_ifnet) || addr->sin6_family != AF_INET6) 667 return (EADDRNOTAVAIL); 668 if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) 669 return (error); 670 671 if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) && 672 (ia = ifa_ifwithaddr((struct sockaddr *)addr)) == 0) 673 return (EADDRNOTAVAIL); --- 162 unchanged lines hidden --- | 679 if (TAILQ_EMPTY(&V_ifnet) || addr->sin6_family != AF_INET6) 680 return (EADDRNOTAVAIL); 681 if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) 682 return (error); 683 684 if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) && 685 (ia = ifa_ifwithaddr((struct sockaddr *)addr)) == 0) 686 return (EADDRNOTAVAIL); --- 162 unchanged lines hidden --- |