kmod-amneziawg: add AmneziaWG kernel module package - #30492
Conversation
3d46569 to
cd182d0
Compare
cd182d0 to
76e0c31
Compare
|
Thanks for this endeavour, I'm sure it would be appreciated by many OpenWrt users. FWIW regarding the luci app -- as far as I remember the previous discussions, there was a strong preference from the core team to adjust the luci-app-wireguard to support additional amneziawg options, rather than duplicating the code of the existing app into luci-app-amneziawg. |
|
Thanks, that makes sense, and I agree that avoiding a duplicated LuCI implementation would be preferable. There is one part I am not yet sure how you would prefer to handle: the existing AmneziaWG uses So I think sharing the existing WireGuard LuCI code is possible, and I would actually prefer that if it is acceptable upstream, but it would require making the existing LuCI/rpcd implementation protocol-aware rather than simply adding the AWG options to the WireGuard form. For example, the common code could select Is this roughly the approach the core team had in mind? Also, what do you think about the overall approach of this integration and the way I am trying to keep the AmneziaWG-specific delta small and reviewable? |
|
What is different than in the last PR #26971 and others https://github.com/openwrt/packages/pulls?q=is%3Apr+state%3Aclosed+kmod-amneziawg ? 🤔 |
|
@BKPepe The main difference is that this time I am submitting the complete integration as a coordinated set of three parts:
They are maintained together in one repository, and the OpenWrt package sources are generated from the corresponding WireGuard packages in a staged way. This makes the AmneziaWG-specific delta explicit and easier to review. I also track upstream changes in both WireGuard/OpenWrt and AmneziaWG, so the generated packages can be kept in sync instead of drifting as independent copies. In addition, I use these packages myself, and around 30 other users are currently using them as well. So far we have not encountered any known issues with the integration. So compared to the previous PRs, this is intended as a complete, actively used, and maintainable integration rather than separate one-off package submissions. |
|
Sorry, but from your response I am kinda confused. For LuCI:
For packages repository:
Well, I am not sure how they are maintained in one repository as looking into the PKG_SOURCE_URL, but fine, maybe the AI prompt was not right. Even thought, all previous attempts were complete and actively used as well. |
|
@BKPepe You're right, my previous wording was unclear. By "maintained together in one repository" I did not mean that the upstream source code of the kernel module and tools lives in the same repository. What I meant is that I maintain the OpenWrt integration for all three parts in one repository:
I also did not mean to imply that the previous attempts were incomplete or unused. I understand that there were several complete attempts before. The main difference in my approach is the maintenance model. The OpenWrt packages are generated from the corresponding WireGuard packages in stages, so I can regularly track changes in the OpenWrt WireGuard implementation and keep the AmneziaWG-specific delta small and explicit. For example, the generation process separates:
This makes it easier for me to see what really differs from WireGuard and to update the packages when either OpenWrt WireGuard or AmneziaWG changes. So the difference I was trying to describe is not that this is the first complete or actively used attempt, but rather that I am trying to provide a reproducible maintenance process for keeping all three parts synchronized over time. https://github.com/karen07/amneziawg-openwrt-package https://github.com/karen07/amneziawg-openwrt-package/blob/main/generate.py |
|
@BKPepe Thanks for the clarification. Then I think the most useful question from my side is: what exactly would need to be changed or improved for AmneziaWG support to be acceptable for inclusion in OpenWrt? There have already been several attempts over the years, so I would really like to understand whether there are still concrete technical or maintenance blockers, and what you would prefer to see addressed. I am happy to rework the integration if needed. For example, if the preferred approach for LuCI is to share more code with My goal is not just to submit another version of the same PR, but to understand the upstream expectations and maintain the packages accordingly. This support is also quite important in practice. AmneziaWG is widely used by people in Russia and other places where ordinary WireGuard traffic may be blocked or filtered, so having the packages available directly from the official OpenWrt repositories would make a significant difference for users. If there are specific requirements that would make these packages mergeable, please let me know and I will try to address them. |
| FILES:=$(PKG_BUILD_DIR)/$(MAKE_PATH)/amneziawg.ko | ||
| DEPENDS:= \ | ||
| +kmod-udptunnel4 \ | ||
| +kmod-udptunnel6 \ |
There was a problem hiding this comment.
kmod-udptunnel6 is declared DEPENDS:=@IPV6, so an unconditional dependency makes kmod-amneziawg unselectable on IPv6-disabled builds. Use the conditional form, like kmod-wireguard and kernel/ovpn-dco.
| +kmod-udptunnel6 \ | |
| +IPV6:kmod-udptunnel6 \ |
Generated by Claude Code
There was a problem hiding this comment.
|
|
||
| PKG_BUILD_PARALLEL:=1 | ||
|
|
||
| MAKE_PATH:=src |
There was a problem hiding this comment.
The module is built in $(PKG_BUILD_DIR)/src, but PKG_EXTMOD_SUBDIRS is left at its default ., so collect_module_symvers looks for Module.symvers/modules.order in the build-dir root and stores an empty symvers file for this package. Set it too, the way kernel/ovpn-dco and net/batman-adv do.
| MAKE_PATH:=src | |
| MAKE_PATH:=src | |
| PKG_EXTMOD_SUBDIRS:=src |
Generated by Claude Code
There was a problem hiding this comment.
| +kmod-udptunnel4 \ | ||
| +kmod-udptunnel6 \ | ||
| +kmod-crypto-lib-chacha20poly1305 \ | ||
| +kmod-crypto-lib-curve25519 |
There was a problem hiding this comment.
No AUTOLOAD here, while kmod-wireguard and the other out-of-tree kmods in this feed (kernel/ovpn-dco, net/siit, net/jool) all set one. The v3.1.20260906 sources do carry MODULE_ALIAS_RTNL_LINK / MODULE_ALIAS_GENL_FAMILY, so on-demand probing should work — is omitting AUTOLOAD:=$(call AutoProbe,amneziawg) intentional?
Generated by Claude Code
There was a problem hiding this comment.
| SECTION:=kernel | ||
| CATEGORY:=Kernel modules | ||
| SUBMENU:=Network Support | ||
| TITLE:=AmneziaWG VPN Kernel Module |
There was a problem hiding this comment.
nit: two things on this block:
SECTIONandCATEGORYare already set for everyKernelPackageby kernel.mk.- A
define KernelPackage/<name>metadata block is indented with two spaces rather than tabs; same for theFILES/DEPENDSlines below.
| SECTION:=kernel | |
| CATEGORY:=Kernel modules | |
| SUBMENU:=Network Support | |
| TITLE:=AmneziaWG VPN Kernel Module | |
| SUBMENU:=Network Support | |
| TITLE:=AmneziaWG VPN Kernel Module |
Generated by Claude Code
There was a problem hiding this comment.
| PKG_VERSION:=3.1.20260906 | ||
| PKG_RELEASE:=1 | ||
|
|
||
| PKG_SOURCE_PROTO:=git |
There was a problem hiding this comment.
Optional: PKG_SOURCE_PROTO:=git is meant as a last resort when upstream ships no archives, and upstream tags releases here. The usual form in this feed is a tarball plus PKG_HASH, e.g. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz with PKG_SOURCE_URL:=https://codeload.github.com/amnezia-vpn/amneziawg-linux-kernel-module/tar.gz/v$(PKG_VERSION)?, which also drops PKG_MIRROR_HASH.
Generated by Claude Code
There was a problem hiding this comment.
fixed, thanks — solved with the archive/refs/tags/ + PKG_SOURCE_URL_FILE form rather than codeload, which works equally well.
Generated by Claude Code
| include $(TOPDIR)/rules.mk | ||
| include $(INCLUDE_DIR)/kernel.mk | ||
|
|
||
| PKG_NAME:=kmod-amneziawg |
There was a problem hiding this comment.
nit: no other package in this feed carries a kmod- prefix in PKG_NAME or in its directory name — kernel-module packages are named after the source (kernel/ovpn-dco → ovpn-backports, net/batman-adv, kernel/mdio-netlink). PKG_NAME:=amneziawg still produces the kmod-amneziawg package through $(eval $(call KernelPackage,amneziawg)).
Generated by Claude Code
There was a problem hiding this comment.
fixed, thanks — solved by renaming both PKG_NAME and the directory to amneziawg.
Generated by Claude Code
76e0c31 to
fd6bca0
Compare
fd6bca0 to
dae00d4
Compare
| PKG_SOURCE_URL:=https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/archive/refs/tags/ | ||
| PKG_SOURCE_URL_FILE:=v$(PKG_VERSION).tar.gz | ||
| PKG_HASH:=e32fa46f1b6f9e319c5261f0b0765c3a9261e40cb7c4616fd73500da961a2932 | ||
| PKG_BUILD_DIR:=$(BUILD_DIR)/amneziawg-linux-kernel-module-$(PKG_VERSION) |
There was a problem hiding this comment.
$(BUILD_DIR) is shared by every subtarget of the same arch (ath79/generic and ath79/nand are both mips_24kc), so an out-of-tree module built here is reused against a different kernel and is not removed by make target/linux/clean — which is why kernel.mk defaults kmod build dirs to $(KERNEL_BUILD_DIR). Keep the override under it, as net/jool/Makefile:23 does.
| PKG_BUILD_DIR:=$(BUILD_DIR)/amneziawg-linux-kernel-module-$(PKG_VERSION) | |
| PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/amneziawg-linux-kernel-module-$(PKG_VERSION) |
Generated by Claude Code
There was a problem hiding this comment.
AmneziaWG is a WireGuard-based VPN protocol with additional traffic obfuscation features designed to make VPN traffic harder to identify and block. This package provides the AmneziaWG Linux kernel module for OpenWrt. Signed-off-by: Karen Khachatryan <karen0734@gmail.com>
dae00d4 to
1d67cff
Compare
|
@BKPepe @stangri, I fixed all the issues raised by the @openwrt-ai reviewer. |
AmneziaWG OpenWrt integration — 1/3
This PR adds the
kmod-amneziawgpackage.It is the first part of a complete AmneziaWG integration for OpenWrt:
The related PRs will be linked here once submitted.
Maintenance approach
I maintain the complete integration here:
https://github.com/karen07/amneziawg-openwrt-package
The repository is built around a generator:
https://github.com/karen07/amneziawg-openwrt-package/blob/main/generate.py
The goal is to avoid maintaining a large, manually diverging copy of the
OpenWrt WireGuard integration.
generate.pyis the source of truth for the generated packages.For
amneziawg-toolsandluci-proto-amneziawg, the generator starts fromthe corresponding upstream OpenWrt / LuCI WireGuard packages, performs the
mechanical WireGuard-to-AmneziaWG transformations, and then applies only the
AmneziaWG-specific changes.
For review, the generation process can be stopped at separate stages:
This makes it possible to inspect separately:
This is intended to make both review and future maintenance easier: when the
OpenWrt or LuCI WireGuard integration changes, the AmneziaWG packages can be
regenerated from the new upstream baseline instead of manually rebasing a
large copied implementation.
kmod-amneziawg/Makefileis also generated by the same script from the pinnedAmneziaWG kernel-module version.
The generator is maintenance and review tooling only. The generated package
files are committed to Git, so OpenWrt does not need the generator at build
time.
Upstream tracking
The generator provides:
to check whether a newer AmneziaWG kernel-module or tools release is available.
I currently run this check manually on a regular basis (normally daily).
When a new upstream version appears, the script stops and requires the version
change to be reviewed explicitly before regeneration, rather than silently
updating to an unreviewed upstream revision.
AmneziaWG sources are pinned to official upstream release tags.
Build and testing workflow
The repository contains an OpenWrt SDK build workflow and a GitHub Actions
target/subtarget matrix for building the generated packages across OpenWrt
targets.
The same repository can also build and install the packages directly on an
OpenWrt device for local testing.
I use this AmneziaWG OpenWrt integration myself, so it is maintained as a
working deployment rather than only as a packaging experiment.
Previous submissions
This is a renewed attempt to bring AmneziaWG support to OpenWrt, with a focus
on addressing the long-term maintenance and reviewability concerns raised
around previous submissions.
Related previous work:
kmod-amneziawgamneziawg-toolsThe reproducible generation approach is specifically intended to keep the
WireGuard-derived parts synchronized with OpenWrt/LuCI upstream while keeping
the AmneziaWG-specific changes small and auditable.
PR series
Once all parts are submitted, this section will link the complete series:
kmod-amneziawg— this PRamneziawg-toolsluci-proto-amneziawg— TODO