From: Pekka Riikonen Date: Thu, 27 Jun 2002 15:32:53 +0000 (+0000) Subject: Fixed New Channel packet handling when received with List flag. X-Git-Tag: silc.toolkit.0.9.3~16 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=8b353496b56f4765ac810ac5400865e815ab4517 Fixed New Channel packet handling when received with List flag. They list packet is not sent to backup, but individual packets assuming router accepts their contents. --- diff --git a/CHANGES b/CHANGES index 09d6d39a..201c1f2b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,19 @@ +Thu Jun 27 16:54:33 EEST 2002 Pekka Riikonen + + * 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 * Stop waiting for backup router through the timeout, not diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 5ed21f83..93e94e80 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -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)) diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index ed8ad2f0..91642938 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -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; diff --git a/apps/silcd/packet_send.c b/apps/silcd/packet_send.c index 65637c15..dbf8fb77 100644 --- a/apps/silcd/packet_send.c +++ b/apps/silcd/packet_send.c @@ -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; diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 4f8658bd..34f7b9ba 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -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; } } diff --git a/doc/draft-riikonen-silc-pp-06.nroff b/doc/draft-riikonen-silc-pp-06.nroff index 5a7d7edf..776912ec 100644 --- a/doc/draft-riikonen-silc-pp-06.nroff +++ b/doc/draft-riikonen-silc-pp-06.nroff @@ -1408,8 +1408,9 @@ UTF-8 [RFC2279] encoded. The is the channel's old ID and the 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