icl_proxy.c (256281) | icl_proxy.c (265509) |
---|---|
1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: stable/10/sys/dev/iscsi/icl_proxy.c 255570 2013-09-14 15:29:06Z trasz $ | 29 * $FreeBSD: stable/10/sys/dev/iscsi/icl_proxy.c 265509 2014-05-07 07:32:45Z trasz $ |
30 */ 31/*- 32 * Copyright (c) 1982, 1986, 1989, 1990, 1993 33 * The Regents of the University of California. All rights reserved. 34 * 35 * sendfile(2) and related extensions: 36 * Copyright (c) 1998, David Greenman. All rights reserved. 37 * --- 139 unchanged lines hidden (view full) --- 177 return (EOPNOTSUPP); 178#endif 179 } 180 181 return (icl_conn_connect_tcp(ic, domain, socktype, protocol, from_sa, to_sa)); 182} 183 184struct icl_listen * | 30 */ 31/*- 32 * Copyright (c) 1982, 1986, 1989, 1990, 1993 33 * The Regents of the University of California. All rights reserved. 34 * 35 * sendfile(2) and related extensions: 36 * Copyright (c) 1998, David Greenman. All rights reserved. 37 * --- 139 unchanged lines hidden (view full) --- 177 return (EOPNOTSUPP); 178#endif 179 } 180 181 return (icl_conn_connect_tcp(ic, domain, socktype, protocol, from_sa, to_sa)); 182} 183 184struct icl_listen * |
185icl_listen_new(void (*accept_cb)(struct socket *)) | 185icl_listen_new(void (*accept_cb)(struct socket *, int)) |
186{ 187 struct icl_listen *il; 188 189 il = malloc(sizeof(*il), M_ICL_PROXY, M_ZERO | M_WAITOK); 190 TAILQ_INIT(&il->il_sockets); 191 sx_init(&il->il_lock, "icl_listen"); 192 il->il_accept = accept_cb; 193 --- 99 unchanged lines hidden (view full) --- 293 error = soaccept(so, &sa); 294 if (error != 0) { 295 ICL_WARN("soaccept error %d", error); 296 if (sa != NULL) 297 free(sa, M_SONAME); 298 soclose(so); 299 } 300 | 186{ 187 struct icl_listen *il; 188 189 il = malloc(sizeof(*il), M_ICL_PROXY, M_ZERO | M_WAITOK); 190 TAILQ_INIT(&il->il_sockets); 191 sx_init(&il->il_lock, "icl_listen"); 192 il->il_accept = accept_cb; 193 --- 99 unchanged lines hidden (view full) --- 293 error = soaccept(so, &sa); 294 if (error != 0) { 295 ICL_WARN("soaccept error %d", error); 296 if (sa != NULL) 297 free(sa, M_SONAME); 298 soclose(so); 299 } 300 |
301 (ils->ils_listen->il_accept)(so); | 301 (ils->ils_listen->il_accept)(so, ils->ils_id); |
302 } 303} 304 305static int | 302 } 303} 304 305static int |
306icl_listen_add_tcp(struct icl_listen *il, int domain, int socktype, int protocol, 307 struct sockaddr *sa) | 306icl_listen_add_tcp(struct icl_listen *il, int domain, int socktype, 307 int protocol, struct sockaddr *sa, int portal_id) |
308{ 309 struct icl_listen_sock *ils; 310 struct socket *so; 311 struct sockopt sopt; 312 int error, one = 1; 313 314 error = socreate(domain, &so, socktype, protocol, 315 curthread->td_ucred, curthread); --- 27 unchanged lines hidden (view full) --- 343 ICL_WARN("solisten failed with error %d", error); 344 soclose(so); 345 return (error); 346 } 347 348 ils = malloc(sizeof(*ils), M_ICL_PROXY, M_ZERO | M_WAITOK); 349 ils->ils_listen = il; 350 ils->ils_socket = so; | 308{ 309 struct icl_listen_sock *ils; 310 struct socket *so; 311 struct sockopt sopt; 312 int error, one = 1; 313 314 error = socreate(domain, &so, socktype, protocol, 315 curthread->td_ucred, curthread); --- 27 unchanged lines hidden (view full) --- 343 ICL_WARN("solisten failed with error %d", error); 344 soclose(so); 345 return (error); 346 } 347 348 ils = malloc(sizeof(*ils), M_ICL_PROXY, M_ZERO | M_WAITOK); 349 ils->ils_listen = il; 350 ils->ils_socket = so; |
351 ils->ils_id = portal_id; |
|
351 352 error = kthread_add(icl_accept_thread, ils, NULL, NULL, 0, 0, "iclacc"); 353 if (error != 0) { 354 ICL_WARN("kthread_add failed with error %d", error); 355 soclose(so); 356 free(ils, M_ICL_PROXY); 357 358 return (error); 359 } 360 361 sx_xlock(&il->il_lock); 362 TAILQ_INSERT_TAIL(&il->il_sockets, ils, ils_next); 363 sx_xunlock(&il->il_lock); 364 365 return (0); 366} 367 368int | 352 353 error = kthread_add(icl_accept_thread, ils, NULL, NULL, 0, 0, "iclacc"); 354 if (error != 0) { 355 ICL_WARN("kthread_add failed with error %d", error); 356 soclose(so); 357 free(ils, M_ICL_PROXY); 358 359 return (error); 360 } 361 362 sx_xlock(&il->il_lock); 363 TAILQ_INSERT_TAIL(&il->il_sockets, ils, ils_next); 364 sx_xunlock(&il->il_lock); 365 366 return (0); 367} 368 369int |
369icl_listen_add(struct icl_listen *il, bool rdma, int domain, int socktype, int protocol, 370 struct sockaddr *sa) | 370icl_listen_add(struct icl_listen *il, bool rdma, int domain, int socktype, 371 int protocol, struct sockaddr *sa, int portal_id) |
371{ 372 373 if (rdma) { 374#ifndef ICL_RDMA 375 ICL_DEBUG("RDMA not supported"); 376 return (EOPNOTSUPP); 377#else | 372{ 373 374 if (rdma) { 375#ifndef ICL_RDMA 376 ICL_DEBUG("RDMA not supported"); 377 return (EOPNOTSUPP); 378#else |
378 return (icl_listen_add_rdma(il, domain, socktype, protocol, sa)); | 379 return (icl_listen_add_rdma(il, domain, socktype, protocol, 380 sa, portal_id)); |
379#endif 380 } 381 382 | 381#endif 382 } 383 384 |
383 return (icl_listen_add_tcp(il, domain, socktype, protocol, sa)); | 385 return (icl_listen_add_tcp(il, domain, socktype, protocol, sa, 386 portal_id)); |
384} 385 386int 387icl_listen_remove(struct icl_listen *il, struct sockaddr *sa) 388{ 389 390 /* 391 * XXX 392 */ 393 394 return (EOPNOTSUPP); 395} 396 397#endif /* ICL_KERNEL_PROXY */ | 387} 388 389int 390icl_listen_remove(struct icl_listen *il, struct sockaddr *sa) 391{ 392 393 /* 394 * XXX 395 */ 396 397 return (EOPNOTSUPP); 398} 399 400#endif /* ICL_KERNEL_PROXY */ |