Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/inet/sockmods/sockmod_sctp.c
+++ new/usr/src/uts/common/inet/sockmods/sockmod_sctp.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #include <sys/sysmacros.h>
28 28 #include <sys/strsubr.h>
29 29 #include <sys/socket.h>
30 30 #include <sys/socketvar.h>
31 31 #include <sys/modctl.h>
32 32 #include <sys/cmn_err.h>
33 33 #include <netinet/sctp.h>
34 34 #include <fs/sockfs/sockcommon.h>
35 35 #include "socksctp.h"
36 36
37 37 struct sonode *socksctp_create(struct sockparams *, int, int, int,
38 38 int, int, int *, cred_t *);
39 39 void socksctp_destroy(struct sonode *);
40 40
41 41 static int socksctp_constructor(void *, void *, int);
42 42 static void socksctp_destructor(void *, void *);
43 43
44 44 static __smod_priv_t sosctp_priv = {
45 45 socksctp_create,
46 46 socksctp_destroy,
47 47 NULL
48 48 };
49 49
50 50 static smod_reg_t sinfo = {
51 51 SOCKMOD_VERSION,
52 52 "socksctp",
53 53 SOCK_UC_VERSION,
54 54 SOCK_DC_VERSION,
55 55 NULL,
56 56 &sosctp_priv
57 57 };
58 58
59 59 kmem_cache_t *sosctp_assoccache;
60 60 static kmem_cache_t *sosctp_sockcache;
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
61 61
62 62 /*
63 63 * Module linkage information for the kernel.
64 64 */
65 65 static struct modlsockmod modlsockmod = {
66 66 &mod_sockmodops, "SCTP socket module", &sinfo
67 67 };
68 68
69 69 static struct modlinkage modlinkage = {
70 70 MODREV_1,
71 - &modlsockmod,
72 - NULL
71 + { &modlsockmod, NULL }
73 72 };
74 73
75 74 static int
76 75 socksctp_init(void)
77 76 {
78 77 sosctp_sockcache = kmem_cache_create("sctpsock",
79 78 sizeof (struct sctp_sonode), 0, socksctp_constructor,
80 79 socksctp_destructor, NULL, NULL, NULL, 0);
81 80 sosctp_assoccache = kmem_cache_create("sctp_assoc",
82 81 sizeof (struct sctp_soassoc), 0, NULL, NULL, NULL, NULL, NULL, 0);
83 82 return (0);
84 83 }
85 84
86 85 static void
87 86 socksctp_fini(void)
88 87 {
89 88 kmem_cache_destroy(sosctp_sockcache);
90 89 kmem_cache_destroy(sosctp_assoccache);
91 90 }
92 91
93 92 /*ARGSUSED*/
94 93 static int
95 94 socksctp_constructor(void *buf, void *cdrarg, int kmflags)
96 95 {
97 96 struct sctp_sonode *ss = buf;
98 97 struct sonode *so = &ss->ss_so;
99 98
100 99 ss->ss_type = SOSCTP_SOCKET;
101 100 return (sonode_constructor((void *)so, cdrarg, kmflags));
102 101 }
103 102
104 103 /*ARGSUSED*/
105 104 static void
106 105 socksctp_destructor(void *buf, void *cdrarg)
107 106 {
108 107 struct sctp_sonode *ss = buf;
109 108 struct sonode *so = &ss->ss_so;
110 109
111 110 sonode_destructor((void *)so, cdrarg);
112 111 }
113 112
114 113 /*
115 114 * Creates a sctp socket data structure.
116 115 */
117 116 /* ARGSUSED */
118 117 struct sonode *
119 118 socksctp_create(struct sockparams *sp, int family, int type, int protocol,
120 119 int version, int sflags, int *errorp, cred_t *cr)
121 120 {
122 121 struct sctp_sonode *ss;
123 122 struct sonode *so;
124 123 int kmflags = (sflags & SOCKET_NOSLEEP) ? KM_NOSLEEP : KM_SLEEP;
125 124
126 125 if (version == SOV_STREAM) {
127 126 *errorp = EINVAL;
128 127 return (NULL);
129 128 }
130 129
131 130 /*
132 131 * We only support two types of SCTP socket. Let sotpi_create()
133 132 * handle all other cases, such as raw socket.
134 133 */
135 134 if (!(family == AF_INET || family == AF_INET6) ||
136 135 !(type == SOCK_STREAM || type == SOCK_SEQPACKET)) {
137 136 *errorp = EINVAL;
138 137 return (NULL);
139 138 }
140 139
141 140 ss = kmem_cache_alloc(sosctp_sockcache, kmflags);
142 141 if (ss == NULL) {
143 142 *errorp = ENOMEM;
144 143 return (NULL);
145 144 }
146 145
147 146 so = &ss->ss_so;
148 147
149 148 ss->ss_maxassoc = 0;
150 149 ss->ss_assoccnt = 0;
151 150 ss->ss_assocs = NULL;
152 151
153 152 if (type == SOCK_STREAM) {
154 153 sonode_init(so, sp, family, type, protocol,
155 154 &sosctp_sonodeops);
156 155 } else {
157 156 sonode_init(so, sp, family, type, protocol,
158 157 &sosctp_seq_sonodeops);
159 158 ASSERT(type == SOCK_SEQPACKET);
160 159 mutex_enter(&so->so_lock);
161 160 (void) sosctp_aid_grow(ss, 1, kmflags);
162 161 mutex_exit(&so->so_lock);
163 162 }
164 163
165 164 if (version == SOV_DEFAULT) {
166 165 version = so_default_version;
167 166 }
168 167 so->so_version = (short)version;
169 168
170 169 dprint(2, ("sosctp_create: %p domain %d type %d\n", (void *)so, family,
171 170 type));
172 171
173 172 /*
174 173 * set the default values to be INFPSZ
175 174 * if a protocol desires it can change the value later
176 175 */
177 176 so->so_proto_props.sopp_rxhiwat = SOCKET_RECVHIWATER;
178 177 so->so_proto_props.sopp_rxlowat = SOCKET_RECVLOWATER;
179 178 so->so_proto_props.sopp_maxpsz = INFPSZ;
180 179 so->so_proto_props.sopp_maxblk = INFPSZ;
181 180
182 181 return (so);
183 182 }
184 183
185 184 /*
186 185 * Free SCTP socket data structure.
187 186 */
188 187 void
189 188 socksctp_destroy(struct sonode *so)
190 189 {
191 190 struct sctp_sonode *ss;
192 191
193 192 ASSERT((so->so_type == SOCK_STREAM || so->so_type == SOCK_SEQPACKET) &&
194 193 so->so_protocol == IPPROTO_SCTP);
195 194
196 195 sosctp_fini(so, CRED());
197 196
198 197 ss = SOTOSSO(so);
199 198 kmem_cache_free(sosctp_sockcache, ss);
200 199 }
201 200
202 201 int
203 202 _init(void)
204 203 {
205 204 int error = 0;
206 205
207 206 (void) socksctp_init();
208 207
209 208 if ((error = mod_install(&modlinkage)) != 0)
210 209 socksctp_fini();
211 210
212 211 return (error);
213 212 }
214 213
215 214 int
216 215 _fini(void)
217 216 {
218 217 int error = 0;
219 218
220 219 if ((error = mod_remove(&modlinkage)) == 0)
221 220 socksctp_fini();
222 221
223 222 return (error);
224 223 }
225 224
226 225 int
227 226 _info(struct modinfo *modinfop)
228 227 {
229 228 return (mod_info(&modlinkage, modinfop));
230 229 }
↓ open down ↓ |
148 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX