Date: Thu, 10 Dec 2015 05:17:04 +0000 (UTC) From: Stanislav Sedov <stas@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292047 - head/lib/libc/rpc Message-ID: <201512100517.tBA5H4xP069394@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <alex.burlyga.ietf@gmail.com> 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512100517.tBA5H4xP069394>