From patchwork Fri Mar 6 14:58:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 5955211 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D33EEBF440 for ; Fri, 6 Mar 2015 14:59:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EEFFB2034E for ; Fri, 6 Mar 2015 14:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 734B62034C for ; Fri, 6 Mar 2015 14:58:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754499AbbCFO65 (ORCPT ); Fri, 6 Mar 2015 09:58:57 -0500 Received: from mail-we0-f177.google.com ([74.125.82.177]:41024 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbbCFO64 (ORCPT ); Fri, 6 Mar 2015 09:58:56 -0500 Received: by wevm14 with SMTP id m14so59968945wev.8 for ; Fri, 06 Mar 2015 06:58:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=rhDYqawd+RqTKgEmjHYK+jIIP9sfpN5QaMfMz+rtU+0=; b=C6xMi6r9hdF39AdrRMv3PLRPwfsSPPaUcYlk2HW78WMQI1gdjZb2SexyNY2YzAR28P jIe5KP8jEqieMmLSIaHVW+IjkZd+N4tlWf6Au6Gu0BeXo90k8K9mF499j9IJr6n9Nxc7 DRVt2UNeaPFv/A/+0vPuwNUlHNSZEmlnGBdTsFjIdZR4eWjvel2fbTVHMirtEJNUHifV R5G5vtFSysRmNOAdtmQcQub3/+gM82IVbxiW9QS4HW56hYhJz8emT0LXlcitWhwsEOOe UXApWeLDhpf4hv7CeklgDtTJLwf4iyLRly3tTaknDWLIXmpOzlwOhxK5mNTPokrrhYXn JG7Q== X-Gm-Message-State: ALoCoQnvFkpMksIHwgJngQMM/T45J5nyX44Op9R9L+lHiUwrN8UiQvAuE4hPwyImRXmRX9fMrm8J X-Received: by 10.194.200.68 with SMTP id jq4mr30738429wjc.58.1425653935213; Fri, 06 Mar 2015 06:58:55 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id l9sm2594902wij.16.2015.03.06.06.58.52 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Mar 2015 06:58:53 -0800 (PST) Message-ID: <54F9C0A5.5010909@dev.mellanox.co.il> Date: Fri, 06 Mar 2015 09:58:45 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "Hefty, Sean" CC: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH librdmacm] rstream.c: Add missing binding to source address in client_connect 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, T_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 This is needed for IPv6 connections. Signed-off-by: Hal Rosenstock --- -- 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/examples/rstream.c b/examples/rstream.c index 05598a8..d93e9aa 100644 --- a/examples/rstream.c +++ b/examples/rstream.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2011-2012 Intel Corporation. All rights reserved. + * Copyright (c) 2014-2015 Mellanox Technologies LTD. All rights reserved. * * This software is available to you under the OpenIB.org BSD license * below: @@ -401,8 +402,8 @@ static int server_connect(void) static int client_connect(void) { - struct rdma_addrinfo *rai = NULL; - struct addrinfo *ai; + struct rdma_addrinfo *rai = NULL, *rai_src = NULL; + struct addrinfo *ai, *ai_src; struct pollfd fds; int ret, err; socklen_t len; @@ -415,6 +416,20 @@ static int client_connect(void) return ret; } + if (src_addr) { + if (use_rgai) { + rai_hints.ai_flags |= RAI_PASSIVE; + ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai_src); + } else { + ai_hints.ai_flags |= RAI_PASSIVE; + ret = getaddrinfo(src_addr, port, &ai_hints, &ai_src); + } + if (ret) { + perror("getaddrinfo src_addr"); + return ret; + } + } + rs = rai ? rs_socket(rai->ai_family, SOCK_STREAM, 0) : rs_socket(ai->ai_family, SOCK_STREAM, 0); if (rs < 0) { @@ -424,7 +439,15 @@ static int client_connect(void) } set_options(rs); - /* TODO: bind client to src_addr */ + + if (src_addr) { + ret = rai ? rs_bind(rs, rai_src->ai_src_addr, rai_src->ai_src_len) : + rs_bind(rs, ai_src->ai_addr, ai_src->ai_addrlen); + if (ret) { + perror("rbind"); + goto close; + } + } if (rai && rai->ai_route) { ret = rs_setsockopt(rs, SOL_RDMA, RDMA_ROUTE, rai->ai_route,