Skip to content
Snippets Groups Projects
Commit 3d4e8e50 authored by Libor Peltan's avatar Libor Peltan
Browse files

XDP-TCP: dont use structures if their allocation fails

parent 5616782f
No related branches found
No related tags found
1 merge request!1327XDP-TCP: dont use structures if their allocation fails
Pipeline #85198 passed
......@@ -299,11 +299,13 @@ int knot_tcp_relay(knot_xdp_socket_t *socket, knot_xdp_msg_t msgs[], uint32_t ms
if (knot_tcp_relay_dynarray_add(relays, &relay) == NULL) {
ret = KNOT_ENOMEM;
}
relay.conn->state = XDP_TCP_ESTABLISHING;
relay.conn->seqno++;
relay.conn->mss = MAX(msg->mss, 536); // minimal MSS, most importantly not zero!
relay.conn->acked = acks[n_acks - 1].seqno;
relay.conn->ackno = relay.conn->acked + (synack ? 0 : 1);
if (ret == KNOT_EOK) {
relay.conn->state = XDP_TCP_ESTABLISHING;
relay.conn->seqno++;
relay.conn->mss = MAX(msg->mss, 536); // minimal MSS, most importantly not zero!
relay.conn->acked = acks[n_acks - 1].seqno;
relay.conn->ackno = relay.conn->acked + (synack ? 0 : 1);
}
} else {
resp_ack(msg, KNOT_XDP_MSG_RST); // TODO consider resetting the OLD conn and accepting new one
}
......@@ -318,7 +320,7 @@ int knot_tcp_relay(knot_xdp_socket_t *socket, knot_xdp_msg_t msgs[], uint32_t ms
*conn = NULL;
relay.action = XDP_TCP_ESTABLISH;
ret = tcp_table_add(msg, conn_hash, tcp_table, &relay.conn);
if (knot_tcp_relay_dynarray_add(relays, &relay) == NULL) {
if (ret == KNOT_EOK && knot_tcp_relay_dynarray_add(relays, &relay) == NULL) {
ret = KNOT_ENOMEM;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment