From: Pekka Riikonen Date: Sun, 6 Oct 2002 10:45:48 +0000 (+0000) Subject: More error printing to backup resuming code. X-Git-Tag: silc.client.0.9.6~63 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=e1459c7b692417464cf23b820ab74c98b0c36f25 More error printing to backup resuming code. Do not switch to become primary on backup if packet decryption error occurred. --- diff --git a/CHANGES b/CHANGES index 724c73b6..200ec63b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Sun Oct 6 13:20:04 EEST 2002 Pekka Riikonen + + * Don't swtich to become primary router if we are backup if + decryption error has occurred. Affected file silcd/server.c. + Thu Sep 26 13:51:02 CEST 2002 Pekka Riikonen * If packet processing fails (like integrity check fails) diff --git a/TODO b/TODO index 165c657f..a978578f 100644 --- a/TODO +++ b/TODO @@ -30,6 +30,12 @@ TODO/bugs In SILC Client Library TODO/bugs In SILC Server ======================== + o Still ghost clients in server signoff from server having secondary + interface. + + o Normal server doesn't reconnect to backup router if connection was + lost. + o Add support for the in WHOIS. Sending and reception, with clients and servers should be added. diff --git a/TODO-1.0 b/TODO-1.0 index 731ab4b9..7e37bd92 100644 --- a/TODO-1.0 +++ b/TODO-1.0 @@ -116,6 +116,8 @@ least could be done. SIGNOFF of notify at all (using SIGNOFF takes the idea about SERVER_SIGNOFF away entirely). + o See also ~/silcserver + o Add SilcAsyncOperation to utility library. Any function that takes callback as an argument must/should return SilcAsyncOperation (see ~/silcasync). diff --git a/apps/silcd/server.c b/apps/silcd/server.c index d711caf3..4ac168f0 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -2235,6 +2235,12 @@ SILC_TASK_CALLBACK(silc_server_packet_process) /* If processing failed the connection is closed. */ if (!ret) { + /* On packet processing errors we may close our primary router + connection but won't become primary router if we are the backup + since this is local error condition. */ + if (SILC_PRIMARY_ROUTE(server) == sock && server->backup_router) + server->backup_noswitch = TRUE; + if (sock->user_data) silc_server_free_sock_user_data(server, sock, NULL); silc_server_close_connection(server, sock); @@ -2340,6 +2346,7 @@ bool silc_server_packet_parse(SilcPacketParserContext *parser_context, SilcServer server = (SilcServer)context; SilcSocketConnection sock = parser_context->sock; SilcIDListData idata = (SilcIDListData)sock->user_data; + bool ret; if (idata) idata->psn_receive = parser_context->packet->sequence + 1; @@ -2360,14 +2367,29 @@ bool silc_server_packet_parse(SilcPacketParserContext *parser_context, the idata->receive_key might have become valid in the last packet and we want to call this processor with valid cipher. */ if (idata) - silc_packet_receive_process(sock, server->server_type == SILC_ROUTER ? + ret = silc_packet_receive_process( + sock, server->server_type == SILC_ROUTER ? TRUE : FALSE, idata->receive_key, idata->hmac_receive, idata->psn_receive, silc_server_packet_parse, server); else - silc_packet_receive_process(sock, server->server_type == SILC_ROUTER ? + ret = silc_packet_receive_process( + sock, server->server_type == SILC_ROUTER ? TRUE : FALSE, NULL, NULL, 0, silc_server_packet_parse, server); + + if (!ret) { + /* On packet processing errors we may close our primary router + connection but won't become primary router if we are the backup + since this is local error condition. */ + if (SILC_PRIMARY_ROUTE(server) == sock && server->backup_router) + server->backup_noswitch = TRUE; + + if (sock->user_data) + silc_server_free_sock_user_data(server, sock, NULL); + silc_server_close_connection(server, sock); + } + return FALSE; } @@ -3077,7 +3099,7 @@ void silc_server_free_sock_user_data(SilcServer server, sock->type != SILC_SOCKET_TYPE_ROUTER) backup_router = NULL; - if (server->server_shutdown) + if (server->server_shutdown || server->backup_noswitch) backup_router = NULL; /* If this was our primary router connection then we're lost to @@ -3202,6 +3224,7 @@ void silc_server_free_sock_user_data(SilcServer server, server->server_name, server->router->server_name)); } + server->backup_noswitch = FALSE; /* Free the server entry */ silc_server_backup_del(server, user_data); diff --git a/apps/silcd/server_backup.c b/apps/silcd/server_backup.c index 196ab565..5d7ff35c 100644 --- a/apps/silcd/server_backup.c +++ b/apps/silcd/server_backup.c @@ -444,7 +444,7 @@ void silc_server_backup_resume_router(SilcServer server, SILC_STR_UI_CHAR(&session), SILC_STR_END); if (ret < 0) { - SILC_LOG_DEBUG(("Malformed packet received")); + SILC_LOG_ERROR(("Malformed resume router packet received")); return; } @@ -492,7 +492,7 @@ void silc_server_backup_resume_router(SilcServer server, return; } - SILC_LOG_DEBUG(("Bad resume router packet")); + SILC_LOG_ERROR(("Bad resume router packet RESUMED %d", type)); return; } @@ -528,6 +528,7 @@ void silc_server_backup_resume_router(SilcServer server, proto_ctx->start = time(0); SILC_LOG_DEBUG(("Starting backup resuming protocol as responder")); + SILC_LOG_INFO(("Starting backup resuming protocol")); /* Run the backup resuming protocol */ silc_protocol_alloc(SILC_PROTOCOL_SERVER_BACKUP, @@ -577,6 +578,8 @@ void silc_server_backup_reconnect(SilcServer server, { SilcServerConnection sconn; + SILC_LOG_INFO(("Attempting to reconnect to primary router")); + sconn = silc_calloc(1, sizeof(*sconn)); sconn->remote_host = strdup(ip); sconn->remote_port = port; @@ -600,6 +603,7 @@ SILC_TASK_CALLBACK(silc_server_backup_connected_later) SilcSocketConnection sock = proto_ctx->sock; SILC_LOG_DEBUG(("Starting backup resuming protocol as initiator")); + SILC_LOG_INFO(("Starting backup resuming protocol")); /* Run the backup resuming protocol */ silc_protocol_alloc(SILC_PROTOCOL_SERVER_BACKUP, @@ -869,7 +873,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup) /* We should have received START or START_GLOBAL packet */ if (ctx->type != SILC_SERVER_BACKUP_START && ctx->type != SILC_SERVER_BACKUP_START_GLOBAL) { - SILC_LOG_DEBUG(("Bad resume router packet")); + SILC_LOG_ERROR(("Bad resume router packet START %d", ctx->type)); break; } @@ -923,7 +927,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup) /* We should have received CONNECTED packet */ if (ctx->type != SILC_SERVER_BACKUP_CONNECTED) { - SILC_LOG_DEBUG(("Bad resume router packet")); + SILC_LOG_ERROR(("Bad resume router packet CONNECTED %d", ctx->type)); break; } @@ -955,7 +959,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup) /* We should have been received ENDING packet */ if (ctx->type != SILC_SERVER_BACKUP_ENDING) { - SILC_LOG_DEBUG(("Bad resume router packet")); + SILC_LOG_ERROR(("Bad resume router packet ENDING %d", ctx->type)); break; } @@ -1084,7 +1088,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup) router. */ if (ctx->type != SILC_SERVER_BACKUP_RESUMED && ctx->type != SILC_SERVER_BACKUP_RESUMED_GLOBAL) { - SILC_LOG_DEBUG(("Bad resume router packet")); + SILC_LOG_ERROR(("Bad resume router packet RESUMED %d", ctx->type)); break; } @@ -1157,6 +1161,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup) case SILC_PROTOCOL_STATE_FAILURE: /* Protocol has ended, call the final callback */ + SILC_LOG_ERROR(("Error during backup resume: received Failure")); if (protocol->final_callback) silc_protocol_execute_final(protocol, server->schedule); else diff --git a/apps/silcd/server_internal.h b/apps/silcd/server_internal.h index 64141a70..e521db68 100644 --- a/apps/silcd/server_internal.h +++ b/apps/silcd/server_internal.h @@ -85,6 +85,8 @@ struct SilcServerStruct { unsigned int backup_router : 1; /* Set if this is backup router */ unsigned int backup_primary : 1; /* Set if we've switched our primary router to a backup router. */ + unsigned int backup_noswitch: 1; /* Set if we've won't switch to + become primary (we are backup) */ unsigned int wait_backup : 1; /* Set if we are waiting for backup router to connect to us. */ unsigned int server_shutdown: 1; /* Set when shutting down */ diff --git a/lib/silccrypt/none.c b/lib/silccrypt/none.c index 239be910..ea6e6484 100644 --- a/lib/silccrypt/none.c +++ b/lib/silccrypt/none.c @@ -17,14 +17,6 @@ GNU General Public License for more details. */ -/* - * $Id$ - * $Log$ - * Revision 1.1 2000/06/27 11:36:55 priikone - * Initial revision - * - * - */ #include "silcincludes.h" #include "none.h" diff --git a/lib/silcske/silcske.c b/lib/silcske/silcske.c index 5e277b83..c423b27c 100644 --- a/lib/silcske/silcske.c +++ b/lib/silcske/silcske.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2002 - 2002 Pekka Riikonen + Copyright (C) 2000 - 2002 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by