sctp_pcb.c (197173) | sctp_pcb.c (197288) |
---|---|
1/*- 2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 17 unchanged lines hidden (view full) --- 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31/* $KAME: sctp_pcb.c,v 1.38 2005/03/06 16:04:18 itojun Exp $ */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 17 unchanged lines hidden (view full) --- 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31/* $KAME: sctp_pcb.c,v 1.38 2005/03/06 16:04:18 itojun Exp $ */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 197173 2009-09-13 17:45:31Z rrs $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 197288 2009-09-17 15:11:12Z rrs $"); |
35 36#include <netinet/sctp_os.h> 37#include <sys/proc.h> 38#include <netinet/sctp_var.h> 39#include <netinet/sctp_sysctl.h> 40#include <netinet/sctp_pcb.h> 41#include <netinet/sctputil.h> 42#include <netinet/sctp.h> 43#include <netinet/sctp_header.h> 44#include <netinet/sctp_asconf.h> 45#include <netinet/sctp_output.h> 46#include <netinet/sctp_timer.h> 47#include <netinet/sctp_bsd_addr.h> 48#include <netinet/udp.h> 49 50 | 35 36#include <netinet/sctp_os.h> 37#include <sys/proc.h> 38#include <netinet/sctp_var.h> 39#include <netinet/sctp_sysctl.h> 40#include <netinet/sctp_pcb.h> 41#include <netinet/sctputil.h> 42#include <netinet/sctp.h> 43#include <netinet/sctp_header.h> 44#include <netinet/sctp_asconf.h> 45#include <netinet/sctp_output.h> 46#include <netinet/sctp_timer.h> 47#include <netinet/sctp_bsd_addr.h> 48#include <netinet/udp.h> 49 50 |
51struct sctp_base_info system_base_info; | 51VNET_DEFINE(struct sctp_base_info, system_base_info); |
52 53/* FIX: we don't handle multiple link local scopes */ 54/* "scopeless" replacement IN6_ARE_ADDR_EQUAL */ 55#ifdef INET6 56int 57SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b) 58{ 59 struct sockaddr_in6 tmp_a, tmp_b; 60 61 memcpy(&tmp_a, a, sizeof(struct sockaddr_in6)); | 52 53/* FIX: we don't handle multiple link local scopes */ 54/* "scopeless" replacement IN6_ARE_ADDR_EQUAL */ 55#ifdef INET6 56int 57SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b) 58{ 59 struct sockaddr_in6 tmp_a, tmp_b; 60 61 memcpy(&tmp_a, a, sizeof(struct sockaddr_in6)); |
62 if (sa6_embedscope(&tmp_a, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) { | 62 if (sa6_embedscope(&tmp_a, MODULE_GLOBAL(ip6_use_defzone)) != 0) { |
63 return 0; 64 } 65 memcpy(&tmp_b, b, sizeof(struct sockaddr_in6)); | 63 return 0; 64 } 65 memcpy(&tmp_b, b, sizeof(struct sockaddr_in6)); |
66 if (sa6_embedscope(&tmp_b, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) { | 66 if (sa6_embedscope(&tmp_b, MODULE_GLOBAL(ip6_use_defzone)) != 0) { |
67 return 0; 68 } 69 return (IN6_ARE_ADDR_EQUAL(&tmp_a.sin6_addr, &tmp_b.sin6_addr)); 70} 71 72#endif 73 74void --- 1928 unchanged lines hidden (view full) --- 2003 bzero(from6, sizeof(*from6)); 2004 from6->sin6_family = AF_INET6; 2005 from6->sin6_len = sizeof(struct sockaddr_in6); 2006 from6->sin6_addr = ip6->ip6_src; 2007 from6->sin6_port = sh->src_port; 2008 /* Get the scopes in properly to the sin6 addr's */ 2009 /* we probably don't need these operations */ 2010 (void)sa6_recoverscope(from6); | 67 return 0; 68 } 69 return (IN6_ARE_ADDR_EQUAL(&tmp_a.sin6_addr, &tmp_b.sin6_addr)); 70} 71 72#endif 73 74void --- 1928 unchanged lines hidden (view full) --- 2003 bzero(from6, sizeof(*from6)); 2004 from6->sin6_family = AF_INET6; 2005 from6->sin6_len = sizeof(struct sockaddr_in6); 2006 from6->sin6_addr = ip6->ip6_src; 2007 from6->sin6_port = sh->src_port; 2008 /* Get the scopes in properly to the sin6 addr's */ 2009 /* we probably don't need these operations */ 2010 (void)sa6_recoverscope(from6); |
2011 sa6_embedscope(from6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)); | 2011 sa6_embedscope(from6, MODULE_GLOBAL(ip6_use_defzone)); |
2012 break; 2013 } 2014#endif 2015 default: 2016 /* Currently not supported. */ 2017 return (NULL); 2018 } 2019 --- 24 unchanged lines hidden (view full) --- 2044 bzero(to6, sizeof(*to6)); 2045 to6->sin6_family = AF_INET6; 2046 to6->sin6_len = sizeof(struct sockaddr_in6); 2047 to6->sin6_addr = ip6->ip6_dst; 2048 to6->sin6_port = sh->dest_port; 2049 /* Get the scopes in properly to the sin6 addr's */ 2050 /* we probably don't need these operations */ 2051 (void)sa6_recoverscope(to6); | 2012 break; 2013 } 2014#endif 2015 default: 2016 /* Currently not supported. */ 2017 return (NULL); 2018 } 2019 --- 24 unchanged lines hidden (view full) --- 2044 bzero(to6, sizeof(*to6)); 2045 to6->sin6_family = AF_INET6; 2046 to6->sin6_len = sizeof(struct sockaddr_in6); 2047 to6->sin6_addr = ip6->ip6_dst; 2048 to6->sin6_port = sh->dest_port; 2049 /* Get the scopes in properly to the sin6 addr's */ 2050 /* we probably don't need these operations */ 2051 (void)sa6_recoverscope(to6); |
2052 sa6_embedscope(to6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)); | 2052 sa6_embedscope(to6, MODULE_GLOBAL(ip6_use_defzone)); |
2053 break; 2054 } 2055#endif 2056 default: 2057 /* TSNH */ 2058 break; 2059 } 2060 if (sh->v_tag) { --- 250 unchanged lines hidden (view full) --- 2311 } 2312 if (error != 0) { 2313 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); 2314 SCTP_INP_INFO_WUNLOCK(); 2315 return error; 2316 } 2317#endif /* IPSEC */ 2318 SCTP_INCR_EP_COUNT(); | 2053 break; 2054 } 2055#endif 2056 default: 2057 /* TSNH */ 2058 break; 2059 } 2060 if (sh->v_tag) { --- 250 unchanged lines hidden (view full) --- 2311 } 2312 if (error != 0) { 2313 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); 2314 SCTP_INP_INFO_WUNLOCK(); 2315 return error; 2316 } 2317#endif /* IPSEC */ 2318 SCTP_INCR_EP_COUNT(); |
2319 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(MOD_INET, ip_defttl); | 2319 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl); |
2320 SCTP_INP_INFO_WUNLOCK(); 2321 2322 so->so_pcb = (caddr_t)inp; 2323 2324 if ((SCTP_SO_TYPE(so) == SOCK_DGRAM) || 2325 (SCTP_SO_TYPE(so) == SOCK_SEQPACKET)) { 2326 /* UDP style socket */ 2327 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE | --- 355 unchanged lines hidden (view full) --- 2683 if (p && (error = prison_local_ip6(p->td_ucred, &sin6->sin6_addr, 2684 (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) { 2685 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); 2686 return (error); 2687 } 2688 if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { 2689 bindall = 0; 2690 /* KAME hack: embed scopeid */ | 2320 SCTP_INP_INFO_WUNLOCK(); 2321 2322 so->so_pcb = (caddr_t)inp; 2323 2324 if ((SCTP_SO_TYPE(so) == SOCK_DGRAM) || 2325 (SCTP_SO_TYPE(so) == SOCK_SEQPACKET)) { 2326 /* UDP style socket */ 2327 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE | --- 355 unchanged lines hidden (view full) --- 2683 if (p && (error = prison_local_ip6(p->td_ucred, &sin6->sin6_addr, 2684 (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) { 2685 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); 2686 return (error); 2687 } 2688 if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { 2689 bindall = 0; 2690 /* KAME hack: embed scopeid */ |
2691 if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) { | 2691 if (sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone)) != 0) { |
2692 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); 2693 return (EINVAL); 2694 } 2695 } 2696 /* this must be cleared for ifa_ifwithaddr() */ 2697 sin6->sin6_scope_id = 0; 2698 break; 2699 } --- 109 unchanged lines hidden (view full) --- 2809 } 2810 } 2811 } else { 2812 uint16_t first, last, candidate; 2813 uint16_t count; 2814 int done; 2815 2816 if (ip_inp->inp_flags & INP_HIGHPORT) { | 2692 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL); 2693 return (EINVAL); 2694 } 2695 } 2696 /* this must be cleared for ifa_ifwithaddr() */ 2697 sin6->sin6_scope_id = 0; 2698 break; 2699 } --- 109 unchanged lines hidden (view full) --- 2809 } 2810 } 2811 } else { 2812 uint16_t first, last, candidate; 2813 uint16_t count; 2814 int done; 2815 2816 if (ip_inp->inp_flags & INP_HIGHPORT) { |
2817 first = MODULE_GLOBAL(MOD_INET, ipport_hifirstauto); 2818 last = MODULE_GLOBAL(MOD_INET, ipport_hilastauto); | 2817 first = MODULE_GLOBAL(ipport_hifirstauto); 2818 last = MODULE_GLOBAL(ipport_hilastauto); |
2819 } else if (ip_inp->inp_flags & INP_LOWPORT) { 2820 if (p && (error = 2821 priv_check(p, PRIV_NETINET_RESERVEDPORT) 2822 )) { 2823 SCTP_INP_DECR_REF(inp); 2824 SCTP_INP_WUNLOCK(inp); 2825 SCTP_INP_INFO_WUNLOCK(); 2826 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); 2827 return (error); 2828 } | 2819 } else if (ip_inp->inp_flags & INP_LOWPORT) { 2820 if (p && (error = 2821 priv_check(p, PRIV_NETINET_RESERVEDPORT) 2822 )) { 2823 SCTP_INP_DECR_REF(inp); 2824 SCTP_INP_WUNLOCK(inp); 2825 SCTP_INP_INFO_WUNLOCK(); 2826 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error); 2827 return (error); 2828 } |
2829 first = MODULE_GLOBAL(MOD_INET, ipport_lowfirstauto); 2830 last = MODULE_GLOBAL(MOD_INET, ipport_lowlastauto); | 2829 first = MODULE_GLOBAL(ipport_lowfirstauto); 2830 last = MODULE_GLOBAL(ipport_lowlastauto); |
2831 } else { | 2831 } else { |
2832 first = MODULE_GLOBAL(MOD_INET, ipport_firstauto); 2833 last = MODULE_GLOBAL(MOD_INET, ipport_lastauto); | 2832 first = MODULE_GLOBAL(ipport_firstauto); 2833 last = MODULE_GLOBAL(ipport_lastauto); |
2834 } 2835 if (first > last) { 2836 uint16_t temp; 2837 2838 temp = first; 2839 first = last; 2840 last = temp; 2841 } --- 909 unchanged lines hidden (view full) --- 3751 3752 /* Now generate a route for this guy */ 3753#ifdef INET6 3754 /* KAME hack: embed scopeid */ 3755 if (newaddr->sa_family == AF_INET6) { 3756 struct sockaddr_in6 *sin6; 3757 3758 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr; | 2834 } 2835 if (first > last) { 2836 uint16_t temp; 2837 2838 temp = first; 2839 first = last; 2840 last = temp; 2841 } --- 909 unchanged lines hidden (view full) --- 3751 3752 /* Now generate a route for this guy */ 3753#ifdef INET6 3754 /* KAME hack: embed scopeid */ 3755 if (newaddr->sa_family == AF_INET6) { 3756 struct sockaddr_in6 *sin6; 3757 3758 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr; |
3759 (void)sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)); | 3759 (void)sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone)); |
3760 sin6->sin6_scope_id = 0; 3761 } 3762#endif 3763 SCTP_RTALLOC((sctp_route_t *) & net->ro, stcb->asoc.vrf_id); 3764 3765 if (SCTP_ROUTE_HAS_VALID_IFN(&net->ro)) { 3766 /* Get source address */ 3767 net->ro._s_addr = sctp_source_address_selection(stcb->sctp_ep, --- 2923 unchanged lines hidden --- | 3760 sin6->sin6_scope_id = 0; 3761 } 3762#endif 3763 SCTP_RTALLOC((sctp_route_t *) & net->ro, stcb->asoc.vrf_id); 3764 3765 if (SCTP_ROUTE_HAS_VALID_IFN(&net->ro)) { 3766 /* Get source address */ 3767 net->ro._s_addr = sctp_source_address_selection(stcb->sctp_ep, --- 2923 unchanged lines hidden --- |