[PATCH 0/9] use network namespace for iSCSI control interfaces

55 views
Skip to first unread message

Chris Leech

unread,
Oct 31, 2017, 6:41:32 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech
This series of changes makes the iSCSI netlink and sysfs control
interfaces filtered by network namespace. This is required to run
iscsid in any network namespace other than the initial default one.

Currently the netlink communication will fail if iscsid is started in a
non-default network namespace, as there is no kernel side socket. After
fixing that, the rest of these changes are to filter visibility of the
iSCSI transport objects by netns. This allows for multiple iscsid
instances to be run, one per netns, each controlling it's own set of
iSCSI sessions.

The iSCSI transport objects are filtered, but not the SCSI or block
layer devices. So while iSCSI hosts and sessions become limited to a
network namespace, any attached devices remain visible system wide.

This currently only supports iscsi_tcp running in a new namespace, as it
creates a virtual host per session. Support could be added later to
allow assignment of iSCSI HBAs to network namespace, much as is done for
network interfaces.

Chris Leech (9):
iscsi: create per-net iscsi netlink kernel sockets
iscsi: associate endpoints with a host
iscsi: sysfs filtering by network namespace
iscsi: make all iSCSI netlink multicast namespace aware
iscsi: set netns for iscsi_tcp hosts
iscsi: check net namespace for all iscsi lookups
iscsi: convert flashnode devices from bus to class
iscsi: rename iscsi_bus_flash_* to iscsi_flash_*
iscsi: filter flashnode sysfs by net namespace

drivers/infiniband/ulp/iser/iscsi_iser.c | 7 +-
drivers/scsi/be2iscsi/be_iscsi.c | 6 +-
drivers/scsi/bnx2i/bnx2i_iscsi.c | 6 +-
drivers/scsi/cxgbi/libcxgbi.c | 6 +-
drivers/scsi/iscsi_tcp.c | 7 +
drivers/scsi/qedi/qedi_iscsi.c | 6 +-
drivers/scsi/qla4xxx/ql4_os.c | 62 +--
drivers/scsi/scsi_transport_iscsi.c | 625 ++++++++++++++++++++++---------
include/scsi/scsi_transport_iscsi.h | 63 ++--
9 files changed, 538 insertions(+), 250 deletions(-)

--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:33 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open list
Prepare iSCSI netlink to operate in multiple namespaces.

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/scsi/scsi_transport_iscsi.c | 67 +++++++++++++++++++++++++++++++------
1 file changed, 57 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 7404d26895f5..0b23ba346cbe 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -26,6 +26,8 @@
#include <linux/bsg-lib.h>
#include <linux/idr.h>
#include <net/tcp.h>
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_device.h>
@@ -1601,7 +1603,11 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
NULL,
NULL);

-static struct sock *nls;
+struct iscsi_net {
+ struct sock *nls;
+};
+
+static int iscsi_net_id __read_mostly;
static DEFINE_MUTEX(rx_queue_mutex);

static LIST_HEAD(sesslist);
@@ -2317,11 +2323,23 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
}

static int
-iscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)
+iscsi_multicast_netns(struct net *net, struct sk_buff *skb,
+ uint32_t group, gfp_t gfp)
{
+ struct sock *nls;
+ struct iscsi_net *isn;
+
+ isn = net_generic(net, iscsi_net_id);
+ nls = isn->nls;
return nlmsg_multicast(nls, skb, 0, group, gfp);
}

+static int
+iscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)
+{
+ return iscsi_multicast_netns(&init_net, skb, group, gfp);
+}
+
int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
char *data, uint32_t data_size)
{
@@ -4490,13 +4508,42 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
}
EXPORT_SYMBOL_GPL(iscsi_unregister_transport);

-static __init int iscsi_transport_init(void)
+static int __net_init iscsi_net_init(struct net *net)
{
- int err;
+ struct sock *nls;
+ struct iscsi_net *isn;
struct netlink_kernel_cfg cfg = {
.groups = 1,
.input = iscsi_if_rx,
};
+
+ nls = netlink_kernel_create(net, NETLINK_ISCSI, &cfg);
+ if (!nls)
+ return -ENOMEM;
+ isn = net_generic(net, iscsi_net_id);
+ isn->nls = nls;
+ return 0;
+}
+
+static void __net_exit iscsi_net_exit(struct net *net)
+{
+ struct iscsi_net *isn;
+
+ isn = net_generic(net, iscsi_net_id);
+ netlink_kernel_release(isn->nls);
+ isn->nls = NULL;
+}
+
+static struct pernet_operations iscsi_net_ops = {
+ .init = iscsi_net_init,
+ .exit = iscsi_net_exit,
+ .id = &iscsi_net_id,
+ .size = sizeof(struct iscsi_net),
+};
+
+static __init int iscsi_transport_init(void)
+{
+ int err;
printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
ISCSI_TRANSPORT_VERSION);

@@ -4530,8 +4577,8 @@ static __init int iscsi_transport_init(void)
if (err)
goto unregister_session_class;

- nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, &cfg);
- if (!nls) {
+ err = register_pernet_subsys(&iscsi_net_ops);
+ if (err) {
err = -ENOBUFS;
goto unregister_flashnode_bus;
}
@@ -4539,13 +4586,13 @@ static __init int iscsi_transport_init(void)
iscsi_eh_timer_workq = create_singlethread_workqueue("iscsi_eh");
if (!iscsi_eh_timer_workq) {
err = -ENOMEM;
- goto release_nls;
+ goto unregister_pernet_subsys;
}

return 0;

-release_nls:
- netlink_kernel_release(nls);
+unregister_pernet_subsys:
+ unregister_pernet_subsys(&iscsi_net_ops);
unregister_flashnode_bus:
bus_unregister(&iscsi_flashnode_bus);
unregister_session_class:
@@ -4566,7 +4613,7 @@ static __init int iscsi_transport_init(void)
static void __exit iscsi_transport_exit(void)
{
destroy_workqueue(iscsi_eh_timer_workq);
- netlink_kernel_release(nls);
+ unregister_pernet_subsys(&iscsi_net_ops);
bus_unregister(&iscsi_flashnode_bus);
transport_class_unregister(&iscsi_connection_class);
transport_class_unregister(&iscsi_session_class);
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:36 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open list
This makes the iscsi_host, iscsi_session, iscsi_connection, iscsi_iface,
and iscsi_endpoint transport class devices only visible in sysfs under a
matching network namespace. The network namespace for all of these
objects is tracked in the iscsi_cls_host structure.

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/scsi/scsi_transport_iscsi.c | 128 +++++++++++++++++++++++++++++++-----
include/scsi/scsi_transport_iscsi.h | 1 +
2 files changed, 112 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 6ab7ca82b121..d29c095ccc7d 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -161,9 +161,31 @@ static void iscsi_endpoint_release(struct device *dev)
kfree(ep);
}

+static struct net *iscsi_host_net(struct iscsi_cls_host *ihost)
+{
+ return ihost->netns;
+}
+
+static struct net *iscsi_endpoint_net(struct iscsi_endpoint *ep)
+{
+ struct Scsi_Host *shost = iscsi_endpoint_to_shost(ep);
+ struct iscsi_cls_host *ihost = shost->shost_data;
+
+ return iscsi_host_net(ihost);
+}
+
+static const void *iscsi_endpoint_namespace(struct device *dev)
+{
+ struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev);
+
+ return iscsi_endpoint_net(ep);
+}
+
static struct class iscsi_endpoint_class = {
.name = "iscsi_endpoint",
.dev_release = iscsi_endpoint_release,
+ .ns_type = &net_ns_type_operations,
+ .namespace = iscsi_endpoint_namespace,
};

static ssize_t
@@ -285,10 +307,26 @@ static void iscsi_iface_release(struct device *dev)
put_device(parent);
}

+static struct net *iscsi_iface_net(struct iscsi_iface *iface)
+{
+ struct Scsi_Host *shost = iscsi_iface_to_shost(iface);
+ struct iscsi_cls_host *ihost = shost->shost_data;
+
+ return iscsi_host_net(ihost);
+}
+
+static const void *iscsi_iface_namespace(struct device *dev)
+{
+ struct iscsi_iface *iface = iscsi_dev_to_iface(dev);
+
+ return iscsi_iface_net(iface);
+}

static struct class iscsi_iface_class = {
.name = "iscsi_iface",
.dev_release = iscsi_iface_release,
+ .ns_type = &net_ns_type_operations,
+ .namespace = iscsi_iface_namespace,
};

#define ISCSI_IFACE_ATTR(_prefix, _name, _mode, _show, _store) \
@@ -1566,6 +1604,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
memset(ihost, 0, sizeof(*ihost));
atomic_set(&ihost->nr_scans, 0);
mutex_init(&ihost->mutex);
+ ihost->netns = &init_net;

iscsi_bsg_host_add(shost, ihost);
/* ignore any bsg add error - we just can't do sgio */
@@ -1586,23 +1625,78 @@ static int iscsi_remove_host(struct transport_container *tc,
return 0;
}

-static DECLARE_TRANSPORT_CLASS(iscsi_host_class,
- "iscsi_host",
- iscsi_setup_host,
- iscsi_remove_host,
- NULL);
-
-static DECLARE_TRANSPORT_CLASS(iscsi_session_class,
- "iscsi_session",
- NULL,
- NULL,
- NULL);
-
-static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
- "iscsi_connection",
- NULL,
- NULL,
- NULL);
+#define DECLARE_TRANSPORT_CLASS_NS(cls, nm, su, rm, cfg, ns, nslookup) \
+struct transport_class cls = { \
+ .class = { \
+ .name = nm, \
+ .ns_type = ns, \
+ .namespace = nslookup, \
+ }, \
+ .setup = su, \
+ .remove = rm, \
+ .configure = cfg, \
+}
+
+static const void *iscsi_host_namespace(struct device *dev)
+{
+ struct Scsi_Host *shost = transport_class_to_shost(dev);
+ struct iscsi_cls_host *ihost = shost->shost_data;
+
+ return iscsi_host_net(ihost);
+}
+
+static DECLARE_TRANSPORT_CLASS_NS(iscsi_host_class,
+ "iscsi_host",
+ iscsi_setup_host,
+ iscsi_remove_host,
+ NULL,
+ &net_ns_type_operations,
+ iscsi_host_namespace);
+
+static struct net *iscsi_sess_net(struct iscsi_cls_session *cls_session)
+{
+ struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
+ struct iscsi_cls_host *ihost = shost->shost_data;
+
+ return iscsi_host_net(ihost);
+}
+
+static const void *iscsi_sess_namespace(struct device *dev)
+{
+ struct iscsi_cls_session *cls_session = transport_class_to_session(dev);
+
+ return iscsi_sess_net(cls_session);
+}
+
+static DECLARE_TRANSPORT_CLASS_NS(iscsi_session_class,
+ "iscsi_session",
+ NULL,
+ NULL,
+ NULL,
+ &net_ns_type_operations,
+ iscsi_sess_namespace);
+
+static struct net *iscsi_conn_net(struct iscsi_cls_conn *cls_conn)
+{
+ struct iscsi_cls_session *cls_session = iscsi_conn_to_session(cls_conn);
+
+ return iscsi_sess_net(cls_session);
+}
+
+static const void *iscsi_conn_namespace(struct device *dev)
+{
+ struct iscsi_cls_conn *cls_conn = transport_class_to_conn(dev);
+
+ return iscsi_conn_net(cls_conn);
+}
+
+static DECLARE_TRANSPORT_CLASS_NS(iscsi_connection_class,
+ "iscsi_connection",
+ NULL,
+ NULL,
+ NULL,
+ &net_ns_type_operations,
+ iscsi_conn_namespace);

struct iscsi_net {
struct sock *nls;
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 3b40fea93556..8c8191dfdc21 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -279,6 +279,7 @@ struct iscsi_cls_host {
struct request_queue *bsg_q;
uint32_t port_speed;
uint32_t port_state;
+ struct net *netns;
};

#define iscsi_job_to_shost(_job) \
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:36 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, Or Gerlitz, Sagi Grimberg, Roi Dayan, Doug Ledford, Sean Hefty, Hal Rosenstock, Subbu Seetharaman, Ketan Mukadam, Jitendra Bhivare, James E.J. Bottomley, Martin K. Petersen, supporter:BROADCOM BNX2I 1/10 GIGABIT iSCSI DRIVER, supporter:QLOGIC QL41xxx ISCSI DRIVER, open list:ISCSI EXTENSIONS FOR RDMA (ISER) INITIATOR, open list
Right now the iscsi_endpoint is only linked to a connection once that
connection has been established. For net namespace filtering of the
sysfs objects, associate an endpoint with the host that it was
allocated for when it is created.

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/infiniband/ulp/iser/iscsi_iser.c | 2 +-
drivers/scsi/be2iscsi/be_iscsi.c | 2 +-
drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +-
drivers/scsi/cxgbi/libcxgbi.c | 2 +-
drivers/scsi/qedi/qedi_iscsi.c | 2 +-
drivers/scsi/qla4xxx/ql4_os.c | 2 +-
drivers/scsi/scsi_transport_iscsi.c | 3 ++-
include/scsi/scsi_transport_iscsi.h | 6 +++++-
8 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 19624e023ebd..0a4214be4877 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -817,7 +817,7 @@ iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
struct iser_conn *iser_conn;
struct iscsi_endpoint *ep;

- ep = iscsi_create_endpoint(0);
+ ep = iscsi_create_endpoint(shost, 0);
if (!ep)
return ERR_PTR(-ENOMEM);

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index a398c54139aa..33f79f385660 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1157,7 +1157,7 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
return ERR_PTR(ret);
}

