void citp_passthrough_init(citp_alien_fdi* epi) { int rc = oo_os_sock_get(epi->netif, epi->ep->bufid, &epi->os_socket); /* No sensible way to handle oo_os_sock_get failure. Just record it. */ if( rc != 0 ) { Log_U(ci_log("%s: oo_os_sock_get([%d:%d]) returned %d", __func__, NI_ID(epi->netif), epi->ep->bufid, rc)); epi->os_socket = -1; return; } __citp_fdtable_reserve(epi->os_socket, 1); /* ci_tcp_helper_get_sock_fd gets the citp_dup2_lock lock: release it */ oo_rwlock_unlock_read(&citp_dup2_lock); }
int oo_os_sock_ioctl(ci_netif* ni, oo_sp sock_p, int request, void* arg, int* ioctl_rc) { oo_os_file os_sock_fd; int rc; if( (rc = oo_os_sock_get(ni, sock_p, &os_sock_fd)) == 0 ) { rc = ci_sys_ioctl(os_sock_fd, request, arg); if( rc < 0 ) rc = -errno; oo_os_sock_release(ni, os_sock_fd); if( ioctl_rc != NULL ) { *ioctl_rc = rc; rc = 0; } } else { LOG_E(ci_log("%s: [%d:%d] ERROR: failed to get kernel sock fd " "(rc=%d req=%d)", __FUNCTION__, NI_ID(ni), OO_SP_FMT(sock_p), rc, request)); } return rc; }