Print this page
3910 t_look(3NSL) should never return T_ERROR
*** 18,27 ****
--- 18,28 ----
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
+ * Copyright 2014 Gary Mills
* Copyright 2001 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
*** 30,41 ****
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
- #pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Miscellaneous support routines for kernel implentation of AUTH_DES
*/
/*
--- 31,40 ----
*** 109,161 ****
RPCLOG(1, "rtime: t_kbind %d\n", error);
return (-1);
}
if (synconfig->knc_semantics == NC_TPI_CLTS) {
! if ((error = t_kalloc(tiptr, T_UNITDATA, T_UDATA|T_ADDR,
! (char **)&unitdata)) != 0) {
RPCLOG(1, "rtime: t_kalloc %d\n", error);
(void) t_kclose(tiptr, 1);
return (-1);
}
unitdata->addr.len = addrp->len;
! bcopy(addrp->buf, unitdata->addr.buf, unitdata->addr.len);
dummy = 0;
unitdata->udata.buf = (caddr_t)&dummy;
unitdata->udata.len = sizeof (dummy);
! if ((error = t_ksndudata(tiptr, unitdata, NULL)) != 0) {
RPCLOG(1, "rtime: t_ksndudata %d\n", error);
! (void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
(void) t_kclose(tiptr, 1);
return (-1);
}
timo = TIMEVAL_TO_TICK(wait);
RPCLOG(8, "rtime: timo %x\n", timo);
! if ((error = t_kspoll(tiptr, timo, READWAIT, &type)) != 0) {
RPCLOG(1, "rtime: t_kspoll %d\n", error);
! (void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
(void) t_kclose(tiptr, 1);
return (-1);
}
if (type == 0) {
RPCLOG0(1, "rtime: t_kspoll timed out\n");
! (void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
(void) t_kclose(tiptr, 1);
return (-1);
}
error = t_krcvudata(tiptr, unitdata, &type, &uderr);
if (error != 0) {
RPCLOG(1, "rtime: t_krcvudata %d\n", error);
! (void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
(void) t_kclose(tiptr, 1);
return (-1);
}
if (type == T_UDERR) {
if (bcmp(addrp->buf, unitdata->addr.buf,
--- 108,169 ----
RPCLOG(1, "rtime: t_kbind %d\n", error);
return (-1);
}
if (synconfig->knc_semantics == NC_TPI_CLTS) {
! if ((error = t_kalloc(tiptr, T_UNITDATA,
! T_UDATA|T_ADDR, (char **)&unitdata)) != 0) {
RPCLOG(1, "rtime: t_kalloc %d\n", error);
(void) t_kclose(tiptr, 1);
return (-1);
}
unitdata->addr.len = addrp->len;
! bcopy(addrp->buf, unitdata->addr.buf,
! unitdata->addr.len);
dummy = 0;
unitdata->udata.buf = (caddr_t)&dummy;
unitdata->udata.len = sizeof (dummy);
! if ((error = t_ksndudata(tiptr, unitdata, NULL)) !=
! 0) {
RPCLOG(1, "rtime: t_ksndudata %d\n", error);
! (void) t_kfree(tiptr, (char *)unitdata,
! T_UNITDATA);
(void) t_kclose(tiptr, 1);
return (-1);
}
timo = TIMEVAL_TO_TICK(wait);
RPCLOG(8, "rtime: timo %x\n", timo);
! if ((error = t_kspoll(tiptr, timo, READWAIT,
! &type)) != 0) {
RPCLOG(1, "rtime: t_kspoll %d\n", error);
! (void) t_kfree(tiptr, (char *)unitdata,
! T_UNITDATA);
(void) t_kclose(tiptr, 1);
return (-1);
}
if (type == 0) {
RPCLOG0(1, "rtime: t_kspoll timed out\n");
! (void) t_kfree(tiptr, (char *)unitdata,
! T_UNITDATA);
(void) t_kclose(tiptr, 1);
return (-1);
}
error = t_krcvudata(tiptr, unitdata, &type, &uderr);
if (error != 0) {
RPCLOG(1, "rtime: t_krcvudata %d\n", error);
! (void) t_kfree(tiptr, (char *)unitdata,
! T_UNITDATA);
(void) t_kclose(tiptr, 1);
+ if (error == EBADMSG && retries-- > 0)
+ goto again;
return (-1);
}
if (type == T_UDERR) {
if (bcmp(addrp->buf, unitdata->addr.buf,
*** 172,202 ****
goto again;
}
}
if (type != T_DATA) {
! RPCLOG(1, "rtime: t_krcvudata returned type %d\n",
type);
! (void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
(void) t_kclose(tiptr, 1);
if (retries-- == 0)
return (-1);
goto again;
}
if (unitdata->udata.len < sizeof (uint32_t)) {
RPCLOG(1, "rtime: bad rcvd length %d\n",
unitdata->udata.len);
! (void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
(void) t_kclose(tiptr, 1);
if (retries-- == 0)
return (-1);
goto again;
}
/* LINTED pointer alignment */
! thetime = (time_t)ntohl(*(uint32_t *)unitdata->udata.buf);
(void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
} else {
if ((error = t_kalloc(tiptr, T_CALL, T_ADDR,
--- 180,214 ----
goto again;
}
}
if (type != T_DATA) {
! RPCLOG(1,
! "rtime: t_krcvudata returned type %d\n",
type);
! (void) t_kfree(tiptr, (char *)unitdata,
! T_UNITDATA);
(void) t_kclose(tiptr, 1);
if (retries-- == 0)
return (-1);
goto again;
}
if (unitdata->udata.len < sizeof (uint32_t)) {
RPCLOG(1, "rtime: bad rcvd length %d\n",
unitdata->udata.len);
! (void) t_kfree(tiptr, (char *)unitdata,
! T_UNITDATA);
(void) t_kclose(tiptr, 1);
if (retries-- == 0)
return (-1);
goto again;
}
+ thetime = (time_t)ntohl(
/* LINTED pointer alignment */
! *(uint32_t *)unitdata->udata.buf);
(void) t_kfree(tiptr, (char *)unitdata, T_UNITDATA);
} else {
if ((error = t_kalloc(tiptr, T_CALL, T_ADDR,
*** 227,275 ****
/* now read up to 4 bytes from the TIME server */
while (i < sizeof (dummy)) {
error = t_kspoll(tiptr, timo, READWAIT, &type);
if (error != 0) {
! RPCLOG(1, "rtime: t_kspoll %d\n", error);
(void) t_kclose(tiptr, 1);
return (-1);
}
if (type == 0) {
! RPCLOG0(1, "rtime: t_kspoll timed out\n");
(void) t_kclose(tiptr, 1);
return (-1);
}
! error = tli_recv(tiptr, &mp, tiptr->fp->f_flag);
if (error != 0) {
! RPCLOG(1, "rtime: tli_recv %d\n", error);
(void) t_kclose(tiptr, 1);
return (-1);
}
if (mp->b_datap->db_type != M_DATA) {
RPCLOG(1, "rtime: wrong msg type %d\n",
mp->b_datap->db_type);
! RPCLOG(1, "rtime: wrong msg type: read %d"
" bytes\n", i);
(void) t_kclose(tiptr, 1);
freemsg(mp);
return (-1);
}
mp2 = mp;
/*
! * The outer loop iterates until we reach the end of
! * the mblk chain.
*/
while (mp2 != NULL) {
/*
! * The inner loop iterates until we've gotten
! * 4 bytes or until the mblk is exhausted.
*/
while (i < sizeof (dummy) &&
mp2->b_rptr < mp2->b_wptr) {
i++;
--- 239,293 ----
/* now read up to 4 bytes from the TIME server */
while (i < sizeof (dummy)) {
error = t_kspoll(tiptr, timo, READWAIT, &type);
if (error != 0) {
! RPCLOG(1, "rtime: t_kspoll %d\n",
! error);
(void) t_kclose(tiptr, 1);
return (-1);
}
if (type == 0) {
! RPCLOG0(1,
! "rtime: t_kspoll timed out\n");
(void) t_kclose(tiptr, 1);
return (-1);
}
! error = tli_recv(tiptr, &mp,
! tiptr->fp->f_flag);
if (error != 0) {
! RPCLOG(1, "rtime: tli_recv %d\n",
! error);
(void) t_kclose(tiptr, 1);
return (-1);
}
if (mp->b_datap->db_type != M_DATA) {
RPCLOG(1, "rtime: wrong msg type %d\n",
mp->b_datap->db_type);
! RPCLOG(1,
! "rtime: wrong msg type: read %d"
" bytes\n", i);
(void) t_kclose(tiptr, 1);
freemsg(mp);
return (-1);
}
mp2 = mp;
/*
! * The outer loop iterates until we reach the
! * end of the mblk chain.
*/
while (mp2 != NULL) {
/*
! * The inner loop iterates until
! * we've gotten 4 bytes or until
! * the mblk is exhausted.
*/
while (i < sizeof (dummy) &&
mp2->b_rptr < mp2->b_wptr) {
i++;
*** 278,288 ****
* We avoid big-endian/little-endian
* issues by serializing the result
* one byte at a time.
*/
dummy <<= 8;
! dummy += ((*mp2->b_rptr) & 0xFF);
mp2->b_rptr++;
}
mp2 = mp2->b_cont;
--- 296,307 ----
* We avoid big-endian/little-endian
* issues by serializing the result
* one byte at a time.
*/
dummy <<= 8;
! dummy += ((*mp2->b_rptr) &
! 0xFF);
mp2->b_rptr++;
}
mp2 = mp2->b_cont;