- ep = iscsi_create_endpoint(sizeof(struct beiscsi_endpoint));
+ ep = iscsi_create_endpoint(shost, sizeof(struct beiscsi_endpoint));
if (!ep) {
ret = -ENOMEM;
return ERR_PTR(ret);
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 03c104b47f31..19fadb5d3b3c 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -384,7 +384,7 @@ static struct iscsi_endpoint *bnx2i_alloc_ep(struct bnx2i_hba *hba)
struct bnx2i_endpoint *bnx2i_ep;
u32 ec_div;

- ep = iscsi_create_endpoint(sizeof(*bnx2i_ep));
+ ep = iscsi_create_endpoint(hba->shost, sizeof(*bnx2i_ep));
if (!ep) {
printk(KERN_ERR "bnx2i: Could not allocate ep\n");
return NULL;
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 858e32e8ad2d..558484f72738 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -2616,7 +2616,7 @@ struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *shost,
goto release_conn;
}

- ep = iscsi_create_endpoint(sizeof(*cep));
+ ep = iscsi_create_endpoint(shost, sizeof(*cep));
if (!ep) {
err = -ENOMEM;
pr_info("iscsi alloc ep, OOM.\n");
diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
index a02b34ea5cab..5ae589ea1dd2 100644
--- a/drivers/scsi/qedi/qedi_iscsi.c
+++ b/drivers/scsi/qedi/qedi_iscsi.c
@@ -847,7 +847,7 @@ qedi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
return ERR_PTR(ret);
}

- ep = iscsi_create_endpoint(sizeof(struct qedi_endpoint));
+ ep = iscsi_create_endpoint(shost, sizeof(struct qedi_endpoint));
if (!ep) {
QEDI_ERR(&qedi->dbg_ctx, "endpoint create fail\n");
ret = -ENOMEM;
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 64c6fa563fdb..5785bf6c3ec0 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -1673,7 +1673,7 @@ qla4xxx_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
}

ha = iscsi_host_priv(shost);
- ep = iscsi_create_endpoint(sizeof(struct qla_endpoint));
+ ep = iscsi_create_endpoint(shost, sizeof(struct qla_endpoint));
if (!ep) {
ret = -ENOMEM;
return ERR_PTR(ret);
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 0b23ba346cbe..6ab7ca82b121 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -194,7 +194,7 @@ static int iscsi_match_epid(struct device *dev, const void *data)
}

struct iscsi_endpoint *
-iscsi_create_endpoint(int dd_size)
+iscsi_create_endpoint(struct Scsi_Host *shost, int dd_size)
{
struct device *dev;
struct iscsi_endpoint *ep;
@@ -221,6 +221,7 @@ iscsi_create_endpoint(int dd_size)

ep->id = id;
ep->dev.class = &iscsi_endpoint_class;
+ ep->dev.parent = &shost->shost_gendev;
dev_set_name(&ep->dev, "ep-%llu", (unsigned long long) id);
err = device_register(&ep->dev);
if (err)
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index b266d2a3bcb1..3b40fea93556 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -267,6 +267,9 @@ struct iscsi_cls_session {
#define iscsi_session_to_shost(_session) \
dev_to_shost(_session->dev.parent)

+#define iscsi_endpoint_to_shost(_ep) \
+ dev_to_shost(_ep->dev.parent)
+
#define starget_to_session(_stgt) \
iscsi_dev_to_session(_stgt->dev.parent)

@@ -440,7 +443,8 @@ extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
extern void iscsi_unblock_session(struct iscsi_cls_session *session);
extern void iscsi_block_session(struct iscsi_cls_session *session);
extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time);
-extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size);
+extern struct iscsi_endpoint *iscsi_create_endpoint(struct Scsi_Host *shost,
+ int dd_size);
extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep);
extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle);
extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd);
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:38 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open list
This lets iscsi_tcp operate in multiple namespaces. It uses current
during session creation to find the net namespace, but it might be
better to manage to pass it along from the iscsi netlink socket.

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/scsi/iscsi_tcp.c | 7 +++++++
drivers/scsi/scsi_transport_iscsi.c | 7 ++++++-
include/scsi/scsi_transport_iscsi.h | 1 +
3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 4d934d6c3e13..b368c94c884b 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -957,6 +957,11 @@ static int iscsi_sw_tcp_slave_configure(struct scsi_device *sdev)
return 0;
}

+static struct net *iscsi_sw_tcp_netns(struct Scsi_Host *shost)
+{
+ return current->nsproxy->net_ns;
+}
+
static struct scsi_host_template iscsi_sw_tcp_sht = {
.module = THIS_MODULE,
.name = "iSCSI Initiator over TCP/IP",
@@ -1013,6 +1018,8 @@ static struct iscsi_transport iscsi_sw_tcp_transport = {
.alloc_pdu = iscsi_sw_tcp_pdu_alloc,
/* recovery */
.session_recovery_timedout = iscsi_session_recovery_timedout,
+ /* net namespace */
+ .get_netns = iscsi_sw_tcp_netns,
};

static int __init iscsi_sw_tcp_init(void)
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 1fc5878b1a8c..2ec10f6ac3a2 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1600,11 +1600,16 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
{
struct Scsi_Host *shost = dev_to_shost(dev);
struct iscsi_cls_host *ihost = shost->shost_data;
+ struct iscsi_internal *priv = to_iscsi_internal(shost->transportt);
+ struct iscsi_transport *transport = priv->iscsi_transport;

memset(ihost, 0, sizeof(*ihost));
atomic_set(&ihost->nr_scans, 0);
mutex_init(&ihost->mutex);
- ihost->netns = &init_net;
+ if (transport->get_netns)
+ ihost->netns = transport->get_netns(shost);
+ else
+ ihost->netns = &init_net;

iscsi_bsg_host_add(shost, ihost);
/* ignore any bsg add error - we just can't do sgio */
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 8c8191dfdc21..3c4cd4779f72 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -168,6 +168,7 @@ struct iscsi_transport {
int (*logout_flashnode_sid) (struct iscsi_cls_session *cls_sess);
int (*get_host_stats) (struct Scsi_Host *shost, char *buf, int len);
u8 (*check_protection)(struct iscsi_task *task, sector_t *sector);
+ struct net *(*get_netns)(struct Scsi_Host *shost);
};

/*
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:38 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open list
Make use of the per-net netlink sockets. Responses are sent back on the
same socket/namespace the request was received on. Async events are
reported on the socket/namespace stored in the iscsi_cls_host associated
with the event.

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/scsi/scsi_transport_iscsi.c | 92 ++++++++++++++++++++++++-------------
1 file changed, 61 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index d29c095ccc7d..1fc5878b1a8c 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2418,8 +2418,8 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
}

static int
-iscsi_multicast_netns(struct net *net, struct sk_buff *skb,
- uint32_t group, gfp_t gfp)
+iscsi_multicast_skb(struct net *net, struct sk_buff *skb,
+ uint32_t group, gfp_t gfp)
{
struct sock *nls;
struct iscsi_net *isn;
@@ -2429,12 +2429,6 @@ iscsi_multicast_netns(struct net *net, struct sk_buff *skb,
return nlmsg_multicast(nls, skb, 0, group, gfp);
}

-static int
-iscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)
-{
- return iscsi_multicast_netns(&init_net, skb, group, gfp);
-}
-
int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
char *data, uint32_t data_size)
{
@@ -2443,6 +2437,7 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
struct iscsi_uevent *ev;
char *pdu;
struct iscsi_internal *priv;
+ struct net *net;
int len = nlmsg_total_size(sizeof(*ev) + sizeof(struct iscsi_hdr) +
data_size);

@@ -2469,7 +2464,8 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);

- return iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
+ net = iscsi_conn_net(conn);
+ return iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
}
EXPORT_SYMBOL_GPL(iscsi_recv_pdu);

@@ -2480,6 +2476,7 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,
struct nlmsghdr *nlh;
struct sk_buff *skb;
struct iscsi_uevent *ev;
+ struct net *net;
int len = nlmsg_total_size(sizeof(*ev) + data_size);

skb = alloc_skb(len, GFP_ATOMIC);
@@ -2504,7 +2501,8 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,

memcpy((char *)ev + sizeof(*ev), data, data_size);

- return iscsi_multicast_skb(skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);
+ net = iscsi_host_net(shost->shost_data);
+ return iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);
}
EXPORT_SYMBOL_GPL(iscsi_offload_mesg);

@@ -2514,6 +2512,7 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
struct sk_buff *skb;
struct iscsi_uevent *ev;
struct iscsi_internal *priv;
+ struct net *net;
int len = nlmsg_total_size(sizeof(*ev));

priv = iscsi_if_transport_lookup(conn->transport);
@@ -2535,7 +2534,8 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
ev->r.connerror.cid = conn->cid;
ev->r.connerror.sid = iscsi_conn_get_sid(conn);

- iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
+ net = iscsi_conn_net(conn);
+ iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);

iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn error (%d)\n",
error);
@@ -2549,6 +2549,7 @@ void iscsi_conn_login_event(struct iscsi_cls_conn *conn,
struct sk_buff *skb;
struct iscsi_uevent *ev;
struct iscsi_internal *priv;
+ struct net *net;
int len = nlmsg_total_size(sizeof(*ev));

priv = iscsi_if_transport_lookup(conn->transport);
@@ -2569,7 +2570,9 @@ void iscsi_conn_login_event(struct iscsi_cls_conn *conn,
ev->r.conn_login.state = state;
ev->r.conn_login.cid = conn->cid;
ev->r.conn_login.sid = iscsi_conn_get_sid(conn);
- iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
+
+ net = iscsi_conn_net(conn);
+ iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);

iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn login (%d)\n",
state);
@@ -2580,11 +2583,17 @@ void iscsi_post_host_event(uint32_t host_no, struct iscsi_transport *transport,
enum iscsi_host_event_code code, uint32_t data_size,
uint8_t *data)
{
+ struct Scsi_Host *shost;
+ struct net *net;
struct nlmsghdr *nlh;
struct sk_buff *skb;
struct iscsi_uevent *ev;
int len = nlmsg_total_size(sizeof(*ev) + data_size);

+ shost = scsi_host_lookup(host_no);
+ if (!shost)
+ return;
+
skb = alloc_skb(len, GFP_NOIO);
if (!skb) {
printk(KERN_ERR "gracefully ignored host event (%d):%d OOM\n",
@@ -2603,7 +2612,9 @@ void iscsi_post_host_event(uint32_t host_no, struct iscsi_transport *transport,
if (data_size)
memcpy((char *)ev + sizeof(*ev), data, data_size);

- iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_NOIO);
+ net = iscsi_host_net(shost->shost_data);
+ scsi_host_put(shost);
+ iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_NOIO);
}
EXPORT_SYMBOL_GPL(iscsi_post_host_event);

@@ -2611,11 +2622,17 @@ void iscsi_ping_comp_event(uint32_t host_no, struct iscsi_transport *transport,
uint32_t status, uint32_t pid, uint32_t data_size,
uint8_t *data)
{
+ struct Scsi_Host *shost;
+ struct net *net;
struct nlmsghdr *nlh;
struct sk_buff *skb;
struct iscsi_uevent *ev;
int len = nlmsg_total_size(sizeof(*ev) + data_size);

+ shost = scsi_host_lookup(host_no);
+ if (!shost)
+ return;
+
skb = alloc_skb(len, GFP_NOIO);
if (!skb) {
printk(KERN_ERR "gracefully ignored ping comp: OOM\n");
@@ -2632,13 +2649,15 @@ void iscsi_ping_comp_event(uint32_t host_no, struct iscsi_transport *transport,
ev->r.ping_comp.data_size = data_size;
memcpy((char *)ev + sizeof(*ev), data, data_size);

- iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_NOIO);
+ net = iscsi_host_net(shost->shost_data);
+ scsi_host_put(shost);
+ iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_NOIO);
}
EXPORT_SYMBOL_GPL(iscsi_ping_comp_event);

static int
-iscsi_if_send_reply(uint32_t group, int seq, int type, int done, int multi,
- void *payload, int size)
+iscsi_if_send_reply(struct net *net, uint32_t group, int seq, int type,
+ int done, int multi, void *payload, int size)
{
struct sk_buff *skb;
struct nlmsghdr *nlh;
@@ -2655,11 +2674,12 @@ iscsi_if_send_reply(uint32_t group, int seq, int type, int done, int multi,
nlh = __nlmsg_put(skb, 0, 0, t, (len - sizeof(*nlh)), 0);
nlh->nlmsg_flags = flags;
memcpy(nlmsg_data(nlh), payload, size);
- return iscsi_multicast_skb(skb, group, GFP_ATOMIC);
+ return iscsi_multicast_skb(net, skb, group, GFP_ATOMIC);
}

static int
-iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
+iscsi_if_get_stats(struct net *net, struct iscsi_transport *transport,
+ struct nlmsghdr *nlh)
{
struct iscsi_uevent *ev = nlmsg_data(nlh);
struct iscsi_stats *stats;
@@ -2716,7 +2736,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
skb_trim(skbstat, NLMSG_ALIGN(actual_size));
nlhstat->nlmsg_len = actual_size;

- err = iscsi_multicast_skb(skbstat, ISCSI_NL_GRP_ISCSID,
+ err = iscsi_multicast_skb(net, skbstat, ISCSI_NL_GRP_ISCSID,
GFP_ATOMIC);
} while (err < 0 && err != -ECONNREFUSED);

@@ -2736,6 +2756,7 @@ int iscsi_session_event(struct iscsi_cls_session *session,
struct iscsi_uevent *ev;
struct sk_buff *skb;
struct nlmsghdr *nlh;
+ struct net *net;
int rc, len = nlmsg_total_size(sizeof(*ev));

priv = iscsi_if_transport_lookup(session->transport);
@@ -2780,7 +2801,8 @@ int iscsi_session_event(struct iscsi_cls_session *session,
* this will occur if the daemon is not up, so we just warn
* the user and when the daemon is restarted it will handle it
*/
- rc = iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_KERNEL);
+ net = iscsi_sess_net(session);
+ rc = iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_KERNEL);
if (rc == -ESRCH)
iscsi_cls_session_printk(KERN_ERR, session,
"Cannot notify userspace of session "
@@ -3103,7 +3125,8 @@ iscsi_send_ping(struct iscsi_transport *transport, struct iscsi_uevent *ev)
}

static int
-iscsi_get_chap(struct iscsi_transport *transport, struct nlmsghdr *nlh)
+iscsi_get_chap(struct net *net, struct iscsi_transport *transport,
+ struct nlmsghdr *nlh)
{
struct iscsi_uevent *ev = nlmsg_data(nlh);
struct Scsi_Host *shost = NULL;
@@ -3162,7 +3185,7 @@ iscsi_get_chap(struct iscsi_transport *transport, struct nlmsghdr *nlh)
skb_trim(skbchap, NLMSG_ALIGN(actual_size));
nlhchap->nlmsg_len = actual_size;

- err = iscsi_multicast_skb(skbchap, ISCSI_NL_GRP_ISCSID,
+ err = iscsi_multicast_skb(net, skbchap, ISCSI_NL_GRP_ISCSID,
GFP_KERNEL);
} while (err < 0 && err != -ECONNREFUSED);

@@ -3509,7 +3532,8 @@ static int iscsi_logout_flashnode_sid(struct iscsi_transport *transport,
}

static int
-iscsi_get_host_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
+iscsi_get_host_stats(struct net *net, struct iscsi_transport *transport,
+ struct nlmsghdr *nlh)
{
struct iscsi_uevent *ev = nlmsg_data(nlh);
struct Scsi_Host *shost = NULL;
@@ -3569,8 +3593,8 @@ iscsi_get_host_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
skb_trim(skbhost_stats, NLMSG_ALIGN(actual_size));
nlhhost_stats->nlmsg_len = actual_size;

- err = iscsi_multicast_skb(skbhost_stats, ISCSI_NL_GRP_ISCSID,
- GFP_KERNEL);
+ err = iscsi_multicast_skb(net, skbhost_stats,
+ ISCSI_NL_GRP_ISCSID, GFP_KERNEL);
} while (err < 0 && err != -ECONNREFUSED);

exit_host_stats:
@@ -3580,7 +3604,8 @@ iscsi_get_host_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)


