Fixed New Channel packet handling when received with List flag.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 27 Jun 2002 15:32:53 +0000 (15:32 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 27 Jun 2002 15:32:53 +0000 (15:32 +0000)
They list packet is not sent to backup, but individual packets
assuming router accepts their contents.

CHANGES
apps/silcd/command.c
apps/silcd/packet_receive.c
apps/silcd/packet_send.c
apps/silcd/server.c
doc/draft-riikonen-silc-pp-06.nroff

diff --git a/CHANGES b/CHANGES
index 09d6d39aea3e73cd71d1508329eedfdba1fb52d1..201c1f2bb08c236197840445399892542d68c4c5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,19 @@
+Thu Jun 27 16:54:33 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+       * Allow heartbeat packets to go disabled connections anyway.
+         Affected files silcd/server.c and silcd/packet_send.c.
+
+       * Do not broadcast New Channel packets with List flag set
+         in the packet to backup routers.  The router must check
+         for the correctness of the packets before sending them.
+         It is possible that router will have enforce Channel ID
+         change and this would cause desync in the backup router.
+         Affected file silcd/packet_receive.c.
+
+       * Remove SILC_PACKET_FLAG_LIST from the temp packets that
+         are handled in list parsing.  They are not list packets
+         anymore.  Affected file silcd/packet_receive.c.
+
 Thu Jun 27 11:27:07 CEST 2002 Pekka Riikonen <priikone@silcnet.org>
 
        * Stop waiting for backup router through the timeout, not
index 5ed21f8354e710fcb041c29839ede868490f59c5..93e94e80bca35c2c41f56685ad9820e0ba9c95c6 100644 (file)
@@ -4815,6 +4815,11 @@ SILC_SERVER_CMD_FUNC(kick)
                                     idp->data, idp->len);
   silc_buffer_free(idp);
 
+  /* Send KICKED notify to primary route */
+  silc_server_send_notify_kicked(server, SILC_PRIMARY_ROUTE(server),
+                                SILC_BROADCAST(server), channel,
+                                target_client->id, client->id, comment);
+
   /* Remove the client from the channel. If the channel does not exist
      after removing the client then the client kicked itself off the channel
      and we don't have to send anything after that. */
@@ -4822,11 +4827,6 @@ SILC_SERVER_CMD_FUNC(kick)
                                           target_client, FALSE))
     goto out;
 
-  /* Send KICKED notify to primary route */
-  silc_server_send_notify_kicked(server, SILC_PRIMARY_ROUTE(server),
-                                SILC_BROADCAST(server), channel,
-                                target_client->id, client->id, comment);
-
   if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
     /* Re-generate channel key */
     if (!silc_server_create_channel_key(server, channel, 0))
index ed8ad2f02233f60144601d03e16a4a5f08571f07..9164293803488e04bce3d3ee36f6b768fef40eee 100644 (file)
@@ -2779,7 +2779,7 @@ void silc_server_new_id_list(SilcServer server, SilcSocketConnection sock,
      data buffer, which we will here now fetch from the original buffer. */
   new_id = silc_packet_context_alloc();
   new_id->type = SILC_PACKET_NEW_ID;
-  new_id->flags = packet->flags;
+  new_id->flags = packet->flags & (~SILC_PACKET_FLAG_LIST);
   new_id->src_id = packet->src_id;
   new_id->src_id_len = packet->src_id_len;
   new_id->src_id_type = packet->src_id_type;
@@ -2909,13 +2909,15 @@ void silc_server_new_channel(SilcServer server,
          !SILC_ID_COMPARE(channel_id, server->id, server->id->ip.data_len)) {
        SilcChannelID *tmp;
        SILC_LOG_DEBUG(("Forcing the server to change Channel ID"));
-       
        if (silc_id_create_channel_id(server, server->id, server->rng, &tmp)) {
          silc_server_send_notify_channel_change(server, sock, FALSE, 
                                                 channel_id, tmp);
          silc_free(channel_id);
-         channel_id = tmp;
+         silc_free(tmp);
        }
+
+       /* Wait that server re-announces this channel */
+       return;
       }
 
       /* Create the channel with the provided Channel ID */
@@ -3052,6 +3054,24 @@ void silc_server_new_channel(SilcServer server,
     }
   }
 
+  /* If the sender of this packet is server and we are router we need to
+     broadcast this packet to other routers in the network. Broadcast
+     this list packet instead of multiple New Channel packets. */
+  if (server->server_type == SILC_ROUTER &&
+      sock->type == SILC_SOCKET_TYPE_SERVER &&
+      !(packet->flags & SILC_PACKET_FLAG_BROADCAST)) {
+    SILC_LOG_DEBUG(("Broadcasting received New Channel packet"));
+    silc_server_packet_send(server, SILC_PRIMARY_ROUTE(server),
+                           packet->type, 
+                           packet->flags | SILC_PACKET_FLAG_BROADCAST,
+                           packet->buffer->data, 
+                           packet->buffer->len, FALSE);
+    silc_server_backup_send(server, sock->user_data, 
+                           packet->type, packet->flags,
+                           packet->buffer->data, packet->buffer->len, 
+                           FALSE, TRUE);
+  }
+
   silc_channel_payload_free(payload);
 }
 
