From owner-freebsd-bugs Fri Jun 1 6: 0:14 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3ECEF37B424 for ; Fri, 1 Jun 2001 06:00:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f51D02Y34782; Fri, 1 Jun 2001 06:00:02 -0700 (PDT) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2EAD537B424 for ; Fri, 1 Jun 2001 05:58:12 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f51CwCD34619; Fri, 1 Jun 2001 05:58:12 -0700 (PDT) (envelope-from nobody) Message-Id: <200106011258.f51CwCD34619@freefall.freebsd.org> Date: Fri, 1 Jun 2001 05:58:12 -0700 (PDT) From: Jean-Luc.Richier@imag.fr To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: misc/27813: clnt_control option CLGET_SVC_ADDR does not work with rpc vc transport Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 27813 >Category: misc >Synopsis: clnt_control option CLGET_SVC_ADDR does not work with rpc vc transport >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jun 01 06:00:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Jean-Luc Richier >Release: FreeBSD5.0 current >Organization: IMAG >Environment: FreeBSD lagavulin.imag.fr 5.0-CURRENT FreeBSD 5.0-CURRENT #1 >Description: With the new TI-RPC libc code, the control call which allows clients to find the address of the server (clnt_control(clnt, CLGET_SVC_ADDR, ..) return an incorrect value. >How-To-Repeat: Consider the code at the end, which allows to test rpc calls (unicast or not) on different transports, compile it (cc -o tstrpc tstrpc.c) - on udp: it works: % tstrpc tuna.imag.fr response from: tuna.imag.fr - on tcp there is an error % tstrpc -t tuna.imag.fr incorrect response test program tstrpc.c: #include #include #include #include #define RPCBPROC_NULL 0 char *transp; int reply(caddr_t replyp, struct netbuf *raddrp, struct netconfig *nconf) { char host[NI_MAXHOST]; struct sockaddr *sock = raddrp->buf; if (getnameinfo(sock, sock->sa_len, host, sizeof (host), NULL, 0, 0)) printf("incorrect response\n"); else printf("response from: %s\n", host); return(0); } void onehost(char *host) { CLIENT *clnt; struct netbuf addr; struct timeval tv; if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL) errx(1, "%s", clnt_spcreateerror("")); tv.tv_sec = 15; tv.tv_usec = 0; if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv) != RPC_SUCCESS) errx(1, "%s", clnt_sperror(clnt, "")); clnt_control(clnt, CLGET_SVC_ADDR, (char *)&addr); reply(NULL, &addr, NULL); } void allhosts() { enum clnt_stat clnt_stat; clnt_stat = rpc_broadcast(RPCBPROG, RPCBVERS, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, (resultproc_t)reply, transp); if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_TIMEDOUT) errx(1, "%s", clnt_sperrno(clnt_stat)); } int main(int argc, char *argv[]) { int ch; transp = "udp"; while ((ch = getopt(argc, argv, "ut")) != -1) switch (ch) { case 't': transp = "tcp"; break; case 'u': transp = "udp"; break; default: errx(1, "tstrpc -[u|t] ..."); } if (argc == optind) allhosts(); else for (; optind < argc; optind++) onehost(argv[optind]); exit(0); } >Fix: The problem is in lib/libc/rpc/clnt_vc.c, an incorrect reference. To correct: *** lib/libc/rpc/clnt_vc.c.DIST Wed Apr 4 01:34:45 2001 --- lib/libc/rpc/clnt_vc.c Mon May 7 17:35:30 2001 *************** *** 257,263 **** ct->ct_addr.buf = malloc(raddr->maxlen); if (ct->ct_addr.buf == NULL) goto err; ! memcpy(ct->ct_addr.buf, &raddr->buf, raddr->len); ct->ct_addr.len = raddr->maxlen; ct->ct_addr.maxlen = raddr->maxlen; --- 257,263 ---- ct->ct_addr.buf = malloc(raddr->maxlen); if (ct->ct_addr.buf == NULL) goto err; ! memcpy(ct->ct_addr.buf, raddr->buf, raddr->len); ct->ct_addr.len = raddr->maxlen; ct->ct_addr.maxlen = raddr->maxlen; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message