Deleted Added
full compact
sctp_bsd_addr.c (197955) sctp_bsd_addr.c (208160)
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_output.c,v 1.46 2005/03/06 16:04:17 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_output.c,v 1.46 2005/03/06 16:04:17 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 197955 2009-10-11 12:23:56Z tuexen $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 208160 2010-05-16 17:03:56Z rrs $");
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_var.h>
38#include <netinet/sctp_pcb.h>
39#include <netinet/sctp_header.h>
40#include <netinet/sctputil.h>
41#include <netinet/sctp_output.h>
42#include <netinet/sctp_bsd_addr.h>
43#include <netinet/sctp_uio.h>
44#include <netinet/sctputil.h>
45#include <netinet/sctp_timer.h>
46#include <netinet/sctp_asconf.h>
47#include <netinet/sctp_sysctl.h>
48#include <netinet/sctp_indata.h>
49#include <sys/unistd.h>
50
51/* Declare all of our malloc named types */
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_var.h>
38#include <netinet/sctp_pcb.h>
39#include <netinet/sctp_header.h>
40#include <netinet/sctputil.h>
41#include <netinet/sctp_output.h>
42#include <netinet/sctp_bsd_addr.h>
43#include <netinet/sctp_uio.h>
44#include <netinet/sctputil.h>
45#include <netinet/sctp_timer.h>
46#include <netinet/sctp_asconf.h>
47#include <netinet/sctp_sysctl.h>
48#include <netinet/sctp_indata.h>
49#include <sys/unistd.h>
50
51/* Declare all of our malloc named types */
52
53/* Note to Michael/Peter for mac-os,
54 * I think mac has this too since I
55 * do see the M_PCB type, so I
56 * will also put in the mac file the
57 * MALLOC_DECLARE. If this does not
58 * work for mac uncomment the defines for
59 * the strings that we use in Panda, I put
60 * them in comments in the mac-os file.
61 */
62MALLOC_DEFINE(SCTP_M_MAP, "sctp_map", "sctp asoc map descriptor");
63MALLOC_DEFINE(SCTP_M_STRMI, "sctp_stri", "sctp stream in array");
64MALLOC_DEFINE(SCTP_M_STRMO, "sctp_stro", "sctp stream out array");
65MALLOC_DEFINE(SCTP_M_ASC_ADDR, "sctp_aadr", "sctp asconf address");
66MALLOC_DEFINE(SCTP_M_ASC_IT, "sctp_a_it", "sctp asconf iterator");
67MALLOC_DEFINE(SCTP_M_AUTH_CL, "sctp_atcl", "sctp auth chunklist");
68MALLOC_DEFINE(SCTP_M_AUTH_KY, "sctp_atky", "sctp auth key");
69MALLOC_DEFINE(SCTP_M_AUTH_HL, "sctp_athm", "sctp auth hmac list");

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

74MALLOC_DEFINE(SCTP_M_VRF, "sctp_vrf", "sctp vrf struct");
75MALLOC_DEFINE(SCTP_M_IFA, "sctp_ifa", "sctp ifa struct");
76MALLOC_DEFINE(SCTP_M_IFN, "sctp_ifn", "sctp ifn struct");
77MALLOC_DEFINE(SCTP_M_TIMW, "sctp_timw", "sctp time block");
78MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list");
79MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control");
80MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option");
81
52MALLOC_DEFINE(SCTP_M_MAP, "sctp_map", "sctp asoc map descriptor");
53MALLOC_DEFINE(SCTP_M_STRMI, "sctp_stri", "sctp stream in array");
54MALLOC_DEFINE(SCTP_M_STRMO, "sctp_stro", "sctp stream out array");
55MALLOC_DEFINE(SCTP_M_ASC_ADDR, "sctp_aadr", "sctp asconf address");
56MALLOC_DEFINE(SCTP_M_ASC_IT, "sctp_a_it", "sctp asconf iterator");
57MALLOC_DEFINE(SCTP_M_AUTH_CL, "sctp_atcl", "sctp auth chunklist");
58MALLOC_DEFINE(SCTP_M_AUTH_KY, "sctp_atky", "sctp auth key");
59MALLOC_DEFINE(SCTP_M_AUTH_HL, "sctp_athm", "sctp auth hmac list");

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

