Thread (38 messages) 38 messages, 7 authors, 2025-08-26

Re: [PATCH net-next v2 08/15] quic: add path management

flat view

From: Xin Long <lucien.xin@gmail.com>
Date: 2025-08-23 15:41:04
Also in: linux-cifs

On Thu, Aug 21, 2025 at 10:18 AM Paolo Abeni [off-list ref] wrote:
On 8/18/25 4:04 PM, Xin Long wrote:
quoted
+/* Lookup a quic_udp_sock in the global hash table. If not found, creates and returns a new one
+ * associated with the given kernel socket.
+ */
+static struct quic_udp_sock *quic_udp_sock_lookup(struct sock *sk, union quic_addr *a, u16 port)
+{
+     struct net *net = sock_net(sk);
+     struct quic_hash_head *head;
+     struct quic_udp_sock *us;
+
+     head = quic_udp_sock_head(net, port);
+     hlist_for_each_entry(us, &head->head, node) {
+             if (net != sock_net(us->sk))
+                     continue;
+             if (a) {
+                     if (quic_cmp_sk_addr(us->sk, &us->addr, a) &&
+                         (!us->bind_ifindex || !sk->sk_bound_dev_if ||
+                          us->bind_ifindex == sk->sk_bound_dev_if))
+                             return us;
+                     continue;
+             }
+             if (ntohs(us->addr.v4.sin_port) == port)
+                     return us;
+     }
+     return NULL;
+}
The function description does not match the actual function implementation.
Right, I forgot to update the description after moving the creation out.
quoted
+
+/* Binds a QUIC path to a local port and sets up a UDP socket. */
+int quic_path_bind(struct sock *sk, struct quic_path_group *paths, u8 path)
+{
+     union quic_addr *a = quic_path_saddr(paths, path);
+     int rover, low, high, remaining;
+     struct net *net = sock_net(sk);
+     struct quic_hash_head *head;
+     struct quic_udp_sock *us;
+     u16 port;
+
+     port = ntohs(a->v4.sin_port);
+     if (port) {
+             head = quic_udp_sock_head(net, port);
+             mutex_lock(&head->m_lock);
+             us = quic_udp_sock_lookup(sk, a, port);
+             if (!quic_udp_sock_get(us)) {
+                     us = quic_udp_sock_create(sk, a);
+                     if (!us) {
+                             mutex_unlock(&head->m_lock);
+                             return -EINVAL;
+                     }
+             }
+             mutex_unlock(&head->m_lock);
+
+             quic_udp_sock_put(paths->path[path].udp_sk);
+             paths->path[path].udp_sk = us;
+             return 0;
+     }
+
+     inet_get_local_port_range(net, &low, &high);
you could/should use inet_sk_get_local_port_range().
True, will update.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help