From patchwork Sat May 6 23:29:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Leech X-Patchwork-Id: 13233641 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBD0B11C80 for ; Sat, 6 May 2023 23:30:06 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC19A5D4 for ; Sat, 6 May 2023 16:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683415803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hqhmg8Av0eHkGffW04hqyQM86CV5Jf1/OdaPhsIJszw=; b=DLYrtZKa811gY2MszjDOnCTnYIM+r9KfPIiRRgOO0r73DlXqvnbMHyxokL74ahLXq7KO21 JScB2NcsklJldwy9XO1tbC3r9IZc7HYWoYsgVDvyOQ/zX5aTrRFfmBZqyTGYy4mVADLP+o RSc3rLPU4HFiiJsHZCxZmUZTmCVpu7Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-Sw4aRg4WPYKqbogOMpK5Nw-1; Sat, 06 May 2023 19:30:00 -0400 X-MC-Unique: Sw4aRg4WPYKqbogOMpK5Nw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B0E9F857DD7; Sat, 6 May 2023 23:29:59 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.2.16.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 294E6440BC; Sat, 6 May 2023 23:29:59 +0000 (UTC) From: Chris Leech To: Lee Duncan , linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com, netdev@vger.kernel.org Cc: Chris Leech Subject: [PATCH 09/11] iscsi: filter flashnode sysfs by net namespace Date: Sat, 6 May 2023 16:29:28 -0700 Message-Id: <20230506232930.195451-10-cleech@redhat.com> In-Reply-To: <20230506232930.195451-1-cleech@redhat.com> References: <20230506232930.195451-1-cleech@redhat.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Lee Duncan This finishes the net namespace support for flashnode sysfs devices. Signed-off-by: Lee Duncan Reviewed-by: Hannes Reinecke Signed-off-by: Chris Leech --- 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);