More error printing to backup resuming code.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 6 Oct 2002 10:45:48 +0000 (10:45 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 6 Oct 2002 10:45:48 +0000 (10:45 +0000)
Do not switch to become primary on backup if packet decryption
error occurred.

CHANGES
TODO
TODO-1.0
apps/silcd/server.c
apps/silcd/server_backup.c
apps/silcd/server_internal.h
lib/silccrypt/none.c
lib/silcske/silcske.c

diff --git a/CHANGES b/CHANGES
index 724c73b6ff53f18e00e6cad5093ae52cd4c1e084..200ec63b62b09884d1d113a09f46ce731d826d9d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Sun Oct  6 13:20:04 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * If packet processing fails (like integrity check fails)
diff --git a/TODO b/TODO
index 165c657f5a26e21d3d4e35bd7d307de4958dcf66..a978578f1512371e3bcdf955f06419b445c51f82 100644 (file)
--- 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 <Requested Attributes> in WHOIS.  Sending and
    reception, with clients and servers should be added.
 
index 731ab4b9a3d9475d4e62628316eb01928f2edc8f..7e37bd927ba491c73b342d530e4d70234e58dff3 100644 (file)
--- 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).
index d711caf35bea58c1c49ca6dd1cd1d4e8f5244b3c..4ac168f004c8bb514db393d2a775aae10e4f3a7e 100644 (file)
@@ -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);
index 196ab565c3324d3acb19e93a2d132150d113e530..5d7ff35c4bc8ad39acefff0d384d857f334db50a 100644 (file)
@@ -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
index 64141a70ce58902254d8848040aa2ba976b519ee..e521db68fedfec1bb0d829b58cb716f3da73fa7c 100644 (file)
@@ -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 */
index 239be9106e4251a88f6d68c77c8e83e5ac1f0653..ea6e6484e5fc5c0127b15b7825d820f2d71fa66f 100644 (file)
   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"
index 5e277b838b142c7008c51397d677e2cd52f6c8d0..c423b27cb6fd3976d1ca724a55aa6319896dd18c 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  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