static int
-iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
+iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
+ struct nlmsghdr *nlh, uint32_t *group)
{
int err = 0;
struct iscsi_uevent *ev = nlmsg_data(nlh);
@@ -3703,7 +3728,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
err = -EINVAL;
break;
case ISCSI_UEVENT_GET_STATS:
- err = iscsi_if_get_stats(transport, nlh);
+ err = iscsi_if_get_stats(net, transport, nlh);
break;
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
case ISCSI_UEVENT_TRANSPORT_EP_POLL:
@@ -3728,7 +3753,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
err = iscsi_send_ping(transport, ev);
break;
case ISCSI_UEVENT_GET_CHAP:
- err = iscsi_get_chap(transport, nlh);
+ err = iscsi_get_chap(net, transport, nlh);
break;
case ISCSI_UEVENT_DELETE_CHAP:
err = iscsi_delete_chap(transport, ev);
@@ -3759,7 +3784,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
nlmsg_attrlen(nlh, sizeof(*ev)));
break;
case ISCSI_UEVENT_GET_HOST_STATS:
- err = iscsi_get_host_stats(transport, nlh);
+ err = iscsi_get_host_stats(net, transport, nlh);
break;
default:
err = -ENOSYS;
@@ -3777,6 +3802,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
static void
iscsi_if_rx(struct sk_buff *skb)
{
+ struct sock *sk = skb->sk;
+ struct net *net = sock_net(sk);
+
mutex_lock(&rx_queue_mutex);
while (skb->len >= NLMSG_HDRLEN) {
int err;
@@ -3796,7 +3824,7 @@ iscsi_if_rx(struct sk_buff *skb)
if (rlen > skb->len)
rlen = skb->len;

- err = iscsi_if_recv_msg(skb, nlh, &group);
+ err = iscsi_if_recv_msg(net, skb, nlh, &group);
if (err) {
ev->type = ISCSI_KEVENT_IF_ERROR;
ev->iferror = err;
@@ -3812,7 +3840,9 @@ iscsi_if_rx(struct sk_buff *skb)
break;
if (ev->type == ISCSI_UEVENT_GET_CHAP && !err)
break;
- err = iscsi_if_send_reply(group, nlh->nlmsg_seq,
+ if (ev->type == ISCSI_UEVENT_GET_HOST_STATS && !err)
+ break;
+ err = iscsi_if_send_reply(net, group, nlh->nlmsg_seq,
nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
} while (err < 0 && err != -ECONNREFUSED && err != -ESRCH);
skb_pull(skb, rlen);
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:40 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, Or Gerlitz, Sagi Grimberg, Roi Dayan, Doug Ledford, Sean Hefty, Hal Rosenstock, Subbu Seetharaman, Ketan Mukadam, Jitendra Bhivare, James E.J. Bottomley, Martin K. Petersen, supporter:BROADCOM BNX2I 1/10 GIGABIT iSCSI DRIVER, supporter:QLOGIC QL41xxx ISCSI DRIVER, open list:ISCSI EXTENSIONS FOR RDMA (ISER) INITIATOR, open list
All internal lookups of iSCSI transport objects need to be filtered by
net namespace.

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/infiniband/ulp/iser/iscsi_iser.c | 5 +-
drivers/scsi/be2iscsi/be_iscsi.c | 4 +-
drivers/scsi/bnx2i/bnx2i_iscsi.c | 4 +-
drivers/scsi/cxgbi/libcxgbi.c | 4 +-
drivers/scsi/qedi/qedi_iscsi.c | 4 +-
drivers/scsi/qla4xxx/ql4_os.c | 6 +-
drivers/scsi/scsi_transport_iscsi.c | 201 +++++++++++++++++++------------
include/scsi/scsi_transport_iscsi.h | 5 +-
8 files changed, 150 insertions(+), 83 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 0a4214be4877..6d088634a806 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -464,15 +464,18 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
struct iscsi_conn *conn = cls_conn->dd_data;
struct iser_conn *iser_conn;
struct iscsi_endpoint *ep;
+ struct net *net;
int error;

error = iscsi_conn_bind(cls_session, cls_conn, is_leading);
if (error)
return error;

+
/* the transport ep handle comes from user space so it must be
* verified against the global ib connections list */
- ep = iscsi_lookup_endpoint(transport_eph);
+ net = iscsi_sess_net(cls_session);
+ ep = iscsi_lookup_endpoint(net, transport_eph);
if (!ep) {
iser_err("can't bind eph %llx\n",
(unsigned long long)transport_eph);
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 33f79f385660..1f4b1b98b4e6 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -181,8 +181,10 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
struct beiscsi_endpoint *beiscsi_ep;
struct iscsi_endpoint *ep;
uint16_t cri_index;
+ struct net *net;

- ep = iscsi_lookup_endpoint(transport_fd);
+ net = iscsi_sess_net(cls_session);
+ ep = iscsi_lookup_endpoint(net, transport_fd);
if (!ep)
return -EINVAL;

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 19fadb5d3b3c..58dca20f0ba0 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1414,9 +1414,11 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session,
struct bnx2i_hba *hba = iscsi_host_priv(shost);
struct bnx2i_endpoint *bnx2i_ep;
struct iscsi_endpoint *ep;
+ struct net *net;
int ret_code;

- ep = iscsi_lookup_endpoint(transport_fd);
+ net = iscsi_sess_net(cls_session);
+ ep = iscsi_lookup_endpoint(net, transport_fd);
if (!ep)
return -EINVAL;
/*
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 558484f72738..e768fe285e85 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -2373,9 +2373,11 @@ int cxgbi_bind_conn(struct iscsi_cls_session *cls_session,
struct iscsi_endpoint *ep;
struct cxgbi_endpoint *cep;
struct cxgbi_sock *csk;
+ struct net *net;
int err;

- ep = iscsi_lookup_endpoint(transport_eph);
+ net = iscsi_sess_net(cls_session);
+ ep = iscsi_lookup_endpoint(net, transport_eph);
if (!ep)
return -EINVAL;

diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
index 5ae589ea1dd2..5cd267a457f4 100644
--- a/drivers/scsi/qedi/qedi_iscsi.c
+++ b/drivers/scsi/qedi/qedi_iscsi.c
@@ -381,8 +381,10 @@ static int qedi_conn_bind(struct iscsi_cls_session *cls_session,
struct qedi_ctx *qedi = iscsi_host_priv(shost);
struct qedi_endpoint *qedi_ep;
struct iscsi_endpoint *ep;
+ struct net *net;

- ep = iscsi_lookup_endpoint(transport_fd);
+ net = iscsi_sess_net(cls_session);
+ ep = iscsi_lookup_endpoint(net, transport_fd);
if (!ep)
return -EINVAL;

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 5785bf6c3ec0..770313d0b986 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -3178,6 +3178,7 @@ static int qla4xxx_conn_bind(struct iscsi_cls_session *cls_session,
struct ddb_entry *ddb_entry;
struct scsi_qla_host *ha;
struct iscsi_session *sess;
+ struct net *net;

sess = cls_session->dd_data;
ddb_entry = sess->dd_data;
@@ -3186,9 +3187,12 @@ static int qla4xxx_conn_bind(struct iscsi_cls_session *cls_session,
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: sid = %d, cid = %d\n", __func__,
cls_session->sid, cls_conn->cid));

+ net = iscsi_sess_net(cls_session);
+ ep = iscsi_lookup_endpoint(net, transport_fd);
+ if (!ep)
+ return -EINVAL;
if (iscsi_conn_bind(cls_session, cls_conn, is_leading))
return -EINVAL;
- ep = iscsi_lookup_endpoint(transport_fd);
conn = cls_conn->dd_data;
qla_conn = conn->dd_data;
qla_conn->qla_ep = ep->dd_data;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 2ec10f6ac3a2..fbec3a019f00 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -274,10 +274,11 @@ void iscsi_destroy_endpoint(struct iscsi_endpoint *ep)
}
EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint);

-struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
+struct iscsi_endpoint *iscsi_lookup_endpoint(struct net *net, u64 handle)
{
struct iscsi_endpoint *ep;
struct device *dev;
+ struct net *ns;

dev = class_find_device(&iscsi_endpoint_class, NULL, &handle,
iscsi_match_epid);
@@ -285,6 +286,9 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
return NULL;

ep = iscsi_dev_to_endpoint(dev);
+ ns = iscsi_endpoint_net(ep);
+ if (ns != net)
+ ep = NULL;
/*
* we can drop this now because the interface will prevent
* removals and lookups from racing.
@@ -1658,13 +1662,14 @@ static DECLARE_TRANSPORT_CLASS_NS(iscsi_host_class,
&net_ns_type_operations,
iscsi_host_namespace);

-static struct net *iscsi_sess_net(struct iscsi_cls_session *cls_session)
+struct net *iscsi_sess_net(struct iscsi_cls_session *cls_session)
{
struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
struct iscsi_cls_host *ihost = shost->shost_data;

return iscsi_host_net(ihost);
}
+EXPORT_SYMBOL_GPL(iscsi_sess_net);

static const void *iscsi_sess_namespace(struct device *dev)
{
@@ -1724,14 +1729,19 @@ static uint32_t iscsi_conn_get_sid(struct iscsi_cls_conn *conn)
/*
* Returns the matching session to a given sid
*/
-static struct iscsi_cls_session *iscsi_session_lookup(uint32_t sid)
+static struct iscsi_cls_session *iscsi_session_lookup(struct net *net,
+ uint32_t sid)
{
unsigned long flags;
struct iscsi_cls_session *sess;
+ struct net *ns;

spin_lock_irqsave(&sesslock, flags);
list_for_each_entry(sess, &sesslist, sess_list) {
if (sess->sid == sid) {
+ ns = iscsi_sess_net(sess);
+ if (ns != net)
+ continue;
spin_unlock_irqrestore(&sesslock, flags);
return sess;
}
@@ -1743,14 +1753,19 @@ static struct iscsi_cls_session *iscsi_session_lookup(uint32_t sid)
/*
* Returns the matching connection to a given sid / cid tuple
*/
-static struct iscsi_cls_conn *iscsi_conn_lookup(uint32_t sid, uint32_t cid)
+static struct iscsi_cls_conn *iscsi_conn_lookup(struct net *net, uint32_t sid,
+ uint32_t cid)
{
unsigned long flags;
struct iscsi_cls_conn *conn;
+ struct net *ns;

spin_lock_irqsave(&connlock, flags);
list_for_each_entry(conn, &connlist, conn_list) {
if ((conn->cid == cid) && (iscsi_conn_get_sid(conn) == sid)) {
+ ns = iscsi_conn_net(conn);
+ if (ns != net)
+ continue;
spin_unlock_irqrestore(&connlock, flags);
return conn;
}
@@ -2703,7 +2718,7 @@ iscsi_if_get_stats(struct net *net, struct iscsi_transport *transport,
if (!priv)
return -EINVAL;

- conn = iscsi_conn_lookup(ev->u.get_stats.sid, ev->u.get_stats.cid);
+ conn = iscsi_conn_lookup(net, ev->u.get_stats.sid, ev->u.get_stats.cid);
if (!conn)
return -EEXIST;

@@ -2845,12 +2860,13 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_endpoint *ep,
}

static int
-iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+iscsi_if_create_conn(struct net *net, struct iscsi_transport *transport,
+ struct iscsi_uevent *ev)
{
struct iscsi_cls_conn *conn;
struct iscsi_cls_session *session;

- session = iscsi_session_lookup(ev->u.c_conn.sid);
+ session = iscsi_session_lookup(net, ev->u.c_conn.sid);
if (!session) {
printk(KERN_ERR "iscsi: invalid session %d.\n",
ev->u.c_conn.sid);
@@ -2872,11 +2888,12 @@ iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
}

static int
-iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+iscsi_if_destroy_conn(struct net *net, struct iscsi_transport *transport,
+ struct iscsi_uevent *ev)
{
struct iscsi_cls_conn *conn;

- conn = iscsi_conn_lookup(ev->u.d_conn.sid, ev->u.d_conn.cid);
+ conn = iscsi_conn_lookup(net, ev->u.d_conn.sid, ev->u.d_conn.cid);
if (!conn)
return -EINVAL;

@@ -2888,15 +2905,16 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev
}

static int
-iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+iscsi_set_param(struct net *net, struct iscsi_transport *transport,
+ struct iscsi_uevent *ev)
{
char *data = (char*)ev + sizeof(*ev);
struct iscsi_cls_conn *conn;
struct iscsi_cls_session *session;
int err = 0, value = 0;

- session = iscsi_session_lookup(ev->u.set_param.sid);
- conn = iscsi_conn_lookup(ev->u.set_param.sid, ev->u.set_param.cid);
+ session = iscsi_session_lookup(net, ev->u.set_param.sid);
+ conn = iscsi_conn_lookup(net, ev->u.set_param.sid, ev->u.set_param.cid);
if (!conn || !session)
return -EINVAL;

@@ -2914,7 +2932,21 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
return err;
}

-static int iscsi_if_ep_connect(struct iscsi_transport *transport,
+static struct Scsi_Host *iscsi_host_lookup(struct net *net,
+ unsigned short hostnum)
+{
+ struct Scsi_Host *shost;
+
+ shost = scsi_host_lookup(hostnum);
+ if (shost && iscsi_host_net(shost->shost_data) != net) {
+ scsi_host_put(shost);
+ shost = NULL;
+ }
+ return shost;
+}
+
+static int iscsi_if_ep_connect(struct net *net,
+ struct iscsi_transport *transport,
struct iscsi_uevent *ev, int msg_type)
{
struct iscsi_endpoint *ep;
@@ -2926,7 +2958,8 @@ static int iscsi_if_ep_connect(struct iscsi_transport *transport,
return -EINVAL;

if (msg_type == ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST) {
- shost = scsi_host_lookup(ev->u.ep_connect_through_host.host_no);
+ shost = iscsi_host_lookup(net,
+ ev->u.ep_connect_through_host.host_no);
if (!shost) {
printk(KERN_ERR "ep connect failed. Could not find "
"host no %u\n",
@@ -2951,7 +2984,8 @@ static int iscsi_if_ep_connect(struct iscsi_transport *transport,
return err;
}

-static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,
+static int iscsi_if_ep_disconnect(struct net *net,
+ struct iscsi_transport *transport,
u64 ep_handle)
{
struct iscsi_cls_conn *conn;
@@ -2960,7 +2994,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,
if (!transport->ep_disconnect)
return -EINVAL;

- ep = iscsi_lookup_endpoint(ep_handle);
+ ep = iscsi_lookup_endpoint(net, ep_handle);
if (!ep)
return -EINVAL;
conn = ep->conn;
@@ -2975,7 +3009,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,
}

static int
-iscsi_if_transport_ep(struct iscsi_transport *transport,
+iscsi_if_transport_ep(struct net *net, struct iscsi_transport *transport,
struct iscsi_uevent *ev, int msg_type)
{
struct iscsi_endpoint *ep;
@@ -2984,13 +3018,13 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,
switch (msg_type) {
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST:
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
- rc = iscsi_if_ep_connect(transport, ev, msg_type);
+ rc = iscsi_if_ep_connect(net, transport, ev, msg_type);
break;
case ISCSI_UEVENT_TRANSPORT_EP_POLL:
if (!transport->ep_poll)
return -EINVAL;

- ep = iscsi_lookup_endpoint(ev->u.ep_poll.ep_handle);
+ ep = iscsi_lookup_endpoint(net, ev->u.ep_poll.ep_handle);
if (!ep)
return -EINVAL;

@@ -2998,7 +3032,7 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,
ev->u.ep_poll.timeout_ms);
break;
case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
- rc = iscsi_if_ep_disconnect(transport,
+ rc = iscsi_if_ep_disconnect(net, transport,
ev->u.ep_disconnect.ep_handle);
break;
}
@@ -3006,7 +3040,7 @@ iscsi_if_transport_ep(struct iscsi_transport *transport,
}

static int
-iscsi_tgt_dscvr(struct iscsi_transport *transport,
+iscsi_tgt_dscvr(struct net *net, struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
@@ -3016,7 +3050,7 @@ iscsi_tgt_dscvr(struct iscsi_transport *transport,
if (!transport->tgt_dscvr)
return -EINVAL;

- shost = scsi_host_lookup(ev->u.tgt_dscvr.host_no);
+ shost = iscsi_host_lookup(net, ev->u.tgt_dscvr.host_no);
if (!shost) {
printk(KERN_ERR "target discovery could not find host no %u\n",
ev->u.tgt_dscvr.host_no);
@@ -3032,7 +3066,7 @@ iscsi_tgt_dscvr(struct iscsi_transport *transport,
}

static int
-iscsi_set_host_param(struct iscsi_transport *transport,
+iscsi_set_host_param(struct net *net, struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
char *data = (char*)ev + sizeof(*ev);
@@ -3042,7 +3076,7 @@ iscsi_set_host_param(struct iscsi_transport *transport,
if (!transport->set_host_param)
return -ENOSYS;

- shost = scsi_host_lookup(ev->u.set_host_param.host_no);
+ shost = iscsi_host_lookup(net, ev->u.set_host_param.host_no);
if (!shost) {
printk(KERN_ERR "set_host_param could not find host no %u\n",
ev->u.set_host_param.host_no);
@@ -3056,7 +3090,8 @@ iscsi_set_host_param(struct iscsi_transport *transport,
}

static int
-iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+iscsi_set_path(struct net *net, struct iscsi_transport *transport,
+ struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
struct iscsi_path *params;
@@ -3065,7 +3100,7 @@ iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
if (!transport->set_path)
return -ENOSYS;

- shost = scsi_host_lookup(ev->u.set_path.host_no);
+ shost = iscsi_host_lookup(net, ev->u.set_path.host_no);
if (!shost) {
printk(KERN_ERR "set path could not find host no %u\n",
ev->u.set_path.host_no);
@@ -3080,7 +3115,7 @@ iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
}

static int
-iscsi_set_iface_params(struct iscsi_transport *transport,
+iscsi_set_iface_params(struct net *net, struct iscsi_transport *transport,
struct iscsi_uevent *ev, uint32_t len)
{
char *data = (char *)ev + sizeof(*ev);
@@ -3090,7 +3125,7 @@ iscsi_set_iface_params(struct iscsi_transport *transport,
if (!transport->set_iface_param)
return -ENOSYS;

- shost = scsi_host_lookup(ev->u.set_iface_params.host_no);
+ shost = iscsi_host_lookup(net, ev->u.set_iface_params.host_no);
if (!shost) {
printk(KERN_ERR "set_iface_params could not find host no %u\n",
ev->u.set_iface_params.host_no);
@@ -3103,7 +3138,8 @@ iscsi_set_iface_params(struct iscsi_transport *transport,
}

static int
-iscsi_send_ping(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+iscsi_send_ping(struct net *net, struct iscsi_transport *transport,
+ struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
struct sockaddr *dst_addr;
@@ -3112,7 +3148,7 @@ iscsi_send_ping(struct iscsi_transport *transport, struct iscsi_uevent *ev)
if (!transport->send_ping)
return -ENOSYS;

- shost = scsi_host_lookup(ev->u.iscsi_ping.host_no);
+ shost = iscsi_host_lookup(net, ev->u.iscsi_ping.host_no);
if (!shost) {
printk(KERN_ERR "iscsi_ping could not find host no %u\n",
ev->u.iscsi_ping.host_no);
@@ -3154,7 +3190,7 @@ iscsi_get_chap(struct net *net, struct iscsi_transport *transport,
chap_buf_size = (ev->u.get_chap.num_entries * sizeof(*chap_rec));
len = nlmsg_total_size(sizeof(*ev) + chap_buf_size);

- shost = scsi_host_lookup(ev->u.get_chap.host_no);
+ shost = iscsi_host_lookup(net, ev->u.get_chap.host_no);
if (!shost) {
printk(KERN_ERR "%s: failed. Could not find host no %u\n",
__func__, ev->u.get_chap.host_no);
@@ -3199,7 +3235,7 @@ iscsi_get_chap(struct net *net, struct iscsi_transport *transport,
return err;
}

-static int iscsi_set_chap(struct iscsi_transport *transport,
+static int iscsi_set_chap(struct net *net, struct iscsi_transport *transport,
struct iscsi_uevent *ev, uint32_t len)
{
char *data = (char *)ev + sizeof(*ev);
@@ -3209,7 +3245,7 @@ static int iscsi_set_chap(struct iscsi_transport *transport,
if (!transport->set_chap)
return -ENOSYS;

- shost = scsi_host_lookup(ev->u.set_path.host_no);
+ shost = iscsi_host_lookup(net, ev->u.set_path.host_no);
if (!shost) {
pr_err("%s could not find host no %u\n",
__func__, ev->u.set_path.host_no);
@@ -3221,7 +3257,7 @@ static int iscsi_set_chap(struct iscsi_transport *transport,
return err;
}

-static int iscsi_delete_chap(struct iscsi_transport *transport,
+static int iscsi_delete_chap(struct net *net, struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
@@ -3230,7 +3266,7 @@ static int iscsi_delete_chap(struct iscsi_transport *transport,
if (!transport->delete_chap)
return -ENOSYS;

- shost = scsi_host_lookup(ev->u.delete_chap.host_no);
+ shost = iscsi_host_lookup(net, ev->u.delete_chap.host_no);
if (!shost) {
printk(KERN_ERR "%s could not find host no %u\n",
__func__, ev->u.delete_chap.host_no);
@@ -3266,7 +3302,8 @@ char *iscsi_get_discovery_parent_name(int parent_type)
}
EXPORT_SYMBOL_GPL(iscsi_get_discovery_parent_name);

-static int iscsi_set_flashnode_param(struct iscsi_transport *transport,
+static int iscsi_set_flashnode_param(struct net *net,
+ struct iscsi_transport *transport,
struct iscsi_uevent *ev, uint32_t len)
{
char *data = (char *)ev + sizeof(*ev);
@@ -3282,7 +3319,7 @@ static int iscsi_set_flashnode_param(struct iscsi_transport *transport,
goto exit_set_fnode;
}

- shost = scsi_host_lookup(ev->u.set_flashnode.host_no);
+ shost = iscsi_host_lookup(net, ev->u.set_flashnode.host_no);
if (!shost) {
pr_err("%s could not find host no %u\n",
__func__, ev->u.set_flashnode.host_no);
@@ -3319,7 +3356,8 @@ static int iscsi_set_flashnode_param(struct iscsi_transport *transport,
return err;
}

-static int iscsi_new_flashnode(struct iscsi_transport *transport,
+static int iscsi_new_flashnode(struct net *net,
+ struct iscsi_transport *transport,
struct iscsi_uevent *ev, uint32_t len)
{
char *data = (char *)ev + sizeof(*ev);
@@ -3332,7 +3370,7 @@ static int iscsi_new_flashnode(struct iscsi_transport *transport,
goto exit_new_fnode;
}

- shost = scsi_host_lookup(ev->u.new_flashnode.host_no);
+ shost = iscsi_host_lookup(net, ev->u.new_flashnode.host_no);
if (!shost) {
pr_err("%s could not find host no %u\n",
__func__, ev->u.new_flashnode.host_no);
@@ -3354,7 +3392,8 @@ static int iscsi_new_flashnode(struct iscsi_transport *transport,
return err;
}

-static int iscsi_del_flashnode(struct iscsi_transport *transport,
+static int iscsi_del_flashnode(struct net *net,
+ struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
@@ -3367,7 +3406,7 @@ static int iscsi_del_flashnode(struct iscsi_transport *transport,
goto exit_del_fnode;
}

- shost = scsi_host_lookup(ev->u.del_flashnode.host_no);
+ shost = iscsi_host_lookup(net, ev->u.del_flashnode.host_no);
if (!shost) {
pr_err("%s could not find host no %u\n",
__func__, ev->u.del_flashnode.host_no);
@@ -3394,7 +3433,8 @@ static int iscsi_del_flashnode(struct iscsi_transport *transport,
return err;
}

-static int iscsi_login_flashnode(struct iscsi_transport *transport,
+static int iscsi_login_flashnode(struct net *net,
+ struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
@@ -3409,7 +3449,7 @@ static int iscsi_login_flashnode(struct iscsi_transport *transport,
goto exit_login_fnode;
}

- shost = scsi_host_lookup(ev->u.login_flashnode.host_no);
+ shost = iscsi_host_lookup(net, ev->u.login_flashnode.host_no);
if (!shost) {
pr_err("%s could not find host no %u\n",
__func__, ev->u.login_flashnode.host_no);
@@ -3446,7 +3486,8 @@ static int iscsi_login_flashnode(struct iscsi_transport *transport,
return err;
}

-static int iscsi_logout_flashnode(struct iscsi_transport *transport,
+static int iscsi_logout_flashnode(struct net *net,
+ struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
@@ -3461,7 +3502,7 @@ static int iscsi_logout_flashnode(struct iscsi_transport *transport,
goto exit_logout_fnode;
}

- shost = scsi_host_lookup(ev->u.logout_flashnode.host_no);
+ shost = iscsi_host_lookup(net, ev->u.logout_flashnode.host_no);
if (!shost) {
pr_err("%s could not find host no %u\n",
__func__, ev->u.logout_flashnode.host_no);
@@ -3499,7 +3540,8 @@ static int iscsi_logout_flashnode(struct iscsi_transport *transport,
return err;
}

-static int iscsi_logout_flashnode_sid(struct iscsi_transport *transport,
+static int iscsi_logout_flashnode_sid(struct net *net,
+ struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
@@ -3511,7 +3553,7 @@ static int iscsi_logout_flashnode_sid(struct iscsi_transport *transport,
goto exit_logout_sid;
}

- shost = scsi_host_lookup(ev->u.logout_flashnode_sid.host_no);
+ shost = iscsi_host_lookup(net, ev->u.logout_flashnode_sid.host_no);
if (!shost) {
pr_err("%s could not find host no %u\n",
__func__, ev->u.logout_flashnode.host_no);
@@ -3519,7 +3561,7 @@ static int iscsi_logout_flashnode_sid(struct iscsi_transport *transport,
goto put_host;
}

- session = iscsi_session_lookup(ev->u.logout_flashnode_sid.sid);
+ session = iscsi_session_lookup(net, ev->u.logout_flashnode_sid.sid);
if (!session) {
pr_err("%s could not find session id %u\n",
__func__, ev->u.logout_flashnode_sid.sid);
@@ -3560,7 +3602,7 @@ iscsi_get_host_stats(struct net *net, struct iscsi_transport *transport,
host_stats_size = sizeof(struct iscsi_offload_host_stats);
len = nlmsg_total_size(sizeof(*ev) + host_stats_size);

- shost = scsi_host_lookup(ev->u.get_host_stats.host_no);
+ shost = iscsi_host_lookup(net, ev->u.get_host_stats.host_no);
if (!shost) {
pr_err("%s: failed. Cound not find host no %u\n",
__func__, ev->u.get_host_stats.host_no);
@@ -3641,8 +3683,10 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
ev->u.c_session.cmds_max,
ev->u.c_session.queue_depth);
break;
+ /* MARK */
case ISCSI_UEVENT_CREATE_BOUND_SESSION:
- ep = iscsi_lookup_endpoint(ev->u.c_bound_session.ep_handle);
+ ep = iscsi_lookup_endpoint(net,
+ ev->u.c_bound_session.ep_handle);
if (!ep) {
err = -EINVAL;
break;
@@ -3655,14 +3699,14 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
ev->u.c_bound_session.queue_depth);
break;
case ISCSI_UEVENT_DESTROY_SESSION:
- session = iscsi_session_lookup(ev->u.d_session.sid);
+ session = iscsi_session_lookup(net, ev->u.d_session.sid);
if (session)
transport->destroy_session(session);
else
err = -EINVAL;
break;
case ISCSI_UEVENT_UNBIND_SESSION:
- session = iscsi_session_lookup(ev->u.d_session.sid);
+ session = iscsi_session_lookup(net, ev->u.d_session.sid);
if (session)
scsi_queue_work(iscsi_session_to_shost(session),
&session->unbind_work);
@@ -3670,17 +3714,18 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
err = -EINVAL;
break;
case ISCSI_UEVENT_CREATE_CONN:
- err = iscsi_if_create_conn(transport, ev);
+ err = iscsi_if_create_conn(net, transport, ev);
break;
case ISCSI_UEVENT_DESTROY_CONN:
- err = iscsi_if_destroy_conn(transport, ev);
+ err = iscsi_if_destroy_conn(net, transport, ev);
break;
case ISCSI_UEVENT_BIND_CONN:
- session = iscsi_session_lookup(ev->u.b_conn.sid);
- conn = iscsi_conn_lookup(ev->u.b_conn.sid, ev->u.b_conn.cid);
+ session = iscsi_session_lookup(net, ev->u.b_conn.sid);
+ conn = iscsi_conn_lookup(net, ev->u.b_conn.sid,
+ ev->u.b_conn.cid);

if (conn && conn->ep)
- iscsi_if_ep_disconnect(transport, conn->ep->id);
+ iscsi_if_ep_disconnect(net, transport, conn->ep->id);

if (!session || !conn) {
err = -EINVAL;
@@ -3693,7 +3738,7 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
if (ev->r.retcode || !transport->ep_connect)
break;

- ep = iscsi_lookup_endpoint(ev->u.b_conn.transport_eph);
+ ep = iscsi_lookup_endpoint(net, ev->u.b_conn.transport_eph);
if (ep) {
ep->conn = conn;

@@ -3706,24 +3751,27 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
"binding\n");
break;
case ISCSI_UEVENT_SET_PARAM:
- err = iscsi_set_param(transport, ev);
+ err = iscsi_set_param(net, transport, ev);
break;
case ISCSI_UEVENT_START_CONN:
- conn = iscsi_conn_lookup(ev->u.start_conn.sid, ev->u.start_conn.cid);
+ conn = iscsi_conn_lookup(net, ev->u.start_conn.sid,
+ ev->u.start_conn.cid);
if (conn)
ev->r.retcode = transport->start_conn(conn);
else
err = -EINVAL;
break;
case ISCSI_UEVENT_STOP_CONN:
- conn = iscsi_conn_lookup(ev->u.stop_conn.sid, ev->u.stop_conn.cid);
+ conn = iscsi_conn_lookup(net, ev->u.stop_conn.sid,
+ ev->u.stop_conn.cid);
if (conn)
transport->stop_conn(conn, ev->u.stop_conn.flag);
else
err = -EINVAL;
break;
case ISCSI_UEVENT_SEND_PDU:
- conn = iscsi_conn_lookup(ev->u.send_pdu.sid, ev->u.send_pdu.cid);
+ conn = iscsi_conn_lookup(net, ev->u.send_pdu.sid,
+ ev->u.send_pdu.cid);
if (conn)
ev->r.retcode = transport->send_pdu(conn,
(struct iscsi_hdr*)((char*)ev + sizeof(*ev)),
@@ -3739,53 +3787,54 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
case ISCSI_UEVENT_TRANSPORT_EP_POLL:
case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST:
- err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type);
+ err = iscsi_if_transport_ep(net, transport, ev,
+ nlh->nlmsg_type);
break;
case ISCSI_UEVENT_TGT_DSCVR:
- err = iscsi_tgt_dscvr(transport, ev);
+ err = iscsi_tgt_dscvr(net, transport, ev);
break;
case ISCSI_UEVENT_SET_HOST_PARAM:
- err = iscsi_set_host_param(transport, ev);
+ err = iscsi_set_host_param(net, transport, ev);
break;
case ISCSI_UEVENT_PATH_UPDATE:
- err = iscsi_set_path(transport, ev);
+ err = iscsi_set_path(net, transport, ev);
break;
case ISCSI_UEVENT_SET_IFACE_PARAMS:
- err = iscsi_set_iface_params(transport, ev,
+ err = iscsi_set_iface_params(net, transport, ev,
nlmsg_attrlen(nlh, sizeof(*ev)));
break;
case ISCSI_UEVENT_PING:
- err = iscsi_send_ping(transport, ev);
+ err = iscsi_send_ping(net, transport, ev);
break;
case ISCSI_UEVENT_GET_CHAP:
err = iscsi_get_chap(net, transport, nlh);
break;
case ISCSI_UEVENT_DELETE_CHAP:
- err = iscsi_delete_chap(transport, ev);
+ err = iscsi_delete_chap(net, transport, ev);
break;
case ISCSI_UEVENT_SET_FLASHNODE_PARAMS:
- err = iscsi_set_flashnode_param(transport, ev,
+ err = iscsi_set_flashnode_param(net, transport, ev,
nlmsg_attrlen(nlh,
sizeof(*ev)));
break;
case ISCSI_UEVENT_NEW_FLASHNODE:
- err = iscsi_new_flashnode(transport, ev,
+ err = iscsi_new_flashnode(net, transport, ev,
nlmsg_attrlen(nlh, sizeof(*ev)));
break;
case ISCSI_UEVENT_DEL_FLASHNODE:
- err = iscsi_del_flashnode(transport, ev);
+ err = iscsi_del_flashnode(net, transport, ev);
break;
case ISCSI_UEVENT_LOGIN_FLASHNODE:
- err = iscsi_login_flashnode(transport, ev);
+ err = iscsi_login_flashnode(net, transport, ev);
break;
case ISCSI_UEVENT_LOGOUT_FLASHNODE:
- err = iscsi_logout_flashnode(transport, ev);
+ err = iscsi_logout_flashnode(net, transport, ev);
break;
case ISCSI_UEVENT_LOGOUT_FLASHNODE_SID:
- err = iscsi_logout_flashnode_sid(transport, ev);
+ err = iscsi_logout_flashnode_sid(net, transport, ev);
break;
case ISCSI_UEVENT_SET_CHAP:
- err = iscsi_set_chap(transport, ev,
+ err = iscsi_set_chap(net, transport, ev,
nlmsg_attrlen(nlh, sizeof(*ev)));
break;
case ISCSI_UEVENT_GET_HOST_STATS:
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 3c4cd4779f72..601e8633d495 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -271,6 +271,8 @@ struct iscsi_cls_session {
#define iscsi_endpoint_to_shost(_ep) \
dev_to_shost(_ep->dev.parent)

+extern struct net *iscsi_sess_net(struct iscsi_cls_session *session);
+
#define starget_to_session(_stgt) \
iscsi_dev_to_session(_stgt->dev.parent)

@@ -448,7 +450,8 @@ extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time);
extern struct iscsi_endpoint *iscsi_create_endpoint(struct Scsi_Host *shost,
int dd_size);
extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep);
-extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle);
+extern struct iscsi_endpoint *iscsi_lookup_endpoint(struct net *net,
+ u64 handle);
extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd);
extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost,
struct iscsi_transport *t,
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:44 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, supporter:QLOGIC QLA4XXX iSCSI DRIVER, James E.J. Bottomley, Martin K. Petersen, open list
The flashnode session and connection devices should be filtered by net
namespace along with the iscsi_host, but we can't do that with a bus
device. As these don't use any of the bus matching functionality, they
make more sense as a class device anyway.

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/scsi/qla4xxx/ql4_os.c | 2 +-
drivers/scsi/scsi_transport_iscsi.c | 36 +++++++++++++++---------------------
include/scsi/scsi_transport_iscsi.h | 2 ++
3 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 770313d0b986..55a729568873 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -7164,7 +7164,7 @@ static int qla4xxx_sysfs_ddb_is_non_persistent(struct device *dev, void *data)
{
struct iscsi_bus_flash_session *fnode_sess;

- if (!iscsi_flashnode_bus_match(dev, NULL))
+ if (!iscsi_is_flashnode_session_dev(dev))
return 0;

fnode_sess = iscsi_dev_to_flash_session(dev);
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index fbec3a019f00..b053d57a482d 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1060,6 +1060,12 @@ static const struct device_type iscsi_flashnode_sess_dev_type = {
.release = iscsi_flashnode_sess_release,
};

+bool iscsi_is_flashnode_session_dev(struct device *dev)
+{
+ return dev->type == &iscsi_flashnode_sess_dev_type;
+}
+EXPORT_SYMBOL_GPL(iscsi_is_flashnode_session_dev);
+
/* flash node connection attrs show */
#define iscsi_flashnode_conn_attr_show(type, name, param) \
static ssize_t \
@@ -1246,20 +1252,8 @@ static const struct device_type iscsi_flashnode_conn_dev_type = {
.release = iscsi_flashnode_conn_release,
};

-static struct bus_type iscsi_flashnode_bus;
-
-int iscsi_flashnode_bus_match(struct device *dev,
- struct device_driver *drv)
-{
- if (dev->bus == &iscsi_flashnode_bus)
- return 1;
- return 0;
-}
-EXPORT_SYMBOL_GPL(iscsi_flashnode_bus_match);
-
-static struct bus_type iscsi_flashnode_bus = {
+static struct class iscsi_flashnode_bus = {
.name = "iscsi_flashnode",
- .match = &iscsi_flashnode_bus_match,
};

/**
@@ -1290,7 +1284,7 @@ iscsi_create_flashnode_sess(struct Scsi_Host *shost, int index,
fnode_sess->transport = transport;
fnode_sess->target_id = index;
fnode_sess->dev.type = &iscsi_flashnode_sess_dev_type;
- fnode_sess->dev.bus = &iscsi_flashnode_bus;
+ fnode_sess->dev.class = &iscsi_flashnode_bus;
fnode_sess->dev.parent = &shost->shost_gendev;
dev_set_name(&fnode_sess->dev, "flashnode_sess-%u:%u",
shost->host_no, index);
@@ -1338,7 +1332,7 @@ iscsi_create_flashnode_conn(struct Scsi_Host *shost,

fnode_conn->transport = transport;
fnode_conn->dev.type = &iscsi_flashnode_conn_dev_type;
- fnode_conn->dev.bus = &iscsi_flashnode_bus;
+ fnode_conn->dev.class = &iscsi_flashnode_bus;
fnode_conn->dev.parent = &fnode_sess->dev;
dev_set_name(&fnode_conn->dev, "flashnode_conn-%u:%u:0",
shost->host_no, fnode_sess->target_id);
@@ -1371,7 +1365,7 @@ EXPORT_SYMBOL_GPL(iscsi_create_flashnode_conn);
*/
static int iscsi_is_flashnode_conn_dev(struct device *dev, void *data)
{
- return dev->bus == &iscsi_flashnode_bus;
+ return dev->type == &iscsi_flashnode_conn_dev_type;
}

static int iscsi_destroy_flashnode_conn(struct iscsi_bus_flash_conn *fnode_conn)
@@ -1385,7 +1379,7 @@ static int flashnode_match_index(struct device *dev, void *data)
struct iscsi_bus_flash_session *fnode_sess = NULL;
int ret = 0;

- if (!iscsi_flashnode_bus_match(dev, NULL))
+ if (dev->type != &iscsi_flashnode_sess_dev_type)
goto exit_match_index;

fnode_sess = iscsi_dev_to_flash_session(dev);
@@ -1491,7 +1485,7 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_flashnode_sess);

static int iscsi_iter_destroy_flashnode_fn(struct device *dev, void *data)
{
- if (!iscsi_flashnode_bus_match(dev, NULL))
+ if (dev->type != &iscsi_flashnode_sess_dev_type)
return 0;

iscsi_destroy_flashnode_sess(iscsi_dev_to_flash_session(dev));
@@ -4752,7 +4746,7 @@ static __init int iscsi_transport_init(void)
if (err)
goto unregister_conn_class;

- err = bus_register(&iscsi_flashnode_bus);
+ err = class_register(&iscsi_flashnode_bus);
if (err)
goto unregister_session_class;

@@ -4773,7 +4767,7 @@ static __init int iscsi_transport_init(void)
unregister_pernet_subsys:
unregister_pernet_subsys(&iscsi_net_ops);
unregister_flashnode_bus:
- bus_unregister(&iscsi_flashnode_bus);
+ class_unregister(&iscsi_flashnode_bus);
unregister_session_class:
transport_class_unregister(&iscsi_session_class);
unregister_conn_class:
@@ -4793,7 +4787,7 @@ static void __exit iscsi_transport_exit(void)
{
destroy_workqueue(iscsi_eh_timer_workq);
unregister_pernet_subsys(&iscsi_net_ops);
- bus_unregister(&iscsi_flashnode_bus);
+ class_unregister(&iscsi_flashnode_bus);
transport_class_unregister(&iscsi_connection_class);
transport_class_unregister(&iscsi_session_class);
transport_class_unregister(&iscsi_host_class);
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 601e8633d495..2f461896e91f 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -489,6 +489,8 @@ iscsi_find_flashnode_sess(struct Scsi_Host *shost, void *data,
extern struct device *
iscsi_find_flashnode_conn(struct iscsi_bus_flash_session *fnode_sess);

+extern bool iscsi_is_flashnode_session_dev(struct device *dev);
+
extern char *
iscsi_get_ipaddress_state_name(enum iscsi_ipaddress_state port_state);
extern char *iscsi_get_router_state_name(enum iscsi_router_state router_state);
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:45 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open list
Finished the net namespace support for flashnode sysfs devices

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/scsi/scsi_transport_iscsi.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 5ffda170ac9d..783971d72c4c 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1268,8 +1268,41 @@ static int iscsi_is_flashnode_conn_dev(struct device *dev, void *data)
return dev->type == &iscsi_flashnode_conn_dev_type;
}

+static struct net *iscsi_flashnode_sess_net(struct iscsi_flash_session *f_sess)
+{
+ struct Scsi_Host *shost = iscsi_flash_session_to_shost(f_sess);
+ struct iscsi_cls_host *ihost = shost->shost_data;
+
+ return iscsi_host_net(ihost);
+}
+
+static struct net *iscsi_flashnode_conn_net(struct iscsi_flash_conn *f_conn)
+{
+ struct iscsi_flash_session *f_sess =
+ iscsi_flash_conn_to_flash_session(f_conn);
+
+ return iscsi_flashnode_sess_net(f_sess);
+}
+
+static const void *iscsi_flashnode_namespace(struct device *dev)
+{
+ struct iscsi_flash_conn *f_conn;
+ struct iscsi_flash_session *f_sess;
+
+ if (iscsi_is_flashnode_conn_dev(dev, NULL)) {
+ f_conn = iscsi_dev_to_flash_conn(dev);
+ return iscsi_flashnode_conn_net(f_conn);
+ } else if (iscsi_is_flashnode_session_dev(dev)) {
+ f_sess = iscsi_dev_to_flash_session(dev);
+ return iscsi_flashnode_sess_net(f_sess);
+ }
+ return NULL;
+}
+
static struct class iscsi_flashnode = {
.name = "iscsi_flashnode",
+ .ns_type = &net_ns_type_operations,
+ .namespace = iscsi_flashnode_namespace,
};

/**
--
2.9.5

Chris Leech

unread,
Oct 31, 2017, 6:41:45 PM10/31/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan, Chris Leech, supporter:QLOGIC QLA4XXX iSCSI DRIVER, James E.J. Bottomley, Martin K. Petersen, open list
cleanups after the bus to class conversion

Signed-off-by: Chris Leech <cle...@redhat.com>
---
drivers/scsi/qla4xxx/ql4_os.c | 52 +++++++++---------
drivers/scsi/scsi_transport_iscsi.c | 102 ++++++++++++++++++------------------
include/scsi/scsi_transport_iscsi.h | 48 +++++++++--------
3 files changed, 102 insertions(+), 100 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 55a729568873..9c80688d0681 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -169,20 +169,20 @@ static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type);
* iSCSI Flash DDB sysfs entry points
*/
static int
-qla4xxx_sysfs_ddb_set_param(struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn,
+qla4xxx_sysfs_ddb_set_param(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn,
void *data, int len);
static int
-qla4xxx_sysfs_ddb_get_param(struct iscsi_bus_flash_session *fnode_sess,
+qla4xxx_sysfs_ddb_get_param(struct iscsi_flash_session *fnode_sess,
int param, char *buf);
static int qla4xxx_sysfs_ddb_add(struct Scsi_Host *shost, const char *buf,
int len);
static int
-qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess);
-static int qla4xxx_sysfs_ddb_login(struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn);
-static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn);
+qla4xxx_sysfs_ddb_delete(struct iscsi_flash_session *fnode_sess);
+static int qla4xxx_sysfs_ddb_login(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn);
+static int qla4xxx_sysfs_ddb_logout(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn);
static int qla4xxx_sysfs_ddb_logout_sid(struct iscsi_cls_session *cls_sess);

static struct qla4_8xxx_legacy_intr_set legacy_intr[] =
@@ -3454,8 +3454,8 @@ static int qla4xxx_task_xmit(struct iscsi_task *task)
return -ENOSYS;
}

-static int qla4xxx_copy_from_fwddb_param(struct iscsi_bus_flash_session *sess,
- struct iscsi_bus_flash_conn *conn,
+static int qla4xxx_copy_from_fwddb_param(struct iscsi_flash_session *sess,
+ struct iscsi_flash_conn *conn,
struct dev_db_entry *fw_ddb_entry)
{
unsigned long options = 0;
@@ -3596,8 +3596,8 @@ static int qla4xxx_copy_from_fwddb_param(struct iscsi_bus_flash_session *sess,
return rc;
}

-static int qla4xxx_copy_to_fwddb_param(struct iscsi_bus_flash_session *sess,
- struct iscsi_bus_flash_conn *conn,
+static int qla4xxx_copy_to_fwddb_param(struct iscsi_flash_session *sess,
+ struct iscsi_flash_conn *conn,
struct dev_db_entry *fw_ddb_entry)
{
uint16_t options;
@@ -7162,7 +7162,7 @@ static void qla4xxx_build_new_nt_list(struct scsi_qla_host *ha,
**/
static int qla4xxx_sysfs_ddb_is_non_persistent(struct device *dev, void *data)
{
- struct iscsi_bus_flash_session *fnode_sess;
+ struct iscsi_flash_session *fnode_sess;

if (!iscsi_is_flashnode_session_dev(dev))
return 0;
@@ -7192,8 +7192,8 @@ static int qla4xxx_sysfs_ddb_tgt_create(struct scsi_qla_host *ha,
struct dev_db_entry *fw_ddb_entry,
uint16_t *idx, int user)
{
- struct iscsi_bus_flash_session *fnode_sess = NULL;
- struct iscsi_bus_flash_conn *fnode_conn = NULL;
+ struct iscsi_flash_session *fnode_sess = NULL;
+ struct iscsi_flash_conn *fnode_conn = NULL;
int rc = QLA_ERROR;

fnode_sess = iscsi_create_flashnode_sess(ha->host, *idx,
@@ -7330,8 +7330,8 @@ static int qla4xxx_sysfs_ddb_add(struct Scsi_Host *shost, const char *buf,
* This writes the contents of target ddb buffer to Flash with a valid cookie
* value in order to make the ddb entry persistent.
**/
-static int qla4xxx_sysfs_ddb_apply(struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn)
+static int qla4xxx_sysfs_ddb_apply(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn)
{
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
struct scsi_qla_host *ha = to_qla_host(shost);
@@ -7520,8 +7520,8 @@ static int qla4xxx_ddb_login_nt(struct scsi_qla_host *ha,
*
* This logs in to the specified target
**/
-static int qla4xxx_sysfs_ddb_login(struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn)
+static int qla4xxx_sysfs_ddb_login(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn)
{
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
struct scsi_qla_host *ha = to_qla_host(shost);
@@ -7704,8 +7704,8 @@ static int qla4xxx_sysfs_ddb_logout_sid(struct iscsi_cls_session *cls_sess)
*
* This performs log out from the specified target
**/
-static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn)
+static int qla4xxx_sysfs_ddb_logout(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn)
{
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
struct scsi_qla_host *ha = to_qla_host(shost);
@@ -7816,12 +7816,12 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
}

static int
-qla4xxx_sysfs_ddb_get_param(struct iscsi_bus_flash_session *fnode_sess,
+qla4xxx_sysfs_ddb_get_param(struct iscsi_flash_session *fnode_sess,
int param, char *buf)
{
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
struct scsi_qla_host *ha = to_qla_host(shost);
- struct iscsi_bus_flash_conn *fnode_conn;
+ struct iscsi_flash_conn *fnode_conn;
struct ql4_chap_table chap_tbl;
struct device *dev;
int parent_type;
@@ -8070,8 +8070,8 @@ qla4xxx_sysfs_ddb_get_param(struct iscsi_bus_flash_session *fnode_sess,
* This sets the parameter of flash ddb entry and writes them to flash
**/
static int
-qla4xxx_sysfs_ddb_set_param(struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn,
+qla4xxx_sysfs_ddb_set_param(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn,
void *data, int len)
{
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
@@ -8298,7 +8298,7 @@ qla4xxx_sysfs_ddb_set_param(struct iscsi_bus_flash_session *fnode_sess,
*
* This invalidates the flash ddb entry at the given index
**/
-static int qla4xxx_sysfs_ddb_delete(struct iscsi_bus_flash_session *fnode_sess)
+static int qla4xxx_sysfs_ddb_delete(struct iscsi_flash_session *fnode_sess)
{
struct Scsi_Host *shost = iscsi_flash_session_to_shost(fnode_sess);
struct scsi_qla_host *ha = to_qla_host(shost);
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index b053d57a482d..5ffda170ac9d 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -854,7 +854,7 @@ static ssize_t \
show_##type##_##name(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
- struct iscsi_bus_flash_session *fnode_sess = \
+ struct iscsi_flash_session *fnode_sess = \
iscsi_dev_to_flash_session(dev);\
struct iscsi_transport *t = fnode_sess->transport; \
return t->get_flashnode_param(fnode_sess, param, buf); \
@@ -954,7 +954,7 @@ static umode_t iscsi_flashnode_sess_attr_is_visible(struct kobject *kobj,
int i)
{
struct device *dev = container_of(kobj, struct device, kobj);
- struct iscsi_bus_flash_session *fnode_sess =
+ struct iscsi_flash_session *fnode_sess =
iscsi_dev_to_flash_session(dev);
struct iscsi_transport *t = fnode_sess->transport;
int param;
@@ -1045,7 +1045,7 @@ static const struct attribute_group *iscsi_flashnode_sess_attr_groups[] = {

static void iscsi_flashnode_sess_release(struct device *dev)
{
- struct iscsi_bus_flash_session *fnode_sess =
+ struct iscsi_flash_session *fnode_sess =
iscsi_dev_to_flash_session(dev);

kfree(fnode_sess->targetname);
@@ -1055,7 +1055,7 @@ static void iscsi_flashnode_sess_release(struct device *dev)
}

static const struct device_type iscsi_flashnode_sess_dev_type = {
- .name = "iscsi_flashnode_sess_dev_type",
+ .name = "iscsi_flashnode_sess",
.groups = iscsi_flashnode_sess_attr_groups,
.release = iscsi_flashnode_sess_release,
};
@@ -1072,8 +1072,8 @@ static ssize_t \
show_##type##_##name(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
- struct iscsi_bus_flash_conn *fnode_conn = iscsi_dev_to_flash_conn(dev);\
- struct iscsi_bus_flash_session *fnode_sess = \
+ struct iscsi_flash_conn *fnode_conn = iscsi_dev_to_flash_conn(dev);\
+ struct iscsi_flash_session *fnode_sess = \
iscsi_flash_conn_to_flash_session(fnode_conn);\
struct iscsi_transport *t = fnode_conn->transport; \
return t->get_flashnode_param(fnode_sess, param, buf); \
@@ -1162,7 +1162,7 @@ static umode_t iscsi_flashnode_conn_attr_is_visible(struct kobject *kobj,
int i)
{
struct device *dev = container_of(kobj, struct device, kobj);
- struct iscsi_bus_flash_conn *fnode_conn = iscsi_dev_to_flash_conn(dev);
+ struct iscsi_flash_conn *fnode_conn = iscsi_dev_to_flash_conn(dev);
struct iscsi_transport *t = fnode_conn->transport;
int param;

@@ -1238,7 +1238,7 @@ static const struct attribute_group *iscsi_flashnode_conn_attr_groups[] = {

static void iscsi_flashnode_conn_release(struct device *dev)
{
- struct iscsi_bus_flash_conn *fnode_conn = iscsi_dev_to_flash_conn(dev);
+ struct iscsi_flash_conn *fnode_conn = iscsi_dev_to_flash_conn(dev);

kfree(fnode_conn->ipaddress);
kfree(fnode_conn->redirect_ipaddr);
@@ -1247,12 +1247,28 @@ static void iscsi_flashnode_conn_release(struct device *dev)
}

static const struct device_type iscsi_flashnode_conn_dev_type = {
- .name = "iscsi_flashnode_conn_dev_type",
+ .name = "iscsi_flashnode_conn",
.groups = iscsi_flashnode_conn_attr_groups,
.release = iscsi_flashnode_conn_release,
};

-static struct class iscsi_flashnode_bus = {
+/**
+ * iscsi_is_flashnode_conn_dev - verify passed device is to be flashnode conn
+ * @dev: device to verify
+ * @data: pointer to data containing value to use for verification
+ *
+ * Verifies if the passed device is flashnode conn device
+ *
+ * Returns:
+ * 1 on success
+ * 0 on failure
+ */
+static int iscsi_is_flashnode_conn_dev(struct device *dev, void *data)
+{
+ return dev->type == &iscsi_flashnode_conn_dev_type;
+}
+
+static struct class iscsi_flashnode = {
.name = "iscsi_flashnode",
};

@@ -1269,12 +1285,12 @@ static struct class iscsi_flashnode_bus = {
* pointer to allocated flashnode sess on success
* %NULL on failure
*/
-struct iscsi_bus_flash_session *
+struct iscsi_flash_session *
iscsi_create_flashnode_sess(struct Scsi_Host *shost, int index,
struct iscsi_transport *transport,
int dd_size)
{
- struct iscsi_bus_flash_session *fnode_sess;
+ struct iscsi_flash_session *fnode_sess;
int err;

fnode_sess = kzalloc(sizeof(*fnode_sess) + dd_size, GFP_KERNEL);
@@ -1284,7 +1300,7 @@ iscsi_create_flashnode_sess(struct Scsi_Host *shost, int index,
fnode_sess->transport = transport;
fnode_sess->target_id = index;
fnode_sess->dev.type = &iscsi_flashnode_sess_dev_type;
- fnode_sess->dev.class = &iscsi_flashnode_bus;
+ fnode_sess->dev.class = &iscsi_flashnode;
fnode_sess->dev.parent = &shost->shost_gendev;
dev_set_name(&fnode_sess->dev, "flashnode_sess-%u:%u",
shost->host_no, index);
@@ -1317,13 +1333,13 @@ EXPORT_SYMBOL_GPL(iscsi_create_flashnode_sess);
* pointer to allocated flashnode conn on success
* %NULL on failure
*/
-struct iscsi_bus_flash_conn *
+struct iscsi_flash_conn *
iscsi_create_flashnode_conn(struct Scsi_Host *shost,
- struct iscsi_bus_flash_session *fnode_sess,
+ struct iscsi_flash_session *fnode_sess,
struct iscsi_transport *transport,
int dd_size)
{
- struct iscsi_bus_flash_conn *fnode_conn;
+ struct iscsi_flash_conn *fnode_conn;
int err;

fnode_conn = kzalloc(sizeof(*fnode_conn) + dd_size, GFP_KERNEL);
@@ -1332,7 +1348,7 @@ iscsi_create_flashnode_conn(struct Scsi_Host *shost,

fnode_conn->transport = transport;
fnode_conn->dev.type = &iscsi_flashnode_conn_dev_type;
- fnode_conn->dev.class = &iscsi_flashnode_bus;
+ fnode_conn->dev.class = &iscsi_flashnode;
fnode_conn->dev.parent = &fnode_sess->dev;
dev_set_name(&fnode_conn->dev, "flashnode_conn-%u:%u:0",
shost->host_no, fnode_sess->target_id);
@@ -1352,23 +1368,7 @@ iscsi_create_flashnode_conn(struct Scsi_Host *shost,
}
EXPORT_SYMBOL_GPL(iscsi_create_flashnode_conn);

-/**
- * iscsi_is_flashnode_conn_dev - verify passed device is to be flashnode conn
- * @dev: device to verify
- * @data: pointer to data containing value to use for verification
- *
- * Verifies if the passed device is flashnode conn device
- *
- * Returns:
- * 1 on success
- * 0 on failure
- */
-static int iscsi_is_flashnode_conn_dev(struct device *dev, void *data)
-{
- return dev->type == &iscsi_flashnode_conn_dev_type;
-}
-
-static int iscsi_destroy_flashnode_conn(struct iscsi_bus_flash_conn *fnode_conn)
+static int iscsi_destroy_flashnode_conn(struct iscsi_flash_conn *fnode_conn)
{
device_unregister(&fnode_conn->dev);
return 0;
@@ -1376,10 +1376,10 @@ static int iscsi_destroy_flashnode_conn(struct iscsi_bus_flash_conn *fnode_conn)

static int flashnode_match_index(struct device *dev, void *data)
{
- struct iscsi_bus_flash_session *fnode_sess = NULL;
+ struct iscsi_flash_session *fnode_sess = NULL;
int ret = 0;

- if (dev->type != &iscsi_flashnode_sess_dev_type)
+ if (!iscsi_is_flashnode_session_dev(dev))
goto exit_match_index;

fnode_sess = iscsi_dev_to_flash_session(dev);
@@ -1400,10 +1400,10 @@ static int flashnode_match_index(struct device *dev, void *data)
* pointer to found flashnode session object on success
* %NULL on failure
*/
-static struct iscsi_bus_flash_session *
+static struct iscsi_flash_session *
iscsi_get_flashnode_by_index(struct Scsi_Host *shost, uint32_t idx)
{
- struct iscsi_bus_flash_session *fnode_sess = NULL;
+ struct iscsi_flash_session *fnode_sess = NULL;
struct device *dev;

dev = device_find_child(&shost->shost_gendev, &idx,
@@ -1447,7 +1447,7 @@ EXPORT_SYMBOL_GPL(iscsi_find_flashnode_sess);
* %NULL on failure
*/
struct device *
-iscsi_find_flashnode_conn(struct iscsi_bus_flash_session *fnode_sess)
+iscsi_find_flashnode_conn(struct iscsi_flash_session *fnode_sess)
{
return device_find_child(&fnode_sess->dev, NULL,
iscsi_is_flashnode_conn_dev);
@@ -1469,7 +1469,7 @@ static int iscsi_iter_destroy_flashnode_conn_fn(struct device *dev, void *data)
* Deletes the flashnode session entry and all children flashnode connection
* entries from sysfs
*/
-void iscsi_destroy_flashnode_sess(struct iscsi_bus_flash_session *fnode_sess)
+void iscsi_destroy_flashnode_sess(struct iscsi_flash_session *fnode_sess)
{
int err;

@@ -1485,7 +1485,7 @@ EXPORT_SYMBOL_GPL(iscsi_destroy_flashnode_sess);

static int iscsi_iter_destroy_flashnode_fn(struct device *dev, void *data)
{
- if (dev->type != &iscsi_flashnode_sess_dev_type)
+ if (!iscsi_is_flashnode_session_dev(dev))
return 0;

iscsi_destroy_flashnode_sess(iscsi_dev_to_flash_session(dev));
@@ -3302,8 +3302,8 @@ static int iscsi_set_flashnode_param(struct net *net,
{
char *data = (char *)ev + sizeof(*ev);
struct Scsi_Host *shost;
- struct iscsi_bus_flash_session *fnode_sess;
- struct iscsi_bus_flash_conn *fnode_conn;
+ struct iscsi_flash_session *fnode_sess;
+ struct iscsi_flash_conn *fnode_conn;
struct device *dev;
uint32_t idx;
int err = 0;
@@ -3391,7 +3391,7 @@ static int iscsi_del_flashnode(struct net *net,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
- struct iscsi_bus_flash_session *fnode_sess;
+ struct iscsi_flash_session *fnode_sess;
uint32_t idx;
int err = 0;

@@ -3432,8 +3432,8 @@ static int iscsi_login_flashnode(struct net *net,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
- struct iscsi_bus_flash_session *fnode_sess;
- struct iscsi_bus_flash_conn *fnode_conn;
+ struct iscsi_flash_session *fnode_sess;
+ struct iscsi_flash_conn *fnode_conn;
struct device *dev;
uint32_t idx;
int err = 0;
@@ -3485,8 +3485,8 @@ static int iscsi_logout_flashnode(struct net *net,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
- struct iscsi_bus_flash_session *fnode_sess;
- struct iscsi_bus_flash_conn *fnode_conn;
+ struct iscsi_flash_session *fnode_sess;
+ struct iscsi_flash_conn *fnode_conn;
struct device *dev;
uint32_t idx;
int err = 0;
@@ -4746,7 +4746,7 @@ static __init int iscsi_transport_init(void)
if (err)
goto unregister_conn_class;

- err = class_register(&iscsi_flashnode_bus);
+ err = class_register(&iscsi_flashnode);
if (err)
goto unregister_session_class;

@@ -4767,7 +4767,7 @@ static __init int iscsi_transport_init(void)
unregister_pernet_subsys:
unregister_pernet_subsys(&iscsi_net_ops);
unregister_flashnode_bus:
- class_unregister(&iscsi_flashnode_bus);
+ class_unregister(&iscsi_flashnode);
unregister_session_class:
transport_class_unregister(&iscsi_session_class);
unregister_conn_class:
@@ -4787,7 +4787,7 @@ static void __exit iscsi_transport_exit(void)
{
destroy_workqueue(iscsi_eh_timer_workq);
unregister_pernet_subsys(&iscsi_net_ops);
- class_unregister(&iscsi_flashnode_bus);
+ class_unregister(&iscsi_flashnode);
transport_class_unregister(&iscsi_connection_class);
transport_class_unregister(&iscsi_session_class);
transport_class_unregister(&iscsi_host_class);
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 2f461896e91f..df56a8454386 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -39,8 +39,8 @@ struct iscsi_task;
struct sockaddr;
struct iscsi_iface;
struct bsg_job;
-struct iscsi_bus_flash_session;
-struct iscsi_bus_flash_conn;
+struct iscsi_flash_session;
+struct iscsi_flash_conn;

/**
* struct iscsi_transport - iSCSI Transport template
@@ -153,18 +153,18 @@ struct iscsi_transport {
uint32_t *num_entries, char *buf);
int (*delete_chap) (struct Scsi_Host *shost, uint16_t chap_tbl_idx);
int (*set_chap) (struct Scsi_Host *shost, void *data, int len);
- int (*get_flashnode_param) (struct iscsi_bus_flash_session *fnode_sess,
- int param, char *buf);
- int (*set_flashnode_param) (struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn,
- void *data, int len);
- int (*new_flashnode) (struct Scsi_Host *shost, const char *buf,
- int len);
- int (*del_flashnode) (struct iscsi_bus_flash_session *fnode_sess);
- int (*login_flashnode) (struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn);
- int (*logout_flashnode) (struct iscsi_bus_flash_session *fnode_sess,
- struct iscsi_bus_flash_conn *fnode_conn);
+ int (*get_flashnode_param)(struct iscsi_flash_session *fnode_sess,
+ int param, char *buf);
+ int (*set_flashnode_param)(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn,
+ void *data, int len);
+ int (*new_flashnode)(struct Scsi_Host *shost, const char *buf,
+ int len);
+ int (*del_flashnode)(struct iscsi_flash_session *fnode_sess);
+ int (*login_flashnode)(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn);
+ int (*logout_flashnode)(struct iscsi_flash_session *fnode_sess,
+ struct iscsi_flash_conn *fnode_conn);
int (*logout_flashnode_sid) (struct iscsi_cls_session *cls_sess);
int (*get_host_stats) (struct Scsi_Host *shost, char *buf, int len);
u8 (*check_protection)(struct iscsi_task *task, sector_t *sector);
@@ -313,7 +313,7 @@ struct iscsi_iface {
dev_to_shost(_iface->dev.parent)


-struct iscsi_bus_flash_conn {
+struct iscsi_flash_conn {
struct list_head conn_list; /* item in connlist */
void *dd_data; /* LLD private data */
struct iscsi_transport *transport;
@@ -351,14 +351,14 @@ struct iscsi_bus_flash_conn {
};

#define iscsi_dev_to_flash_conn(_dev) \
- container_of(_dev, struct iscsi_bus_flash_conn, dev)
+ container_of(_dev, struct iscsi_flash_conn, dev)

#define iscsi_flash_conn_to_flash_session(_conn) \
iscsi_dev_to_flash_session(_conn->dev.parent)

#define ISID_SIZE 6

-struct iscsi_bus_flash_session {
+struct iscsi_flash_session {
struct list_head sess_list; /* item in session_list */
struct iscsi_transport *transport;
unsigned int target_id;
@@ -413,7 +413,7 @@ struct iscsi_bus_flash_session {
};

#define iscsi_dev_to_flash_session(_dev) \
- container_of(_dev, struct iscsi_bus_flash_session, dev)
+ container_of(_dev, struct iscsi_flash_session, dev)

#define iscsi_flash_session_to_shost(_session) \
dev_to_shost(_session->dev.parent)
@@ -468,17 +468,17 @@ extern struct device *
iscsi_find_flashnode(struct Scsi_Host *shost, void *data,
int (*fn)(struct device *dev, void *data));

-extern struct iscsi_bus_flash_session *
+extern struct iscsi_flash_session *
iscsi_create_flashnode_sess(struct Scsi_Host *shost, int index,
struct iscsi_transport *transport, int dd_size);

-extern struct iscsi_bus_flash_conn *
+extern struct iscsi_flash_conn *
iscsi_create_flashnode_conn(struct Scsi_Host *shost,
- struct iscsi_bus_flash_session *fnode_sess,
+ struct iscsi_flash_session *fnode_sess,
struct iscsi_transport *transport, int dd_size);

extern void
-iscsi_destroy_flashnode_sess(struct iscsi_bus_flash_session *fnode_sess);
+iscsi_destroy_flashnode_sess(struct iscsi_flash_session *fnode_sess);

extern void iscsi_destroy_all_flashnode(struct Scsi_Host *shost);
extern int iscsi_flashnode_bus_match(struct device *dev,
@@ -487,7 +487,9 @@ extern struct device *
iscsi_find_flashnode_sess(struct Scsi_Host *shost, void *data,
int (*fn)(struct device *dev, void *data));
extern struct device *
-iscsi_find_flashnode_conn(struct iscsi_bus_flash_session *fnode_sess);
+iscsi_find_flashnode_conn(struct iscsi_flash_session *fnode_sess);
+
+extern bool iscsi_is_flashnode_session_dev(struct device *dev);

extern bool iscsi_is_flashnode_session_dev(struct device *dev);

--
2.9.5

Chris Leech

unread,
Nov 7, 2017, 12:44:18 PM11/7/17
to linux...@vger.kernel.org, open-...@googlegroups.com, Lee Duncan
Anyone have comments or criticisms? Lee?

Suggestions on anyone else I should be pinging for feedback?
These changes are in the iSCSI code, but are all netlink and sysfs
related namespace issues so I get that it's not a typical SCSI review.

- Chris

Chris Leech

unread,
Nov 7, 2017, 1:02:03 PM11/7/17
to Greg Kroah-Hartman, David S. Miller, linux...@vger.kernel.org, open-...@googlegroups.com
Hello,

I have this set of changes to the iSCSI control interfaces pending
review, but seeing as it's sysfs and netlink changes there's not a lot
of feedback from linux-scsi.

I was hoping I could get a brief review on the adding of network
namespace support here.

Thank you,
Chris

On Tue, Oct 31, 2017 at 03:40:55PM -0700, Chris Leech wrote:

Greg Kroah-Hartman

unread,
Nov 7, 2017, 3:28:34 PM11/7/17
to Chris Leech, David S. Miller, linux...@vger.kernel.org, open-...@googlegroups.com
On Tue, Nov 07, 2017 at 10:01:56AM -0800, Chris Leech wrote:
> Hello,
>
> I have this set of changes to the iSCSI control interfaces pending
> review, but seeing as it's sysfs and netlink changes there's not a lot
> of feedback from linux-scsi.
>
> I was hoping I could get a brief review on the adding of network
> namespace support here.

Where is "here"? I don't see any patches "here" to review :(

And no, I'm not on the scsi mailing lists :)

thanks,

greg k-h

Chris Leech

unread,
Nov 7, 2017, 5:32:33 PM11/7/17
to James Bottomley, Greg Kroah-Hartman, David S. Miller, linux...@vger.kernel.org, open-...@googlegroups.com
On Tue, Nov 07, 2017 at 12:45:26PM -0800, James Bottomley wrote:
> On Tue, 2017-11-07 at 10:01 -0800, Chris Leech wrote:
> > Hello,
> >
> > I have this set of changes to the iSCSI control interfaces pending
> > review, but seeing as it's sysfs and netlink changes there's not a
> > lot of feedback from linux-scsi.
>
> Well, it's a bit unlikely that they understand network namespaces.

I get that, just looking for suggestions of the right place to go before
going to crazy with the cross posting.

> > I was hoping I could get a brief review on the adding of network
> > namespace support here.
>
> Most network namespace work is done on net...@vger.kernel.org, but they
> probably won't understand all the SCSI bits, but perhaps they don't
> need to; it's basically the netlink and the filters, right?
>
> The other list that would take a more generic view is the containers
> one conta...@lists.linux-foundation.org because that's where most
> namespace stuff ends up.

Thanks James, the container list isn't one I would have come up with.

Chris

>
> James

The Lee-Man

unread,
Nov 13, 2017, 7:35:00 PM11/13/17
to open-iscsi
I will review these patches individually (it might take an extra day), but
I have an initial question: will this change the sysfs interface for iscsi.
But I'm pretty sure the answer is yes. Which would mean we could
break other things. If this is true, perhaps we should bump the
major version number?

Are there any other interfaces that will change? Is there anything
that might depend on the single-namespace approach iscsi currently
uses?

The Lee-Man

unread,
Nov 13, 2017, 7:38:11 PM11/13/17
to open-iscsi
On Tuesday, October 31, 2017 at 3:41:38 PM UTC-7, Chris Leech wrote:
This lets iscsi_tcp operate in multiple namespaces.  It uses current
during session creation to find the net namespace, but it might be
better to manage to pass it along from the iscsi netlink socket.

Could you add that idea as a comment then, so it isn't lost?

The Lee-Man

unread,
Nov 13, 2017, 7:42:44 PM11/13/17
to open-iscsi
On Tuesday, October 31, 2017 at 3:41:45 PM UTC-7, Chris Leech wrote:
Finished the net namespace support for flashnode sysfs devices

Needs a better explanation, though I can understand if you were tired
of typing by this point!

The Lee-Man

unread,
Nov 13, 2017, 7:45:12 PM11/13/17
to open-iscsi
On Tuesday, October 31, 2017 at 3:41:45 PM UTC-7, Chris Leech wrote:
cleanups after the bus to class conversion

If this has no functional change I'd prefer it if you made
that more clear. Or maybe it's just me? Not that I have
anything against cleanups, in general.

The Lee-Man

unread,
Nov 13, 2017, 7:48:42 PM11/13/17
to open-iscsi
I have reviewed all the patches to the best of my ability.
Other than the comments I made, please add my reviewed-by
tag to all of them.

I was surprised as how pervasive the single-namespace assumption
was buried in the code, as evidenced by how much you had to
change.

I assume you've tested this with containers and it fixed the
"only one iscsid at a time" issue?

I'm also trying to think of any other interesting applications of
this new ability. Have any ideas?

James Bottomley

unread,
Nov 14, 2017, 11:27:49 AM11/14/17
to Chris Leech, Greg Kroah-Hartman, David S. Miller, linux...@vger.kernel.org, open-...@googlegroups.com
On Tue, 2017-11-07 at 10:01 -0800, Chris Leech wrote:
> Hello,
>
> I have this set of changes to the iSCSI control interfaces pending
> review, but seeing as it's sysfs and netlink changes there's not a
> lot of feedback from linux-scsi.

Well, it's a bit unlikely that they understand network namespaces.

> I was hoping I could get a brief review on the adding of network
> namespace support here.

Most network namespace work is done on net...@vger.kernel.org, but they
probably won't understand all the SCSI bits, but perhaps they don't
need to; it's basically the netlink and the filters, right?

The other list that would take a more generic view is the containers
one conta...@lists.linux-foundation.org because that's where most
namespace stuff ends up.

James

Chris Leech

unread,
Nov 20, 2017, 1:41:33 PM11/20/17
to open-...@googlegroups.com
On Mon, Nov 13, 2017 at 04:35:00PM -0800, The Lee-Man wrote:
> I will review these patches individually (it might take an extra day), but
> I have an initial question: will this change the sysfs interface for iscsi.
> But I'm pretty sure the answer is yes. Which would mean we could
> break other things. If this is true, perhaps we should bump the
> major version number?

The flashnode sysfs stuff is the only breaking change, as it needs to
switch from a bus to a class in order to gain the namespace filtering
support. I don't know how widely that's used, it's only supported by
one driver and I hardly ever hear anything about it. Having the
subsystem move from /sys/bus to /sys/class shouldn't be a breaking
change if the sysfs programming guidelines are followed, but of course
they may not be and in this case the flashnode support in the Open-iSCSI
tools doesn't and needs an update.

> Are there any other interfaces that will change? Is there anything
> that might depend on the single-namespace approach iscsi currently
> uses?

Currently, the sysfs objects are always visible but the netlink control
interface only works from the initial network namespace. That's what
prompted me down this path, as I've heard from people interested in
running iscsid in a container.

My line of thinking was, once you enable the netlink interface to run in
multiple namespaces things need to be isolated. For iscsi_tcp we rely
on the network configuration obvisouly, so you may want multiple
instances of iscsid managing sessions from different namespaces? If so,
the sysfs filtering is needed to prevent them from trying to manage the
same resources.

Happy to discuss different ideas of how iSCSI and namespaces should
interact, especially this next bit bellow.

Sorry about the late response, went off last week looking more closely
at the namespace reference coutning with all of this.

With this patch set, iscsid creates a TCP connection and then iscsi_tcp
holds a reference to the socket. That keeps the file alive even when
iscsid terminates, which in turn keeps the network namespace alive. The
problem is that you can terminate all the processes and unlink any
references to the namespace inode (bind mount created by ip-netns for
example) and I have no idea how to "recover" that namespace then in
order to shut down the iSCSI session.

I've been looking at getting iscsi_tcp to interact directly with the TCP
connection state (difference between socket and sock structs) and let
the sockfd file close with iscsid. I was thinking that would let
iscsi_tcp then shutdown cleanly when the network namespace is removed.
That assumes that shutting down in the right thing, otherwise we
probably want a kernel thread of some sort that could be used to
reference the namespace if userspace terminates.

All this namespace internals is new to me, so I'm trying to figure out
what the right thing for iSCSI support even is.

- Chris
> --
> You received this message because you are subscribed to the Google Groups "open-iscsi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+...@googlegroups.com.
> To post to this group, send email to open-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/open-iscsi.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages