const struct sockaddr_in6 *loc,
uint64_t *hash, knot_tcp_table_t *table)
{
- *hash = hash_four_tuple(rem, loc, table);
+ if (*hash == 0) {
+ *hash = hash_four_tuple(rem, loc, table);
+ }
size_t sdl = sockaddr_data_len(rem, loc);
knot_tcp_conn_t **res = table->conns + (*hash % table->size);
while (*res != NULL) {
static knot_tcp_conn_t **tcp_table_re_lookup(knot_tcp_conn_t *conn,
knot_tcp_table_t *table)
{
- uint64_t unused_hash;
+ uint64_t unused_hash = 0;
knot_tcp_conn_t **res = tcp_table_lookup(&conn->ip_rem, &conn->ip_loc,
&unused_hash, table);
assert(*res == conn);
continue;
}
- uint64_t conn_hash;
+ uint64_t conn_hash = 0;
knot_tcp_conn_t **pconn = tcp_table_lookup(&msg->ip_from, &msg->ip_to,
&conn_hash, tcp_table);
knot_tcp_conn_t *conn = *pconn;
if (conn == NULL) {
bool synack = (msg->flags & KNOT_XDP_MSG_ACK);
- ret = tcp_table_add(msg, conn_hash,
- (syn_table == NULL || synack) ? tcp_table : syn_table,
- &relay->conn);
+ knot_tcp_table_t *add_table = tcp_table;
+ if (syn_table != NULL && !synack) {
+ add_table = syn_table;
+ if (*tcp_table_lookup(&msg->ip_from, &msg->ip_to, &conn_hash, syn_table) != NULL) {
+ break;
+ }
+ }
+
+ ret = tcp_table_add(msg, conn_hash, add_table, &relay->conn);
if (ret == KNOT_EOK) {
relay->action = synack ? XDP_TCP_ESTABLISH : XDP_TCP_SYN;
if (!(ignore & XDP_TCP_IGNORE_ESTABLISH)) {
break;
case KNOT_XDP_MSG_ACK:
if (!seq_ack_match) {
- uint64_t syn_hash;
if (syn_table != NULL && msg->payload.iov_len == 0 &&
- (pconn = tcp_table_lookup(&msg->ip_from, &msg->ip_to, &syn_hash, syn_table)) != NULL &&
+ (pconn = tcp_table_lookup(&msg->ip_from, &msg->ip_to, &conn_hash, syn_table)) != NULL &&
(conn = *pconn) != NULL && check_seq_ack(msg, conn)) {
// move conn from syn_table to tcp_table
tcp_table_remove(pconn, syn_table);