ctl_frontend_iscsi.c (265508) | ctl_frontend_iscsi.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/cam/ctl/ctl_frontend_iscsi.c 265508 2014-05-07 07:31:25Z trasz $ | 29 * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 265509 2014-05-07 07:32:45Z trasz $ |
30 */ 31 32/* 33 * CTL frontend for the iSCSI protocol. 34 */ 35 36#include <sys/cdefs.h> | 30 */ 31 32/* 33 * CTL frontend for the iSCSI protocol. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 265508 2014-05-07 07:31:25Z trasz $"); | 37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 265509 2014-05-07 07:32:45Z trasz $"); |
38 39#include <sys/param.h> 40#include <sys/capability.h> 41#include <sys/condvar.h> 42#include <sys/file.h> 43#include <sys/kernel.h> 44#include <sys/kthread.h> 45#include <sys/lock.h> --- 1299 unchanged lines hidden (view full) --- 1345 return (EBUSY); 1346 default: 1347 return (EOPNOTSUPP); 1348 } 1349} 1350 1351#ifdef ICL_KERNEL_PROXY 1352static void | 38 39#include <sys/param.h> 40#include <sys/capability.h> 41#include <sys/condvar.h> 42#include <sys/file.h> 43#include <sys/kernel.h> 44#include <sys/kthread.h> 45#include <sys/lock.h> --- 1299 unchanged lines hidden (view full) --- 1345 return (EBUSY); 1346 default: 1347 return (EOPNOTSUPP); 1348 } 1349} 1350 1351#ifdef ICL_KERNEL_PROXY 1352static void |
1353cfiscsi_accept(struct socket *so) | 1353cfiscsi_accept(struct socket *so, int portal_id) |
1354{ 1355 struct cfiscsi_session *cs; 1356 1357 cs = cfiscsi_session_new(&cfiscsi_softc); 1358 if (cs == NULL) { 1359 CFISCSI_WARN("failed to create session"); 1360 return; 1361 } 1362 1363 icl_conn_handoff_sock(cs->cs_conn, so); | 1354{ 1355 struct cfiscsi_session *cs; 1356 1357 cs = cfiscsi_session_new(&cfiscsi_softc); 1358 if (cs == NULL) { 1359 CFISCSI_WARN("failed to create session"); 1360 return; 1361 } 1362 1363 icl_conn_handoff_sock(cs->cs_conn, so); |
1364 cs->cs_portal_id = portal_id; |
|
1364 cs->cs_waiting_for_ctld = true; 1365 cv_signal(&cfiscsi_softc.accept_cv); 1366} 1367#endif 1368 1369static void 1370cfiscsi_online(void *arg) 1371{ --- 362 unchanged lines hidden (view full) --- 1734 if (error != 0) { 1735 CFISCSI_DEBUG("getsockaddr, error %d", error); 1736 snprintf(ci->error_str, sizeof(ci->error_str), "getsockaddr failed"); 1737 ci->status = CTL_ISCSI_ERROR; 1738 return; 1739 } 1740 1741 error = icl_listen_add(cfiscsi_softc.listener, cilp->iser, cilp->domain, | 1365 cs->cs_waiting_for_ctld = true; 1366 cv_signal(&cfiscsi_softc.accept_cv); 1367} 1368#endif 1369 1370static void 1371cfiscsi_online(void *arg) 1372{ --- 362 unchanged lines hidden (view full) --- 1735 if (error != 0) { 1736 CFISCSI_DEBUG("getsockaddr, error %d", error); 1737 snprintf(ci->error_str, sizeof(ci->error_str), "getsockaddr failed"); 1738 ci->status = CTL_ISCSI_ERROR; 1739 return; 1740 } 1741 1742 error = icl_listen_add(cfiscsi_softc.listener, cilp->iser, cilp->domain, |
1742 cilp->socktype, cilp->protocol, sa); | 1743 cilp->socktype, cilp->protocol, sa, cilp->portal_id); |
1743 if (error != 0) { 1744 free(sa, M_SONAME); 1745 CFISCSI_DEBUG("icl_listen_add, error %d", error); 1746 snprintf(ci->error_str, sizeof(ci->error_str), 1747 "icl_listen_add failed, error %d", error); 1748 ci->status = CTL_ISCSI_ERROR; 1749 return; 1750 } --- 27 unchanged lines hidden (view full) --- 1778 } 1779 } 1780 mtx_unlock(&cfiscsi_softc.lock); 1781 1782 cs->cs_waiting_for_ctld = false; 1783 cs->cs_login_phase = true; 1784 1785 ciap->connection_id = cs->cs_id; | 1744 if (error != 0) { 1745 free(sa, M_SONAME); 1746 CFISCSI_DEBUG("icl_listen_add, error %d", error); 1747 snprintf(ci->error_str, sizeof(ci->error_str), 1748 "icl_listen_add failed, error %d", error); 1749 ci->status = CTL_ISCSI_ERROR; 1750 return; 1751 } --- 27 unchanged lines hidden (view full) --- 1779 } 1780 } 1781 mtx_unlock(&cfiscsi_softc.lock); 1782 1783 cs->cs_waiting_for_ctld = false; 1784 cs->cs_login_phase = true; 1785 1786 ciap->connection_id = cs->cs_id; |
1787 ciap->portal_id = cs->cs_portal_id; |
|
1786 ci->status = CTL_ISCSI_OK; 1787} 1788 1789static void 1790cfiscsi_ioctl_send(struct ctl_iscsi *ci) 1791{ 1792 struct ctl_iscsi_send_params *cisp; 1793 struct cfiscsi_session *cs; --- 117 unchanged lines hidden (view full) --- 1911 copyout(data, cirp->data_segment, ip->ip_data_len); 1912 free(data, M_CFISCSI); 1913 } 1914 1915 icl_pdu_free(ip); 1916 ci->status = CTL_ISCSI_OK; 1917} 1918 | 1788 ci->status = CTL_ISCSI_OK; 1789} 1790 1791static void 1792cfiscsi_ioctl_send(struct ctl_iscsi *ci) 1793{ 1794 struct ctl_iscsi_send_params *cisp; 1795 struct cfiscsi_session *cs; --- 117 unchanged lines hidden (view full) --- 1913 copyout(data, cirp->data_segment, ip->ip_data_len); 1914 free(data, M_CFISCSI); 1915 } 1916 1917 icl_pdu_free(ip); 1918 ci->status = CTL_ISCSI_OK; 1919} 1920 |
1919static void 1920cfiscsi_ioctl_close(struct ctl_iscsi *ci) 1921{ 1922 /* 1923 * XXX 1924 */ 1925} | |
1926#endif /* !ICL_KERNEL_PROXY */ 1927 1928static int 1929cfiscsi_ioctl(struct cdev *dev, 1930 u_long cmd, caddr_t addr, int flag, struct thread *td) 1931{ 1932 struct ctl_iscsi *ci; 1933 --- 22 unchanged lines hidden (view full) --- 1956 cfiscsi_ioctl_accept(ci); 1957 break; 1958 case CTL_ISCSI_SEND: 1959 cfiscsi_ioctl_send(ci); 1960 break; 1961 case CTL_ISCSI_RECEIVE: 1962 cfiscsi_ioctl_receive(ci); 1963 break; | 1921#endif /* !ICL_KERNEL_PROXY */ 1922 1923static int 1924cfiscsi_ioctl(struct cdev *dev, 1925 u_long cmd, caddr_t addr, int flag, struct thread *td) 1926{ 1927 struct ctl_iscsi *ci; 1928 --- 22 unchanged lines hidden (view full) --- 1951 cfiscsi_ioctl_accept(ci); 1952 break; 1953 case CTL_ISCSI_SEND: 1954 cfiscsi_ioctl_send(ci); 1955 break; 1956 case CTL_ISCSI_RECEIVE: 1957 cfiscsi_ioctl_receive(ci); 1958 break; |
1964 case CTL_ISCSI_CLOSE: 1965 cfiscsi_ioctl_close(ci); 1966 break; | |
1967#else 1968 case CTL_ISCSI_LISTEN: 1969 case CTL_ISCSI_ACCEPT: 1970 case CTL_ISCSI_SEND: 1971 case CTL_ISCSI_RECEIVE: | 1959#else 1960 case CTL_ISCSI_LISTEN: 1961 case CTL_ISCSI_ACCEPT: 1962 case CTL_ISCSI_SEND: 1963 case CTL_ISCSI_RECEIVE: |
1972 case CTL_ISCSI_CLOSE: | |
1973 ci->status = CTL_ISCSI_ERROR; 1974 snprintf(ci->error_str, sizeof(ci->error_str), 1975 "%s: CTL compiled without ICL_KERNEL_PROXY", 1976 __func__); 1977 break; 1978#endif /* !ICL_KERNEL_PROXY */ 1979 default: 1980 ci->status = CTL_ISCSI_ERROR; --- 847 unchanged lines hidden --- | 1964 ci->status = CTL_ISCSI_ERROR; 1965 snprintf(ci->error_str, sizeof(ci->error_str), 1966 "%s: CTL compiled without ICL_KERNEL_PROXY", 1967 __func__); 1968 break; 1969#endif /* !ICL_KERNEL_PROXY */ 1970 default: 1971 ci->status = CTL_ISCSI_ERROR; --- 847 unchanged lines hidden --- |