From 5ca8b0cf7559efc4736a3ecf3b45a612ed6e1e32 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Mon, 27 Apr 2015 19:15:10 +0000 Subject: [PATCH] - don't count all messages as pid when checking, only payload --- src/cadet/gnunet-service-cadet_connection.c | 57 +++++++++++---------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index cf3f7faf7..522e9ced3 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -2167,37 +2167,40 @@ check_message (const struct GNUNET_MessageHeader *message, } } - /* Check PID */ - fc = fwd ? &c->bck_fc : &c->fwd_fc; - LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n", - pid, fc->last_pid_recv + 1, fc->last_ack_sent); - if (GC_is_pid_bigger (pid, fc->last_ack_sent)) + /* Check PID for payload messages */ + if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == ntohs (message->type)) { - GNUNET_break_op (0); - GNUNET_STATISTICS_update (stats, "# unsolicited message", 1, GNUNET_NO); - LOG (GNUNET_ERROR_TYPE_WARNING, "Received PID %u, (prev %u), ACK %u\n", - pid, fc->last_pid_recv, fc->last_ack_sent); - return GNUNET_SYSERR; - } - if (GC_is_pid_bigger (pid, fc->last_pid_recv)) - { - unsigned int delta; - - delta = pid - fc->last_pid_recv; - fc->last_pid_recv = pid; - fc->recv_bitmap <<= delta; - fc->recv_bitmap |= 1; - } - else - { - GNUNET_STATISTICS_update (stats, "# out of order PID", 1, GNUNET_NO); - if (GNUNET_NO == is_ooo_ok (fc->last_pid_recv, pid, fc->recv_bitmap)) + fc = fwd ? &c->bck_fc : &c->fwd_fc; + LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n", + pid, fc->last_pid_recv + 1, fc->last_ack_sent); + if (GC_is_pid_bigger (pid, fc->last_ack_sent)) { - LOG (GNUNET_ERROR_TYPE_WARNING, "PID %u not expected (%u+), dropping!\n", - pid, fc->last_pid_recv - 31); + GNUNET_break_op (0); + GNUNET_STATISTICS_update (stats, "# unsolicited message", 1, GNUNET_NO); + LOG (GNUNET_ERROR_TYPE_WARNING, "Received PID %u, (prev %u), ACK %u\n", + pid, fc->last_pid_recv, fc->last_ack_sent); return GNUNET_SYSERR; } - fc->recv_bitmap |= get_recv_bitmask (fc->last_pid_recv, pid); + if (GC_is_pid_bigger (pid, fc->last_pid_recv)) + { + unsigned int delta; + + delta = pid - fc->last_pid_recv; + fc->last_pid_recv = pid; + fc->recv_bitmap <<= delta; + fc->recv_bitmap |= 1; + } + else + { + GNUNET_STATISTICS_update (stats, "# out of order PID", 1, GNUNET_NO); + if (GNUNET_NO == is_ooo_ok (fc->last_pid_recv, pid, fc->recv_bitmap)) + { + LOG (GNUNET_ERROR_TYPE_WARNING, "PID %u unexpected (%u+), dropping!\n", + pid, fc->last_pid_recv - 31); + return GNUNET_SYSERR; + } + fc->recv_bitmap |= get_recv_bitmask (fc->last_pid_recv, pid); + } } /* Count as connection confirmation. */ -- 2.25.1