Changeset 688:8c3dc8584dab in freeDiameter
- Timestamp:
- Jan 19, 2011, 7:05:30 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/dbg_interactive.py.sample
r649 r688 364 364 a_msg = msg() 365 365 a_msg.dump() 366 a_msg.log(FD_MSG_LOG_DROPPED, "Check libfdproto for more details. Configure with fd_msg_log_config.") 366 367 del a_msg 367 368 -
extensions/app_radgw/rgwx_acct.c
r639 r688 1215 1215 out: 1216 1216 if (answer && *answer) { 1217 TRACE_DEBUG(INFO, "Received the following problematic STA message, discarding ...");1217 TRACE_DEBUG(INFO, "Received the following problematic STA message, discarding anyway..."); 1218 1218 fd_msg_dump_walk( INFO, *answer ); 1219 1219 fd_msg_free(*answer); -
extensions/dbg_interactive/messages.i
r662 r688 254 254 } 255 255 256 /* Log to file (depending on config) */ 257 void log ( enum fd_msg_log_cause cause, char * message ) { 258 fd_msg_log( cause, $self, message ); 259 } 260 256 261 /* Model */ 257 262 struct dict_object * model() { -
include/freeDiameter/libfdproto.h
r687 r688 2055 2055 FD_MSG_LOG_DROPPED = 0, /* message has been dropped by the framework */ 2056 2056 FD_MSG_LOG_RECEIVED, /* message received from the network */ 2057 FD_MSG_LOG_SENT /* message sent to another peer */ 2058 }; 2059 #define FD_MSG_LOG_MAX FD_MSG_LOG_SENT 2057 FD_MSG_LOG_SENT, /* message sent to another peer */ 2058 FD_MSG_LOG_NODELIVER /* message could not be delivered to any peer */ 2059 }; 2060 #define FD_MSG_LOG_MAX FD_MSG_LOG_NODELIVER 2060 2061 void fd_msg_log( enum fd_msg_log_cause cause, struct msg * msg, const char * prefix_format, ... ); 2061 2062 … … 2067 2068 }; 2068 2069 int fd_msg_log_config(enum fd_msg_log_cause cause, enum fd_msg_log_method method, const char * arg); 2070 void ml_conf_init(struct dictionary *dict); 2069 2071 2070 2072 /*********************************************/ -
libfdcore/core.c
r686 r688 195 195 fd_g_config = &g_conf; 196 196 CHECK_FCT( fd_conf_init() ); 197 198 /* Initialize the message logging facility */ 199 ml_conf_init(fd_g_config->cnf_dict); 197 200 198 201 /* Add definitions of the base protocol */ -
libfdcore/messages.c
r658 r688 313 313 return ret; 314 314 315 fd_log_debug("The following message does not comply to the dictionary and/or rules (%s):\n", pei.pei_errcode);316 fd_msg_dump_walk( NONE, m);315 TRACE_DEBUG(INFO, "A message does not comply to the dictionary and/or rules (%s)", pei.pei_errcode); 316 fd_msg_dump_walk(FULL, m); 317 317 318 318 CHECK_FCT( fd_msg_hdr(m, &hdr) ); … … 364 364 365 365 /* Just discard */ 366 fd_msg_log( FD_MSG_LOG_DROPPED, m, "Answer not compliant to dictionary's ABNF (%s)", pei.pei_errcode ); 366 367 CHECK_FCT( fd_msg_free( m ) ); 367 368 *msg = NULL; -
libfdcore/p_ce.c
r662 r688 598 598 fd_cnx_destroy(recv_cnx); 599 599 if (*cer) { 600 fd_msg_log(FD_MSG_LOG_DROPPED, *cer, "An error occurred while rejecting a CER."); 600 601 fd_msg_free(*cer); 601 602 *cer = NULL; … … 665 666 if (req || (peer->p_hdr.info.runtime.pir_state != STATE_WAITCEA)) { 666 667 if (*msg) { 667 fd_log_debug("Received CER/CEA message while in state '%s', discarded.\n", STATE_STR(peer->p_hdr.info.runtime.pir_state)); 668 fd_msg_dump_walk(NONE, *msg); 668 fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Received CER/CEA while in '%s' state.\n", STATE_STR(peer->p_hdr.info.runtime.pir_state)); 669 669 CHECK_FCT_DO( fd_msg_free(*msg), /* continue */); 670 670 *msg = NULL; … … 911 911 cleanup: 912 912 if (msg) { 913 fd_msg_log(FD_MSG_LOG_DROPPED, msg, "An error occurred while processing a CER."); 913 914 fd_msg_free(msg); 914 915 } -
libfdcore/p_out.c
r662 r688 60 60 } 61 61 62 /* Log the message */63 if (TRACE_BOOL(FULL)) {64 CHECK_FCT_DO( fd_msg_update_length(*msg), /* continue */ );65 TRACE_DEBUG(FULL, "Sending the following message on connection '%s':", fd_cnx_getid(cnx));66 fd_msg_dump_walk(FULL, *msg);67 }68 69 62 /* Create the message buffer */ 70 63 CHECK_FCT(fd_msg_bufferize( *msg, &buf, &sz )); 71 64 pthread_cleanup_push( free, buf ); 65 66 /* Log the message */ 67 fd_msg_log( FD_MSG_LOG_SENT, *msg, "Sent to '%s'", fd_cnx_getid(cnx)); 72 68 73 69 /* Save a request before sending so that there is no race condition with the answer */ … … 93 89 struct msg *msg = arg; 94 90 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &msg), 95 CHECK_FCT_DO(fd_msg_free(msg), /* What can we do more? */)); 91 { 92 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "An error occurred while attempting to requeue this message during cancellation of the sending function"); 93 CHECK_FCT_DO(fd_msg_free(msg), /* What can we do more? */); 94 } ); 96 95 } 97 96 … … 112 111 while (1) { 113 112 struct msg * msg; 113 int ret; 114 114 115 115 /* Retrieve next message to send */ … … 120 120 121 121 /* Send the message, log any error */ 122 CHECK_FCT_DO( do_send(&msg, 0, peer->p_cnxctx, &peer->p_hbh, &peer->p_sr),122 CHECK_FCT_DO( ret = do_send(&msg, 0, peer->p_cnxctx, &peer->p_hbh, &peer->p_sr), 123 123 { 124 124 if (msg) { 125 fd_log_debug("An error occurred while sending this message, it was lost:\n"); 126 fd_msg_dump_walk(NONE, msg); 125 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: Problem while sending (%s)\n", strerror(ret) ); 127 126 fd_msg_free(msg); 128 127 } … … 151 150 152 151 } else { 152 int ret; 153 153 uint32_t *hbh = NULL; 154 154 … … 161 161 162 162 /* Do send the message */ 163 CHECK_FCT_DO( do_send(msg, flags, cnx, hbh, peer ? &peer->p_sr : NULL),163 CHECK_FCT_DO( ret = do_send(msg, flags, cnx, hbh, peer ? &peer->p_sr : NULL), 164 164 { 165 165 if (msg) { 166 fd_log_debug("An error occurred while sending this message, it was lost:\n"); 167 fd_msg_dump_walk(NONE, *msg); 166 fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: Problem while sending (%s)\n", strerror(ret) ); 168 167 fd_msg_free(*msg); 169 168 *msg = NULL; -
libfdcore/p_psm.c
r662 r688 166 166 case FDEVP_CNX_INCOMING: { 167 167 struct cnx_incoming * evd = ev->data; 168 fd_msg_log( FD_MSG_LOG_DROPPED, evd->cer, "Message discarded while cleaning peer state machine queue." ); 168 169 CHECK_FCT_DO( fd_msg_free(evd->cer), /* continue */); 169 170 fd_cnx_destroy(evd->cnx); … … 394 395 } ); 395 396 396 TRACE_DEBUG(FULL, "Received a message (%zdb) from '%s'", ev_sz, peer->p_hdr.info.pi_diamid); 397 if (TRACE_BOOL(FULL+1)) { 398 CHECK_FCT_DO( fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ), ); 399 fd_msg_dump_walk(FULL, msg); 400 } else { 401 fd_msg_dump_one(FULL, msg); 402 } 397 /* Log incoming message */ 398 fd_msg_log( FD_MSG_LOG_RECEIVED, msg, "Received %zdb from '%s'", ev_sz, peer->p_hdr.info.pi_diamid ); 403 399 404 400 /* Extract the header */ … … 411 407 CHECK_FCT_DO( fd_p_sr_fetch(&peer->p_sr, hdr->msg_hbhid, &req), goto psm_end ); 412 408 if (req == NULL) { 413 fd_log_debug("Received a Diameter answer message with no corresponding sent request, discarding.\n"); 414 fd_msg_dump_walk(NONE, msg); 409 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Answer received with no corresponding sent request." ); 415 410 fd_msg_free(msg); 416 411 goto psm_loop; … … 453 448 default: 454 449 /* In such case, just discard the message */ 455 fd_log_debug("Received a routable message while not in OPEN state from peer '%s', discarded.\n", peer->p_hdr.info.pi_diamid); 456 fd_msg_dump_walk(NONE, msg); 450 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received from peer '%s' while connection was not in OPEN state.", peer->p_hdr.info.pi_diamid ); 457 451 fd_msg_free(msg); 458 452 } … … 468 462 if (msg) { 469 463 /* Send the error back to the peer */ 470 CHECK_FCT_DO( fd_out_send(&msg, NULL, peer, FD_CNX_ORDERED), /* In case of error the message has already been dumped */);464 CHECK_FCT_DO( ret = fd_out_send(&msg, NULL, peer, FD_CNX_ORDERED), ); 471 465 if (msg) { 466 /* Only if an error occurred & the message was not saved / dumped */ 467 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: Problem while sending (%s)\n", strerror(ret) ); 472 468 CHECK_FCT_DO( fd_msg_free(msg), goto psm_end); 473 469 } … … 498 494 default: 499 495 /* Unknown / unexpected / invalid message */ 500 fd_log_debug("Received an unknown local message from peer '%s', discarded.\n", peer->p_hdr.info.pi_diamid); 501 fd_msg_dump_walk(NONE, msg); 496 TRACE_DEBUG(INFO, "Invalid non-routable command received: %u.", hdr->msg_code); 502 497 if (hdr->msg_flags & CMD_FLAG_REQUEST) { 503 498 do { … … 518 513 /* Cleanup the message if not done */ 519 514 if (msg) { 515 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received un-handled non-routable command from peer '%s'.", peer->p_hdr.info.pi_diamid ); 520 516 CHECK_FCT_DO( fd_msg_free(msg), /* continue */); 521 517 msg = NULL; … … 525 521 /* At this point the message must have been fully handled already */ 526 522 if (msg) { 527 fd_log_debug("Internal error: unhandled message (discarded)!\n"); 528 fd_msg_dump_walk(NONE, msg); 523 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: unhandled message.", peer->p_hdr.info.pi_diamid ); 529 524 fd_msg_free(msg); 530 525 } … … 602 597 } 603 598 if (params->cer) { 599 fd_msg_log( FD_MSG_LOG_DROPPED, params->cer, "Internal error: this CER was not handled as expected." ); 604 600 CHECK_FCT_DO( fd_msg_free(params->cer), ); 605 601 params->cer = NULL; -
libfdcore/p_sr.c
r662 r688 109 109 /* If the callback did not dispose of the message, do it now */ 110 110 if (expired_req) { 111 fd_msg_log(FD_MSG_LOG_DROPPED, expired_req, "Expiration period completed without an answer, and the expiry callback did not dispose of the message."); 111 112 CHECK_FCT_DO( fd_msg_free(expired_req), /* ignore */ ); 112 113 } … … 296 297 if (fd_msg_is_routable(sr->req)) { 297 298 struct msg_hdr * hdr = NULL; 299 int ret; 298 300 299 301 /* Set the 'T' flag */ … … 303 305 304 306 /* Requeue for sending to another peer */ 305 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &sr->req), 306 CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */)); 307 CHECK_FCT_DO( ret = fd_fifo_post(fd_g_outgoing, &sr->req), 308 { 309 fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Internal error: error while requeuing during failover: %s", strerror(ret) ); 310 CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */) 311 }); 307 312 } else { 308 /* Just free the request... */ 313 /* Just free the request. */ 314 fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Local message discarded during failover" ); 309 315 CHECK_FCT_DO(fd_msg_free(sr->req), /* Ignore */); 310 316 } -
libfdcore/peers.c
r662 r688 211 211 while ( fd_fifo_tryget(peer->p_tosend, &m) == 0 ) { 212 212 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &m), 213 { 213 214 /* fallback: destroy the message */ 214 CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)); 215 fd_msg_log(FD_MSG_LOG_DROPPED, m, "Internal error: unable to requeue this message during failover process"); 216 CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */) 217 } ); 215 218 } 216 219 -
libfdcore/queues.c
r686 r688 74 74 75 75 /* We got one! */ 76 fd_log_debug("The following message is lost because the daemon is stopping:\n"); 77 fd_msg_dump_walk(NONE, msg); 76 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Message lost because framework is terminating." ); 78 77 fd_msg_free(msg); 79 78 } -
libfdcore/routing_dispatch.c
r686 r688 409 409 410 410 if (!peer) { 411 TRACE_DEBUG(INFO, "Unable to send error '%s' to deleted peer '%s' in reply to:", error_code, id); 412 fd_msg_dump_walk(INFO, *pmsg); 411 fd_msg_log(FD_MSG_LOG_DROPPED, *pmsg, "Unable to send error '%s' to deleted peer '%s' in reply to this message.", error_code, id); 413 412 fd_msg_free(*pmsg); 414 413 *pmsg = NULL; … … 467 466 } 468 467 if (*pmsg) { /* another error happen'd */ 469 TRACE_DEBUG(INFO, "An unexpected error occurred (%s), discarding a message:", strerror(ret)); 470 fd_msg_dump_walk(INFO, *pmsg); 468 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "An unexpected error occurred while parsing the message (%s)", strerror(ret)); 471 469 CHECK_FCT_DO( fd_msg_free(*pmsg), /* continue */); 472 470 *pmsg = NULL; … … 522 520 523 521 if (!is_req) { 524 TRACE_DEBUG(INFO, "Received an answer to a localy issued query, but no handler processed this answer!"); 525 fd_msg_dump_walk(INFO, *pmsg); 522 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: Answer received to locally issued request, but not handled by any handler."); 526 523 fd_msg_free(*pmsg); 527 524 *pmsg = NULL; … … 748 745 for ( li = (is_req ? rt_fwd_list.next : rt_fwd_list.prev) ; *pmsg && (li != &rt_fwd_list) ; li = (is_req ? li->next : li->prev) ) { 749 746 struct rt_hdl * rh = (struct rt_hdl *)li; 747 int ret; 750 748 751 749 if (is_req && (rh->dir > RT_FWD_ALL)) … … 756 754 /* Ok, call this cb */ 757 755 TRACE_DEBUG(ANNOYING, "Calling next FWD callback on %p : %p", *pmsg, rh->rt_fwd_cb); 758 CHECK_FCT_DO( (*rh->rt_fwd_cb)(rh->cbdata, pmsg),756 CHECK_FCT_DO( ret = (*rh->rt_fwd_cb)(rh->cbdata, pmsg), 759 757 { 760 TRACE_DEBUG(INFO, "A FWD routing callback returned an error, message discarded."); 761 fd_msg_dump_walk(INFO, *pmsg); 758 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: a FWD routing callback returned an error (%s)", strerror(ret)); 762 759 fd_msg_free(*pmsg); 763 760 *pmsg = NULL; … … 817 814 fd_cpu_flush_cache(); 818 815 if ((!peer) || (peer->p_hdr.info.runtime.pir_state != STATE_OPEN)) { 819 TRACE_DEBUG(INFO, "Unable to forward answer message to peer '%s', deleted or not in OPEN state.", qry_src); 820 fd_msg_dump_walk(INFO, *pmsg); 816 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Unable to forward answer to deleted / closed peer '%s'.", qry_src); 821 817 fd_msg_free(*pmsg); 822 818 *pmsg = NULL; … … 897 893 CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, *pmsg, candidates), 898 894 { 899 TRACE_DEBUG(INFO, "An OUT routing callback returned an error (%s) ! Message discarded.", strerror(ret)); 900 fd_msg_dump_walk(INFO, *pmsg); 895 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: an OUT routing callback returned an error (%s)", strerror(ret)); 901 896 fd_msg_free(*pmsg); 902 897 *pmsg = NULL; … … 947 942 /* If the message has not been sent, return an error */ 948 943 if (*pmsg) { 949 TRACE_DEBUG(INFO, "Could not send the following message, replying with UNABLE_TO_DELIVER"); 950 fd_msg_dump_walk(INFO, *pmsg); 944 fd_msg_log( FD_MSG_LOG_NODELIVER, *pmsg, "No suitable candidate to route the message to." ); 951 945 return_error( pmsg, "DIAMETER_UNABLE_TO_DELIVER", "No suitable candidate to route the message to", NULL); 952 946 } -
libfdcore/server.c
r686 r688 143 143 CHECK_FCT_DO( fd_msg_parse_rules( msg, fd_g_config->cnf_dict, NULL ), /* Parsing failed -- trace details ? */ goto cleanup ); 144 144 145 fd_msg_dump_walk(FULL, msg);146 147 145 /* Now check we received a CER */ 148 146 CHECK_FCT_DO( fd_msg_hdr ( msg, &hdr ), goto fatal_error ); … … 164 162 CHECK_POSIX_DO( pthread_mutex_unlock(&s->clients_mtx), goto fatal_error ); 165 163 164 /* Cleanup the parsed message if any */ 165 if (msg) { 166 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received invalid/unexpected message from connecting client '%s'", fd_cnx_getid(c->conn) ); 167 CHECK_FCT_DO( fd_msg_free(msg), /* continue */); 168 } 169 166 170 /* Destroy the connection object if present */ 167 171 if (c->conn) … … 170 174 /* Cleanup the received buffer if any */ 171 175 free(buf); 172 173 /* Cleanup the parsed message if any */174 if (msg) {175 CHECK_FCT_DO( fd_msg_free(msg), /* continue */);176 }177 176 178 177 /* Detach the thread, cleanup the client structure */ -
libfdproto/messages.c
r687 r688 793 793 794 794 /* Dump a message to a specified file stream */ 795 staticvoid fd_msg_dump_fstr ( struct msg * msg, FILE * fstr )795 void fd_msg_dump_fstr ( struct msg * msg, FILE * fstr ) 796 796 { 797 797 msg_or_avp * ref = msg; … … 2263 2263 *action = DISP_ACT_ERROR; 2264 2264 } else { 2265 TRACE_DEBUG(INFO, "Received an answer to a local query with an unsupported application %d, discarding...", (*msg)->msg_public.msg_appl); 2266 fd_msg_dump_walk(INFO, *msg); 2265 fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: Received this answer to a local query with an unsupported application %d", (*msg)->msg_public.msg_appl); 2267 2266 fd_msg_free(*msg); 2268 2267 *msg = NULL; … … 2337 2336 pthread_mutex_t lock; 2338 2337 int init; 2338 struct dictionary *dict; 2339 2339 } ml_conf = { .lock = PTHREAD_MUTEX_INITIALIZER, .init = 0 }; 2340 2340 2341 static void ml_conf_init(void)2341 void ml_conf_init(struct dictionary *dict) 2342 2342 { 2343 2343 memset(&ml_conf.causes, 0, sizeof(ml_conf.causes)); 2344 2344 ml_conf.init = 1; 2345 ml_conf.dict = dict; 2345 2346 } 2346 2347 … … 2357 2358 CHECK_POSIX( pthread_mutex_lock(&ml_conf.lock) ); 2358 2359 if (!ml_conf.init) { 2359 ml_conf_init();2360 ASSERT(0); 2360 2361 } 2361 2362 … … 2406 2407 CHECK_POSIX_DO( pthread_mutex_lock(&ml_conf.lock), ); 2407 2408 if (!ml_conf.init) { 2408 ml_conf_init();2409 ASSERT(0); 2409 2410 } 2410 2411 meth = ml_conf.causes[cause].meth; … … 2420 2421 case FD_MSG_LOGTO_FILE: 2421 2422 TODO("Log to arg file"); 2423 TODO("Log a note to debug stream"); 2422 2424 break; 2423 2425 case FD_MSG_LOGTO_DIR: 2424 2426 TODO("Log to arg directory in a new file"); 2425 break; 2426 } 2427 2428 /* Then dump the prefix message to this stream */ 2427 TODO("Log a note to debug stream"); 2428 break; 2429 } 2430 2431 /* For file methods, let's parse the message so it looks better */ 2432 if ((meth != FD_MSG_LOGTO_DEBUGONLY) && ml_conf.dict) { 2433 CHECK_FCT_DO( fd_msg_parse_dict( msg, ml_conf.dict, NULL ), ); 2434 } 2435 2436 /* Then dump the prefix message to this stream, & to debug stream */ 2429 2437 (void)pthread_mutex_lock(&fd_log_lock); 2430 2438 pthread_cleanup_push(fd_cleanup_mutex_silent, &fd_log_lock); -
tests/testcnx.c
r662 r688 642 642 CHECK( 0, fd_msg_avp_add( cer, MSG_BRW_LAST_CHILD, oh) ); 643 643 644 #if 1644 #if 0 645 645 /* For debug: dump the object */ 646 646 fd_log_debug("Dumping CER\n");
Note: See TracChangeset
for help on using the changeset viewer.