@@ -3073,29 +3093,11 @@ void silc_server_new_channel_list(SilcServer server,
       server->server_type == SILC_SERVER)
     return;
 
-  /* If the sender of this packet is server and we are router we need to
-     broadcast this packet to other routers in the network. Broadcast
-     this list packet instead of multiple New Channel packets. */
-  if (server->server_type == SILC_ROUTER &&
-      sock->type == SILC_SOCKET_TYPE_SERVER &&
-      !(packet->flags & SILC_PACKET_FLAG_BROADCAST)) {
-    SILC_LOG_DEBUG(("Broadcasting received New Channel List packet"));
-    silc_server_packet_send(server, SILC_PRIMARY_ROUTE(server),
-                           packet->type, 
-                           packet->flags | SILC_PACKET_FLAG_BROADCAST,
-                           packet->buffer->data, 
-                           packet->buffer->len, FALSE);
-    silc_server_backup_send(server, sock->user_data, 
-                           packet->type, packet->flags,
-                           packet->buffer->data, packet->buffer->len, 
-                           FALSE, TRUE);
-  }
-
   /* Make copy of the original packet context, except for the actual
      data buffer, which we will here now fetch from the original buffer. */
   new = silc_packet_context_alloc();
   new->type = SILC_PACKET_NEW_CHANNEL;
-  new->flags = packet->flags;
+  new->flags = packet->flags & (~SILC_PACKET_FLAG_LIST);
   new->src_id = packet->src_id;
   new->src_id_len = packet->src_id_len;
   new->src_id_type = packet->src_id_type;
index 65637c159c79e73438fa85cf8e658e8f0a7173df..dbf8fb773a6ce8cb9dae5df7c5587f916009c328 100644 (file)
@@ -97,7 +97,8 @@ void silc_server_packet_send(SilcServer server,
     return;
 
   /* If entry is disabled do not sent anything. */
-  if ((idata && idata->status & SILC_IDLIST_STATUS_DISABLED) ||
+  if ((idata && idata->status & SILC_IDLIST_STATUS_DISABLED &&
+       type != SILC_PACKET_HEARTBEAT) ||
       sock->user_data == server->id_entry) {
     SILC_LOG_DEBUG(("Connection is disabled"));
     return;
index 4f8658bd629150c00c8a9a4df82578767def5adb..34f7b9ba34d39d3ecc2f96cb104c2290b4669a4e 100644 (file)
@@ -1915,6 +1915,12 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final)
        if (backup_local)
          ctx->conn_type = SILC_SOCKET_TYPE_SERVER;
        new_server->server_type = SILC_BACKUP_ROUTER;
+
+       /* Remove the backup waiting with timeout */
+       silc_schedule_task_add(server->schedule, 0,
+                              silc_server_backup_router_wait,
+                              (void *)server, 5, 0,
+                              SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
       }
 
       /* Statistics */
@@ -2153,6 +2159,11 @@ SILC_TASK_CALLBACK(silc_server_packet_parse_real)
     SILC_LOG_DEBUG(("Connection is disabled"));
     goto out;
   }
+  if (ret != SILC_PACKET_HEARTBEAT &&
+      idata && idata->status & SILC_IDLIST_STATUS_DISABLED) {
+    SILC_LOG_DEBUG(("Connection is disabled"));
+    goto out;
+  }
 
   if (ret == SILC_PACKET_NONE) {
     SILC_LOG_DEBUG(("Error parsing packet"));
@@ -3696,6 +3707,7 @@ SilcChannelEntry silc_server_save_channel_key(SilcServer server,
       if (!channel) {
        SILC_LOG_ERROR(("Received key for non-existent channel %s",
                        silc_id_render(id, SILC_ID_CHANNEL)));
+       assert(FALSE);
        goto out;
       }
     }
index 5a7d7edfeb20d774b56adada490abb3061a9d9a5..776912ec2c81f06bb02f451c14b6a084f6ecc07b 100644 (file)
@@ -1408,8 +1408,9 @@ UTF-8 [RFC2279] encoded.
 
       The <Old Channel ID> is the channel's old ID and the <New
       Channel ID> is the new one that MUST replace the old one.
-
-
+      Server which receives this from router MUST re-announce the
+      channel to the router by sending SILC_PACKET_NEW_CHANNEL packet
+      with the new Channel ID.
 
 
 11    SILC_NOTIFY_TYPE_SERVER_SIGNOFF