Deleted Added
full compact
sctp_pcb.c (179803) sctp_pcb.c (180387)
1/*-
2 * Copyright (c) 2001-2007, 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-2007, 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 179803 2008-06-15 12:31:23Z rrs $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 180387 2008-07-09 16:45:30Z 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>

--- 11 unchanged lines hidden (view full) ---

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));
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>

--- 11 unchanged lines hidden (view full) ---

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, ip6_use_defzone) != 0) {
62 if (sa6_embedscope(&tmp_a, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, 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, ip6_use_defzone) != 0) {
66 if (sa6_embedscope(&tmp_b, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, 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

--- 1814 unchanged lines hidden (view full) ---

1889 bzero(from6, sizeof(*from6));
1890 from6->sin6_family = AF_INET6;
1891 from6->sin6_len = sizeof(struct sockaddr_in6);
1892 from6->sin6_addr = ip6->ip6_src;
1893 from6->sin6_port = sh->src_port;
1894 /* Get the scopes in properly to the sin6 addr's */
1895 /* we probably don't need these operations */
1896 (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

--- 1814 unchanged lines hidden (view full) ---

1889 bzero(from6, sizeof(*from6));
1890 from6->sin6_family = AF_INET6;
1891 from6->sin6_len = sizeof(struct sockaddr_in6);
1892 from6->sin6_addr = ip6->ip6_src;
1893 from6->sin6_port = sh->src_port;
1894 /* Get the scopes in properly to the sin6 addr's */
1895 /* we probably don't need these operations */
1896 (void)sa6_recoverscope(from6);
1897 sa6_embedscope(from6, ip6_use_defzone);
1897 sa6_embedscope(from6, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)));
1898 break;
1899 }
1900#endif
1901 default:
1902 /* Currently not supported. */
1903 return (NULL);
1904 }
1905 if (sh->v_tag) {

--- 30 unchanged lines hidden (view full) ---

1936 bzero(to6, sizeof(*to6));
1937 to6->sin6_family = AF_INET6;
1938 to6->sin6_len = sizeof(struct sockaddr_in6);
1939 to6->sin6_addr = ip6->ip6_dst;
1940 to6->sin6_port = sh->dest_port;
1941 /* Get the scopes in properly to the sin6 addr's */
1942 /* we probably don't need these operations */
1943 (void)sa6_recoverscope(to6);
1898 break;
1899 }
1900#endif
1901 default:
1902 /* Currently not supported. */
1903 return (NULL);
1904 }
1905 if (sh->v_tag) {

--- 30 unchanged lines hidden (view full) ---

1936 bzero(to6, sizeof(*to6));
1937 to6->sin6_family = AF_INET6;
1938 to6->sin6_len = sizeof(struct sockaddr_in6);
1939 to6->sin6_addr = ip6->ip6_dst;
1940 to6->sin6_port = sh->dest_port;
1941 /* Get the scopes in properly to the sin6 addr's */
1942 /* we probably don't need these operations */
1943 (void)sa6_recoverscope(to6);
1944 sa6_embedscope(to6, ip6_use_defzone);
1944 sa6_embedscope(to6, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)));
1945 break;
1946 }
1947#endif
1948 default:
1949 /* TSNH */
1950 break;
1951 }
1952 find_tcp_pool = 0;

--- 235 unchanged lines hidden (view full) ---

2188 }
2189 if (error != 0) {
2190 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2191 SCTP_INP_INFO_WUNLOCK();
2192 return error;
2193 }
2194#endif /* IPSEC */
2195 SCTP_INCR_EP_COUNT();
1945 break;
1946 }
1947#endif
1948 default:
1949 /* TSNH */
1950 break;
1951 }
1952 find_tcp_pool = 0;

--- 235 unchanged lines hidden (view full) ---

