X-Git-Url: https://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Frx%2Frx.c;h=850108195c9d24decb6085cdf536715fa7f0126d;hp=7a50472ccd4ed90005a905d43a69be115a6f417d;hb=d820af6cd0eb1c6655ecf8e210294791825cfbad;hpb=ad71d031ec219ca418303bea3f37e40f59dde05d diff --git a/src/rx/rx.c b/src/rx/rx.c index 7a50472..8501081 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -4778,6 +4778,30 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np, return np; } +/** + * Schedule a connection abort to be sent after some delay. + * + * @param[in] conn The connection to send the abort on. + * @param[in] msec The number of milliseconds to wait before sending. + * + * @pre conn_data_lock must be held + */ +static void +rxi_SendConnectionAbortLater(struct rx_connection *conn, int msec) +{ + struct clock when, now; + if (!conn->error) { + return; + } + if (!conn->delayedAbortEvent) { + clock_GetTime(&now); + when = now; + clock_Addmsec(&when, msec); + conn->delayedAbortEvent = + rxevent_Post(&when, &now, rxi_SendDelayedConnAbort, conn, NULL, 0); + } +} + /* Received a response to a challenge packet */ static struct rx_packet * rxi_ReceiveResponsePacket(struct rx_connection *conn, @@ -4797,13 +4821,12 @@ rxi_ReceiveResponsePacket(struct rx_connection *conn, error = RXS_CheckResponse(conn->securityObject, conn, np); if (error) { /* If the response is invalid, reset the connection, sending - * an abort to the peer */ -#ifndef KERNEL - rxi_Delay(1); -#endif + * an abort to the peer. Send the abort with a 1 second delay, + * to avoid a peer hammering us by constantly recreating a + * connection with bad credentials. */ rxi_ConnectionError(conn, error); MUTEX_ENTER(&conn->conn_data_lock); - np = rxi_SendConnectionAbort(conn, np, istack, 0); + rxi_SendConnectionAbortLater(conn, 1000); MUTEX_EXIT(&conn->conn_data_lock); return np; } else { @@ -5197,7 +5220,6 @@ rxi_SendConnectionAbort(struct rx_connection *conn, struct rx_packet *packet, int istack, int force) { afs_int32 error; - struct clock when, now; if (!conn->error) return packet; @@ -5218,12 +5240,8 @@ rxi_SendConnectionAbort(struct rx_connection *conn, RX_PACKET_TYPE_ABORT, (char *)&error, sizeof(error), istack); MUTEX_ENTER(&conn->conn_data_lock); - } else if (!conn->delayedAbortEvent) { - clock_GetTime(&now); - when = now; - clock_Addmsec(&when, rxi_connAbortDelay); - conn->delayedAbortEvent = - rxevent_Post(&when, &now, rxi_SendDelayedConnAbort, conn, NULL, 0); + } else { + rxi_SendConnectionAbortLater(conn, rxi_connAbortDelay); } return packet; }