Skip to content

Commit

Permalink
RDMA/cma: Handle global/non-linklocal IPv6 addresses in cma_check_lin…
Browse files Browse the repository at this point in the history
…klocal()

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 <[email protected]>
Signed-off-by: Roland Dreier <[email protected]>
  • Loading branch information
Somnath Kotur authored and rolandd committed Jan 23, 2014
1 parent 7e22e91 commit 5462edd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5462edd

Please sign in to comment.