Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Jun 2001 05:58:12 -0700 (PDT)
From:      Jean-Luc.Richier@imag.fr
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/27813: clnt_control option CLGET_SVC_ADDR does not work with rpc vc transport
Message-ID:  <200106011258.f51CwCD34619@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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 <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <rpc/rpc.h>

#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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106011258.f51CwCD34619>