@@ -646,6 +646,8 @@ __iscsi_iser_session_create(struct iscsi_endpoint *ep,
if (!(ib_dev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG))
shost->virt_boundary_mask = SZ_4K - 1;
+ iscsi_host_set_netns(shost, ep->netns);
+
if (iscsi_host_add(shost, ib_dev->dev.parent)) {
mutex_unlock(&iser_conn->state_mutex);
goto free_host;
@@ -653,6 +655,7 @@ __iscsi_iser_session_create(struct iscsi_endpoint *ep,
mutex_unlock(&iser_conn->state_mutex);
} else {
shost->can_queue = min_t(u16, cmds_max, ISER_DEF_XMIT_CMDS_MAX);
+ iscsi_host_set_netns(shost, net);
if (iscsi_host_add(shost, NULL))
goto free_host;
}
@@ -1029,7 +1032,9 @@ static struct iscsi_transport iscsi_iser_transport = {
.ep_connect_net = iscsi_iser_ep_connect,
.ep_poll = iscsi_iser_ep_poll,
- .ep_disconnect = iscsi_iser_ep_disconnect
+ .ep_disconnect = iscsi_iser_ep_disconnect,
+ /* net namespace */
+ .get_netns = iscsi_host_get_netns,
};
static int __init iser_init(void)
@@ -947,7 +947,7 @@ iscsi_sw_tcp_session_create(struct net *net, uint16_t cmds_max,
shost->can_queue = rc;
tcp_sw_host = iscsi_host_priv(shost);
- tcp_sw_host->net_ns = net;
+ iscsi_host_set_netns(shost, net);
if (iscsi_host_add(shost, NULL))
goto free_host;
@@ -1068,12 +1068,6 @@ static int iscsi_sw_tcp_slave_configure(struct scsi_device *sdev)
return 0;
}
-static struct net *iscsi_sw_tcp_netns(struct Scsi_Host *shost)
-{
- struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(shost);
- return tcp_sw_host->net_ns;
-}
-
static struct scsi_host_template iscsi_sw_tcp_sht = {
.module = THIS_MODULE,
.name = "iSCSI Initiator over TCP/IP",
@@ -1130,7 +1124,7 @@ static struct iscsi_transport iscsi_sw_tcp_transport = {
/* recovery */
.session_recovery_timedout = iscsi_session_recovery_timedout,
/* net namespace */
- .get_netns = iscsi_sw_tcp_netns,
+ .get_netns = iscsi_host_get_netns,
};
static int __init iscsi_sw_tcp_init(void)
@@ -53,7 +53,6 @@ struct iscsi_sw_tcp_conn {
struct iscsi_sw_tcp_host {
struct iscsi_session *session;
- struct net *net_ns;
};
struct iscsi_sw_tcp_hdrbuf {
@@ -3929,6 +3929,18 @@ int iscsi_host_set_param(struct Scsi_Host *shost, enum iscsi_host_param param,
}
EXPORT_SYMBOL_GPL(iscsi_host_set_param);
+void iscsi_host_set_netns(struct Scsi_Host *shost, struct net *netns) {
+ struct iscsi_host *ihost = shost_priv(shost);
+ ihost->net_ns = netns;
+}
+EXPORT_SYMBOL_GPL(iscsi_host_set_netns);
+
+struct net *iscsi_host_get_netns(struct Scsi_Host *shost) {
+ struct iscsi_host *ihost = shost_priv(shost);
+ return ihost->net_ns;
+}
+EXPORT_SYMBOL_GPL(iscsi_host_get_netns);
+
MODULE_AUTHOR("Mike Christie");
MODULE_DESCRIPTION("iSCSI library functions");
MODULE_LICENSE("GPL");
@@ -383,6 +383,7 @@ struct iscsi_host {
int state;
struct workqueue_struct *workq;
+ struct net *net_ns;
};
/*
@@ -492,6 +493,9 @@ extern void iscsi_pool_free(struct iscsi_pool *);
extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
extern int iscsi_switch_str_param(char **, char *);
+extern void iscsi_host_set_netns(struct Scsi_Host *, struct net *);
+extern struct net *iscsi_host_get_netns(struct Scsi_Host *);
+
/*
* inline functions to deal with padding.
*/
Move the logic to store the network namespace during virtual host creation (due to the way transport-class object setup callbacks function) from iscsi_tcp into libiscsi, and share it with iser. Signed-off-by: Chris Leech <cleech@redhat.com> --- drivers/infiniband/ulp/iser/iscsi_iser.c | 7 ++++++- drivers/scsi/iscsi_tcp.c | 10 ++-------- drivers/scsi/iscsi_tcp.h | 1 - drivers/scsi/libiscsi.c | 12 ++++++++++++ include/scsi/libiscsi.h | 4 ++++ 5 files changed, 24 insertions(+), 10 deletions(-)