From patchwork Fri Feb 9 03:09:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10208231 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 AB5B760247 for ; Fri, 9 Feb 2018 03:09:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A1B529683 for ; Fri, 9 Feb 2018 03:09:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F63029687; Fri, 9 Feb 2018 03:09:29 +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 2E99B29683 for ; Fri, 9 Feb 2018 03:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752523AbeBIDJ0 (ORCPT ); Thu, 8 Feb 2018 22:09:26 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:32886 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752507AbeBIDJO (ORCPT ); Thu, 8 Feb 2018 22:09:14 -0500 Received: by mail-it0-f66.google.com with SMTP id u12so1602404ite.0 for ; Thu, 08 Feb 2018 19:09:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KiPo7WDNNw0J6hAZ4BcTs+XmcrYdkxTkuOW/1Ztzdd0=; b=fxl0e6PjGu6lBjkomAQl9a0ePDkqZnQtiun3wpKjEXm4fQ3nR2nzI6u/QJRHiqe389 jMLVfJ1uiNcwA3onjW+9jKY+fUI2fkzMJCAYzoeTsR3aEl5fuAX3spHZaPrE0J4ZdkVd kSlSUa5zlE+8RqyQU3dJ4I59yHc5wDpi9lxkguEO/RsCAtcmOp8y/b5kETCKuP/nM2AS GisoGgwpATaP4Aro9wCShLlQcie0oxuTyxWPxfcqVfxtwgDvkgEHqiV/SUU89Ptxtf5V 2zliMA2PKCkMlsJhrX4uzWHc3ecfSEk6MVwG0SE0VPzB6whbuLVIdbBRim/vWgk0H9Aw PQTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KiPo7WDNNw0J6hAZ4BcTs+XmcrYdkxTkuOW/1Ztzdd0=; b=W4KCDiu1Jow/BNXtDlNR+8/4iIGyUPSVxJd7eslagS817Q96ZAExKpChRRiknQWP6p QVEcr0F4Oa2+hXDMZWYK6GG0wELMfbJxPnUTfhIsDrlcXZKGE7qwl/JN4SPzp6lKHIZs I3DjDBtLQVOgFd1fDBXnahodNkpR1H20IeDzcZgqwcPJjqPkVPErSYduCTNap2jFwQF2 76qf20m5LDlRIm7MhWyZuO1Rx7NvTlSZ29o5ixSaXQeCG7lDCdk0iGOBvi9Ne/aiO7MV w2jdAg55DWrPQkyjypxRkihiTuEFtFRPT7zd3hUjaqU7oxV97PCljvgMK6muSrly/DIF +t3Q== X-Gm-Message-State: APf1xPAvZhIy6M1t8NKPzalbMDezVgvpLXaAABq9O23+iZLV68zQXWNe AShvkGgK5zZJ4Ly6aJzLlj1KMkFKymo= X-Google-Smtp-Source: AH8x2271qj+QVAa9C4S7N8nimv1qdorpV6jiRslZXHowZ9yVkptBh4pzu5uKa5hqnAxTQqq3ZADG2Q== X-Received: by 10.36.65.74 with SMTP id x71mr1675271ita.95.1518145754127; Thu, 08 Feb 2018 19:09:14 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [70.74.179.152]) by smtp.gmail.com with ESMTPSA id o123sm1218208ioo.66.2018.02.08.19.09.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 19:09:11 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1ejz3m-0005qJ-8f; Thu, 08 Feb 2018 20:09:10 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH rdma-core 4/7] rxe: Do not use _sockaddr in struct rxe_av Date: Thu, 8 Feb 2018 20:09:01 -0700 Message-Id: <20180209030904.22370-5-jgg@ziepe.ca> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209030904.22370-1-jgg@ziepe.ca> References: <20180209030904.22370-1-jgg@ziepe.ca> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe The kernel cannot export this type as a uAPI so don't use it. Instead pass the union directly to the helper function and refer to the in6/in members without casting. Signed-off-by: Jason Gunthorpe --- providers/rxe/rxe.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c index fcc8cfcb6fe49c..38140ba49c620a 100644 --- a/providers/rxe/rxe.c +++ b/providers/rxe/rxe.c @@ -761,17 +761,17 @@ static inline int ipv6_addr_v4mapped(const struct in6_addr *a) return IN6_IS_ADDR_V4MAPPED(a); } -static inline int rdma_gid2ip(struct sockaddr *out, union ibv_gid *gid) +typedef typeof(((struct rxe_av *)0)->sgid_addr) sockaddr_union_t; + +static inline int rdma_gid2ip(sockaddr_union_t *out, union ibv_gid *gid) { if (ipv6_addr_v4mapped((struct in6_addr *)gid)) { - struct sockaddr_in *out_in = (struct sockaddr_in *)out; - memset(out_in, 0, sizeof(*out_in)); - memcpy(&out_in->sin_addr.s_addr, gid->raw + 12, 4); + memset(&out->_sockaddr_in, 0, sizeof(out->_sockaddr_in)); + memcpy(&out->_sockaddr_in.sin_addr.s_addr, gid->raw + 12, 4); } else { - struct sockaddr_in6 *out_in = (struct sockaddr_in6 *)out; - memset(out_in, 0, sizeof(*out_in)); - out_in->sin6_family = AF_INET6; - memcpy(&out_in->sin6_addr.s6_addr, gid->raw, 16); + memset(&out->_sockaddr_in6, 0, sizeof(out->_sockaddr_in6)); + out->_sockaddr_in6.sin6_family = AF_INET6; + memcpy(&out->_sockaddr_in6.sin6_addr.s6_addr, gid->raw, 16); } return 0; } @@ -802,8 +802,8 @@ static struct ibv_ah *rxe_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) ipv6_addr_v4mapped((struct in6_addr *)attr->grh.dgid.raw) ? RDMA_NETWORK_IPV4 : RDMA_NETWORK_IPV6; - rdma_gid2ip(&av->sgid_addr._sockaddr, &sgid); - rdma_gid2ip(&av->dgid_addr._sockaddr, &attr->grh.dgid); + rdma_gid2ip(&av->sgid_addr, &sgid); + rdma_gid2ip(&av->dgid_addr, &attr->grh.dgid); memset(&resp, 0, sizeof(resp)); if (ibv_cmd_create_ah(pd, &ah->ibv_ah, attr, &resp, sizeof(resp))) {