From patchwork Mon Oct 8 17:47:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 1566641 X-Patchwork-Delegate: roland@digitalvampire.org Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D1DCADFF71 for ; Mon, 8 Oct 2012 17:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753841Ab2JHRsV (ORCPT ); Mon, 8 Oct 2012 13:48:21 -0400 Received: from mga09.intel.com ([134.134.136.24]:9542 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753205Ab2JHRsV convert rfc822-to-8bit (ORCPT ); Mon, 8 Oct 2012 13:48:21 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 08 Oct 2012 10:48:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,555,1344236400"; d="scan'208";a="223503494" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by orsmga002.jf.intel.com with ESMTP; 08 Oct 2012 10:47:51 -0700 Received: from orsmsx101.amr.corp.intel.com ([169.254.8.223]) by ORSMSX104.amr.corp.intel.com ([169.254.3.159]) with mapi id 14.01.0355.002; Mon, 8 Oct 2012 10:47:51 -0700 From: "Hefty, Sean" To: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH] [librdmacm] librdmacm: Disable ACM support if ibacm.port is not found Thread-Topic: [PATCH] [librdmacm] librdmacm: Disable ACM support if ibacm.port is not found Thread-Index: Ac2lfMuA6mi7sMvhQNyrmHusZmcw1g== Date: Mon, 8 Oct 2012 17:47:50 +0000 Message-ID: <1828884A29C6694DAF28B7E6B8A8237346AA3A96@ORSMSX101.amr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The librdmacm will try to connect port 6125 if ibacm.port is not found. The problem is that some other service or application could be using that port and respond with garbage. Rather than falling back to a hard coded port number, if ibacm.port is not found, simply disable ACM support. This has the effect of removing support for older versions of ibacm, unless the port file is created manually. Patch created based on feedback from Doug Ledford and Florian Weimer from RedHat. Signed-off-by: Sean Hefty --- src/acm.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/src/acm.c b/src/acm.c index 3d8c912..c9ca5b5 100755 --- a/src/acm.c +++ b/src/acm.c @@ -62,7 +62,7 @@ typedef struct acm_msg cma_acm_msg_t; static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER; static int sock = -1; -static short server_port = 6125; +static short server_port; struct ib_connect_hdr { uint8_t cma_version; @@ -76,7 +76,7 @@ struct ib_connect_hdr { #define cma_dst_ip6 dst_addr[0] }; -static void ucma_set_server_port(void) +static int ucma_set_server_port(void) { FILE *f; @@ -84,6 +84,7 @@ static void ucma_set_server_port(void) fscanf(f, "%hu", (unsigned short *) &server_port); fclose(f); } + return server_port; } void ucma_ib_init(void) @@ -96,7 +97,9 @@ void ucma_ib_init(void) return; pthread_mutex_lock(&acm_lock); - ucma_set_server_port(); + if (!ucma_set_server_port()) + goto out; + sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) goto out;