Re: [PATCH net-next v2 04/15] quic: provide family ops for address and protocol
flat view
From: Paolo Abeni <pabeni@redhat.com>
Date: 2025-08-21 13:17:43
Also in:
linux-cifs
On 8/18/25 4:04 PM, Xin Long wrote:
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. [...]
quoted hunk ↗ jump to hunk
+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. /P