[PR #265] compat: detect udp_tunnel sock/socket signatures instead of gating on kernel version (#259) #267

Open
opened 2026-10-13 21:08:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/265
Author: @CptTZ
Created: 10/5/2026
Status: 🔄 Open

Base: master ← Head: master


📝 Commits (1)

  • 2560c48 compat: detect udp_tunnel sock/socket signatures instead of gating on kernel version (#259)

📊 Changes

1 file changed (+22 additions, -4 deletions)

View changed files

📝 src/compat/compat.h (+22 -4)

📄 Description

Problem

Linux 7.1.5 changed setup_udp_tunnel_sock() and udp_tunnel_sock_release() to take struct sock * instead of struct socket *. compat.h handled that with a single LINUX_VERSION_CODE < 7.1.5 gate that wraps both calls in ->sk_socket.

Ubuntu 7.0.0-38 (aka. 26.04) backported only the setup_udp_tunnel_sock half. udp_tunnel_sock_release still takes struct socket * there, and LINUX_VERSION_CODE stays at 7.0.14. So the gate fires, the setup call gets sk->sk_socket, and the build fails:

compat.h:1449:79: error: passing argument 2 of 'setup_udp_tunnel_sock' from incompatible pointer type

note - could also be an Ubuntu issue

headers setup_udp_tunnel_sock udp_tunnel_sock_release LINUX_VERSION_CODE
Ubuntu 7.0.0-34 struct socket * struct socket * 7.0.14
Ubuntu 7.0.0-38 struct sock * struct socket * 7.0.14
upstream 7.1.5+ struct sock * struct sock * 7.1.5

Fix

Drop the gate using gcc built-in compat helpers __builtin_types_compatible_p and __builtin_choose_expr, also ref #262.

The pre-3.18 fallbacks in compat/udp_tunnel/ declare the struct socket * variants, so they keep working through the same check.

Testing

Built on Ubuntu 26.04.1 with gcc 15.2, no errors or warnings:

  • 7.0.0-38-generic headers (setup=sock, release=socket), previously failing
  • 7.0.0-34-generic headers (both socket)

Not tested: a 7.1.5+ kernel.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/265 **Author:** [@CptTZ](https://github.com/CptTZ) **Created:** 10/5/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`2560c48`](https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/commit/2560c48863326a21938d6e2b9837b185089cd79c) compat: detect udp_tunnel sock/socket signatures instead of gating on kernel version (#259) ### 📊 Changes **1 file changed** (+22 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/compat/compat.h` (+22 -4) </details> ### 📄 Description ## Problem Linux 7.1.5 changed `setup_udp_tunnel_sock()` and `udp_tunnel_sock_release()` to take `struct sock *` instead of `struct socket *`. compat.h handled that with a single `LINUX_VERSION_CODE < 7.1.5` gate that wraps both calls in `->sk_socket`. Ubuntu 7.0.0-38 (aka. 26.04) backported only the `setup_udp_tunnel_sock` half. `udp_tunnel_sock_release` still takes `struct socket *` there, and `LINUX_VERSION_CODE` stays at 7.0.14. So the gate fires, the setup call gets `sk->sk_socket`, and the build fails: ``` compat.h:1449:79: error: passing argument 2 of 'setup_udp_tunnel_sock' from incompatible pointer type ``` note - could also be an Ubuntu issue | headers | `setup_udp_tunnel_sock` | `udp_tunnel_sock_release` | `LINUX_VERSION_CODE` | |---|---|---|---| | Ubuntu 7.0.0-34 | `struct socket *` | `struct socket *` | 7.0.14 | | Ubuntu 7.0.0-38 | `struct sock *` | `struct socket *` | 7.0.14 | | upstream 7.1.5+ | `struct sock *` | `struct sock *` | 7.1.5 | ## Fix Drop the gate using gcc built-in compat helpers `__builtin_types_compatible_p` and `__builtin_choose_expr`, also ref #262. The pre-3.18 fallbacks in `compat/udp_tunnel/` declare the `struct socket *` variants, so they keep working through the same check. ## Testing Built on Ubuntu 26.04.1 with gcc 15.2, no errors or warnings: - `7.0.0-38-generic` headers (setup=`sock`, release=`socket`), previously failing - `7.0.0-34-generic` headers (both `socket`) Not tested: a 7.1.5+ kernel. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-linux-kernel-module#267
No description provided.