From patchwork Fri Nov 15 05:07:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 3186681 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 86F7B9F3AE for ; Fri, 15 Nov 2013 05:08:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F98120983 for ; Fri, 15 Nov 2013 05:08:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A03FE20984 for ; Fri, 15 Nov 2013 05:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754172Ab3KOFIh (ORCPT ); Fri, 15 Nov 2013 00:08:37 -0500 Received: from cmexedge1.ext.emulex.com ([138.239.224.99]:43837 "EHLO CMEXEDGE1.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754146Ab3KOFIg (ORCPT ); Fri, 15 Nov 2013 00:08:36 -0500 Received: from CMEXHTCAS2.ad.emulex.com (138.239.115.218) by CMEXEDGE1.ext.emulex.com (138.239.224.99) with Microsoft SMTP Server (TLS) id 14.3.146.0; Thu, 14 Nov 2013 21:08:45 -0800 Received: from localhost.localdomain (10.192.201.1) by smtp.emulex.com (138.239.115.208) with Microsoft SMTP Server id 14.3.146.2; Thu, 14 Nov 2013 21:08:34 -0800 From: Somnath Kotur To: CC: , Somnath Kotur Subject: [PATCH] IB/CMA: Fix to handle global/non-linklocal IPv6 address in cma_check_linklocal() Date: Fri, 15 Nov 2013 10:37:12 +0530 X-Mailer: git-send-email 1.6.0.2 MIME-Version: 1.0 Message-ID: <3f13d926-d132-4463-ac38-f6e6ef3501c6@CMEXHTCAS2.ad.emulex.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Even if the addr is not a linklocal address, the code treats it as such and assigns the bound dev addr to the scope id of the address which is invalid. Fix by checking if it's a link local address first and return 0 if not. Signed-off-by: Somnath Kotur --- drivers/infiniband/core/cma.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index dab4b41..7f8ee93 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -2466,8 +2466,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;