Blame SOURCES/bz212923-fix-dst_seq_num_init-race.patch

30d765
commit 62271c5c0b08041b24930310c04e3933720917c6
30d765
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
30d765
Date:   Mon Nov 8 09:14:22 2021 +0100
30d765
30d765
    [host] fix dst_seq_num initialization race condition
30d765
    
30d765
    There is a potential race condition where the sender
30d765
    is overloaded, sending data packets before pings
30d765
    can kick in and set the correct dst_seq_num.
30d765
    
30d765
    if this node is starting up (dst_seq_num = 0),
30d765
    it can start rejecing valid packets and get stuck.
30d765
    
30d765
    Set the dst_seq_num to the first seen packet and
30d765
    use that as reference instead.
30d765
    
30d765
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
30d765
30d765
diff --git a/libknet/host.c b/libknet/host.c
30d765
index f02ef02..54061fd 100644
30d765
--- a/libknet/host.c
30d765
+++ b/libknet/host.c
30d765
@@ -573,6 +573,21 @@ int _seq_num_lookup(knet_handle_t knet_h, struct knet_host *host, seq_num_t seq_
30d765
 	char *dst_cbuf_defrag = host->circular_buffer_defrag;
30d765
 	seq_num_t *dst_seq_num = &host->rx_seq_num;
30d765
 
30d765
+	/*
30d765
+	 * There is a potential race condition where the sender
30d765
+	 * is overloaded, sending data packets before pings
30d765
+	 * can kick in and set the correct dst_seq_num.
30d765
+	 *
30d765
+	 * if this node is starting up (dst_seq_num = 0),
30d765
+	 * it can start rejecing valid packets and get stuck.
30d765
+	 *
30d765
+	 * Set the dst_seq_num to the first seen packet and
30d765
+	 * use that as reference instead.
30d765
+	 */
30d765
+	if (!*dst_seq_num) {
30d765
+		*dst_seq_num = seq_num;
30d765
+	}
30d765
+
30d765
 	if (clear_buf) {
30d765
 		_clear_cbuffers(host, seq_num);
30d765
 	}