# HG changeset patch # User Sebastien Decugis # Date 1284514903 -32400 # Node ID 345537783a9033da9b9691cd664e7909fc69ba01 # Parent 77b5752501036320a2b2348ab154e3fefa100935 Allow duplicate messages to be processed after Diameter answer has been received. diff -r 77b575250103 -r 345537783a90 extensions/app_radgw/rgw.h --- a/extensions/app_radgw/rgw.h Tue Sep 14 17:12:17 2010 +0900 +++ b/extensions/app_radgw/rgw.h Wed Sep 15 10:41:43 2010 +0900 @@ -99,6 +99,7 @@ int rgw_clients_check_dup(struct rgw_radius_msg_meta **msg, struct rgw_client *cli); int rgw_clients_create_origin(struct rgw_radius_msg_meta *msg, struct rgw_client * cli, struct msg ** diam); int rgw_client_finish_send(struct radius_msg ** msg, struct rgw_radius_msg_meta * req, struct rgw_client * cli); +int rgw_client_finish_nosend(struct rgw_radius_msg_meta * req, struct rgw_client * cli); void rgw_clients_dispose(struct rgw_client ** ref); void rgw_clients_dump(void); int rgw_clients_init(void); diff -r 77b575250103 -r 345537783a90 extensions/app_radgw/rgw_clients.c --- a/extensions/app_radgw/rgw_clients.c Tue Sep 14 17:12:17 2010 +0900 +++ b/extensions/app_radgw/rgw_clients.c Wed Sep 15 10:41:43 2010 +0900 @@ -1052,3 +1052,53 @@ return 0; } +/* Call this function when a RADIUS request has explicitely no answer (mainly accounting) so +that we purge the duplicate cache and allow further message to be translated again. +This is useful for example when a temporary error occurred in Diameter (like UNABLE_TO_DELIVER) */ +int rgw_client_finish_nosend(struct rgw_radius_msg_meta * req, struct rgw_client * cli) +{ + int p; + struct fd_list * li; + + TRACE_ENTRY("%p %p", req, cli); + CHECK_PARAMS( req && cli ); + + /* update the duplicate cache */ + if (req->serv_type == RGW_PLG_TYPE_AUTH) + p = 0; + else + p = 1; + + CHECK_POSIX( pthread_mutex_lock( &cli->dupl_info[p].dupl_lock ) ); + + /* Search this message in our list */ + for (li = cli->dupl_info[p].dupl_by_id.next; li != &cli->dupl_info[p].dupl_by_id; li = li->next) { + int cmp = 0; + struct req_info * r = (struct req_info *)(li->o); + if (r->id < req->radius.hdr->identifier) + continue; + if (r->id > req->radius.hdr->identifier) + break; + if (r->port < req->port) + continue; + if (r->port > req->port) + break; + cmp = memcmp(&r->auth[0], &req->radius.hdr->authenticator[0], 16); + if (cmp < 0) + continue; + if (cmp > 0) + break; + + /* We have the request in our duplicate cache, remove it */ + fd_list_unlink(&r->by_id); + fd_list_unlink(&r->by_time); + dupl_free_req_info(r); + break; + } + + CHECK_POSIX( pthread_mutex_unlock( &cli->dupl_info[p].dupl_lock ) ); + + /* Finished */ + return 0; +} + diff -r 77b575250103 -r 345537783a90 extensions/app_radgw/rgw_worker.c --- a/extensions/app_radgw/rgw_worker.c Tue Sep 14 17:12:17 2010 +0900 +++ b/extensions/app_radgw/rgw_worker.c Wed Sep 15 10:41:43 2010 +0900 @@ -287,6 +287,9 @@ /* Now try and send the RADIUS answer */ if (rad_ans) { CHECK_FCT_DO( rgw_client_finish_send(&rad_ans, pa->rad, pa->cli), ); + } else { + /* Remove the request from the duplicate cache */ + CHECK_FCT_DO( rgw_client_finish_nosend(pa->rad, pa->cli), ); } out: