Commit | Line | Data |
---|---|---|
d7e09d03 PT |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 only, | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License version 2 for more details (a copy is included | |
14 | * in the LICENSE file that accompanied this code). | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * version 2 along with this program; If not, see | |
18 | * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf | |
19 | * | |
20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
21 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
22 | * have any questions. | |
23 | * | |
24 | * GPL HEADER END | |
25 | */ | |
26 | /* | |
27 | * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. | |
28 | * Use is subject to license terms. | |
29 | * | |
1dc563a6 | 30 | * Copyright (c) 2011, 2015, Intel Corporation. |
d7e09d03 PT |
31 | */ |
32 | /* | |
33 | * This file is part of Lustre, http://www.lustre.org/ | |
34 | * Lustre is a trademark of Sun Microsystems, Inc. | |
35 | */ | |
36 | ||
37 | #define DEBUG_SUBSYSTEM S_LNET | |
2f4246f7 | 38 | #include <linux/completion.h> |
9fdaf8c0 | 39 | #include "../../include/linux/lnet/lib-lnet.h" |
d7e09d03 | 40 | |
d7e09d03 PT |
41 | static int accept_port = 988; |
42 | static int accept_backlog = 127; | |
43 | static int accept_timeout = 5; | |
44 | ||
c49d4b96 | 45 | static struct { |
d7e09d03 | 46 | int pta_shutdown; |
e327dc88 | 47 | struct socket *pta_sock; |
d7e09d03 PT |
48 | struct completion pta_signal; |
49 | } lnet_acceptor_state; | |
50 | ||
51 | int | |
52 | lnet_acceptor_port(void) | |
53 | { | |
54 | return accept_port; | |
55 | } | |
735c2e26 | 56 | EXPORT_SYMBOL(lnet_acceptor_port); |
d7e09d03 PT |
57 | |
58 | static inline int | |
59 | lnet_accept_magic(__u32 magic, __u32 constant) | |
60 | { | |
61 | return (magic == constant || | |
62 | magic == __swab32(constant)); | |
63 | } | |
64 | ||
d7e09d03 PT |
65 | static char *accept = "secure"; |
66 | ||
8cc7b4b9 PT |
67 | module_param(accept, charp, 0444); |
68 | MODULE_PARM_DESC(accept, "Accept connections (secure|all|none)"); | |
69 | module_param(accept_port, int, 0444); | |
70 | MODULE_PARM_DESC(accept_port, "Acceptor's port (same on all nodes)"); | |
71 | module_param(accept_backlog, int, 0444); | |
72 | MODULE_PARM_DESC(accept_backlog, "Acceptor's listen backlog"); | |
73 | module_param(accept_timeout, int, 0644); | |
74 | MODULE_PARM_DESC(accept_timeout, "Acceptor's timeout (seconds)"); | |
d7e09d03 | 75 | |
9f100b8b | 76 | static char *accept_type; |
d7e09d03 | 77 | |
c49d4b96 | 78 | static int |
d7e09d03 PT |
79 | lnet_acceptor_get_tunables(void) |
80 | { | |
4420cfd3 JS |
81 | /* |
82 | * Userland acceptor uses 'accept_type' instead of 'accept', due to | |
d7e09d03 | 83 | * conflict with 'accept(2)', but kernel acceptor still uses 'accept' |
4420cfd3 JS |
84 | * for compatibility. Hence the trick. |
85 | */ | |
d7e09d03 PT |
86 | accept_type = accept; |
87 | return 0; | |
88 | } | |
89 | ||
90 | int | |
91 | lnet_acceptor_timeout(void) | |
92 | { | |
93 | return accept_timeout; | |
94 | } | |
95 | EXPORT_SYMBOL(lnet_acceptor_timeout); | |
96 | ||
97 | void | |
f93c0616 | 98 | lnet_connect_console_error(int rc, lnet_nid_t peer_nid, |
d7e09d03 PT |
99 | __u32 peer_ip, int peer_port) |
100 | { | |
101 | switch (rc) { | |
102 | /* "normal" errors */ | |
103 | case -ECONNREFUSED: | |
5129097b | 104 | CNETERR("Connection to %s at host %pI4h on port %d was refused: check that Lustre is running on that node.\n", |
d7e09d03 | 105 | libcfs_nid2str(peer_nid), |
5e8f6920 | 106 | &peer_ip, peer_port); |
d7e09d03 PT |
107 | break; |
108 | case -EHOSTUNREACH: | |
109 | case -ENETUNREACH: | |
5129097b | 110 | CNETERR("Connection to %s at host %pI4h was unreachable: the network or that node may be down, or Lustre may be misconfigured.\n", |
5e8f6920 | 111 | libcfs_nid2str(peer_nid), &peer_ip); |
d7e09d03 PT |
112 | break; |
113 | case -ETIMEDOUT: | |
5129097b | 114 | CNETERR("Connection to %s at host %pI4h on port %d took too long: that node may be hung or experiencing high load.\n", |
d7e09d03 | 115 | libcfs_nid2str(peer_nid), |
5e8f6920 | 116 | &peer_ip, peer_port); |
d7e09d03 PT |
117 | break; |
118 | case -ECONNRESET: | |
5129097b | 119 | LCONSOLE_ERROR_MSG(0x11b, "Connection to %s at host %pI4h on port %d was reset: is it running a compatible version of Lustre and is %s one of its NIDs?\n", |
d7e09d03 | 120 | libcfs_nid2str(peer_nid), |
5e8f6920 | 121 | &peer_ip, peer_port, |
d7e09d03 PT |
122 | libcfs_nid2str(peer_nid)); |
123 | break; | |
124 | case -EPROTO: | |
5129097b | 125 | LCONSOLE_ERROR_MSG(0x11c, "Protocol error connecting to %s at host %pI4h on port %d: is it running a compatible version of Lustre?\n", |
d7e09d03 | 126 | libcfs_nid2str(peer_nid), |
5e8f6920 | 127 | &peer_ip, peer_port); |
d7e09d03 PT |
128 | break; |
129 | case -EADDRINUSE: | |
5129097b RK |
130 | LCONSOLE_ERROR_MSG(0x11d, "No privileged ports available to connect to %s at host %pI4h on port %d\n", |
131 | libcfs_nid2str(peer_nid), | |
5e8f6920 | 132 | &peer_ip, peer_port); |
d7e09d03 PT |
133 | break; |
134 | default: | |
5129097b RK |
135 | LCONSOLE_ERROR_MSG(0x11e, "Unexpected error %d connecting to %s at host %pI4h on port %d\n", |
136 | rc, libcfs_nid2str(peer_nid), | |
5e8f6920 | 137 | &peer_ip, peer_port); |
d7e09d03 PT |
138 | break; |
139 | } | |
140 | } | |
141 | EXPORT_SYMBOL(lnet_connect_console_error); | |
142 | ||
143 | int | |
e327dc88 | 144 | lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, |
c314c319 | 145 | __u32 local_ip, __u32 peer_ip, int peer_port) |
d7e09d03 PT |
146 | { |
147 | lnet_acceptor_connreq_t cr; | |
7e7ab095 MS |
148 | struct socket *sock; |
149 | int rc; | |
150 | int port; | |
151 | int fatal; | |
d7e09d03 | 152 | |
f93c0616 | 153 | CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */ |
d7e09d03 PT |
154 | |
155 | for (port = LNET_ACCEPTOR_MAX_RESERVED_PORT; | |
156 | port >= LNET_ACCEPTOR_MIN_RESERVED_PORT; | |
157 | --port) { | |
158 | /* Iterate through reserved ports. */ | |
159 | ||
1ad6a73e JS |
160 | rc = lnet_sock_connect(&sock, &fatal, local_ip, port, peer_ip, |
161 | peer_port); | |
d7e09d03 PT |
162 | if (rc != 0) { |
163 | if (fatal) | |
164 | goto failed; | |
165 | continue; | |
166 | } | |
167 | ||
f93c0616 | 168 | CLASSERT(LNET_PROTO_ACCEPTOR_VERSION == 1); |
d7e09d03 PT |
169 | |
170 | cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; | |
171 | cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; | |
172 | cr.acr_nid = peer_nid; | |
173 | ||
174 | if (the_lnet.ln_testprotocompat != 0) { | |
175 | /* single-shot proto check */ | |
176 | lnet_net_lock(LNET_LOCK_EX); | |
177 | if ((the_lnet.ln_testprotocompat & 4) != 0) { | |
178 | cr.acr_version++; | |
179 | the_lnet.ln_testprotocompat &= ~4; | |
180 | } | |
181 | if ((the_lnet.ln_testprotocompat & 8) != 0) { | |
182 | cr.acr_magic = LNET_PROTO_MAGIC; | |
183 | the_lnet.ln_testprotocompat &= ~8; | |
184 | } | |
185 | lnet_net_unlock(LNET_LOCK_EX); | |
186 | } | |
187 | ||
1ad6a73e | 188 | rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout); |
d7e09d03 PT |
189 | if (rc != 0) |
190 | goto failed_sock; | |
191 | ||
192 | *sockp = sock; | |
193 | return 0; | |
194 | } | |
195 | ||
196 | rc = -EADDRINUSE; | |
197 | goto failed; | |
198 | ||
199 | failed_sock: | |
e52fc91d | 200 | sock_release(sock); |
d7e09d03 PT |
201 | failed: |
202 | lnet_connect_console_error(rc, peer_nid, peer_ip, peer_port); | |
203 | return rc; | |
204 | } | |
205 | EXPORT_SYMBOL(lnet_connect); | |
206 | ||
d7e09d03 PT |
207 | /* Below is the code common for both kernel and MT user-space */ |
208 | ||
c49d4b96 | 209 | static int |
e327dc88 | 210 | lnet_accept(struct socket *sock, __u32 magic) |
d7e09d03 PT |
211 | { |
212 | lnet_acceptor_connreq_t cr; | |
7e7ab095 MS |
213 | __u32 peer_ip; |
214 | int peer_port; | |
215 | int rc; | |
216 | int flip; | |
217 | lnet_ni_t *ni; | |
218 | char *str; | |
d7e09d03 | 219 | |
f93c0616 | 220 | LASSERT(sizeof(cr) <= 16); /* not too big for the stack */ |
d7e09d03 | 221 | |
1ad6a73e | 222 | rc = lnet_sock_getaddr(sock, 1, &peer_ip, &peer_port); |
f93c0616 | 223 | LASSERT(rc == 0); /* we succeeded before */ |
d7e09d03 PT |
224 | |
225 | if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) { | |
d7e09d03 | 226 | if (lnet_accept_magic(magic, LNET_PROTO_MAGIC)) { |
4420cfd3 JS |
227 | /* |
228 | * future version compatibility! | |
d7e09d03 | 229 | * When LNET unifies protocols over all LNDs, the first |
4420cfd3 JS |
230 | * thing sent will be a version query. I send back |
231 | * LNET_PROTO_ACCEPTOR_MAGIC to tell her I'm "old" | |
232 | */ | |
f93c0616 | 233 | memset(&cr, 0, sizeof(cr)); |
d7e09d03 PT |
234 | cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; |
235 | cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; | |
1ad6a73e JS |
236 | rc = lnet_sock_write(sock, &cr, sizeof(cr), |
237 | accept_timeout); | |
d7e09d03 PT |
238 | |
239 | if (rc != 0) | |
5129097b | 240 | CERROR("Error sending magic+version in response to LNET magic from %pI4h: %d\n", |
5e8f6920 | 241 | &peer_ip, rc); |
d7e09d03 PT |
242 | return -EPROTO; |
243 | } | |
244 | ||
245 | if (magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) | |
246 | str = "'old' socknal/tcpnal"; | |
d7e09d03 PT |
247 | else |
248 | str = "unrecognised"; | |
249 | ||
5129097b | 250 | LCONSOLE_ERROR_MSG(0x11f, "Refusing connection from %pI4h magic %08x: %s acceptor protocol\n", |
5e8f6920 | 251 | &peer_ip, magic, str); |
d7e09d03 PT |
252 | return -EPROTO; |
253 | } | |
254 | ||
255 | flip = (magic != LNET_PROTO_ACCEPTOR_MAGIC); | |
256 | ||
1ad6a73e JS |
257 | rc = lnet_sock_read(sock, &cr.acr_version, sizeof(cr.acr_version), |
258 | accept_timeout); | |
d7e09d03 | 259 | if (rc != 0) { |
5129097b | 260 | CERROR("Error %d reading connection request version from %pI4h\n", |
c314c319 | 261 | rc, &peer_ip); |
d7e09d03 PT |
262 | return -EIO; |
263 | } | |
264 | ||
265 | if (flip) | |
266 | __swab32s(&cr.acr_version); | |
267 | ||
268 | if (cr.acr_version != LNET_PROTO_ACCEPTOR_VERSION) { | |
4420cfd3 JS |
269 | /* |
270 | * future version compatibility! | |
d7e09d03 PT |
271 | * An acceptor-specific protocol rev will first send a version |
272 | * query. I send back my current version to tell her I'm | |
4420cfd3 JS |
273 | * "old". |
274 | */ | |
d7e09d03 PT |
275 | int peer_version = cr.acr_version; |
276 | ||
f93c0616 | 277 | memset(&cr, 0, sizeof(cr)); |
d7e09d03 PT |
278 | cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; |
279 | cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; | |
280 | ||
1ad6a73e | 281 | rc = lnet_sock_write(sock, &cr, sizeof(cr), accept_timeout); |
d7e09d03 | 282 | if (rc != 0) |
5129097b | 283 | CERROR("Error sending magic+version in response to version %d from %pI4h: %d\n", |
5e8f6920 | 284 | peer_version, &peer_ip, rc); |
d7e09d03 PT |
285 | return -EPROTO; |
286 | } | |
287 | ||
1ad6a73e JS |
288 | rc = lnet_sock_read(sock, &cr.acr_nid, |
289 | sizeof(cr) - | |
290 | offsetof(lnet_acceptor_connreq_t, acr_nid), | |
291 | accept_timeout); | |
d7e09d03 | 292 | if (rc != 0) { |
5129097b | 293 | CERROR("Error %d reading connection request from %pI4h\n", |
c314c319 | 294 | rc, &peer_ip); |
d7e09d03 PT |
295 | return -EIO; |
296 | } | |
297 | ||
298 | if (flip) | |
299 | __swab64s(&cr.acr_nid); | |
300 | ||
301 | ni = lnet_net2ni(LNET_NIDNET(cr.acr_nid)); | |
06ace26e | 302 | if (!ni || /* no matching net */ |
d7e09d03 | 303 | ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */ |
06ace26e | 304 | if (ni) |
d7e09d03 | 305 | lnet_ni_decref(ni); |
5129097b | 306 | LCONSOLE_ERROR_MSG(0x120, "Refusing connection from %pI4h for %s: No matching NI\n", |
5e8f6920 | 307 | &peer_ip, libcfs_nid2str(cr.acr_nid)); |
d7e09d03 PT |
308 | return -EPERM; |
309 | } | |
310 | ||
06ace26e | 311 | if (!ni->ni_lnd->lnd_accept) { |
d7e09d03 PT |
312 | /* This catches a request for the loopback LND */ |
313 | lnet_ni_decref(ni); | |
5129097b | 314 | LCONSOLE_ERROR_MSG(0x121, "Refusing connection from %pI4h for %s: NI doesn not accept IP connections\n", |
c314c319 | 315 | &peer_ip, libcfs_nid2str(cr.acr_nid)); |
d7e09d03 PT |
316 | return -EPERM; |
317 | } | |
318 | ||
5e8f6920 PT |
319 | CDEBUG(D_NET, "Accept %s from %pI4h\n", |
320 | libcfs_nid2str(cr.acr_nid), &peer_ip); | |
d7e09d03 PT |
321 | |
322 | rc = ni->ni_lnd->lnd_accept(ni, sock); | |
323 | ||
324 | lnet_ni_decref(ni); | |
325 | return rc; | |
326 | } | |
327 | ||
c49d4b96 | 328 | static int |
d7e09d03 PT |
329 | lnet_acceptor(void *arg) |
330 | { | |
e327dc88 | 331 | struct socket *newsock; |
7e7ab095 MS |
332 | int rc; |
333 | __u32 magic; | |
334 | __u32 peer_ip; | |
335 | int peer_port; | |
336 | int secure = (int)((long_ptr_t)arg); | |
d7e09d03 | 337 | |
06ace26e | 338 | LASSERT(!lnet_acceptor_state.pta_sock); |
d7e09d03 PT |
339 | |
340 | cfs_block_allsigs(); | |
341 | ||
1ad6a73e JS |
342 | rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock, 0, accept_port, |
343 | accept_backlog); | |
d7e09d03 PT |
344 | if (rc != 0) { |
345 | if (rc == -EADDRINUSE) | |
5129097b | 346 | LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port %d: port already in use\n", |
d7e09d03 PT |
347 | accept_port); |
348 | else | |
5129097b | 349 | LCONSOLE_ERROR_MSG(0x123, "Can't start acceptor on port %d: unexpected error %d\n", |
d7e09d03 PT |
350 | accept_port, rc); |
351 | ||
352 | lnet_acceptor_state.pta_sock = NULL; | |
353 | } else { | |
354 | LCONSOLE(0, "Accept %s, port %d\n", accept_type, accept_port); | |
355 | } | |
356 | ||
357 | /* set init status and unblock parent */ | |
358 | lnet_acceptor_state.pta_shutdown = rc; | |
359 | complete(&lnet_acceptor_state.pta_signal); | |
360 | ||
361 | if (rc != 0) | |
362 | return rc; | |
363 | ||
364 | while (!lnet_acceptor_state.pta_shutdown) { | |
1ad6a73e | 365 | rc = lnet_sock_accept(&newsock, lnet_acceptor_state.pta_sock); |
d7e09d03 PT |
366 | if (rc != 0) { |
367 | if (rc != -EAGAIN) { | |
368 | CWARN("Accept error %d: pausing...\n", rc); | |
d3caf4d5 PT |
369 | set_current_state(TASK_UNINTERRUPTIBLE); |
370 | schedule_timeout(cfs_time_seconds(1)); | |
d7e09d03 PT |
371 | } |
372 | continue; | |
373 | } | |
374 | ||
45bd3ebe | 375 | /* maybe the LNet acceptor thread has been waken */ |
d7e09d03 | 376 | if (lnet_acceptor_state.pta_shutdown) { |
e52fc91d | 377 | sock_release(newsock); |
d7e09d03 PT |
378 | break; |
379 | } | |
380 | ||
1ad6a73e | 381 | rc = lnet_sock_getaddr(newsock, 1, &peer_ip, &peer_port); |
d7e09d03 PT |
382 | if (rc != 0) { |
383 | CERROR("Can't determine new connection's address\n"); | |
384 | goto failed; | |
385 | } | |
386 | ||
387 | if (secure && peer_port > LNET_ACCEPTOR_MAX_RESERVED_PORT) { | |
5129097b | 388 | CERROR("Refusing connection from %pI4h: insecure port %d\n", |
5e8f6920 | 389 | &peer_ip, peer_port); |
d7e09d03 PT |
390 | goto failed; |
391 | } | |
392 | ||
1ad6a73e JS |
393 | rc = lnet_sock_read(newsock, &magic, sizeof(magic), |
394 | accept_timeout); | |
d7e09d03 | 395 | if (rc != 0) { |
5129097b | 396 | CERROR("Error %d reading connection request from %pI4h\n", |
c314c319 | 397 | rc, &peer_ip); |
d7e09d03 PT |
398 | goto failed; |
399 | } | |
400 | ||
401 | rc = lnet_accept(newsock, magic); | |
402 | if (rc != 0) | |
403 | goto failed; | |
404 | ||
405 | continue; | |
406 | ||
b5154614 | 407 | failed: |
e52fc91d | 408 | sock_release(newsock); |
d7e09d03 PT |
409 | } |
410 | ||
e52fc91d | 411 | sock_release(lnet_acceptor_state.pta_sock); |
d7e09d03 PT |
412 | lnet_acceptor_state.pta_sock = NULL; |
413 | ||
414 | CDEBUG(D_NET, "Acceptor stopping\n"); | |
415 | ||
416 | /* unblock lnet_acceptor_stop() */ | |
417 | complete(&lnet_acceptor_state.pta_signal); | |
418 | return 0; | |
419 | } | |
420 | ||
421 | static inline int | |
422 | accept2secure(const char *acc, long *sec) | |
423 | { | |
424 | if (!strcmp(acc, "secure")) { | |
425 | *sec = 1; | |
426 | return 1; | |
427 | } else if (!strcmp(acc, "all")) { | |
428 | *sec = 0; | |
429 | return 1; | |
430 | } else if (!strcmp(acc, "none")) { | |
431 | return 0; | |
d7e09d03 | 432 | } |
2c1d2535 TP |
433 | |
434 | LCONSOLE_ERROR_MSG(0x124, "Can't parse 'accept=\"%s\"'\n", | |
435 | acc); | |
436 | return -EINVAL; | |
d7e09d03 PT |
437 | } |
438 | ||
439 | int | |
440 | lnet_acceptor_start(void) | |
441 | { | |
7e7ab095 | 442 | int rc; |
d7e09d03 PT |
443 | long rc2; |
444 | long secure; | |
445 | ||
06ace26e | 446 | LASSERT(!lnet_acceptor_state.pta_sock); |
d7e09d03 PT |
447 | |
448 | rc = lnet_acceptor_get_tunables(); | |
449 | if (rc != 0) | |
450 | return rc; | |
451 | ||
d7e09d03 PT |
452 | init_completion(&lnet_acceptor_state.pta_signal); |
453 | rc = accept2secure(accept_type, &secure); | |
6de9710b | 454 | if (rc <= 0) |
d7e09d03 | 455 | return rc; |
d7e09d03 PT |
456 | |
457 | if (lnet_count_acceptor_nis() == 0) /* not required */ | |
458 | return 0; | |
459 | ||
460 | rc2 = PTR_ERR(kthread_run(lnet_acceptor, | |
461 | (void *)(ulong_ptr_t)secure, | |
462 | "acceptor_%03ld", secure)); | |
463 | if (IS_ERR_VALUE(rc2)) { | |
464 | CERROR("Can't start acceptor thread: %ld\n", rc2); | |
d7e09d03 PT |
465 | |
466 | return -ESRCH; | |
467 | } | |
468 | ||
469 | /* wait for acceptor to startup */ | |
470 | wait_for_completion(&lnet_acceptor_state.pta_signal); | |
471 | ||
472 | if (!lnet_acceptor_state.pta_shutdown) { | |
473 | /* started OK */ | |
06ace26e | 474 | LASSERT(lnet_acceptor_state.pta_sock); |
d7e09d03 PT |
475 | return 0; |
476 | } | |
477 | ||
06ace26e | 478 | LASSERT(!lnet_acceptor_state.pta_sock); |
d7e09d03 PT |
479 | |
480 | return -ENETDOWN; | |
481 | } | |
482 | ||
483 | void | |
484 | lnet_acceptor_stop(void) | |
485 | { | |
06ace26e | 486 | if (!lnet_acceptor_state.pta_sock) /* not running */ |
d7e09d03 PT |
487 | return; |
488 | ||
489 | lnet_acceptor_state.pta_shutdown = 1; | |
45bd3ebe | 490 | wake_up_all(sk_sleep(lnet_acceptor_state.pta_sock->sk)); |
d7e09d03 PT |
491 | |
492 | /* block until acceptor signals exit */ | |
493 | wait_for_completion(&lnet_acceptor_state.pta_signal); | |
d7e09d03 | 494 | } |