From: Somnath Kotur Date: Sat, 16 Nov 2013 04:00:01 +0000 (+0530) Subject: RDMA/cma: Handle global/non-linklocal IPv6 addresses in cma_check_linklocal() X-Git-Tag: firefly_0821_release~176^2~4579^2~2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5462eddd7a78131ccb514d52473625d99769215e;p=firefly-linux-kernel-4.4.55.git RDMA/cma: Handle global/non-linklocal IPv6 addresses in cma_check_linklocal() If addr is not a linklocal address, the code incorrectly fails to return and ends up assigning the scope ID to the scope id of the address, which is wrong. Fix by checking if it's a link local address first, and immediately return 0 if not. Signed-off-by: Somnath Kotur Signed-off-by: Roland Dreier --- diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 8e49db690f33..4173a2ad6d08 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -2480,8 +2480,11 @@ static int cma_check_linklocal(struct rdma_dev_addr *dev_addr, return 0; sin6 = (struct sockaddr_in6 *) addr; - if ((ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && - !sin6->sin6_scope_id) + + if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)) + return 0; + + if (!sin6->sin6_scope_id) return -EINVAL; dev_addr->bound_dev_if = sin6->sin6_scope_id;