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

Re: [PATCH net-next v2 04/15] quic: provide family ops for address and protocol

flat view

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

On Thu, Aug 21, 2025 at 9:17 AM Paolo Abeni [off-list ref] wrote:
On 8/18/25 4:04 PM, Xin Long wrote:
quoted
This patch introduces two new abstraction structures to simplify handling
of IPv4 and IPv6 differences across the QUIC stack:

- quic_addr_family_ops: for address comparison, flow routing,
  UDP config, MTU lookup, formatted output, etc.

- quic_proto_family_ops: for socket address helpers and preference.

With these additions, the QUIC core logic can remain agnostic of the
address family and socket type, improving modularity and reducing
repetitive checks throughout the codebase.
Given that you wrap the ops call in quick_<op>() helper, I'm wondering
if such abstraction is necessary/useful? 'if' statements in the quick
helper will likely reduce the code size, and will the indirect function
call overhead.
I'm completely fine to change things to be like:

int quic_flow_route(struct sock *sk, union quic_addr *da, union
quic_addr *sa, struct flowi *fl)
{
        return da->sa.sa_family == AF_INET ? quic_v4_flow_route(sk,
da, sa, fl) :
                quic_v6_flow_route(sk, da, sa, fl);
}
[...]
quoted
+static void quic_v6_set_sk_addr(struct sock *sk, union quic_addr *a, bool src)
+{
+     if (src) {
+             inet_sk(sk)->inet_sport = a->v4.sin_port;
+             if (a->sa.sa_family == AF_INET) {
+                     sk->sk_v6_rcv_saddr.s6_addr32[0] = 0;
+                     sk->sk_v6_rcv_saddr.s6_addr32[1] = 0;
+                     sk->sk_v6_rcv_saddr.s6_addr32[2] = htonl(0x0000ffff);
+                     sk->sk_v6_rcv_saddr.s6_addr32[3] = a->v4.sin_addr.s_addr;
+             } else {
+                     sk->sk_v6_rcv_saddr = a->v6.sin6_addr;
+             }
+     } else {
+             inet_sk(sk)->inet_dport = a->v4.sin_port;
+             if (a->sa.sa_family == AF_INET) {
+                     sk->sk_v6_daddr.s6_addr32[0] = 0;
+                     sk->sk_v6_daddr.s6_addr32[1] = 0;
+                     sk->sk_v6_daddr.s6_addr32[2] = htonl(0x0000ffff);
+                     sk->sk_v6_daddr.s6_addr32[3] = a->v4.sin_addr.s_addr;
+             } else {
+                     sk->sk_v6_daddr = a->v6.sin6_addr;
+             }
+     }
You could factor the addr assignment in an helper and avoid some code
duplication.
Right, I will add a helper.

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