64MALLOC_DEFINE(SCTP_M_VRF, "sctp_vrf", "sctp vrf struct");
65MALLOC_DEFINE(SCTP_M_IFA, "sctp_ifa", "sctp ifa struct");
66MALLOC_DEFINE(SCTP_M_IFN, "sctp_ifn", "sctp ifn struct");
67MALLOC_DEFINE(SCTP_M_TIMW, "sctp_timw", "sctp time block");
68MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list");
69MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control");
70MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option");
71
82#if defined(SCTP_USE_THREAD_BASED_ITERATOR)
72/* Global NON-VNET structure that controls the iterator */
73struct iterator_control sctp_it_ctl;
74static int __sctp_thread_based_iterator_started = 0;
75
76
77static void
78sctp_cleanup_itqueue(void)
79{
80 struct sctp_iterator *it;
81
82 while ((it = TAILQ_FIRST(&sctp_it_ctl.iteratorhead)) != NULL) {
83 if (it->function_atend != NULL) {
84 (*it->function_atend) (it->pointer, it->val);
85 }
86 TAILQ_REMOVE(&sctp_it_ctl.iteratorhead, it, sctp_nxt_itr);
87 SCTP_FREE(it, SCTP_M_ITER);
88 }
89}
90
91
83void
84sctp_wakeup_iterator(void)
85{
92void
93sctp_wakeup_iterator(void)
94{
86 wakeup(&SCTP_BASE_INFO(iterator_running));
95 wakeup(&sctp_it_ctl.iterator_running);
87}
88
89static void
90sctp_iterator_thread(void *v)
91{
96}
97
98static void
99sctp_iterator_thread(void *v)
100{
92 CURVNET_SET((struct vnet *)v);
93 SCTP_IPI_ITERATOR_WQ_LOCK();
101 SCTP_IPI_ITERATOR_WQ_LOCK();
94 SCTP_BASE_INFO(iterator_running) = 0;
95 while (1) {
102 while (1) {
96 msleep(&SCTP_BASE_INFO(iterator_running),
97 &SCTP_BASE_INFO(ipi_iterator_wq_mtx),
103 msleep(&sctp_it_ctl.iterator_running,
104 &sctp_it_ctl.ipi_iterator_wq_mtx,
98 0, "waiting_for_work", 0);
105 0, "waiting_for_work", 0);
99 if (SCTP_BASE_INFO(threads_must_exit)) {
106 if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) {
100 SCTP_IPI_ITERATOR_WQ_DESTROY();
107 SCTP_IPI_ITERATOR_WQ_DESTROY();
108 SCTP_ITERATOR_LOCK_DESTROY();
109 sctp_cleanup_itqueue();
110 __sctp_thread_based_iterator_started = 0;
101 kthread_exit();
102 }
103 sctp_iterator_worker();
104 }
111 kthread_exit();
112 }
113 sctp_iterator_worker();
114 }
105 CURVNET_RESTORE();
106}
107
108void
109sctp_startup_iterator(void)
110{
115}
116
117void
118sctp_startup_iterator(void)
119{
120 if (__sctp_thread_based_iterator_started) {
121 /* You only get one */
122 return;
123 }
124 /* init the iterator head */
125 __sctp_thread_based_iterator_started = 1;
126 sctp_it_ctl.iterator_running = 0;
127 sctp_it_ctl.iterator_flags = 0;
128 sctp_it_ctl.cur_it = NULL;
129 SCTP_ITERATOR_LOCK_INIT();
130 SCTP_IPI_ITERATOR_WQ_INIT();
131 TAILQ_INIT(&sctp_it_ctl.iteratorhead);
132
111 int ret;
112
113 ret = kproc_create(sctp_iterator_thread,
133 int ret;
134
135 ret = kproc_create(sctp_iterator_thread,
114 (void *)curvnet,
115 &SCTP_BASE_INFO(thread_proc),
136 (void *)NULL,
137 &sctp_it_ctl.thread_proc,
116 RFPROC,
117 SCTP_KTHREAD_PAGES,
118 SCTP_KTRHEAD_NAME);
119}
120
138 RFPROC,
139 SCTP_KTHREAD_PAGES,
140 SCTP_KTRHEAD_NAME);
141}
142
121#endif
122
123#ifdef INET6
124
125void
126sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
127{
128 struct in6_ifaddr *ifa6;
129

--- 412 unchanged lines hidden ---
143
144#ifdef INET6
145
146void
147sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
148{
149 struct in6_ifaddr *ifa6;
150

--- 412 unchanged lines hidden ---