From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Leech Subject: [PATCH 9/9] iscsi: filter flashnode sysfs by net namespace Date: Tue, 7 Nov 2017 14:45:13 -0800 Message-ID: <20171107224513.4217-10-cleech@redhat.com> References: <20171107180156.GD29597@straylight.hirudinean.org> <20171107224513.4217-1-cleech@redhat.com> To: netdev@vger.kernel.org, containers@lists.linux-foundation.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60660 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757185AbdKGWqR (ORCPT ); Tue, 7 Nov 2017 17:46:17 -0500 In-Reply-To: <20171107224513.4217-1-cleech@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: Finished the net namespace support for flashnode sysfs devices Signed-off-by: Chris Leech --- 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