Re: [PATCH net-next v6 07/16] quic: add connection id management

Xin Long <[email protected]> Thu, 8 Jan 2026 13:07:42 -0500
Newsgroups dev.linux.lists.quic,dev.linux.lists.kernel-tls-handshake,org.kernel.vger.linux-cifs,org.kernel.vger.netdev
Message-ID <CADvbK_dKYZ6_NyxcsweKRPkFEq046+1RENA7vH9hBhG-6xNxxw@mail.gmail.com>
On Thu, Jan 8, 2026 at 10:52 AM Paolo Abeni <[email protected]> wrote:
>
> 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
>
Yup, this will save some rounds.

>
> > +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?
>
quic_conn_id_first_number() is always called in the socket that is not
in CLOSE state,
and there must be at least one ID in the id_set in such states. I will
leave a comment
in this function if you're okay with it.

Thanks.