From patchwork Tue Feb 6 09:44:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 10202577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2126B6020F for ; Tue, 6 Feb 2018 09:44:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1773128ABD for ; Tue, 6 Feb 2018 09:44:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B88328AC8; Tue, 6 Feb 2018 09:44:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A39F28ABD for ; Tue, 6 Feb 2018 09:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbeBFJot (ORCPT ); Tue, 6 Feb 2018 04:44:49 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:41141 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752263AbeBFJot (ORCPT ); Tue, 6 Feb 2018 04:44:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pQbvCK60r+JWspCDicozHsTtYJPbLx5nzWjZyo111tE=; b=CEctbuv1ME7nJhOqSCykQIgRw LVZaeFkhDmw6Jrp8XUAEykH7Cp3GgCBdE3k01R2Vv4n6zwvfZYCXGUa/HcXUROTAgIawo6z2wRFSz 8tTdX3MXhfmQd7jUgVR/RGa7bTX5tpCz9GicRGE4pTb1JXtrlhILzOzv2TZQnIGk7lUCQfg9lbyEh su3qNc8j57Bf3R/xpu0SzKygaRJoF5eJPzMfxepcjnmDiakgYE76thMlEDse2lz1QWPz+Rf+OflJV mDEjQoKejpyG9FKXAVci65rgr+BkdEPfimBjaMHug0ijZFdsKYdx7zuN9oMlANoeZcE4lfk3Vlc9H SFFJjCKQg==; Received: from bzq-219-42-90.isdn.bezeqint.net ([62.219.42.90] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eizny-0002nI-Gs; Tue, 06 Feb 2018 09:44:46 +0000 From: Sagi Grimberg To: linux-nvme@lists.infradead.org, target-devel@vger.kernel.org Cc: Christoph Hellwig , Johannes Thumshirn , "David S. Miller" , "Nicholas A. Bellinger" Subject: [PATCH 3/3] iscsi-target: use common inet_addr_is_any Date: Tue, 6 Feb 2018 11:44:32 +0200 Message-Id: <20180206094432.12761-4-sagi@grimberg.me> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180206094432.12761-1-sagi@grimberg.me> References: <20180206094432.12761-1-sagi@grimberg.me> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of open-coding it. Signed-off-by: Sagi Grimberg Cc: "Nicholas A. Bellinger" Cc: target-devel@vger.kernel.org --- drivers/target/iscsi/iscsi_target.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 9eb10d34682c..8e223799347a 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -3291,30 +3292,6 @@ iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); } -static bool iscsit_check_inaddr_any(struct iscsi_np *np) -{ - bool ret = false; - - if (np->np_sockaddr.ss_family == AF_INET6) { - const struct sockaddr_in6 sin6 = { - .sin6_addr = IN6ADDR_ANY_INIT }; - struct sockaddr_in6 *sock_in6 = - (struct sockaddr_in6 *)&np->np_sockaddr; - - if (!memcmp(sock_in6->sin6_addr.s6_addr, - sin6.sin6_addr.s6_addr, 16)) - ret = true; - } else { - struct sockaddr_in * sock_in = - (struct sockaddr_in *)&np->np_sockaddr; - - if (sock_in->sin_addr.s_addr == htonl(INADDR_ANY)) - ret = true; - } - - return ret; -} - #define SENDTARGETS_BUF_LIMIT 32768U static int @@ -3393,7 +3370,6 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd, list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, tpg_np_list) { struct iscsi_np *np = tpg_np->tpg_np; - bool inaddr_any = iscsit_check_inaddr_any(np); struct sockaddr_storage *sockaddr; if (np->np_network_transport != network_transport) @@ -3422,7 +3398,7 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd, } } - if (inaddr_any) + if (inet_addr_is_any((struct sockaddr *)&np->np_sockaddr)) sockaddr = &conn->local_sockaddr; else sockaddr = &np->np_sockaddr;