[PR #180] Replace deprecated functions with alternatives #222

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

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/180
Author: @paveloom
Created: 7/1/2026
Status: 🔄 Open

Base: master ← Head: deprecated-functions


📝 Commits (2)

  • 70e7215 Replace prandom_bytes with get_random_bytes
  • 0eeee91 Replace prandom_u32_max with get_random_u32_below

📊 Changes

1 file changed (+18 additions, -18 deletions)

View changed files

📝 src/selftest/allowedips.c (+18 -18)

📄 Description

This PR replaces the following deprecated functions:

This fixes the build with CONFIG_AMNEZIAWG_DEBUG=y that is currently broken for Linux kernel versions >= 6.1:

  /usr/bin/x86_64-pc-linux-gnu-gcc-16 -Wp,-MMD,./.allowedips.o.d -nostdinc -DCOMPAT_VERSION=7 -DCOMPAT_PATCHLEVEL=0 -DCOMPAT_SUBLEVEL=13 -I././compat/version -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include/generated -I/usr/src/linux-7.0.13-gentoo-dist/include -I/usr/src/linux-7.0.13-gentoo-dist/include -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include/uapi -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include/generated/uapi -I/usr/src/linux-7.0.13-gentoo-dist/include/uapi -I/usr/src/linux-7.0.13-gentoo-dist/include/generated/uapi -include /usr/src/linux-7.0.13-gentoo-dist/include/linux/compiler-version.h -include /usr/src/linux-7.0.13-gentoo-dist/include/linux/kconfig.h -include /usr/src/linux-7.0.13-gentoo-dist/include/linux/compiler_types.h -D__KERNEL__ -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -fno-inline-functions-called-once -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fms-extensions -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -g -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt' -Wframe-larger-than=2048 -DDEBUG -g -D'WIREGUARD_VERSION="1.0.0"' -include ././compat/compat.h -I././compat/simd/include -DHZ_TO_USEC_NUM=10000 -DHZ_TO_USEC_DEN=3 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_BMI2=1 -DCONFIG_AS_ADX=1  -fsanitize=bounds-strict -fsanitize=shift    -DMODULE  -DKBUILD_BASENAME='"allowedips"' -DKBUILD_MODNAME='"amneziawg"' -D__KBUILD_MODNAME=amneziawg -c -o allowedips.o allowedips.c  
In file included from allowedips.c:429:
selftest/allowedips.c: In function ‘randomized_test’:
selftest/allowedips.c:287:17: error: implicit declaration of function ‘prandom_bytes’; did you mean ‘get_random_bytes’? [-Wimplicit-function-declaration]
  287 |                 prandom_bytes(ip, 4);
      |                 ^~~~~~~~~~~~~
      |                 get_random_bytes
selftest/allowedips.c:288:24: error: implicit declaration of function ‘prandom_u32_max’ [-Wimplicit-function-declaration]
  288 |                 cidr = prandom_u32_max(32) + 1;
      |                        ^~~~~~~~~~~~~~~
make[4]: *** [/usr/src/linux-7.0.13-gentoo-dist/scripts/Makefile.build:289: allowedips.o] Error 1

This is in response to a downstream Gentoo bug.


🔄 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/180 **Author:** [@paveloom](https://github.com/paveloom) **Created:** 7/1/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `deprecated-functions` --- ### 📝 Commits (2) - [`70e7215`](https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/commit/70e7215fdd6ea208dfeaad00ecdc70e847ace7f6) Replace `prandom_bytes` with `get_random_bytes` - [`0eeee91`](https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/commit/0eeee91a80df90500b9bf7f133eb260872510e7f) Replace `prandom_u32_max` with `get_random_u32_below` ### 📊 Changes **1 file changed** (+18 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/selftest/allowedips.c` (+18 -18) </details> ### 📄 Description This PR replaces the following deprecated functions: - `prandom_bytes` with `get_random_bytes` - See https://github.com/torvalds/linux/commit/d4150779e60fb6c49be25572596b2cdfc5d46a09 and https://github.com/torvalds/linux/commit/197173db990cad244221ba73c43b1df6170ae278 - `prandom_u32_max` with `get_random_u32_below` - See https://github.com/torvalds/linux/commit/3c202d14a9d73fb63c3dccb18feac5618c21e1c4 This fixes the build with `CONFIG_AMNEZIAWG_DEBUG=y` that is currently broken for Linux kernel versions >= 6.1: ``` /usr/bin/x86_64-pc-linux-gnu-gcc-16 -Wp,-MMD,./.allowedips.o.d -nostdinc -DCOMPAT_VERSION=7 -DCOMPAT_PATCHLEVEL=0 -DCOMPAT_SUBLEVEL=13 -I././compat/version -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include/generated -I/usr/src/linux-7.0.13-gentoo-dist/include -I/usr/src/linux-7.0.13-gentoo-dist/include -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include/uapi -I/usr/src/linux-7.0.13-gentoo-dist/arch/x86/include/generated/uapi -I/usr/src/linux-7.0.13-gentoo-dist/include/uapi -I/usr/src/linux-7.0.13-gentoo-dist/include/generated/uapi -include /usr/src/linux-7.0.13-gentoo-dist/include/linux/compiler-version.h -include /usr/src/linux-7.0.13-gentoo-dist/include/linux/kconfig.h -include /usr/src/linux-7.0.13-gentoo-dist/include/linux/compiler_types.h -D__KERNEL__ -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -fno-inline-functions-called-once -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fms-extensions -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -g -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt' -Wframe-larger-than=2048 -DDEBUG -g -D'WIREGUARD_VERSION="1.0.0"' -include ././compat/compat.h -I././compat/simd/include -DHZ_TO_USEC_NUM=10000 -DHZ_TO_USEC_DEN=3 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_BMI2=1 -DCONFIG_AS_ADX=1 -fsanitize=bounds-strict -fsanitize=shift -DMODULE -DKBUILD_BASENAME='"allowedips"' -DKBUILD_MODNAME='"amneziawg"' -D__KBUILD_MODNAME=amneziawg -c -o allowedips.o allowedips.c In file included from allowedips.c:429: selftest/allowedips.c: In function ‘randomized_test’: selftest/allowedips.c:287:17: error: implicit declaration of function ‘prandom_bytes’; did you mean ‘get_random_bytes’? [-Wimplicit-function-declaration] 287 | prandom_bytes(ip, 4); | ^~~~~~~~~~~~~ | get_random_bytes selftest/allowedips.c:288:24: error: implicit declaration of function ‘prandom_u32_max’ [-Wimplicit-function-declaration] 288 | cidr = prandom_u32_max(32) + 1; | ^~~~~~~~~~~~~~~ make[4]: *** [/usr/src/linux-7.0.13-gentoo-dist/scripts/Makefile.build:289: allowedips.o] Error 1 ``` This is in response to a [downstream Gentoo bug](https://bugs.gentoo.org/978340). --- <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#222
No description provided.