From patchwork Wed Feb 7 13:05:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 10205151 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 5904D60247 for ; Wed, 7 Feb 2018 13:05:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4281A28F74 for ; Wed, 7 Feb 2018 13:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 371B228F76; Wed, 7 Feb 2018 13:05:52 +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 A901D28F74 for ; Wed, 7 Feb 2018 13:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753721AbeBGNFv (ORCPT ); Wed, 7 Feb 2018 08:05:51 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:44411 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753539AbeBGNFu (ORCPT ); Wed, 7 Feb 2018 08:05:50 -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=SkIVmVqEi0YyK/BKI1mK7F2eC JrEn7ZYgVJuKG2I4csutRqCpTrNVlm4IHY1IW8gKG0Q6tLao5QqksthQordb0ZQfz2QxH+vbVu/92 PGCFcDMgMJQDOcpCVXkTgKLIDlJbA54CaUa3rOEUUO8U4TT4WLEfjp1xI851f41e5FIL8GE6ynO2q aRh9yHMOfxVk/kazTpAwZ9yAdu+elEyq4Rm1EHBVVclJGLGaVrkZuiTcx6w6y0ilFO/oxyMe7H4D8 pEeQ9VRT6FVtdiBqdo8EunfTb3oZkBUTEYldcmjL62wexOB12GuZH/FHLJNiFESa1XF+30iHRfiWG nUnHAlDng==; 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 1ejPQ5-0006Lv-TR; Wed, 07 Feb 2018 13:05:50 +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 v2 3/3] iscsi-target: use common inet_addr_is_any Date: Wed, 7 Feb 2018 15:05:18 +0200 Message-Id: <20180207130518.22803-4-sagi@grimberg.me> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180207130518.22803-1-sagi@grimberg.me> References: <20180207130518.22803-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 Reviewed-by: Bart Van Assche Reviewed-by: Johannes Thumshirn --- 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;