svn commit: r292047 - head/lib/libc/rpc
Stanislav Sedov
stas at FreeBSD.org
Thu Dec 10 05:17:05 UTC 2015
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 at 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);
More information about the svn-src-head
mailing list