netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Leech <cleech@redhat.com>
To: Lee Duncan <lduncan@suse.com>,
	linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com,
	netdev@vger.kernel.org
Cc: Chris Leech <cleech@redhat.com>
Subject: [PATCH 09/11] iscsi: filter flashnode sysfs by net namespace
Date: Sat,  6 May 2023 16:29:28 -0700	[thread overview]
Message-ID: <20230506232930.195451-10-cleech@redhat.com> (raw)
In-Reply-To: <20230506232930.195451-1-cleech@redhat.com>

From: Lee Duncan <lduncan@suse.com>

This finishes the net namespace support for flashnode sysfs devices.

Signed-off-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Chris Leech <cleech@redhat.com>
---
 drivers/scsi/scsi_transport_iscsi.c | 34 +++++++++++++++++++++++++++++
 include/scsi/scsi_transport_iscsi.h |  4 ----
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 26b3d479b6ac..cd3228293a64 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1289,8 +1289,42 @@ 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(const struct device *dev)
+{
+	struct iscsi_flash_conn *f_conn;
+	struct iscsi_flash_session *f_sess;
+	struct device *dev_tmp = (struct device *)dev;
+
+	if (iscsi_is_flashnode_conn_dev(dev_tmp, NULL)) {
+		f_conn = iscsi_dev_to_flash_conn(dev);
+		return iscsi_flashnode_conn_net(f_conn);
+	} else if (iscsi_is_flashnode_session_dev(dev_tmp)) {
+		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,
 };
 
 /**
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index a23b511b6f53..a540e085de8d 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -516,8 +516,6 @@ extern void
 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,
-				     struct device_driver *drv);
 extern struct device *
 iscsi_find_flashnode_sess(struct Scsi_Host *shost, void *data,
 			  int (*fn)(struct device *dev, void *data));
@@ -526,8 +524,6 @@ 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);
-
 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.39.2


  parent reply	other threads:[~2023-05-06 23:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-06 23:29 [PATCH v2 00/11] Make iscsid-kernel communications namespace-aware Chris Leech
2023-05-06 23:29 ` [PATCH 01/11] iscsi: create per-net iscsi netlink kernel sockets Chris Leech
2023-05-06 23:29 ` [PATCH 02/11] iscsi: associate endpoints with a host Chris Leech
2023-05-06 23:29 ` [PATCH 03/11] iscsi: sysfs filtering by network namespace Chris Leech
2023-05-10 19:50   ` michael.christie
2023-05-06 23:29 ` [PATCH 04/11] iscsi: make all iSCSI netlink multicast namespace aware Chris Leech
2023-05-10 19:48   ` michael.christie
2023-05-06 23:29 ` [PATCH 05/11] iscsi: check net namespace for all iscsi lookup Chris Leech
2023-05-12 22:30   ` Mike Christie
2023-05-06 23:29 ` [PATCH 06/11] iscsi: set netns for tcp and iser hosts Chris Leech
2023-05-07  1:29   ` kernel test robot
2023-05-07  2:01   ` kernel test robot
2023-05-10 19:40   ` michael.christie
2023-05-06 23:29 ` [PATCH 07/11] iscsi: convert flashnode devices from bus to class Chris Leech
2023-05-10 19:28   ` michael.christie
2023-05-06 23:29 ` [PATCH 08/11] iscsi: rename iscsi_bus_flash_* to iscsi_flash_* Chris Leech
2023-05-06 23:29 ` Chris Leech [this message]
2023-05-06 23:29 ` [PATCH 10/11] iscsi: make session and connection lists per-net Chris Leech
2023-05-10 19:25   ` michael.christie
2023-05-06 23:29 ` [PATCH 11/11] iscsi: force destroy sesions when a network namespace exits Chris Leech
2023-05-10 20:09   ` michael.christie
2023-05-10 20:14     ` michael.christie
2023-05-10 19:54 ` [PATCH v2 00/11] Make iscsid-kernel communications namespace-aware michael.christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230506232930.195451-10-cleech@redhat.com \
    --to=cleech@redhat.com \
    --cc=lduncan@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=open-iscsi@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).