From 7a214c2bc13d4d18e534fcc933cae5ba1c34f83c Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Mon, 24 Sep 2001 11:44:32 +0000 Subject: [PATCH] rx-cleanup-20010924 The rxi_ReceiveAckPacket() change makes sure we have two extra fields (the max and recommended packet sizes) hanging off the packet, rather than just one. The PKTFLAG_FREE stuff in rx_packet.c just initialized flags in case PKTFLAG_ACKED somehow didn't get cleared there. The wirevec changes are off-by-1 errors: there's p->niovecs iovecs in a packet, from 0 (header) to p->niovecs-1, so p->niovecs doesn't refer to a meaningful iovec. --- src/rx/rx.c | 2 +- src/rx/rx_packet.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index c74472db3..1ecacf6c0 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -3460,7 +3460,7 @@ struct rx_packet *rxi_ReceiveAckPacket(call, np, istack) /* if the ack packet has a receivelen field hanging off it, * update our state */ - if ( np->length >= rx_AckDataSize(ap->nAcks) +sizeof(afs_int32)) { + if ( np->length >= rx_AckDataSize(ap->nAcks) + 2*sizeof(afs_int32)) { afs_uint32 tSize; /* If the ack packet has a "recommended" size that is less than diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c index b248117ff..e9b6c2a0a 100644 --- a/src/rx/rx_packet.c +++ b/src/rx/rx_packet.c @@ -272,7 +272,7 @@ static struct rx_packet * allocCBuf(int class) queue_Remove(c); if (!(c->flags & RX_PKTFLAG_FREE)) osi_Panic("rxi_AllocPacket: packet not free\n"); - c->flags &= ~RX_PKTFLAG_FREE; + c->flags = 0; /* clear RX_PKTFLAG_FREE, initialize the rest */ c->header.flags = 0; #ifdef KERNEL @@ -631,7 +631,7 @@ struct rx_packet *rxi_AllocPacketNoLock(class) dpf(("Alloc %x, class %d\n", p, class)); queue_Remove(p); - p->flags &= ~RX_PKTFLAG_FREE; + p->flags = 0; /* clear RX_PKTFLAG_FREE, initialize the rest */ p->header.flags = 0; /* have to do this here because rx_FlushWrite fiddles with the iovs in @@ -788,8 +788,8 @@ int rxi_ReadPacket(socket, p, host, port) * our problems caused by the lack of a length field in the rx header. * Use the extra buffer that follows the localdata in each packet * structure. */ - savelen = p->wirevec[p->niovecs].iov_len; - p->wirevec[p->niovecs].iov_len += RX_EXTRABUFFERSIZE; + savelen = p->wirevec[p->niovecs-1].iov_len; + p->wirevec[p->niovecs-1].iov_len += RX_EXTRABUFFERSIZE; memset((char *)&msg, 0, sizeof(msg)); msg.msg_name = (char *) &from; @@ -799,7 +799,7 @@ int rxi_ReadPacket(socket, p, host, port) nbytes = rxi_Recvmsg(socket, &msg, 0); /* restore the vec to its correct state */ - p->wirevec[p->niovecs].iov_len = savelen; + p->wirevec[p->niovecs-1].iov_len = savelen; p->length = (nbytes - RX_HEADER_SIZE); if ((nbytes > tlen) || (p->length & 0x8000)) { /* Bogus packet */ -- 2.39.5