2188 }
2189 if (error != 0) {
2190 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp);
2191 SCTP_INP_INFO_WUNLOCK();
2192 return error;
2193 }
2194#endif /* IPSEC */
2195 SCTP_INCR_EP_COUNT();
2196 inp->ip_inp.inp.inp_ip_ttl = ip_defttl;
2196 inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(MOD_INET, ip_defttl);
2197 SCTP_INP_INFO_WUNLOCK();
2198
2199 so->so_pcb = (caddr_t)inp;
2200
2201 if ((SCTP_SO_TYPE(so) == SOCK_DGRAM) ||
2202 (SCTP_SO_TYPE(so) == SOCK_SEQPACKET)) {
2203 /* UDP style socket */
2204 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |

--- 396 unchanged lines hidden (view full) ---

2601 * Jail checks for IPv6 should go HERE! i.e.
2602 * add the prison_ip() equivilant in this
2603 * postion to transmute the addresses to the
2604 * proper one jailed.
2605 */
2606 if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2607 bindall = 0;
2608 /* KAME hack: embed scopeid */
2197 SCTP_INP_INFO_WUNLOCK();
2198
2199 so->so_pcb = (caddr_t)inp;
2200
2201 if ((SCTP_SO_TYPE(so) == SOCK_DGRAM) ||
2202 (SCTP_SO_TYPE(so) == SOCK_SEQPACKET)) {
2203 /* UDP style socket */
2204 inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |

--- 396 unchanged lines hidden (view full) ---

2601 * Jail checks for IPv6 should go HERE! i.e.
2602 * add the prison_ip() equivilant in this
2603 * postion to transmute the addresses to the
2604 * proper one jailed.
2605 */
2606 if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
2607 bindall = 0;
2608 /* KAME hack: embed scopeid */
2609 if (sa6_embedscope(sin6, ip6_use_defzone) != 0) {
2609 if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
2610 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2611 return (EINVAL);
2612 }
2613 }
2614 /* this must be cleared for ifa_ifwithaddr() */
2615 sin6->sin6_scope_id = 0;
2616 break;
2617 }

--- 83 unchanged lines hidden (view full) ---

2701 }
2702 }
2703 } else {
2704 uint16_t first, last, candidate;
2705 uint16_t count;
2706 int done;
2707
2708 if (ip_inp->inp_flags & INP_HIGHPORT) {
2610 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2611 return (EINVAL);
2612 }
2613 }
2614 /* this must be cleared for ifa_ifwithaddr() */
2615 sin6->sin6_scope_id = 0;
2616 break;
2617 }

--- 83 unchanged lines hidden (view full) ---

