]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
xdp-tcp: bugfix: crash when two packets for same conn...
authorLibor Peltan <libor.peltan@nic.cz>
Mon, 15 Nov 2021 14:24:06 +0000 (15:24 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 16 Mar 2022 13:58:06 +0000 (14:58 +0100)
...and one of them is closing it

src/libknot/xdp/tcp.c
src/libknot/xdp/tcp.h
tests/libknot/test_xdp_tcp.c

index fed16e554f0932096ac21b3cb929bcf6d31337aa..c6c10ec3c6b1b290f0a4bb375062a4d504702e41 100644 (file)
@@ -381,8 +381,7 @@ int knot_tcp_recv(knot_tcp_relay_t *relays, knot_xdp_msg_t *msgs, uint32_t count
                                case XDP_TCP_CLOSING2:
                                        if (msg->payload.iov_len == 0) { // otherwise ignore close
                                                tcp_table_remove(pconn, tcp_table);
-                                               del_conn(conn);
-                                               relay->conn = NULL;
+                                               relay->answer = XDP_TCP_FREE;
                                        }
                                        break;
                                }
@@ -414,8 +413,7 @@ int knot_tcp_recv(knot_tcp_relay_t *relays, knot_xdp_msg_t *msgs, uint32_t count
                        if (conn != NULL && msg->seqno == conn->seqno) {
                                relay->action = XDP_TCP_RESET;
                                tcp_table_remove(pconn, tcp_table);
-                               del_conn(conn);
-                               relay->conn = NULL;
+                               relay->answer = XDP_TCP_FREE;
                        } else if (conn != NULL) {
                                relay->auto_answer = KNOT_XDP_MSG_ACK;
                        }
index cefd96780e0ea9bdb86e9e602009a9a1d4a70c7b..2cde210bed85a958ecb8ed3f3fab7ac96b58f10e 100644 (file)
@@ -125,7 +125,7 @@ inline static uint32_t knot_tcp_next_seqno(const knot_xdp_msg_t *msg)
 
 inline static bool knot_tcp_relay_empty(const knot_tcp_relay_t *r)
 {
-       return r->action == XDP_TCP_NOOP && r->auto_answer == 0 && r->inbufs_count == 0;
+       return r->action == XDP_TCP_NOOP && r->answer == XDP_TCP_NOOP && r->auto_answer == 0 && r->inbufs_count == 0;
 }
 
 /*!
index d0299af25e2e65bf6befe042066ee68f9563b183..b88bee7785eac062be0b0d7a7723707396054d86 100644 (file)
@@ -380,6 +380,7 @@ void test_close(void)
        check_sent(0, 0, 0, 0);
        is_int(conns_pre - 1, test_table->usage, "close: connection removed");
        is_int(conns_pre - 1, tcp_table_timeout_length(test_table), "close: timeout list size");
+       knot_tcp_cleanup(test_table, &rl, 1);
 }
 
 void test_many(void)