From: Frédéric Lécaille Date: Thu, 15 Jun 2023 11:43:47 +0000 (+0200) Subject: MINOR: quic: Remove pool_zalloc() from quic_dgram_parse() X-Git-Tag: v2.9-dev1~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30254d5e757306b0243f618977a82f9924cb8ba6;p=thirdparty%2Fhaproxy.git MINOR: quic: Remove pool_zalloc() from quic_dgram_parse() Replace a call to pool_zalloc() by a call to pool_malloc() into quic_dgram_parse to allocate quic_rx_packet struct objects. Initialize almost all the members of quic_rx_packet struct. ->saddr is initialized by quic_rx_pkt_retrieve_conn(). ->pnl and ->pn are initialized by qc_do_rm_hp(). ->dcid and ->scid are initialized by quic_rx_pkt_parse() which calls quic_packet_read_long_header() for a long packet. For a short packet, only ->dcid will be initialized. --- diff --git a/src/quic_conn.c b/src/quic_conn.c index 9140901d33..29d229edd7 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -7023,10 +7023,7 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt, prx = l->bind_conf->frontend; prx_counters = EXTRA_COUNTERS_GET(prx->extra_counters_fe, &quic_stats_module); - /* This ist only to please to traces and distinguish the - * packet with parsed packet number from others. - */ - pkt->pn_node.key = (uint64_t)-1; + if (end <= pos) { TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT); goto drop; @@ -8350,22 +8347,31 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc, pos = dgram->buf; end = pos + dgram->len; do { - /* TODO replace zalloc -> alloc. */ - pkt = pool_zalloc(pool_head_quic_rx_packet); + pkt = pool_alloc(pool_head_quic_rx_packet); if (!pkt) { TRACE_ERROR("RX packet allocation failed", QUIC_EV_CONN_LPKT); goto err; } + LIST_INIT(&pkt->qc_rx_pkt_list); pkt->version = NULL; + pkt->type = QUIC_PACKET_TYPE_UNKNOWN; pkt->pn_offset = 0; + pkt->len = 0; + pkt->raw_len = 0; + pkt->token = NULL; + pkt->token_len = 0; + pkt->aad_len = 0; + pkt->data = NULL; + pkt->pn_node.key = (uint64_t)-1; + pkt->refcnt = 0; + pkt->flags = 0; + pkt->time_received = now_ms; /* Set flag if pkt is the first one in dgram. */ if (pos == dgram->buf) pkt->flags |= QUIC_FL_RX_PACKET_DGRAM_FIRST; - LIST_INIT(&pkt->qc_rx_pkt_list); - pkt->time_received = now_ms; quic_rx_packet_refinc(pkt); if (quic_rx_pkt_parse(pkt, pos, end, dgram, li)) goto next;