From f78da7e7e15c7786585a18457d65d86959326229 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Mon, 8 Oct 2012 10:33:21 -0700 Subject: [PATCH] librdmacm: Disable ACM support if ibacm.port is not found 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. Signed-off-by: Sean Hefty --- src/acm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/acm.c b/src/acm.c index 3d8c912c..c9ca5b56 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; -- 2.41.0