MFC r264530:
Properly pass the initiator address when running in proxy mode. Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
a59839947c
commit
21ec0cf2d0
@ -1353,7 +1353,7 @@ cfiscsi_module_event_handler(module_t mod, int what, void *arg)
|
|||||||
|
|
||||||
#ifdef ICL_KERNEL_PROXY
|
#ifdef ICL_KERNEL_PROXY
|
||||||
static void
|
static void
|
||||||
cfiscsi_accept(struct socket *so, int portal_id)
|
cfiscsi_accept(struct socket *so, struct sockaddr *sa, int portal_id)
|
||||||
{
|
{
|
||||||
struct cfiscsi_session *cs;
|
struct cfiscsi_session *cs;
|
||||||
|
|
||||||
@ -1364,6 +1364,7 @@ cfiscsi_accept(struct socket *so, int portal_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
icl_conn_handoff_sock(cs->cs_conn, so);
|
icl_conn_handoff_sock(cs->cs_conn, so);
|
||||||
|
cs->cs_initiator_sa = sa;
|
||||||
cs->cs_portal_id = portal_id;
|
cs->cs_portal_id = portal_id;
|
||||||
cs->cs_waiting_for_ctld = true;
|
cs->cs_waiting_for_ctld = true;
|
||||||
cv_signal(&cfiscsi_softc.accept_cv);
|
cv_signal(&cfiscsi_softc.accept_cv);
|
||||||
@ -1788,6 +1789,16 @@ cfiscsi_ioctl_accept(struct ctl_iscsi *ci)
|
|||||||
|
|
||||||
ciap->connection_id = cs->cs_id;
|
ciap->connection_id = cs->cs_id;
|
||||||
ciap->portal_id = cs->cs_portal_id;
|
ciap->portal_id = cs->cs_portal_id;
|
||||||
|
ciap->initiator_addrlen = cs->cs_initiator_sa->sa_len;
|
||||||
|
error = copyout(cs->cs_initiator_sa, ciap->initiator_addr,
|
||||||
|
cs->cs_initiator_sa->sa_len);
|
||||||
|
if (error != 0) {
|
||||||
|
snprintf(ci->error_str, sizeof(ci->error_str),
|
||||||
|
"copyout failed with error %d", error);
|
||||||
|
ci->status = CTL_ISCSI_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ci->status = CTL_ISCSI_OK;
|
ci->status = CTL_ISCSI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ struct cfiscsi_session {
|
|||||||
unsigned int cs_id;
|
unsigned int cs_id;
|
||||||
int cs_ctl_initid;
|
int cs_ctl_initid;
|
||||||
#ifdef ICL_KERNEL_PROXY
|
#ifdef ICL_KERNEL_PROXY
|
||||||
|
struct sockaddr *cs_initiator_sa;
|
||||||
int cs_portal_id;
|
int cs_portal_id;
|
||||||
bool cs_login_phase;
|
bool cs_login_phase;
|
||||||
bool cs_waiting_for_ctld;
|
bool cs_waiting_for_ctld;
|
||||||
|
@ -706,8 +706,9 @@ struct ctl_iscsi_listen_params {
|
|||||||
|
|
||||||
struct ctl_iscsi_accept_params {
|
struct ctl_iscsi_accept_params {
|
||||||
int connection_id;
|
int connection_id;
|
||||||
struct sockaddr *initiator_addr;
|
|
||||||
int portal_id;
|
int portal_id;
|
||||||
|
struct sockaddr *initiator_addr;
|
||||||
|
socklen_t initiator_addrlen;
|
||||||
int spare[4];
|
int spare[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,7 +128,8 @@ struct icl_listen_sock {
|
|||||||
struct icl_listen {
|
struct icl_listen {
|
||||||
TAILQ_HEAD(, icl_listen_sock) il_sockets;
|
TAILQ_HEAD(, icl_listen_sock) il_sockets;
|
||||||
struct sx il_lock;
|
struct sx il_lock;
|
||||||
void (*il_accept)(struct socket *, int);
|
void (*il_accept)(struct socket *,
|
||||||
|
struct sockaddr *, int);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -140,7 +141,8 @@ int icl_conn_connect(struct icl_conn *ic, bool rdma,
|
|||||||
/*
|
/*
|
||||||
* Target part.
|
* Target part.
|
||||||
*/
|
*/
|
||||||
struct icl_listen *icl_listen_new(void (*accept_cb)(struct socket *, int));
|
struct icl_listen *icl_listen_new(void (*accept_cb)(struct socket *,
|
||||||
|
struct sockaddr *, int));
|
||||||
void icl_listen_free(struct icl_listen *il);
|
void icl_listen_free(struct icl_listen *il);
|
||||||
int icl_listen_add(struct icl_listen *il, bool rdma,
|
int icl_listen_add(struct icl_listen *il, bool rdma,
|
||||||
int domain, int socktype, int protocol,
|
int domain, int socktype, int protocol,
|
||||||
|
@ -182,7 +182,7 @@ icl_conn_connect(struct icl_conn *ic, bool rdma, int domain, int socktype,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct icl_listen *
|
struct icl_listen *
|
||||||
icl_listen_new(void (*accept_cb)(struct socket *, int))
|
icl_listen_new(void (*accept_cb)(struct socket *, struct sockaddr *, int))
|
||||||
{
|
{
|
||||||
struct icl_listen *il;
|
struct icl_listen *il;
|
||||||
|
|
||||||
@ -296,9 +296,10 @@ icl_accept_thread(void *arg)
|
|||||||
if (sa != NULL)
|
if (sa != NULL)
|
||||||
free(sa, M_SONAME);
|
free(sa, M_SONAME);
|
||||||
soclose(so);
|
soclose(so);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
(ils->ils_listen->il_accept)(so, ils->ils_id);
|
(ils->ils_listen->il_accept)(so, sa, ils->ils_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,8 +1588,8 @@ wait_for_children(bool block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_connection(struct portal *portal, int fd, const struct sockaddr_storage *ss,
|
handle_connection(struct portal *portal, int fd,
|
||||||
socklen_t sslen, bool dont_fork)
|
const struct sockaddr *client_sa, socklen_t client_salen, bool dont_fork)
|
||||||
{
|
{
|
||||||
struct connection *conn;
|
struct connection *conn;
|
||||||
int error;
|
int error;
|
||||||
@ -1624,16 +1624,7 @@ handle_connection(struct portal *portal, int fd, const struct sockaddr_storage *
|
|||||||
}
|
}
|
||||||
pidfile_close(conf->conf_pidfh);
|
pidfile_close(conf->conf_pidfh);
|
||||||
|
|
||||||
#ifdef ICL_KERNEL_PROXY
|
error = getnameinfo(client_sa, client_salen,
|
||||||
/*
|
|
||||||
* XXX
|
|
||||||
*/
|
|
||||||
if (proxy_mode) {
|
|
||||||
log_set_peer_addr("XXX");
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
assert(proxy_mode == false);
|
|
||||||
error = getnameinfo((struct sockaddr *)ss, sslen,
|
|
||||||
host, sizeof(host), NULL, 0, NI_NUMERICHOST);
|
host, sizeof(host), NULL, 0, NI_NUMERICHOST);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
log_errx(1, "getnameinfo: %s", gai_strerror(error));
|
log_errx(1, "getnameinfo: %s", gai_strerror(error));
|
||||||
@ -1642,9 +1633,6 @@ handle_connection(struct portal *portal, int fd, const struct sockaddr_storage *
|
|||||||
host, portal->p_portal_group->pg_name);
|
host, portal->p_portal_group->pg_name);
|
||||||
log_set_peer_addr(host);
|
log_set_peer_addr(host);
|
||||||
setproctitle("%s", host);
|
setproctitle("%s", host);
|
||||||
#ifdef ICL_KERNEL_PROXY
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
conn = connection_new(portal, fd, host);
|
conn = connection_new(portal, fd, host);
|
||||||
set_timeout(conf);
|
set_timeout(conf);
|
||||||
@ -1699,7 +1687,9 @@ main_loop(struct conf *conf, bool dont_fork)
|
|||||||
|
|
||||||
#ifdef ICL_KERNEL_PROXY
|
#ifdef ICL_KERNEL_PROXY
|
||||||
if (proxy_mode) {
|
if (proxy_mode) {
|
||||||
kernel_accept(&connection_id, &portal_id);
|
client_salen = sizeof(client_sa);
|
||||||
|
kernel_accept(&connection_id, &portal_id,
|
||||||
|
(struct sockaddr *)&client_sa, &client_salen);
|
||||||
|
|
||||||
log_debugx("incoming connection, id %d, portal id %d",
|
log_debugx("incoming connection, id %d, portal id %d",
|
||||||
connection_id, portal_id);
|
connection_id, portal_id);
|
||||||
@ -1715,7 +1705,9 @@ main_loop(struct conf *conf, bool dont_fork)
|
|||||||
portal_id);
|
portal_id);
|
||||||
|
|
||||||
found:
|
found:
|
||||||
handle_connection(portal, connection_id, NULL, 0, dont_fork);
|
handle_connection(portal, connection_id,
|
||||||
|
(struct sockaddr *)&client_sa, client_salen,
|
||||||
|
dont_fork);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
assert(proxy_mode == false);
|
assert(proxy_mode == false);
|
||||||
@ -1743,7 +1735,8 @@ main_loop(struct conf *conf, bool dont_fork)
|
|||||||
if (client_fd < 0)
|
if (client_fd < 0)
|
||||||
log_err(1, "accept");
|
log_err(1, "accept");
|
||||||
handle_connection(portal, client_fd,
|
handle_connection(portal, client_fd,
|
||||||
&client_sa, client_salen, dont_fork);
|
(struct sockaddr *)&client_sa,
|
||||||
|
client_salen, dont_fork);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,10 @@
|
|||||||
#define CTLD_H
|
#define CTLD_H
|
||||||
|
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
#ifdef ICL_KERNEL_PROXY
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
|
|
||||||
@ -269,14 +273,15 @@ int kernel_port_on(void);
|
|||||||
int kernel_port_off(void);
|
int kernel_port_off(void);
|
||||||
void kernel_capsicate(void);
|
void kernel_capsicate(void);
|
||||||
|
|
||||||
/*
|
#ifdef ICL_KERNEL_PROXY
|
||||||
* ICL_KERNEL_PROXY
|
|
||||||
*/
|
|
||||||
void kernel_listen(struct addrinfo *ai, bool iser,
|
void kernel_listen(struct addrinfo *ai, bool iser,
|
||||||
int portal_id);
|
int portal_id);
|
||||||
void kernel_accept(int *connection_id, int *portal_id);
|
void kernel_accept(int *connection_id, int *portal_id,
|
||||||
|
struct sockaddr *client_sa,
|
||||||
|
socklen_t *client_salen);
|
||||||
void kernel_send(struct pdu *pdu);
|
void kernel_send(struct pdu *pdu);
|
||||||
void kernel_receive(struct pdu *pdu);
|
void kernel_receive(struct pdu *pdu);
|
||||||
|
#endif
|
||||||
|
|
||||||
struct keys *keys_new(void);
|
struct keys *keys_new(void);
|
||||||
void keys_delete(struct keys *keys);
|
void keys_delete(struct keys *keys);
|
||||||
|
@ -700,13 +700,16 @@ kernel_listen(struct addrinfo *ai, bool iser, int portal_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
kernel_accept(int *connection_id, int *portal_id)
|
kernel_accept(int *connection_id, int *portal_id,
|
||||||
|
struct sockaddr *client_sa, socklen_t *client_salen)
|
||||||
{
|
{
|
||||||
struct ctl_iscsi req;
|
struct ctl_iscsi req;
|
||||||
|
struct sockaddr_storage ss;
|
||||||
|
|
||||||
bzero(&req, sizeof(req));
|
bzero(&req, sizeof(req));
|
||||||
|
|
||||||
req.type = CTL_ISCSI_ACCEPT;
|
req.type = CTL_ISCSI_ACCEPT;
|
||||||
|
req.data.accept.initiator_addr = (struct sockaddr *)&ss;
|
||||||
|
|
||||||
if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1)
|
if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1)
|
||||||
log_err(1, "error issuing CTL_ISCSI ioctl");
|
log_err(1, "error issuing CTL_ISCSI ioctl");
|
||||||
@ -718,6 +721,8 @@ kernel_accept(int *connection_id, int *portal_id)
|
|||||||
|
|
||||||
*connection_id = req.data.accept.connection_id;
|
*connection_id = req.data.accept.connection_id;
|
||||||
*portal_id = req.data.accept.portal_id;
|
*portal_id = req.data.accept.portal_id;
|
||||||
|
*client_salen = req.data.accept.initiator_addrlen;
|
||||||
|
memcpy(client_sa, &ss, *client_salen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user