Cleaned up some SILC_LOG_DEBUG's in backup protocol code.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 24 Jun 2002 21:20:55 +0000 (21:20 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 24 Jun 2002 21:20:55 +0000 (21:20 +0000)
CHANGES
TODO
apps/silcd/server.c
apps/silcd/server_backup.c
apps/silcd/server_util.c
apps/silcd/silcd.c
doc/examples/cell_router.conf [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index b7f4ad81f237c33b7a9f244eaa148dc29da25be8..d0b13bfa43e3b3f349b10058aa6e7ba5bc8b2344 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,8 @@ Mon Jun 24 17:47:52 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
          closing server and router connections.  Affected file
          silcd/server.c.
 
          closing server and router connections.  Affected file
          silcd/server.c.
 
+       * Rewrote some SILC_LOG_DEBUG's in silcd/server_backup.c.
+
 Sun Jun 23 17:32:31 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
 
        * Don't do SILC_STRING_LANGUAGE encoding if the outbuffer
 Sun Jun 23 17:32:31 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
 
        * Don't do SILC_STRING_LANGUAGE encoding if the outbuffer
diff --git a/TODO b/TODO
index 0c4fa20d5d9ddbeedc082c72c29a655c106685d9..48ae543a37173dd784f48d814de01fe62fcff640 100644 (file)
--- a/TODO
+++ b/TODO
@@ -35,8 +35,6 @@ TODO/bugs In SILC Server
          cell use it.  When primary goes down, also those that are
          not using it (are not connected locally) are signoffed.
 
          cell use it.  When primary goes down, also those that are
          not using it (are not connected locally) are signoffed.
 
-       o Rewrite SILC_LOG_DEBUG's in silcd/server_backup.c.
-
        o Testing
 
  o Add a timeout to handling incoming JOIN commands.  It should be 
        o Testing
 
  o Add a timeout to handling incoming JOIN commands.  It should be 
index 0a8921c382f1a7698a5d3df86a1572f471128037..15c1263c6e1bc3b22a0588fa1d503cc3e9485646 100644 (file)
@@ -2887,21 +2887,15 @@ void silc_server_free_sock_user_data(SilcServer server,
          server->standalone = TRUE;
          backup_router = NULL;
        } else {
          server->standalone = TRUE;
          backup_router = NULL;
        } else {
-         if (server->id_entry == backup_router) {
-           SILC_LOG_INFO(("We are now new router in this cell"));
-           SILC_LOG_DEBUG(("We are now new router in this cell"));
-         } else {
+         if (server->id_entry != backup_router) {
            SILC_LOG_INFO(("New primary router is backup router %s",
                           backup_router->server_name));
            SILC_LOG_INFO(("New primary router is backup router %s",
                           backup_router->server_name));
-           SILC_LOG_DEBUG(("New primary router is backup router %s",
-                           backup_router->server_name));
-         }
-         if (server->id_entry != backup_router) {
            server->id_entry->router = backup_router;
            server->router = backup_router;
            server->router_connect = time(0);
            server->backup_primary = TRUE;
          } else {
            server->id_entry->router = backup_router;
            server->router = backup_router;
            server->router_connect = time(0);
            server->backup_primary = TRUE;
          } else {
+           SILC_LOG_INFO(("We are now new router in this cell"));
            server->id_entry->router = NULL;
            server->router = NULL;
            server->standalone = TRUE;
            server->id_entry->router = NULL;
            server->router = NULL;
            server->standalone = TRUE;
index 4c262c7bdab72f0e8a0fcefd9db8b53745a3030f..1383e6ceb201dc2e78409ed015965a1cb0e0236a 100644 (file)
@@ -76,13 +76,18 @@ void silc_server_backup_add(SilcServer server, SilcServerEntry backup_server,
 {
   int i;
 
 {
   int i;
 
-  SILC_LOG_DEBUG(("Start"));
-
   if (!ip)
     return;
 
   if (!ip)
     return;
 
-  if (!server->backup)
+  if (!server->backup) {
     server->backup = silc_calloc(1, sizeof(*server->backup));
     server->backup = silc_calloc(1, sizeof(*server->backup));
+    if (!server->backup)
+      return;
+  }
+
+  SILC_LOG_DEBUG(("Backup router %s will replace %s",
+                 ((SilcSocketConnection)backup_server->connection)->ip,
+                 ip, port));
 
   for (i = 0; i < server->backup->servers_count; i++) {
     if (!server->backup->servers[i].server) {
 
   for (i = 0; i < server->backup->servers_count; i++) {
     if (!server->backup->servers[i].server) {
@@ -92,7 +97,6 @@ void silc_server_backup_add(SilcServer server, SilcServerEntry backup_server,
             sizeof(server->backup->servers[i].ip.data));
       silc_net_addr2bin(ip, server->backup->servers[i].ip.data,
                        sizeof(server->backup->servers[i].ip.data));
             sizeof(server->backup->servers[i].ip.data));
       silc_net_addr2bin(ip, server->backup->servers[i].ip.data,
                        sizeof(server->backup->servers[i].ip.data));
-      //server->backup->servers[i].port = port;
       return;
     }
   }
       return;
     }
   }
@@ -107,7 +111,6 @@ void silc_server_backup_add(SilcServer server, SilcServerEntry backup_server,
         sizeof(server->backup->servers[i].ip.data));
   silc_net_addr2bin(ip, server->backup->servers[i].ip.data,
                    sizeof(server->backup->servers[i].ip.data));
         sizeof(server->backup->servers[i].ip.data));
   silc_net_addr2bin(ip, server->backup->servers[i].ip.data,
                    sizeof(server->backup->servers[i].ip.data));
-  //server->backup->servers[i].port = server_id->port;
   server->backup->servers_count++;
 }
 
   server->backup->servers_count++;
 }
 
@@ -119,16 +122,18 @@ SilcServerEntry silc_server_backup_get(SilcServer server,
 {
   int i;
 
 {
   int i;
 
-  SILC_LOG_DEBUG(("Start"));
-
   if (!server->backup)
     return NULL;
 
   for (i = 0; i < server->backup->servers_count; i++) {
     if (server->backup->servers[i].server &&
        !memcmp(&server->backup->servers[i].ip, &server_id->ip.data,
   if (!server->backup)
     return NULL;
 
   for (i = 0; i < server->backup->servers_count; i++) {
     if (server->backup->servers[i].server &&
        !memcmp(&server->backup->servers[i].ip, &server_id->ip.data,
-               sizeof(server_id->ip.data)))
+               sizeof(server_id->ip.data))) {
+      SILC_LOG_DEBUG(("Found backup router %s for %s",
+                     server->backup->servers[i].server->server_name,
+                     silc_id_render(server_id, SILC_ID_SERVER)));
       return server->backup->servers[i].server;
       return server->backup->servers[i].server;
+    }
   }
 
   return NULL;
   }
 
   return NULL;
@@ -146,8 +151,8 @@ void silc_server_backup_del(SilcServer server, SilcServerEntry server_entry)
   for (i = 0; i < server->backup->servers_count; i++) {
     if (server->backup->servers[i].server == server_entry) {
       SILC_LOG_DEBUG(("Removing %s as backup router",
   for (i = 0; i < server->backup->servers_count; i++) {
     if (server->backup->servers[i].server == server_entry) {
       SILC_LOG_DEBUG(("Removing %s as backup router",
-                     server_entry->server_name ? server_entry->server_name :
-                     ""));
+                     silc_id_render(server->backup->servers[i].server->id,
+                                    SILC_ID_SERVER)));
       server->backup->servers[i].server = NULL;
       memset(server->backup->servers[i].ip.data, 0,
             sizeof(server->backup->servers[i].ip.data));
       server->backup->servers[i].server = NULL;
       memset(server->backup->servers[i].ip.data, 0,
             sizeof(server->backup->servers[i].ip.data));
@@ -167,8 +172,6 @@ void silc_server_backup_replaced_add(SilcServer server,
   int i;
   SilcServerBackupReplaced *r = silc_calloc(1, sizeof(*r));;
 
   int i;
   SilcServerBackupReplaced *r = silc_calloc(1, sizeof(*r));;
 
-  SILC_LOG_DEBUG(("Start"));
-
   if (!server->backup)
     server->backup = silc_calloc(1, sizeof(*server->backup));
   if (!server->backup->replaced) {
   if (!server->backup)
     server->backup = silc_calloc(1, sizeof(*server->backup));
   if (!server->backup->replaced) {
@@ -177,11 +180,11 @@ void silc_server_backup_replaced_add(SilcServer server,
     server->backup->replaced_count = 1;
   }
 
     server->backup->replaced_count = 1;
   }
 
-  SILC_LOG_DEBUG(("********************************"));
-  SILC_LOG_DEBUG(("Replaced added"));
+  SILC_LOG_DEBUG(("Replacing router %s with %s backup",
+                 silc_id_render(server_id, SILC_ID_SERVER),
+                 server_entry->server_name));
 
   memcpy(&r->ip, &server_id->ip, sizeof(server_id->ip));
 
   memcpy(&r->ip, &server_id->ip, sizeof(server_id->ip));
-  //r->port = server_id->port;
   r->server = server_entry;
 
   for (i = 0; i < server->backup->replaced_count; i++) {
   r->server = server_entry;
 
   for (i = 0; i < server->backup->replaced_count; i++) {
@@ -210,29 +213,25 @@ bool silc_server_backup_replaced_get(SilcServer server,
 {
   int i;
 
 {
   int i;
 
-  SILC_LOG_DEBUG(("Start"));
-
-  SILC_LOG_DEBUG(("*************************************"));
-
   if (!server->backup || !server->backup->replaced)
     return FALSE;
 
   for (i = 0; i < server->backup->replaced_count; i++) {
     if (!server->backup->replaced[i])
       continue;
   if (!server->backup || !server->backup->replaced)
     return FALSE;
 
   for (i = 0; i < server->backup->replaced_count; i++) {
     if (!server->backup->replaced[i])
       continue;
-    SILC_LOG_HEXDUMP(("IP"), server_id->ip.data, server_id->ip.data_len);
-    SILC_LOG_HEXDUMP(("IP"), server->backup->replaced[i]->ip.data, 
-                    server->backup->replaced[i]->ip.data_len);
     if (!memcmp(&server->backup->replaced[i]->ip, &server_id->ip.data,
                sizeof(server_id->ip.data))) {
       if (server_entry)
        *server_entry = server->backup->replaced[i]->server;
     if (!memcmp(&server->backup->replaced[i]->ip, &server_id->ip.data,
                sizeof(server_id->ip.data))) {
       if (server_entry)
        *server_entry = server->backup->replaced[i]->server;
-      SILC_LOG_DEBUG(("REPLACED"));
+      SILC_LOG_DEBUG(("Router %s is replaced by %s",
+                     silc_id_render(server_id, SILC_ID_SERVER),
+                     server->backup->replaced[i]->server->server_name));
       return TRUE;
     }
   }
 
       return TRUE;
     }
   }
 
-  SILC_LOG_DEBUG(("NOT REPLACED"));
+  SILC_LOG_DEBUG(("Router %s is not replaced by backup router",
+                 silc_id_render(server_id, SILC_ID_SERVER)));
   return FALSE;
 }
 
   return FALSE;
 }
 
@@ -243,8 +242,6 @@ void silc_server_backup_replaced_del(SilcServer server,
 {
   int i;
 
 {
   int i;
 
-  SILC_LOG_DEBUG(("Start"));
-
   if (!server->backup || !server->backup->replaced)
     return;
 
   if (!server->backup || !server->backup->replaced)
     return;
 
@@ -420,17 +417,19 @@ void silc_server_backup_resume_router(SilcServer server,
   int i, ret;
 
   if (sock->type == SILC_SOCKET_TYPE_CLIENT ||
   int i, ret;
 
   if (sock->type == SILC_SOCKET_TYPE_CLIENT ||
-      sock->type == SILC_SOCKET_TYPE_UNKNOWN)
+      sock->type == SILC_SOCKET_TYPE_UNKNOWN) {
+    SILC_LOG_DEBUG(("Bad packet received"));
     return;
     return;
-
-  SILC_LOG_DEBUG(("Start"));
+  }
 
   ret = silc_buffer_unformat(packet->buffer,
                             SILC_STR_UI_CHAR(&type),
                             SILC_STR_UI_CHAR(&session),
                             SILC_STR_END);
 
   ret = silc_buffer_unformat(packet->buffer,
                             SILC_STR_UI_CHAR(&type),
                             SILC_STR_UI_CHAR(&session),
                             SILC_STR_END);
-  if (ret < 0)
+  if (ret < 0) {
+    SILC_LOG_DEBUG(("Malformed packet received"));
     return;
     return;
+  }
   
   /* Activate the protocol for this socket if necessary */
   if ((type == SILC_SERVER_BACKUP_RESUMED || 
   
   /* Activate the protocol for this socket if necessary */
   if ((type == SILC_SERVER_BACKUP_RESUMED || 
@@ -462,9 +461,6 @@ void silc_server_backup_resume_router(SilcServer server,
     ctx = sock->protocol->context;
     ctx->type = type;
 
     ctx = sock->protocol->context;
     ctx->type = type;
 
-    SILC_LOG_DEBUG(("********************************"));
-    SILC_LOG_DEBUG(("Continuing protocol, type %d", type));
-
     if (type != SILC_SERVER_BACKUP_RESUMED &&
        type != SILC_SERVER_BACKUP_RESUMED_GLOBAL) {
       for (i = 0; i < ctx->sessions_count; i++) {
     if (type != SILC_SERVER_BACKUP_RESUMED &&
        type != SILC_SERVER_BACKUP_RESUMED_GLOBAL) {
       for (i = 0; i < ctx->sessions_count; i++) {
@@ -495,11 +491,8 @@ void silc_server_backup_resume_router(SilcServer server,
        mark our primary router connection disabled since we are not allowed
        to use it at this moment. */
     SilcIDListData idata = (SilcIDListData)sock->user_data;
        mark our primary router connection disabled since we are not allowed
        to use it at this moment. */
     SilcIDListData idata = (SilcIDListData)sock->user_data;
-
     SILC_LOG_INFO(("We are replaced by an backup router in this cell, will "
                   "wait until backup resuming protocol is executed"));
     SILC_LOG_INFO(("We are replaced by an backup router in this cell, will "
                   "wait until backup resuming protocol is executed"));
-
-    SILC_LOG_DEBUG(("We are replaced by an backup router in this cell"));
     idata->status |= SILC_IDLIST_STATUS_DISABLED;
     return;
   }
     idata->status |= SILC_IDLIST_STATUS_DISABLED;
     return;
   }
@@ -579,6 +572,9 @@ void silc_server_backup_reconnect(SilcServer server,
                         SILC_TASK_PRI_NORMAL);
 }
 
                         SILC_TASK_PRI_NORMAL);
 }
 
+/* Task that is called after backup router has connected back to
+   primary router and we are starting the resuming protocol */
+
 SILC_TASK_CALLBACK(silc_server_backup_connected_later)
 {
   SilcServerBackupProtocolContext proto_ctx = 
 SILC_TASK_CALLBACK(silc_server_backup_connected_later)
 {
   SilcServerBackupProtocolContext proto_ctx = 
@@ -637,10 +633,7 @@ static void silc_server_backup_connect_primary(SilcServer server,
     (SilcServerBackupProtocolContext)backup_router->protocol->context;
   SilcBuffer buffer;
 
     (SilcServerBackupProtocolContext)backup_router->protocol->context;
   SilcBuffer buffer;
 
-  SILC_LOG_DEBUG(("Start"));
-
-  SILC_LOG_DEBUG(("********************************"));
-  SILC_LOG_DEBUG(("Sending CONNECTED packet, session %d", ctx->session));
+  SILC_LOG_DEBUG(("Sending CONNECTED packet (session %d)", ctx->session));
 
   /* Send the CONNECTED packet back to the backup router. */
   buffer = silc_buffer_alloc(2);
 
   /* Send the CONNECTED packet back to the backup router. */
   buffer = silc_buffer_alloc(2);
@@ -695,60 +688,6 @@ SILC_TASK_CALLBACK(silc_server_backup_send_resumed)
   protocol->state = SILC_PROTOCOL_STATE_END;
 }
 
   protocol->state = SILC_PROTOCOL_STATE_END;
 }
 
-/* Resume protocol with RESUME_ROUTER packet: 
-
-   SILC_PACKET_RESUME_ROUTER:
-
-   <SilcUInt8 type> <SilcUInt8 Session ID>
-
-   <type>          = the protocol opcode
-   <Session ID>    = Identifier for this packet and any subsequent reply
-                     packets must include this identifier.
-
-   Types:
-
-     1    = To router: Comensing backup resuming protocol. This will
-            indicate that the sender is backup router acting as primary
-            and the receiver is primary router that has been replaced by
-           the backup router.
-
-           To server. Comensing backup resuming protocol. This will
-           indicate that the sender is backup router and the receiver
-           must reconnect to the real primary router of the cell.
-
-     2    = To Router: Comesning backup resuming protocol in another
-            cell.  The receiver will connect to its primary router 
-           (the router that is now online again) but will not use
-           the link.  If the receiver is not configured to connect
-           to any router it does as locally configured.  The sender
-           is always backup router.
-
-           To server: this is never sent to server.
-
-     3    = To backup router: Sender is normal server or router and it
-            tells to backup router that they have connected to the
-           primary router.  Backup router never sends this type.
-
-     4    = To router: Ending backup resuming protocol. This is sent
-            to the real primary router to tell that it can take over
-           the task as being primary router.
-
-           To server: same as sending for router.
-
-           Backup router sends this also to the primary route but only
-           after it has sent them to normal servers and has purged all
-           traffic coming from normal servers.
-
-     5    = To router: Sender is the real primary router after it has
-            received type 4 from backup router. To tell that it is again
-           primary router of the cell.
-
-     20   = To router: This is sent only when router is connecting to
-            another router and has been replaced by an backup router.
-           The sender knows that the connectee has been replaced.
-
- */
-
 /* Backup resuming protocol. This protocol is executed when the primary
    router wants to resume its position as being primary router. */
 
 /* Backup resuming protocol. This protocol is executed when the primary
    router wants to resume its position as being primary router. */
 
@@ -763,13 +702,9 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
   SilcServerEntry server_entry;
   int i;
 
   SilcServerEntry server_entry;
   int i;
 
-  SILC_LOG_DEBUG(("Start"));
-
   if (protocol->state == SILC_PROTOCOL_STATE_UNKNOWN)
     protocol->state = SILC_PROTOCOL_STATE_START;
 
   if (protocol->state == SILC_PROTOCOL_STATE_UNKNOWN)
     protocol->state = SILC_PROTOCOL_STATE_START;
 
-  SILC_LOG_DEBUG(("State=%d", protocol->state));
-
   switch(protocol->state) {
   case SILC_PROTOCOL_STATE_START:
     if (ctx->responder == FALSE) {
   switch(protocol->state) {
   case SILC_PROTOCOL_STATE_START:
     if (ctx->responder == FALSE) {
@@ -778,9 +713,6 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
       packet = silc_buffer_alloc(2);
       silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
 
       packet = silc_buffer_alloc(2);
       silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
 
-      SILC_LOG_DEBUG(("********************************"));
-      SILC_LOG_DEBUG(("Sending START packets"));
-
       /* Send the START packet to primary router and normal servers. */
       if (silc_idcache_get_all(server->local_list->servers, &list)) {
        if (silc_idcache_list_first(list, &id_cache)) {
       /* Send the START packet to primary router and normal servers. */
       if (silc_idcache_get_all(server->local_list->servers, &list)) {
        if (silc_idcache_list_first(list, &id_cache)) {
@@ -802,9 +734,8 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
            ctx->sessions[ctx->sessions_count].connected = FALSE;
            ctx->sessions[ctx->sessions_count].server_entry = server_entry;
 
            ctx->sessions[ctx->sessions_count].connected = FALSE;
            ctx->sessions[ctx->sessions_count].server_entry = server_entry;
 
-           SILC_LOG_DEBUG(("********************************"));
-           SILC_LOG_DEBUG(("START (local) for session %d", 
-                           ctx->sessions_count));
+           SILC_LOG_DEBUG(("Sending START to %s (session %d)", 
+                           server_entry->server_name, ctx->sessions_count));
 
            /* This connection is performing this protocol too now */
            ((SilcSocketConnection)server_entry->connection)->protocol =
 
            /* This connection is performing this protocol too now */
            ((SilcSocketConnection)server_entry->connection)->protocol =
@@ -848,9 +779,8 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
            ctx->sessions[ctx->sessions_count].connected = FALSE;
            ctx->sessions[ctx->sessions_count].server_entry = server_entry;
 
            ctx->sessions[ctx->sessions_count].connected = FALSE;
            ctx->sessions[ctx->sessions_count].server_entry = server_entry;
 
-           SILC_LOG_DEBUG(("********************************"));
-           SILC_LOG_DEBUG(("START (global) for session %d", 
-                           ctx->sessions_count));
+           SILC_LOG_DEBUG(("Sending START to %s (session %d)", 
+                           server_entry->server_name, ctx->sessions_count));
 
            /* This connection is performing this protocol too now */
            ((SilcSocketConnection)server_entry->connection)->protocol =
 
            /* This connection is performing this protocol too now */
            ((SilcSocketConnection)server_entry->connection)->protocol =
@@ -893,24 +823,22 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
        break;
       }
 
        break;
       }
 
-      SILC_LOG_DEBUG(("********************************"));
-      SILC_LOG_DEBUG(("Received START packet, reconnecting to router"));
-
       /* Connect to the primary router that was down that is now supposed
         to be back online. We send the CONNECTED packet after we've
         established the connection to the primary router. */
       primary = silc_server_config_get_primary_router(server);
       if (primary && server->backup_primary) {
       /* Connect to the primary router that was down that is now supposed
         to be back online. We send the CONNECTED packet after we've
         established the connection to the primary router. */
       primary = silc_server_config_get_primary_router(server);
       if (primary && server->backup_primary) {
+       SILC_LOG_DEBUG(("Received START (session %d), reconnect to router",
+                       ctx->session));
        silc_server_backup_reconnect(server,
                                     primary->host, primary->port,
                                     silc_server_backup_connect_primary,
                                     ctx->sock);
       } else {
        /* Nowhere to connect just return the CONNECTED packet */
        silc_server_backup_reconnect(server,
                                     primary->host, primary->port,
                                     silc_server_backup_connect_primary,
                                     ctx->sock);
       } else {
        /* Nowhere to connect just return the CONNECTED packet */
+       SILC_LOG_DEBUG(("Received START (session %d), send CONNECTED back",
+                       ctx->session));
 
 
-       SILC_LOG_DEBUG(("********************************"));
-       SILC_LOG_DEBUG(("Sending CONNECTED packet, session %d", ctx->session));
-       
        /* Send the CONNECTED packet back to the backup router. */
        packet = silc_buffer_alloc(2);
        silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
        /* Send the CONNECTED packet back to the backup router. */
        packet = silc_buffer_alloc(2);
        silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
@@ -949,8 +877,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
        break;
       }
 
        break;
       }
 
-      SILC_LOG_DEBUG(("********************************"));
-      SILC_LOG_DEBUG(("Received CONNECTED packet, session %d", ctx->session));
+      SILC_LOG_DEBUG(("Received CONNECTED (session %d)", ctx->session));
 
       for (i = 0; i < ctx->sessions_count; i++) {
        if (ctx->sessions[i].session == ctx->session) {
 
       for (i = 0; i < ctx->sessions_count; i++) {
        if (ctx->sessions[i].session == ctx->session) {
@@ -964,8 +891,8 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
          return;
       }
 
          return;
       }
 
-      SILC_LOG_DEBUG(("********************************"));
-      SILC_LOG_DEBUG(("Sending ENDING packet to primary"));
+      SILC_LOG_DEBUG(("All sessions has returned CONNECTED packets"));
+      SILC_LOG_DEBUG(("Sending ENDING packet to primary router"));
 
       /* Send with a timeout */
       silc_schedule_task_add(server->schedule, 0, 
 
       /* Send with a timeout */
       silc_schedule_task_add(server->schedule, 0, 
@@ -982,8 +909,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
        break;
       }
 
        break;
       }
 
-      SILC_LOG_DEBUG(("********************************"));
-      SILC_LOG_DEBUG(("Received ENDING packet, sending RESUMED packets"));
+      SILC_LOG_DEBUG(("Received ENDING packet, we are going to resume now"));
 
       /* This state is received by the primary router but also servers
         and perhaps other routers so check that if we are the primary
 
       /* This state is received by the primary router but also servers
         and perhaps other routers so check that if we are the primary
@@ -1024,8 +950,8 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
                continue;
            }
 
                continue;
            }
 
-           SILC_LOG_DEBUG(("********************************"));
-           SILC_LOG_DEBUG(("RESUMED packet (local)"));
+           SILC_LOG_DEBUG(("Sending RESUMED to %s",
+                           server_entry->server_name));
 
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
 
 
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
 
@@ -1061,8 +987,8 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
                continue;
            }
 
                continue;
            }
 
-           SILC_LOG_DEBUG(("********************************"));
-           SILC_LOG_DEBUG(("RESUMED packet (global)"));
+           SILC_LOG_DEBUG(("Sending RESUMED to %s",
+                           server_entry->server_name));
 
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
 
 
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
 
@@ -1110,8 +1036,7 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
        break;
       }
 
        break;
       }
 
-      SILC_LOG_DEBUG(("********************************"));
-      SILC_LOG_DEBUG(("Received RESUMED packet"));
+      SILC_LOG_DEBUG(("Received RESUMED from new primary router"));
 
       if (server->backup_router)
        server->server_type = SILC_BACKUP_ROUTER;
 
       if (server->backup_router)
        server->server_type = SILC_BACKUP_ROUTER;
@@ -1149,10 +1074,6 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_protocol_backup)
        if (server->server_type == SILC_SERVER)
          silc_server_update_channels_by_server(server, backup_router, router);
        silc_server_backup_replaced_del(server, backup_router);
        if (server->server_type == SILC_SERVER)
          silc_server_update_channels_by_server(server, backup_router, router);
        silc_server_backup_replaced_del(server, backup_router);
-       silc_server_backup_add(server, backup_router, 
-                              ctx->sock->ip, ctx->sock->port,
-                              backup_router->server_type != SILC_ROUTER ?
-                              TRUE : FALSE);
 
        /* Announce all of our information to the router. */
        if (server->server_type == SILC_ROUTER)
 
        /* Announce all of our information to the router. */
        if (server->server_type == SILC_ROUTER)
@@ -1209,8 +1130,6 @@ SILC_TASK_CALLBACK(silc_server_protocol_backup_done)
   SilcIDCacheList list;
   SilcIDCacheEntry id_cache;
 
   SilcIDCacheList list;
   SilcIDCacheEntry id_cache;
 
-  SILC_LOG_DEBUG(("Backup resuming protocol is ended"));
-
   if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
       protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
     SILC_LOG_ERROR(("Error occurred during backup router resuming protcool"));
   if (protocol->state == SILC_PROTOCOL_STATE_ERROR ||
       protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
     SILC_LOG_ERROR(("Error occurred during backup router resuming protcool"));
@@ -1226,9 +1145,6 @@ SILC_TASK_CALLBACK(silc_server_protocol_backup_done)
        if (sock->protocol == protocol) {
          sock->protocol = NULL;
 
        if (sock->protocol == protocol) {
          sock->protocol = NULL;
 
-         SILC_LOG_DEBUG(("***************1 %s:%d",
-                         sock->ip, sock->port));
-
          if (server_entry->data.status & SILC_IDLIST_STATUS_DISABLED)
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
        }
          if (server_entry->data.status & SILC_IDLIST_STATUS_DISABLED)
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
        }
@@ -1249,8 +1165,6 @@ SILC_TASK_CALLBACK(silc_server_protocol_backup_done)
        if (sock->protocol == protocol) {
          sock->protocol = NULL;
 
        if (sock->protocol == protocol) {
          sock->protocol = NULL;
 
-         SILC_LOG_DEBUG(("***************2"));
-
          if (server_entry->data.status & SILC_IDLIST_STATUS_DISABLED)
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
        }
          if (server_entry->data.status & SILC_IDLIST_STATUS_DISABLED)
            server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
        }
@@ -1262,6 +1176,8 @@ SILC_TASK_CALLBACK(silc_server_protocol_backup_done)
     silc_idcache_list_free(list);
   }
 
     silc_idcache_list_free(list);
   }
 
+  SILC_LOG_DEBUG(("Backup resuming protocol has ended"));
+
   if (ctx->sock->protocol)
     ctx->sock->protocol = NULL;
   silc_protocol_free(protocol);
   if (ctx->sock->protocol)
     ctx->sock->protocol = NULL;
   silc_protocol_free(protocol);
index 121bb8d88034f9f361ee54ffbc8846957f0ef76f..c5b6a696c3522b3428ed2f672e04ba05672cdb28 100644 (file)
@@ -476,8 +476,6 @@ void silc_server_update_clients_by_server(SilcServer server,
   SilcClientEntry client = NULL;
   bool local;
 
   SilcClientEntry client = NULL;
   bool local;
 
-  SILC_LOG_DEBUG(("Start"));
-
   if (from)
     SILC_LOG_DEBUG(("Updating %s", silc_id_render(from->id,
                                                  SILC_ID_SERVER)));
   if (from)
     SILC_LOG_DEBUG(("Updating %s", silc_id_render(from->id,
                                                  SILC_ID_SERVER)));
index 12802ef73a8428dff9abae4bd893d5cbdfbea1a9..39c20d82787eab2afc440ffa237c425a59e56ddb 100644 (file)
@@ -322,7 +322,7 @@ static DebugLevel debug_levels[] = {
   { 3, "silcd\\.c,server\\.c" },
 
   /* More stuff from silcd/ */
   { 3, "silcd\\.c,server\\.c" },
 
   /* More stuff from silcd/ */
-  { 7, "silcd\\.c,server\\.c,command\\.c" },
+  { 7, "silcd\\.c,server\\.c,command\\.c,server_backup\\.c" },
 
   /* All basic stuff from silcd/ */
   { 10, "silc_server_*" },
 
   /* All basic stuff from silcd/ */
   { 10, "silc_server_*" },
diff --git a/doc/examples/cell_router.conf b/doc/examples/cell_router.conf
new file mode 100644 (file)
index 0000000..99d6bdc
--- /dev/null
@@ -0,0 +1,68 @@
+#
+# Standalone router
+# 212.146.24.253 on 1334
+#
+# This is the only router in this cell, which means that the router is
+# standalone and the router does not have primary route.
+#
+
+Include "silcalgs.conf";
+
+ServerInfo {
+       hostname = "lassi.kuo.fi.ssh.com";
+       primary { ip = "212.146.42.253"; port = 1334; };
+
+       user = "nobody";
+       group = "nobody";
+
+       servertype = "Test Router";
+       location = "Undisclosed location";
+       Admin = "Pekka Riikonen";
+       AdminEmail = "priikone@silcnet.org";
+
+       publickey = "./silcd.pub";
+       privatekey = "./silcd.prv";
+
+       motdfile = "./motd";
+};
+
+Logging {
+       quicklogs = true;
+       info { file = "cell_router.log"; };
+};
+
+# Router administrator
+Admin {
+       user = "priikone";
+       passphrase = "testi";
+};
+
+##############################################################################
+#
+# Accept all client connections without authentication
+#
+Client { };
+
+##############################################################################
+#
+# This server use me as primary router.  It is normal server in the cell.
+#
+ServerConnection {
+       host = "212.146.42.251";
+       passphrase = "priikone";
+};
+
+##############################################################################
+#
+# This server is our backup router (it will replace me if I go down).  It
+# also can act as normal server in the cell.
+#
+RouterConnection {
+       host = "212.146.42.252";
+       passphrase = "priikone";
+
+       # Mark that this local backup router replaces us
+       backuphost = "212.146.42.253";
+       backupport = 1334;
+       backuplocal = true;
+};