mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-27 13:51:00 +01:00
MINOR: quic: refactor packet drop on reception
Sometimes, a packet is dropped on reception. Several goto statements are used, mostly to increment a proxy drop counter or drop silently the packet. However, this labels are interleaved. Re-arrang goto labels to simplify this process : * drop label is used to drop a packet with counter incrementation. This is the default method. * drop_silent is the next label which does the same thing but skip the counter incrementation. This is useful when we do not need to report the packet dropping operation. This should be backported up to 2.6.
This commit is contained in:
parent
982896961c
commit
6e56a9e055
@ -6056,7 +6056,7 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
|
|||||||
const unsigned char *beg = buf;
|
const unsigned char *beg = buf;
|
||||||
struct proxy *prx;
|
struct proxy *prx;
|
||||||
struct quic_counters *prx_counters;
|
struct quic_counters *prx_counters;
|
||||||
int drop_no_conn = 0, long_header = 0;
|
int long_header = 0;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
const struct quic_version *qv = NULL;
|
const struct quic_version *qv = NULL;
|
||||||
|
|
||||||
@ -6083,7 +6083,7 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
|
|||||||
* the remaining space.
|
* the remaining space.
|
||||||
*/
|
*/
|
||||||
pkt->len = end - buf;
|
pkt->len = end - buf;
|
||||||
goto drop_no_conn;
|
goto drop_silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
|
TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
|
||||||
@ -6105,11 +6105,7 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
|
|||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pkt->type == QUIC_PACKET_TYPE_0RTT && !l->bind_conf->ssl_conf.early_data) {
|
if (pkt->type == QUIC_PACKET_TYPE_INITIAL &&
|
||||||
TRACE_PROTO("0-RTT packet not supported", QUIC_EV_CONN_LPKT);
|
|
||||||
drop_no_conn = 1;
|
|
||||||
}
|
|
||||||
else if (pkt->type == QUIC_PACKET_TYPE_INITIAL &&
|
|
||||||
dgram->len < QUIC_INITIAL_PACKET_MINLEN) {
|
dgram->len < QUIC_INITIAL_PACKET_MINLEN) {
|
||||||
TRACE_PROTO("Too short datagram with an Initial packet", QUIC_EV_CONN_LPKT);
|
TRACE_PROTO("Too short datagram with an Initial packet", QUIC_EV_CONN_LPKT);
|
||||||
HA_ATOMIC_INC(&prx_counters->too_short_initial_dgram);
|
HA_ATOMIC_INC(&prx_counters->too_short_initial_dgram);
|
||||||
@ -6138,11 +6134,11 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
|
|||||||
/* unsupported version, send Negotiation packet */
|
/* unsupported version, send Negotiation packet */
|
||||||
if (send_version_negotiation(l->rx.fd, &dgram->saddr, pkt)) {
|
if (send_version_negotiation(l->rx.fd, &dgram->saddr, pkt)) {
|
||||||
TRACE_ERROR("VN packet not sent", QUIC_EV_CONN_LPKT);
|
TRACE_ERROR("VN packet not sent", QUIC_EV_CONN_LPKT);
|
||||||
goto err;
|
goto drop_silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_PROTO("VN packet sent", QUIC_EV_CONN_LPKT);
|
TRACE_PROTO("VN packet sent", QUIC_EV_CONN_LPKT);
|
||||||
goto err;
|
goto drop_silent;
|
||||||
}
|
}
|
||||||
pkt->version = qv;
|
pkt->version = qv;
|
||||||
|
|
||||||
@ -6169,11 +6165,11 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
|
|||||||
if (send_retry(l->rx.fd, &dgram->saddr, pkt, qv)) {
|
if (send_retry(l->rx.fd, &dgram->saddr, pkt, qv)) {
|
||||||
TRACE_PROTO("Error during Retry generation",
|
TRACE_PROTO("Error during Retry generation",
|
||||||
QUIC_EV_CONN_LPKT, NULL, NULL, NULL, qv);
|
QUIC_EV_CONN_LPKT, NULL, NULL, NULL, qv);
|
||||||
goto err;
|
goto drop_silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
HA_ATOMIC_INC(&prx_counters->retry_sent);
|
HA_ATOMIC_INC(&prx_counters->retry_sent);
|
||||||
goto err;
|
goto drop_silent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!global.cluster_secret && token_len) {
|
else if (!global.cluster_secret && token_len) {
|
||||||
@ -6209,8 +6205,15 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
|
|||||||
*/
|
*/
|
||||||
pkt->pn_offset = buf - beg;
|
pkt->pn_offset = buf - beg;
|
||||||
pkt->len = pkt->pn_offset + len;
|
pkt->len = pkt->pn_offset + len;
|
||||||
if (drop_no_conn)
|
|
||||||
goto drop_no_conn;
|
/* Interrupt parsing after packet length retrieval : this
|
||||||
|
* ensures that only the packet is dropped but not the whole
|
||||||
|
* datagram.
|
||||||
|
*/
|
||||||
|
if (pkt->type == QUIC_PACKET_TYPE_0RTT && !l->bind_conf->ssl_conf.early_data) {
|
||||||
|
TRACE_PROTO("0-RTT packet not supported", QUIC_EV_CONN_LPKT);
|
||||||
|
goto drop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TRACE_PROTO("short header packet received", QUIC_EV_CONN_LPKT);
|
TRACE_PROTO("short header packet received", QUIC_EV_CONN_LPKT);
|
||||||
@ -6242,17 +6245,9 @@ static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
|
|||||||
TRACE_LEAVE(QUIC_EV_CONN_LPKT, NULL, pkt, NULL, qv);
|
TRACE_LEAVE(QUIC_EV_CONN_LPKT, NULL, pkt, NULL, qv);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
drop_no_conn:
|
|
||||||
if (drop_no_conn)
|
|
||||||
HA_ATOMIC_INC(&prx_counters->dropped_pkt);
|
|
||||||
TRACE_LEAVE(QUIC_EV_CONN_LPKT, NULL, pkt);
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
drop:
|
drop:
|
||||||
HA_ATOMIC_INC(&prx_counters->dropped_pkt);
|
HA_ATOMIC_INC(&prx_counters->dropped_pkt);
|
||||||
|
drop_silent:
|
||||||
err:
|
|
||||||
if (!pkt->len)
|
if (!pkt->len)
|
||||||
pkt->len = end - beg;
|
pkt->len = end - beg;
|
||||||
TRACE_LEAVE(QUIC_EV_CONN_LPKT, NULL, pkt, NULL, qv);
|
TRACE_LEAVE(QUIC_EV_CONN_LPKT, NULL, pkt, NULL, qv);
|
||||||
@ -6336,7 +6331,7 @@ static void qc_rx_pkt_handle(struct quic_conn *qc, struct quic_rx_packet *pkt,
|
|||||||
TRACE_PROTO("Packet dropped",
|
TRACE_PROTO("Packet dropped",
|
||||||
QUIC_EV_CONN_LPKT, qc, NULL, NULL, qv);
|
QUIC_EV_CONN_LPKT, qc, NULL, NULL, qv);
|
||||||
HA_ATOMIC_INC(&qc->prx_counters->dropped_pkt_bufoverrun);
|
HA_ATOMIC_INC(&qc->prx_counters->dropped_pkt_bufoverrun);
|
||||||
goto drop_no_conn;
|
goto drop_silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let us consume the remaining contiguous space. */
|
/* Let us consume the remaining contiguous space. */
|
||||||
@ -6349,7 +6344,7 @@ static void qc_rx_pkt_handle(struct quic_conn *qc, struct quic_rx_packet *pkt,
|
|||||||
TRACE_PROTO("Too big packet",
|
TRACE_PROTO("Too big packet",
|
||||||
QUIC_EV_CONN_LPKT, qc, pkt, &pkt->len, qv);
|
QUIC_EV_CONN_LPKT, qc, pkt, &pkt->len, qv);
|
||||||
HA_ATOMIC_INC(&qc->prx_counters->dropped_pkt_bufoverrun);
|
HA_ATOMIC_INC(&qc->prx_counters->dropped_pkt_bufoverrun);
|
||||||
goto drop_no_conn;
|
goto drop_silent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6365,7 +6360,7 @@ static void qc_rx_pkt_handle(struct quic_conn *qc, struct quic_rx_packet *pkt,
|
|||||||
*tasklist_head = tasklet_wakeup_after(*tasklist_head,
|
*tasklist_head = tasklet_wakeup_after(*tasklist_head,
|
||||||
qc->wait_event.tasklet);
|
qc->wait_event.tasklet);
|
||||||
|
|
||||||
drop_no_conn:
|
drop_silent:
|
||||||
TRACE_LEAVE(QUIC_EV_CONN_LPKT, qc ? qc : NULL, pkt, NULL, qv);
|
TRACE_LEAVE(QUIC_EV_CONN_LPKT, qc ? qc : NULL, pkt, NULL, qv);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user