Re: [PATCH net-next v6 07/16] quic: add connection id management
From: Paolo Abeni <pabeni@redhat.com>
Date: 2026-01-08 15:52:38
Also in:
linux-cifs
On 1/5/26 3:04 PM, Xin Long wrote:
+/* Remove connection IDs from the set with sequence numbers less than or equal to a number. */
+void quic_conn_id_remove(struct quic_conn_id_set *id_set, u32 number)
+{
+ struct quic_common_conn_id *common, *tmp;
+ struct list_head *list;
+
+ list = &id_set->head;
+ list_for_each_entry_safe(common, tmp, list, list) {
+ if (common->number <= number) {
+ if (id_set->active == common)
+ id_set->active = tmp;
+ quic_conn_id_del(common);
+ id_set->count--;
+ }Since the list is sorted by number you could break the loop as soon as common->number > number.
+ }
+}
+
+struct quic_conn_id *quic_conn_id_find(struct quic_conn_id_set *id_set, u32 number)
+{
+ struct quic_common_conn_id *common;
+
+ list_for_each_entry(common, &id_set->head, list)
+ if (common->number == number)
+ return &common->id;Same here, you can break the loop when common->number > number
+static inline u32 quic_conn_id_first_number(struct quic_conn_id_set *id_set)
+{
+ struct quic_common_conn_id *common;
+
+ common = list_first_entry(&id_set->head, struct quic_common_conn_id, list);id_set can be empty at creation time. The above assumes it contains at least an element. Does the caller need to check for such condition? Possibly moving the check here would simplify the code? /P