2701 }
2702 }
2703 } else {
2704 uint16_t first, last, candidate;
2705 uint16_t count;
2706 int done;
2707
2708 if (ip_inp->inp_flags & INP_HIGHPORT) {
2709 first = ipport_hifirstauto;
2710 last = ipport_hilastauto;
2709 first = MODULE_GLOBAL(MOD_INET, ipport_hifirstauto);
2710 last = MODULE_GLOBAL(MOD_INET, ipport_hilastauto);
2711 } else if (ip_inp->inp_flags & INP_LOWPORT) {
2712 if (p && (error =
2713 priv_check(p, PRIV_NETINET_RESERVEDPORT)
2714 )) {
2715 SCTP_INP_DECR_REF(inp);
2716 SCTP_INP_WUNLOCK(inp);
2717 SCTP_INP_INFO_WUNLOCK();
2718 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2719 return (error);
2720 }
2711 } else if (ip_inp->inp_flags & INP_LOWPORT) {
2712 if (p && (error =
2713 priv_check(p, PRIV_NETINET_RESERVEDPORT)
2714 )) {
2715 SCTP_INP_DECR_REF(inp);
2716 SCTP_INP_WUNLOCK(inp);
2717 SCTP_INP_INFO_WUNLOCK();
2718 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
2719 return (error);
2720 }
2721 first = ipport_lowfirstauto;
2722 last = ipport_lowlastauto;
2721 first = MODULE_GLOBAL(MOD_INET, ipport_lowfirstauto);
2722 last = MODULE_GLOBAL(MOD_INET, ipport_lowlastauto);
2723 } else {
2724 first = ipport_firstauto;
2725 last = ipport_lastauto;
2726 }
2727 if (first > last) {
2728 uint16_t temp;
2729
2730 temp = first;

--- 899 unchanged lines hidden (view full) ---

3630
3631 /* Now generate a route for this guy */
3632#ifdef INET6
3633 /* KAME hack: embed scopeid */
3634 if (newaddr->sa_family == AF_INET6) {
3635 struct sockaddr_in6 *sin6;
3636
3637 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
2723 } else {
2724 first = ipport_firstauto;
2725 last = ipport_lastauto;
2726 }
2727 if (first > last) {
2728 uint16_t temp;
2729
2730 temp = first;

--- 899 unchanged lines hidden (view full) ---

3630
3631 /* Now generate a route for this guy */
3632#ifdef INET6
3633 /* KAME hack: embed scopeid */
3634 if (newaddr->sa_family == AF_INET6) {
3635 struct sockaddr_in6 *sin6;
3636
3637 sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
3638 (void)sa6_embedscope(sin6, ip6_use_defzone);
3638 (void)sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
3639 sin6->sin6_scope_id = 0;
3640 }
3641#endif
3642 SCTP_RTALLOC((sctp_route_t *) & net->ro, stcb->asoc.vrf_id);
3643
3644 if (SCTP_ROUTE_HAS_VALID_IFN(&net->ro)) {
3645 /* Get source address */
3646 net->ro._s_addr = sctp_source_address_selection(stcb->sctp_ep,

--- 1705 unchanged lines hidden (view full) ---

5352 struct sctp_vrflist *vrf_bucket;
5353 struct sctp_vrf *vrf;
5354 struct sctp_ifn *ifn;
5355 struct sctp_ifa *ifa;
5356 struct sctpvtaghead *chain;
5357 struct sctp_tagblock *twait_block, *prev_twait_block;
5358 int i;
5359
3639 sin6->sin6_scope_id = 0;
3640 }
3641#endif
3642 SCTP_RTALLOC((sctp_route_t *) & net->ro, stcb->asoc.vrf_id);
3643
3644 if (SCTP_ROUTE_HAS_VALID_IFN(&net->ro)) {
3645 /* Get source address */
3646 net->ro._s_addr = sctp_source_address_selection(stcb->sctp_ep,

--- 1705 unchanged lines hidden (view full) ---

5352 struct sctp_vrflist *vrf_bucket;
5353 struct sctp_vrf *vrf;
5354 struct sctp_ifn *ifn;
5355 struct sctp_ifa *ifa;
5356 struct sctpvtaghead *chain;
5357 struct sctp_tagblock *twait_block, *prev_twait_block;
5358 int i;
5359
5360 /* FIXME MT */
5361 SCTP_BASE_INFO(threads_must_exit) = 1;
5362#if defined(SCTP_USE_THREAD_BASED_ITERATOR)
5363 /* Wake the thread up so it will exit now */
5364 sctp_wakeup_iterator();
5365#endif
5366 /*
5367 * free the vrf/ifn/ifa lists and hashes (be sure address monitor is
5368 * destroyed first).
5369 */
5370 vrf_bucket = &SCTP_BASE_INFO(sctp_vrfhash)[(SCTP_DEFAULT_VRFID & SCTP_BASE_INFO(hashvrfmark))];
5371 vrf = LIST_FIRST(vrf_bucket);
5372 while (vrf) {
5373 ifn = LIST_FIRST(&vrf->ifnlist);

--- 1103 unchanged lines hidden ---
5360 /*
5361 * free the vrf/ifn/ifa lists and hashes (be sure address monitor is
5362 * destroyed first).
5363 */
5364 vrf_bucket = &SCTP_BASE_INFO(sctp_vrfhash)[(SCTP_DEFAULT_VRFID & SCTP_BASE_INFO(hashvrfmark))];
5365 vrf = LIST_FIRST(vrf_bucket);
5366 while (vrf) {
5367 ifn = LIST_FIRST(&vrf->ifnlist);

--- 1103 unchanged lines hidden ---