From: Alan T. DeKok Date: Fri, 13 May 2011 11:44:35 +0000 (+0200) Subject: Set "last packet" entry for all sockets X-Git-Tag: release_3_0_0_beta0~830 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=141258e9fddab3057677bb508369b6db6c2113eb;p=thirdparty%2Ffreeradius-server.git Set "last packet" entry for all sockets This will help us track TCP connections --- diff --git a/src/main/listen.c b/src/main/listen.c index ff15ebe0857..1fb1286b366 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -631,6 +631,7 @@ static int dual_tcp_accept(rad_listen_t *listener) sock->other_ipaddr = src_ipaddr; sock->other_port = src_port; sock->client = client; + sock->opened = sock->last_packet = time(NULL); this->fd = newfd; this->status = RAD_LISTEN_STATUS_INIT; diff --git a/src/main/process.c b/src/main/process.c index f65afb1fe6a..b5aba402199 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -1186,6 +1186,20 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet, int count; RADIUS_PACKET **packet_p; REQUEST *request = NULL; + struct timeval now; + + /* + * Set the last packet received. + */ + gettimeofday(&now, NULL); +#ifdef WITH_DETAIL + if (listener->type != RAD_LISTEN_DETAIL) +#endif + { + listen_socket_t *sock = listener->data; + + sock->last_packet = now.tv_sec; + } packet_p = fr_packet_list_find(pl, packet); if (packet_p) { @@ -1248,8 +1262,6 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet, (listener->type != RAD_LISTEN_DETAIL) && #endif ((count = fr_packet_list_num_elements(pl)) > mainconfig.max_requests)) { - struct timeval now; - static time_t last_complained = 0; radlog(L_ERR, "Dropping request (%d is too many): from client %s port %d - ID: %d", count, @@ -1261,7 +1273,6 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet, /* * Complain once every 10 seconds. */ - gettimeofday(&now, NULL); if ((last_complained + 10) < now.tv_sec) { last_complained = now.tv_sec; exec_trigger(NULL, NULL, "server.max_requests"); @@ -1284,7 +1295,7 @@ int request_receive(rad_listen_t *listener, RADIUS_PACKET *packet, request->listener = listener; request->client = client; request->packet = packet; - gettimeofday(&request->packet->timestamp, NULL); + request->packet->timestamp = now; request->number = request_num_counter++; request->priority = listener->type; request->master_state = REQUEST_ACTIVE; @@ -1737,7 +1748,10 @@ int request_proxy_reply(RADIUS_PACKET *packet) * Status-Server packets don't count as real packets. */ if (request->proxy->code != PW_STATUS_SERVER) { + listen_socket_t *sock = request->proxy_listener->data; + request->home_server->last_packet = now.tv_sec; + sock->last_packet = now.tv_sec; } /*