Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Mar 2018 18:38:43 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r331786 - stable/11/sys/ofed/drivers/infiniband/core
Message-ID:  <201803301838.w2UIchvi077730@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Mar 30 18:38:43 2018
New Revision: 331786
URL: https://svnweb.freebsd.org/changeset/base/331786

Log:
  MFC r330580:
  Make sure the IPv6 scope ID gets properly masked in ibcore.
  
  When exchanging CM messages the IPv6 scope ID should be ignored
  for link local addresses when doing comparisons. Make sure the
  scope ID is always set to zero for link local addresses.
  
  Sponsored by:	Mellanox Technologies

Modified:
  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_cma.c
==============================================================================
--- stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c	Fri Mar 30 18:37:51 2018	(r331785)
+++ stable/11/sys/ofed/drivers/infiniband/core/ib_cma.c	Fri Mar 30 18:38:43 2018	(r331786)
@@ -1116,6 +1116,17 @@ static void cma_save_ip4_info(struct sockaddr_in *src_
 	}
 }
 
+static void cma_ip6_clear_scope_id(struct in6_addr *addr)
+{
+	/* make sure link local scope ID gets zeroed */
+	if (IN6_IS_SCOPE_LINKLOCAL(addr) ||
+	    IN6_IS_ADDR_MC_INTFACELOCAL(addr)) {
+		/* use byte-access to be alignment safe */
+		addr->s6_addr[2] = 0;
+		addr->s6_addr[3] = 0;
+	}
+}
+
 static void cma_save_ip6_info(struct sockaddr_in6 *src_addr,
 			      struct sockaddr_in6 *dst_addr,
 			      struct cma_hdr *hdr,
@@ -1128,6 +1139,7 @@ static void cma_save_ip6_info(struct sockaddr_in6 *src
 			.sin6_addr = hdr->dst_addr.ip6,
 			.sin6_port = local_port,
 		};
+		cma_ip6_clear_scope_id(&src_addr->sin6_addr);
 	}
 
 	if (dst_addr) {
@@ -1137,6 +1149,7 @@ static void cma_save_ip6_info(struct sockaddr_in6 *src
 			.sin6_addr = hdr->src_addr.ip6,
 			.sin6_port = hdr->port,
 		};
+		cma_ip6_clear_scope_id(&dst_addr->sin6_addr);
 	}
 }
 
@@ -1395,6 +1408,7 @@ static bool cma_match_private_data(struct rdma_id_priv
 		ip6_addr = ((struct sockaddr_in6 *)addr)->sin6_addr;
 		if (cma_get_ip_ver(hdr) != 6)
 			return false;
+		cma_ip6_clear_scope_id(&ip6_addr);
 		if (!cma_any_addr(addr) &&
 		    memcmp(&hdr->dst_addr.ip6, &ip6_addr, sizeof(ip6_addr)))
 			return false;
@@ -3242,6 +3256,8 @@ static int cma_format_hdr(void *hdr, struct rdma_id_pr
 		cma_hdr->src_addr.ip6 = src6->sin6_addr;
 		cma_hdr->dst_addr.ip6 = dst6->sin6_addr;
 		cma_hdr->port = src6->sin6_port;
+		cma_ip6_clear_scope_id(&cma_hdr->src_addr.ip6);
+		cma_ip6_clear_scope_id(&cma_hdr->dst_addr.ip6);
 	}
 	return 0;
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803301838.w2UIchvi077730>