diff options
author | stas <stas@FreeBSD.org> | 2016-01-08 00:21:55 +0000 |
---|---|---|
committer | stas <stas@FreeBSD.org> | 2016-01-08 00:21:55 +0000 |
commit | 060003c8c0bd2b2b90446a59e20a4734e7eb4e4d (patch) | |
tree | c04bef8310f54613339e052af2a1c549dcf533bb /lib/libc/rpc | |
parent | 012c5f2da94bb4316a139c3c9064323b5eb5e147 (diff) | |
download | FreeBSD-src-060003c8c0bd2b2b90446a59e20a4734e7eb4e4d.zip FreeBSD-src-060003c8c0bd2b2b90446a59e20a4734e7eb4e4d.tar.gz |
MFC r292047: RPC: populate local address for rendezvous transporter.
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r-- | lib/libc/rpc/svc_vc.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c index 31edb93..304f90a 100644 --- a/lib/libc/rpc/svc_vc.c +++ b/lib/libc/rpc/svc_vc.c @@ -292,8 +292,8 @@ rendezvous_request(xprt, msg) 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; @@ -358,6 +358,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); |