From owner-svn-src-all@freebsd.org Thu Dec 10 05:17:05 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74F359D63FD; Thu, 10 Dec 2015 05:17:05 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AEF61290; Thu, 10 Dec 2015 05:17:05 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBA5H4br069395; Thu, 10 Dec 2015 05:17:04 GMT (envelope-from stas@FreeBSD.org) Received: (from stas@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBA5H4xP069394; Thu, 10 Dec 2015 05:17:04 GMT (envelope-from stas@FreeBSD.org) Message-Id: <201512100517.tBA5H4xP069394@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: stas set sender to stas@FreeBSD.org using -f From: Stanislav Sedov Date: Thu, 10 Dec 2015 05:17:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292047 - head/lib/libc/rpc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Dec 2015 05:17:05 -0000 Author: stas Date: Thu Dec 10 05:17:04 2015 New Revision: 292047 URL: https://svnweb.freebsd.org/changeset/base/292047 Log: RPC: populate local address for rendezvous transporter. When accepting a connection on underlying tcp socket rpc vc transporter fails to populate local address. This change rectifies this problem by modifying rendezvous_request() to fill out the xptr structure member with appropriate information. Submitted by: Alex Burlyga MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D4206 Modified: head/lib/libc/rpc/svc_vc.c Modified: head/lib/libc/rpc/svc_vc.c ============================================================================== --- head/lib/libc/rpc/svc_vc.c Thu Dec 10 03:20:10 2015 (r292046) +++ head/lib/libc/rpc/svc_vc.c Thu Dec 10 05:17:04 2015 (r292047) @@ -281,8 +281,8 @@ rendezvous_request(SVCXPRT *xprt, struct int sock, flags; struct cf_rendezvous *r; struct cf_conn *cd; - struct sockaddr_storage addr; - socklen_t len; + struct sockaddr_storage addr, sslocal; + socklen_t len, slen; struct __rpc_sockinfo si; SVCXPRT *newxprt; fd_set cleanfds; @@ -347,6 +347,20 @@ again: __xdrrec_setnonblock(&cd->xdrs, cd->maxrec); } else cd->nonblock = FALSE; + slen = sizeof(struct sockaddr_storage); + if(_getsockname(sock, (struct sockaddr *)(void *)&sslocal, &slen) < 0) { + warnx("svc_vc_create: could not retrieve local addr"); + newxprt->xp_ltaddr.maxlen = newxprt->xp_ltaddr.len = 0; + } else { + newxprt->xp_ltaddr.maxlen = newxprt->xp_ltaddr.len = sslocal.ss_len; + newxprt->xp_ltaddr.buf = mem_alloc((size_t)sslocal.ss_len); + if (newxprt->xp_ltaddr.buf == NULL) { + warnx("svc_vc_create: no mem for local addr"); + newxprt->xp_ltaddr.maxlen = newxprt->xp_ltaddr.len = 0; + } else { + memcpy(newxprt->xp_ltaddr.buf, &sslocal, (size_t)sslocal.ss_len); + } + } gettimeofday(&cd->last_recv_time, NULL);