]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove old-old listener stats
authorAlan T. DeKok <aland@freeradius.org>
Sun, 2 Aug 2020 12:48:15 +0000 (08:48 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 2 Aug 2020 13:06:06 +0000 (09:06 -0400)
these are unused even in v3.  So we remove them for v4

src/lib/server/stats.c

index b76478489318d24ae9973856eaeb4845c81f6b49..634294c7bc34d0772c4d551d8e0a442e11846c57 100644 (file)
@@ -237,417 +237,6 @@ void request_stats_final(REQUEST *request)
        request->master_state = REQUEST_COUNTED;
 }
 
-#if 0                          /* OLD LISTENERS */
-typedef struct {
-       int     attribute;
-       size_t  offset;
-} fr_stats2vp;
-
-/*
- *     Authentication
- */
-static fr_stats2vp authvp[] = {
-       { FR_FREERADIUS_TOTAL_ACCESS_REQUESTS, offsetof(fr_stats_t, total_requests) },
-       { FR_FREERADIUS_TOTAL_ACCESS_ACCEPTS, offsetof(fr_stats_t, total_access_accepts) },
-       { FR_FREERADIUS_TOTAL_ACCESS_REJECTS, offsetof(fr_stats_t, total_access_rejects) },
-       { FR_FREERADIUS_TOTAL_ACCESS_CHALLENGES, offsetof(fr_stats_t, total_access_challenges) },
-       { FR_FREERADIUS_TOTAL_AUTH_RESPONSES, offsetof(fr_stats_t, total_responses) },
-       { FR_FREERADIUS_TOTAL_AUTH_DUPLICATE_REQUESTS, offsetof(fr_stats_t, total_dup_requests) },
-       { FR_FREERADIUS_TOTAL_AUTH_MALFORMED_REQUESTS, offsetof(fr_stats_t, total_malformed_requests) },
-       { FR_FREERADIUS_TOTAL_AUTH_INVALID_REQUESTS, offsetof(fr_stats_t, total_bad_authenticators) },
-       { FR_FREERADIUS_TOTAL_AUTH_DROPPED_REQUESTS, offsetof(fr_stats_t, total_packets_dropped) },
-       { FR_FREERADIUS_TOTAL_AUTH_UNKNOWN_TYPES, offsetof(fr_stats_t, total_unknown_types) },
-       { 0, 0 }
-};
-
-
-#ifdef WITH_PROXY
-/*
- *     Proxied authentication requests.
- */
-static fr_stats2vp proxy_authvp[] = {
-       { FR_FREERADIUS_TOTAL_PROXY_ACCESS_REQUESTS, offsetof(fr_stats_t, total_requests) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCESS_ACCEPTS, offsetof(fr_stats_t, total_access_accepts) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCESS_REJECTS, offsetof(fr_stats_t, total_access_rejects) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCESS_CHALLENGES, offsetof(fr_stats_t, total_access_challenges) },
-       { FR_FREERADIUS_TOTAL_PROXY_AUTH_RESPONSES, offsetof(fr_stats_t, total_responses) },
-       { FR_FREERADIUS_TOTAL_PROXY_AUTH_DUPLICATE_REQUESTS, offsetof(fr_stats_t, total_dup_requests) },
-       { FR_FREERADIUS_TOTAL_PROXY_AUTH_MALFORMED_REQUESTS, offsetof(fr_stats_t, total_malformed_requests) },
-       { FR_FREERADIUS_TOTAL_PROXY_AUTH_INVALID_REQUESTS, offsetof(fr_stats_t, total_bad_authenticators) },
-       { FR_FREERADIUS_TOTAL_PROXY_AUTH_DROPPED_REQUESTS, offsetof(fr_stats_t, total_packets_dropped) },
-       { FR_FREERADIUS_TOTAL_PROXY_AUTH_UNKNOWN_TYPES, offsetof(fr_stats_t, total_unknown_types) },
-       { 0, 0 }
-};
-#endif
-
-
-/*
- *     Accounting
- */
-static fr_stats2vp acctvp[] = {
-       { FR_FREERADIUS_TOTAL_ACCOUNTING_REQUESTS, offsetof(fr_stats_t, total_requests) },
-       { FR_FREERADIUS_TOTAL_ACCOUNTING_RESPONSES, offsetof(fr_stats_t, total_responses) },
-       { FR_FREERADIUS_TOTAL_ACCT_DUPLICATE_REQUESTS, offsetof(fr_stats_t, total_dup_requests) },
-       { FR_FREERADIUS_TOTAL_ACCT_MALFORMED_REQUESTS, offsetof(fr_stats_t, total_malformed_requests) },
-       { FR_FREERADIUS_TOTAL_ACCT_INVALID_REQUESTS, offsetof(fr_stats_t, total_bad_authenticators) },
-       { FR_FREERADIUS_TOTAL_ACCT_DROPPED_REQUESTS, offsetof(fr_stats_t, total_packets_dropped) },
-       { FR_FREERADIUS_TOTAL_ACCT_UNKNOWN_TYPES, offsetof(fr_stats_t, total_unknown_types) },
-       { 0, 0 }
-};
-
-#ifdef WITH_PROXY
-static fr_stats2vp proxy_acctvp[] = {
-       { FR_FREERADIUS_TOTAL_PROXY_ACCOUNTING_REQUESTS, offsetof(fr_stats_t, total_requests) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCOUNTING_RESPONSES, offsetof(fr_stats_t, total_responses) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCT_DUPLICATE_REQUESTS, offsetof(fr_stats_t, total_dup_requests) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCT_MALFORMED_REQUESTS, offsetof(fr_stats_t, total_malformed_requests) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCT_INVALID_REQUESTS, offsetof(fr_stats_t, total_bad_authenticators) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCT_DROPPED_REQUESTS, offsetof(fr_stats_t, total_packets_dropped) },
-       { FR_FREERADIUS_TOTAL_PROXY_ACCT_UNKNOWN_TYPES, offsetof(fr_stats_t, total_unknown_types) },
-       { 0, 0 }
-};
-#endif
-
-static fr_stats2vp client_authvp[] = {
-       { FR_FREERADIUS_TOTAL_ACCESS_REQUESTS, offsetof(fr_stats_t, total_requests) },
-       { FR_FREERADIUS_TOTAL_ACCESS_ACCEPTS, offsetof(fr_stats_t, total_access_accepts) },
-       { FR_FREERADIUS_TOTAL_ACCESS_REJECTS, offsetof(fr_stats_t, total_access_rejects) },
-       { FR_FREERADIUS_TOTAL_ACCESS_CHALLENGES, offsetof(fr_stats_t, total_access_challenges) },
-       { FR_FREERADIUS_TOTAL_AUTH_RESPONSES, offsetof(fr_stats_t, total_responses) },
-       { FR_FREERADIUS_TOTAL_AUTH_DUPLICATE_REQUESTS, offsetof(fr_stats_t, total_dup_requests) },
-       { FR_FREERADIUS_TOTAL_AUTH_MALFORMED_REQUESTS, offsetof(fr_stats_t, total_malformed_requests) },
-       { FR_FREERADIUS_TOTAL_AUTH_INVALID_REQUESTS, offsetof(fr_stats_t, total_bad_authenticators) },
-       { FR_FREERADIUS_TOTAL_AUTH_DROPPED_REQUESTS, offsetof(fr_stats_t, total_packets_dropped) },
-       { FR_FREERADIUS_TOTAL_AUTH_UNKNOWN_TYPES, offsetof(fr_stats_t, total_unknown_types) },
-       { 0, 0 }
-};
-
-static fr_stats2vp client_acctvp[] = {
-       { FR_FREERADIUS_TOTAL_ACCOUNTING_REQUESTS, offsetof(fr_stats_t, total_requests) },
-       { FR_FREERADIUS_TOTAL_ACCOUNTING_RESPONSES, offsetof(fr_stats_t, total_responses) },
-       { FR_FREERADIUS_TOTAL_ACCT_DUPLICATE_REQUESTS, offsetof(fr_stats_t, total_dup_requests) },
-       { FR_FREERADIUS_TOTAL_ACCT_MALFORMED_REQUESTS, offsetof(fr_stats_t, total_malformed_requests) },
-       { FR_FREERADIUS_TOTAL_ACCT_INVALID_REQUESTS, offsetof(fr_stats_t, total_bad_authenticators) },
-       { FR_FREERADIUS_TOTAL_ACCT_DROPPED_REQUESTS, offsetof(fr_stats_t, total_packets_dropped) },
-       { FR_FREERADIUS_TOTAL_ACCT_UNKNOWN_TYPES, offsetof(fr_stats_t, total_unknown_types) },
-       { 0, 0 }
-};
-
-#define ADD_TO_REPLY(_attr, _vendor) \
-do { \
-       MEM(vp = fr_pair_afrom_num(request->reply, _vendor, _attr)); \
-       fr_pair_add(&request->reply->vps, vp); \
-} while (0)
-
-static fr_dict_attr_t const *freeradius_vendor_root;
-
-static void request_stats_addvp(REQUEST *request,
-                               fr_stats2vp *table, fr_stats_t *stats)
-{
-       int i;
-       fr_uint_t counter;
-       VALUE_PAIR *vp;
-
-       for (i = 0; table[i].attribute != 0; i++) {
-               vp = ADD_TO_REPLY(table[i].attribute, VENDORPEC_FREERADIUS);
-               if (!vp) continue;
-
-               counter = *(fr_uint_t *) (((uint8_t *) stats) + table[i].offset);
-               vp->vp_uint32 = counter;
-       }
-}
-
-void request_stats_reply(REQUEST *request)
-{
-       VALUE_PAIR *flag, *vp;
-
-       /*
-        *      Statistics are available ONLY on a "status" port.
-        */
-       fr_assert(request->packet->code == FR_CODE_STATUS_SERVER);
-       fr_assert(request->listener->type == RAD_LISTEN_NONE);
-
-       flag = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS, FR_FREERADIUS_STATISTICS_TYPE, TAG_ANY);
-       if (!flag || (flag->vp_uint32 == 0)) return;
-
-       /*
-        *      Authentication.
-        */
-       if (((flag->vp_uint32 & 0x01) != 0) &&
-           ((flag->vp_uint32 & 0xc0) == 0)) {
-               request_stats_addvp(request, authvp, &radius_auth_stats);
-       }
-
-       /*
-        *      Accounting
-        */
-       if (((flag->vp_uint32 & 0x02) != 0) &&
-           ((flag->vp_uint32 & 0xc0) == 0)) {
-               request_stats_addvp(request, acctvp, &radius_acct_stats);
-       }
-
-#ifdef WITH_PROXY
-       /*
-        *      Proxied authentication requests.
-        */
-       if (((flag->vp_uint32 & 0x04) != 0) &&
-           ((flag->vp_uint32 & 0x20) == 0)) {
-               request_stats_addvp(request, proxy_authvp, &proxy_auth_stats);
-       }
-
-       /*
-        *      Proxied accounting requests.
-        */
-       if (((flag->vp_uint32 & 0x08) != 0) &&
-           ((flag->vp_uint32 & 0x20) == 0)) {
-               request_stats_addvp(request, proxy_acctvp, &proxy_acct_stats);
-       }
-#endif
-
-       /*
-        *      Internal server statistics
-        */
-       if ((flag->vp_uint32 & 0x10) != 0) {
-               vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_START_TIME, VENDORPEC_FREERADIUS);
-               if (vp) vp->vp_date = start_time;
-               vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_HUP_TIME, VENDORPEC_FREERADIUS);
-               if (vp) vp->vp_date = hup_time;
-       }
-
-       /*
-        *      For a particular client.
-        */
-       if ((flag->vp_uint32 & 0x20) != 0) {
-               fr_ipaddr_t ipaddr;
-               VALUE_PAIR *server_ip, *server_port = NULL;
-               RADCLIENT *client = NULL;
-               RADCLIENT_LIST *cl = NULL;
-
-               /*
-                *      See if we need to look up the client by server
-                *      socket.
-                */
-               server_ip = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                               FR_FREERADIUS_STATS_SERVER_IP_ADDRESS, TAG_ANY);
-               if (server_ip) {
-                       server_port = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                                         FR_FREERADIUS_STATS_SERVER_PORT, TAG_ANY);
-
-                       if (server_port) {
-                               ipaddr.af = AF_INET;
-                               ipaddr.addr.v4.s_addr = server_ip->vp_ipv4addr;
-                               cl = listener_find_client_list(&ipaddr, server_port->vp_uint32, IPPROTO_UDP);
-
-                               /*
-                                *      Not found: don't do anything
-                                */
-                               if (!cl) return;
-                       }
-               }
-
-
-               vp = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                        FR_FREERADIUS_STATS_CLIENT_IP_ADDRESS, TAG_ANY);
-               if (vp) {
-                       memset(&ipaddr, 0, sizeof(ipaddr));
-                       ipaddr.af = AF_INET;
-                       ipaddr.addr.v4.s_addr = vp->vp_ipv4addr;
-                       client = client_find(cl, &ipaddr, IPPROTO_UDP);
-                       if (!client) {
-                               client = client_find(cl, &ipaddr, IPPROTO_TCP);
-                       }
-
-                       /*
-                        *      Else look it up by number.
-                        */
-               } else if ((vp = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                                    FR_FREERADIUS_STATS_CLIENT_NUMBER, TAG_ANY)) != NULL) {
-                       client = client_findbynumber(cl, vp->vp_uint32);
-               }
-
-               if (client) {
-                       /*
-                        *      If found, echo it back, along with
-                        *      the requested statistics.
-                        */
-                       fr_pair_add(&request->reply->vps, fr_pair_copy(request->reply, vp));
-
-                       /*
-                        *      When retrieving client by number, also
-                        *      echo back it's IP address.
-                        */
-                       if ((vp->vp_type == FR_TYPE_UINT32) &&
-                           (client->ipaddr.af == AF_INET)) {
-                               vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_CLIENT_IP_ADDRESS, VENDORPEC_FREERADIUS);
-                               if (vp) {
-                                       vp->vp_ipv4addr = client->ipaddr.addr.v4.s_addr;
-                               }
-
-                               if (client->ipaddr.prefix != 32) {
-                                       vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_CLIENT_NETMASK, VENDORPEC_FREERADIUS);
-                                       if (vp) {
-                                               vp->vp_uint32 = client->ipaddr.prefix;
-                                       }
-                               }
-                       }
-
-                       if (server_ip) {
-                               fr_pair_add(&request->reply->vps,
-                                       fr_pair_copy(request->reply, server_ip));
-                       }
-                       if (server_port) {
-                               fr_pair_add(&request->reply->vps,
-                                       fr_pair_copy(request->reply, server_port));
-                       }
-
-                       if ((flag->vp_uint32 & 0x01) != 0) {
-                               request_stats_addvp(request, client_authvp,
-                                                   &client->auth);
-                       }
-                       if ((flag->vp_uint32 & 0x02) != 0) {
-                               request_stats_addvp(request, client_acctvp,
-                                                   &client->acct);
-                       }
-               } /* else client wasn't found, don't echo it back */
-       }
-
-       /*
-        *      For a particular "listen" socket.
-        */
-       if (((flag->vp_uint32 & 0x40) != 0) &&
-           ((flag->vp_uint32 & 0x03) != 0)) {
-               rad_listen_t *this;
-               VALUE_PAIR *server_ip, *server_port;
-               fr_ipaddr_t ipaddr;
-
-               /*
-                *      See if we need to look up the server by socket
-                *      socket.
-                */
-               server_ip = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                               FR_FREERADIUS_STATS_SERVER_IP_ADDRESS, TAG_ANY);
-               if (!server_ip) return;
-
-               server_port = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                                 FR_FREERADIUS_STATS_SERVER_PORT, TAG_ANY);
-               if (!server_port) return;
-
-               ipaddr.af = AF_INET;
-               ipaddr.addr.v4.s_addr = server_ip->vp_ipv4addr;
-               this = listener_find_byipaddr(&ipaddr,
-                                             server_port->vp_uint32,
-                                             IPPROTO_UDP);
-
-               /*
-                *      Not found: don't do anything
-                */
-               if (!this) return;
-
-               fr_pair_add(&request->reply->vps,
-                       fr_pair_copy(request->reply, server_ip));
-               fr_pair_add(&request->reply->vps,
-                       fr_pair_copy(request->reply, server_port));
-
-               if (((flag->vp_uint32 & 0x01) != 0) &&
-                   ((request->listener->type == RAD_LISTEN_AUTH) ||
-                    (request->listener->type == RAD_LISTEN_NONE))) {
-                       request_stats_addvp(request, authvp, &this->stats);
-               }
-
-               if (((flag->vp_uint32 & 0x02) != 0) &&
-                   ((request->listener->type == RAD_LISTEN_ACCT) ||
-                    (request->listener->type == RAD_LISTEN_NONE))) {
-                       request_stats_addvp(request, acctvp, &this->stats);
-               }
-       }
-
-#ifdef WITH_PROXY
-       /*
-        *      Home servers.
-        */
-       if (((flag->vp_uint32 & 0x80) != 0) &&
-           ((flag->vp_uint32 & 0x03) != 0)) {
-               home_server_t *home;
-               VALUE_PAIR *server_ip, *server_port;
-
-               /*
-                *      See if we need to look up the server by socket
-                *      socket.
-                */
-               server_ip = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                               FR_FREERADIUS_STATS_SERVER_IP_ADDRESS, TAG_ANY);
-               if (!server_ip) return;
-
-               server_port = fr_pair_find_by_num(request->packet->vps, VENDORPEC_FREERADIUS,
-                                                 FR_FREERADIUS_STATS_SERVER_PORT, TAG_ANY);
-               if (!server_port) return;
-
-               /*
-                *      Not found: don't do anything
-                */
-               home = NULL;
-               if (!home) return;
-
-               fr_pair_add(&request->reply->vps,
-                       fr_pair_copy(request->reply, server_ip));
-               fr_pair_add(&request->reply->vps,
-                       fr_pair_copy(request->reply, server_port));
-
-               vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_SERVER_OUTSTANDING_REQUESTS, VENDORPEC_FREERADIUS);
-               if (vp) vp->vp_uint32 = home->currently_outstanding;
-
-               vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_SERVER_STATE, VENDORPEC_FREERADIUS);
-               if (vp) vp->vp_uint32 = home->state;
-
-               if ((home->state == HOME_STATE_ALIVE) &&
-                   (home->revive_time.tv_sec != 0)) {
-                       vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_SERVER_TIME_OF_LIFE, VENDORPEC_FREERADIUS);
-                       if (vp) vp->vp_date = fr_time_from_timeval(&home->revive_time);
-               }
-
-               if ((home->state == HOME_STATE_ALIVE) &&
-                   (home->ema.window > 0)) {
-                               vp = ADD_TO_REPLY(FR_FREERADIUS_SERVER_EMA_WINDOW, VENDORPEC_FREERADIUS);
-                               if (vp) vp->vp_uint32 = home->ema.window;
-                               vp = ADD_TO_REPLY(FR_FREERADIUS_SERVER_EMA_USEC_WINDOW_1, VENDORPEC_FREERADIUS);
-                               if (vp) vp->vp_uint32 = home->ema.ema1 / EMA_SCALE;
-                               vp = ADD_TO_REPLY(FR_FREERADIUS_SERVER_EMA_USEC_WINDOW_10, VENDORPEC_FREERADIUS);
-                               if (vp) vp->vp_uint32 = home->ema.ema10 / EMA_SCALE;
-
-               }
-
-               if (home->state == HOME_STATE_IS_DEAD) {
-                       vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_SERVER_TIME_OF_DEATH, VENDORPEC_FREERADIUS);
-                       if (vp) vp->vp_date = fr_time_from_timeval(&(struct timeval) {.tv_sec = home->zombie_period_start.tv_sec + home->zombie_period});
-               }
-
-               /*
-                *      Show more information...
-                *
-                *      FIXME: do this for clients, too!
-                */
-               vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_LAST_PACKET_RECV, VENDORPEC_FREERADIUS);
-               if (vp) vp->vp_date = fr_time_from_timeval(&(struct timeval) {.tv_sec = home->last_packet_recv});
-
-               vp = ADD_TO_REPLY(FR_FREERADIUS_STATS_LAST_PACKET_SENT, VENDORPEC_FREERADIUS);
-               if (vp) vp->vp_date = fr_time_from_timeval(&(struct timeval) {.tv_sec = home->last_packet_sent});
-
-               if (((flag->vp_uint32 & 0x01) != 0) &&
-                   (home->type == HOME_TYPE_AUTH)) {
-                       request_stats_addvp(request, proxy_authvp,
-                                           &home->stats);
-               }
-
-               if (((flag->vp_uint32 & 0x02) != 0) &&
-                   (home->type == HOME_TYPE_ACCT)) {
-                       request_stats_addvp(request, proxy_acctvp,
-                                           &home->stats);
-               }
-       }
-#endif /* WITH_PROXY */
-}
-#endif /* OLD LISTENERS */
-
 void radius_stats_init(int flag)
 {
        if (!flag) {