diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h index 0b33bd026..c7006450e 100644 --- a/include/haproxy/quic_conn-t.h +++ b/include/haproxy/quic_conn-t.h @@ -436,7 +436,7 @@ struct quic_conn_closed { #define QUIC_FL_CONN_RETRANS_NEEDED (1U << 7) #define QUIC_FL_CONN_RETRANS_OLD_DATA (1U << 8) /* retransmission in progress for probing with already sent data */ #define QUIC_FL_CONN_TLS_ALERT (1U << 9) -#define QUIC_FL_CONN_AFFINITY_CHANGED (1U << 10) /* qc_finalize_affinity_rebind() must be called to finalize affinity rebind */ +#define QUIC_FL_CONN_TID_REBIND (1U << 10) /* TID rebind in progress, requires qc_finalize_tid_rebind() call */ #define QUIC_FL_CONN_HALF_OPEN_CNT_DECREMENTED (1U << 11) /* The half-open connection counter was decremented */ #define QUIC_FL_CONN_HANDSHAKE_SPEED_UP (1U << 12) /* Handshake speeding up was done */ #define QUIC_FL_CONN_ACK_TIMER_FIRED (1U << 13) /* idle timer triggered for acknowledgements */ @@ -474,7 +474,7 @@ static forceinline char *qc_show_flags(char *buf, size_t len, const char *delim, _(QUIC_FL_CONN_RETRANS_NEEDED, _(QUIC_FL_CONN_RETRANS_OLD_DATA, _(QUIC_FL_CONN_TLS_ALERT, - _(QUIC_FL_CONN_AFFINITY_CHANGED, + _(QUIC_FL_CONN_TID_REBIND, _(QUIC_FL_CONN_HALF_OPEN_CNT_DECREMENTED, _(QUIC_FL_CONN_HANDSHAKE_SPEED_UP, _(QUIC_FL_CONN_ACK_TIMER_FIRED, diff --git a/include/haproxy/quic_conn.h b/include/haproxy/quic_conn.h index 7082fa073..212e187ba 100644 --- a/include/haproxy/quic_conn.h +++ b/include/haproxy/quic_conn.h @@ -177,10 +177,10 @@ void qc_kill_conn(struct quic_conn *qc); int qc_parse_hd_form(struct quic_rx_packet *pkt, unsigned char **buf, const unsigned char *end); -int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid); -void qc_set_tid_affinity2(struct quic_conn *qc, struct listener *new_li); -void qc_reset_tid_affinity(struct quic_conn *qc); -void qc_finalize_affinity_rebind(struct quic_conn *qc); +int qc_bind_tid_prep(struct quic_conn *qc, uint new_tid); +void qc_bind_tid_commit(struct quic_conn *qc, struct listener *new_li); +void qc_bind_tid_reset(struct quic_conn *qc); +void qc_finalize_tid_rebind(struct quic_conn *qc); int qc_handle_conn_migration(struct quic_conn *qc, const struct sockaddr_storage *peer_addr, diff --git a/include/haproxy/quic_trace-t.h b/include/haproxy/quic_trace-t.h index 7ebc8a7f3..1c977b46f 100644 --- a/include/haproxy/quic_trace-t.h +++ b/include/haproxy/quic_trace-t.h @@ -98,6 +98,6 @@ struct quic_rx_crypto_frm { #define QUIC_EV_CONN_KILL (1ULL << 49) #define QUIC_EV_CONN_KP (1ULL << 50) #define QUIC_EV_CONN_SSL_COMPAT (1ULL << 51) -#define QUIC_EV_CONN_SET_AFFINITY (1ULL << 52) +#define QUIC_EV_CONN_BIND_TID (1ULL << 52) #endif /* _HAPROXY_QUIC_TRACE_T_H */ diff --git a/src/proto_quic.c b/src/proto_quic.c index 593209b4d..60aad85db 100644 --- a/src/proto_quic.c +++ b/src/proto_quic.c @@ -700,19 +700,19 @@ static void quic_disable_listener(struct listener *l) static int quic_bind_tid_prep(struct connection *conn, int new_tid) { struct quic_conn *qc = conn->handle.qc; - return qc_set_tid_affinity1(qc, new_tid); + return qc_bind_tid_prep(qc, new_tid); } static void quic_bind_tid_commit(struct connection *conn) { struct quic_conn *qc = conn->handle.qc; - qc_set_tid_affinity2(qc, objt_listener(conn->target)); + qc_bind_tid_commit(qc, objt_listener(conn->target)); } static void quic_bind_tid_reset(struct connection *conn) { struct quic_conn *qc = conn->handle.qc; - qc_reset_tid_affinity(qc); + qc_bind_tid_reset(qc); } static int quic_alloc_dghdlrs(void) diff --git a/src/quic_conn.c b/src/quic_conn.c index f04ed727c..73b6430d2 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -1315,7 +1315,7 @@ void quic_conn_release(struct quic_conn *qc) goto leave; /* Must not delete a quic_conn if thread affinity rebind in progress. */ - BUG_ON(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED); + BUG_ON(qc->flags & QUIC_FL_CONN_TID_REBIND); /* We must not free the quic-conn if the MUX is still allocated. */ BUG_ON(qc->mux_state == QC_MUX_READY); @@ -1728,12 +1728,12 @@ void qc_notify_err(struct quic_conn *qc) * * Returns 0 on success else non-zero. */ -int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid) +int qc_bind_tid_prep(struct quic_conn *qc, uint new_tid) { struct task *t1 = NULL, *t2 = NULL; struct tasklet *t3 = NULL; - TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc); /* Pre-allocate all required resources. This ensures we do not left a * connection with only some of its field rebinded. @@ -1771,13 +1771,13 @@ int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid) qc->wait_event.events = 0; /* Remove conn from per-thread list instance. It will be hidden from - * "show quic" until qc_finalize_affinity_rebind(). + * "show quic" until qc_finalize_tid_rebind(). */ qc_detach_th_ctx_list(qc, 0); - qc->flags |= QUIC_FL_CONN_AFFINITY_CHANGED; + qc->flags |= QUIC_FL_CONN_TID_REBIND; - TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, qc); return 0; err: @@ -1785,27 +1785,27 @@ int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid) task_destroy(t2); tasklet_free(t3); - TRACE_DEVEL("leaving on error", QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_DEVEL("leaving on error", QUIC_EV_CONN_BIND_TID, qc); return 1; } -/* Complete rebiding to an already selected new thread and associate it +/* Complete rebinding to an already selected new thread and associate it * to if necessary as required when migrating to a new thread group. * * After this function, instance must only be accessed via its newly - * associated thread. qc_finalize_affinity_rebind() must be called to + * associated thread. qc_finalize_tid_rebind() must be called to * reactivate quic_conn elements. */ -void qc_set_tid_affinity2(struct quic_conn *qc, struct listener *new_li) +void qc_bind_tid_commit(struct quic_conn *qc, struct listener *new_li) { const uint new_tid = qc->wait_event.tasklet->tid; struct quic_connection_id *conn_id; struct eb64_node *node; - TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc); - /* Must only be called after qc_set_tid_affinity1(). */ - BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)); + /* Must only be called after qc_bind_tid_prep(). */ + BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND)); /* At this point no connection was accounted for yet on this * listener so it's OK to just swap the pointer. @@ -1836,39 +1836,38 @@ void qc_set_tid_affinity2(struct quic_conn *qc, struct listener *new_li) HA_ATOMIC_STORE(&conn_id->tid, new_tid); qc = NULL; - TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, NULL); + TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, NULL); } /* Interrupt thread migration and stick to the current tid. - * qc_finalize_affinity_rebind() must be called to reactivate quic_conn - * elements. + * qc_finalize_tid_rebind() must be called to reactivate quic_conn elements. */ -void qc_reset_tid_affinity(struct quic_conn *qc) +void qc_bind_tid_reset(struct quic_conn *qc) { - TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc); - /* Must only be called after qc_set_tid_affinity1(). */ - BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)); + /* Must only be called after qc_bind_tid_prep(). */ + BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND)); /* Reset tasks affinity to the current thread. quic_conn will remain - * inactive until qc_finalize_affinity_rebind(). + * inactive until qc_finalize_tid_rebind(). */ task_set_thread(qc->idle_timer_task, tid); if (qc->timer_task) task_set_thread(qc->timer_task, tid); tasklet_set_tid(qc->wait_event.tasklet, tid); - TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, qc); } -/* Must be called after qc_set_tid_affinity() on the new thread. */ -void qc_finalize_affinity_rebind(struct quic_conn *qc) +/* Must be called after TID rebind commit or reset on the new thread. */ +void qc_finalize_tid_rebind(struct quic_conn *qc) { - TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc); /* This function must not be called twice after an affinity rebind. */ - BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)); - qc->flags &= ~QUIC_FL_CONN_AFFINITY_CHANGED; + BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND)); + qc->flags &= ~QUIC_FL_CONN_TID_REBIND; /* If quic_conn is closing it is unnecessary to migrate it as it will * be soon released. Besides, special care must be taken for CLOSING @@ -1897,7 +1896,7 @@ void qc_finalize_affinity_rebind(struct quic_conn *qc) qc->flags &= ~QUIC_FL_CONN_IO_TO_REQUEUE; } - TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc); + TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, qc); } /* diff --git a/src/quic_rx.c b/src/quic_rx.c index abf89f1d7..036e5d30f 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -2169,8 +2169,8 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc, eb64_entry(eb64_first(qc->cids), struct quic_connection_id, seq_num))->tid != tid); /* Ensure thread connection migration is finalized ASAP. */ - if (qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED) - qc_finalize_affinity_rebind(qc); + if (qc->flags & QUIC_FL_CONN_TID_REBIND) + qc_finalize_tid_rebind(qc); if (qc_rx_check_closing(qc, pkt)) { /* Skip the entire datagram. */ diff --git a/src/quic_trace.c b/src/quic_trace.c index 9ab9626d7..bd7a88610 100644 --- a/src/quic_trace.c +++ b/src/quic_trace.c @@ -68,7 +68,7 @@ static const struct trace_event quic_trace_events[] = { { .mask = QUIC_EV_CONN_IDLE_TIMER, .name = "idle_timer", .desc = "idle timer task"}, { .mask = QUIC_EV_CONN_SUB, .name = "xprt_sub", .desc = "RX/TX subscription or unsubscription to QUIC xprt"}, { .mask = QUIC_EV_CONN_RCV, .name = "conn_recv", .desc = "RX on connection" }, - { .mask = QUIC_EV_CONN_SET_AFFINITY, .name = "conn_set_affinity", .desc = "set connection thread affinity" }, + { .mask = QUIC_EV_CONN_BIND_TID, .name = "conn_bind_tid", .desc = "change connection thread affinity" }, { /* end */ } }; diff --git a/src/xprt_quic.c b/src/xprt_quic.c index b83b6340c..558d1a597 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -113,8 +113,8 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx) TRACE_ENTER(QUIC_EV_CONN_NEW, qc); /* Ensure thread connection migration is finalized ASAP. */ - if (qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED) - qc_finalize_affinity_rebind(qc); + if (qc->flags & QUIC_FL_CONN_TID_REBIND) + qc_finalize_tid_rebind(qc); /* do not store the context if already set */ if (*xprt_ctx)