From owner-svn-src-stable-11@freebsd.org Thu Aug 2 08:10:07 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50980105CFD6; Thu, 2 Aug 2018 08:10:07 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 06578797DF; Thu, 2 Aug 2018 08:10:07 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCFDF6F48; Thu, 2 Aug 2018 08:10:06 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w728A6Xw034171; Thu, 2 Aug 2018 08:10:06 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w728A629034169; Thu, 2 Aug 2018 08:10:06 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201808020810.w728A629034169@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 2 Aug 2018 08:10:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r337073 - stable/11/sys/ofed/drivers/infiniband/core X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/ofed/drivers/infiniband/core X-SVN-Commit-Revision: 337073 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Aug 2018 08:10:07 -0000 Author: hselasky Date: Thu Aug 2 08:10:06 2018 New Revision: 337073 URL: https://svnweb.freebsd.org/changeset/base/337073 Log: MFC r336367: Add native FreeBSD support for multicast in ibcore. This change adds support for registering multicast addresses, both IPv4 and IPv6. Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c ============================================================================== --- stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c Thu Aug 2 08:08:02 2018 (r337072) +++ stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c Thu Aug 2 08:10:06 2018 (r337073) @@ -346,9 +346,12 @@ static int addr4_resolve(struct sockaddr_in *src_in, ifp->if_addrlen, MAX_ADDR_LEN); error = 0; } else if (IN_MULTICAST(ntohl(dst_tmp.sin_addr.s_addr))) { + bool is_gw = (rte->rt_flags & RTF_GATEWAY) != 0; error = addr_resolve_multi(edst, ifp, (struct sockaddr *)&dst_tmp); if (error != 0) goto error_put_ifp; + else if (is_gw) + addr->network = RDMA_NETWORK_IPV4; } else if (ifp->if_flags & IFF_LOOPBACK) { memset(edst, 0, MAX_ADDR_LEN); error = 0; @@ -360,7 +363,7 @@ static int addr4_resolve(struct sockaddr_in *src_in, edst, NULL, NULL); if (error != 0) goto error_put_ifp; - else if (is_gw != 0) + else if (is_gw) addr->network = RDMA_NETWORK_IPV4; } @@ -515,10 +518,13 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, * Step 3 - resolve destination MAC address */ if (IN6_IS_ADDR_MULTICAST(&dst_tmp.sin6_addr)) { + bool is_gw = (rte->rt_flags & RTF_GATEWAY) != 0; error = addr_resolve_multi(edst, ifp, (struct sockaddr *)&dst_tmp); if (error != 0) goto error_put_ifp; + else if (is_gw) + addr->network = RDMA_NETWORK_IPV6; } else if (rte->rt_ifp->if_flags & IFF_LOOPBACK) { memset(edst, 0, MAX_ADDR_LEN); error = 0; @@ -530,7 +536,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, edst, NULL, NULL); if (error != 0) goto error_put_ifp; - else if (is_gw != 0) + else if (is_gw) addr->network = RDMA_NETWORK_IPV6; } Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c ============================================================================== --- stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c Thu Aug 2 08:08:02 2018 (r337072) +++ stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c Thu Aug 2 08:10:06 2018 (r337073) @@ -427,6 +427,30 @@ static inline void cma_set_ip_ver(struct cma_hdr *hdr, hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF); } +static int cma_igmp_send(struct net_device *ndev, const union ib_gid *mgid, bool join) +{ + int retval; + + if (ndev) { + union { + struct sockaddr sock; + struct sockaddr_storage storage; + } addr; + + rdma_gid2ip(&addr.sock, mgid); + + CURVNET_SET_QUIET(ndev->if_vnet); + if (join) + retval = -if_addmulti(ndev, &addr.sock, NULL); + else + retval = -if_delmulti(ndev, &addr.sock); + CURVNET_RESTORE(); + } else { + retval = -ENODEV; + } + return retval; +} + static void _cma_attach_to_dev(struct rdma_id_private *id_priv, struct cma_device *cma_dev) { @@ -1621,6 +1645,9 @@ static void cma_leave_mc_groups(struct rdma_id_private ndev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if); if (ndev) { + cma_igmp_send(ndev, + &mc->multicast.ib->rec.mgid, + false); dev_put(ndev); } } @@ -4024,7 +4051,10 @@ static int cma_iboe_join_multicast(struct rdma_id_priv if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) { mc->multicast.ib->rec.hop_limit = IPV6_DEFAULT_HOPLIMIT; if (!send_only) { - mc->igmp_joined = true; + err = cma_igmp_send(ndev, &mc->multicast.ib->rec.mgid, + true); + if (!err) + mc->igmp_joined = true; } } } else { @@ -4129,6 +4159,9 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struc ndev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if); if (ndev) { + cma_igmp_send(ndev, + &mc->multicast.ib->rec.mgid, + false); dev_put(ndev); } mc->igmp_joined = false;