Commit Graph

18 Commits

Author SHA1 Message Date
John Audia
ee3b06e42c nfs-kernel-server: provide a NFSv3 and NFSv4 daemon
Summary:

The current build does not produce an NFSV4 capable package. This commit
fixes that providing a v3 and v4 variant to empower users to have either.

Approx. size differences between v3 and v4:

The v4 variant is approximately 16 MiB larger than the v3 variant
due to additional dependencies, kernel modules, etc.[1]

Detailed changes:

1. Split into a v3 and v4 version series of packages. In doing
   this, the build-time V4 options are removed which is a major "win"
   from a user's perspective because it means that for both release and
   for snapshot builds, both options will be available to users of the
   binary hosted packages.

2. Since V3 and V4 require different init processes, we should simplify
   daemon management by providing a single init script unique to each
   variant.

3. Added CPE_ID and PKG_LICENSE and also added myself as the Makefile
   MAINTAINER.

Discussion about the v4 initd script:

It should be noted that mimicking the systemd implementation in an init.d
script with procd was not straight forward. There are some quirks
associated with the interplay of the five executables (listed below)
with procd, but despite of them, the init script works reliably based
on my somewhat extensive testing.

My observations and justification for the script as-is:
1a. procd_set_param command /usr/sbin/nfsdcld cannot be started with an
    appended -F as doing so will somehow cause the executable to never
    connect to the communication pipe: /var/lib/nfs/rpc_pipefs/nfsd/cld.

    In fact, if you run `watch -n 1 tree /var/lib/nfs/rpc_pipefs` while
    calling the init.d script to start, this pipe will quickly disappear
    resulting in nfsdcld being unable to find it and thus fail to track
    clients. On the other hand, starting it as I have in the init.d
    script works as expected.

1b. Starting /usr/sbin/nfsdcld even with the -F arg outside of procd
    also results in the communication pipe quickly disappearing.

2.  Even though rpc.nfsd is a user space util, and even though it runs
    and then exits, it must be started by procd with the procd_set_param
    or else, the communication pipe: /var/lib/nfs/rpc_pipefs/nfsd/cld
    will again quickly disappear breaking client tracking.

3.  The addition of the umountem function keeps syslog output cleaner as
    a shutdown of rpc.idmapd will cause the following to be logged:

    daemon.warn rpc.idmapd[xxxxx]: dirscancb: scandir(/var/lib/nfs/rpc_pipefs//nfs): No such file or directory

    Adding a 1 sec delay allows procd to kill it before we umount the
    nfs related mounts to prevent that warning.

4.  I can find no way to suppress rpc.idmapd and nfsv4.exportd reporting
    that they received a SIGTERM (signal 15). The syslog will contain
    two lines on exit, e.g.:
    daemon.warn rpc.idmapd[1894]: exiting on signal 15
    daemon.notice nfsv4.exportd[1893]: Caught signal 15, exiting.

The result of points 1 and 2 mean that if a users queries the status of
the daemon when running, (ie /etc/init.d/nfsv4d status), it will show:
running (2/4) despite the kernel serving up NFSV4 mounts 100% correctly.

I am unaware of a more perfect approximation of the systemd units.

List of the five needed calls:
* /usr/sbin/nfsv4.exportd (run once then quit)
* /usr/sbin/rpc.idmapd (needs to continue running)
* /usr/sbin/nfsdcld (needs to continue running)
* /usr/sbin/exportfs -r (run once then quit)
* /usr/sbin/rpc.nfsd -N 3 (run once then quit)

1. As assessed by comparing the uncompressed img files from a build of a
   minimal image for x86/64 with the v3 variant vs with the v4.

Both variants have been tested and work.

v3:
On a network node, the NFSV3 export is fully functional:

% mount -t nfs -o vers=3 10.9.8.1:/mnt/data/nfs/misc ok
% mount | grep ok
10.9.8.1:/mnt/data/nfs/misc on /home/facade/ok type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.9.8.1,mountvers=3,mountport=32780,mountproto=udp,local_lock=none,addr=10.9.8.1)

v4:
On a network node, the NFSV4 export is fully functional:

% mount 10.9.8.1:/misc ok
% mount | grep ok
10.9.8.1:/mnt/data/nfs/misc on /home/facade/ok type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.9.8.102,local_lock=none,addr=10.9.8.1)

Finally, added 240-fix-cleanup_lockfiles-function-linkage-in-exportd.patch[1]

1. https://marc.info/?l=linux-nfs&m=175604879721922&w=2

From commit msg therein:
The cleanup_lockfiles function in utils/exportd/exportd.c was declared
as 'inline void' without a proper function prototype, causing linker
errors during the build process:

  exportd.c:(.text+0x5a): undefined reference to `cleanup_lockfiles'
  exportd.c:(.text.startup+0x317): undefined reference to `cleanup_lockfiles'

This occurred because:
1. The inline keyword prevented the compiler from generating a callable
   function symbol in some build configurations
2. The function lacked a proper prototype declaration, triggering
   -Werror=missing-prototypes

The fix changes the function to:
- Remove the 'inline' keyword to ensure symbol generation
- Add a proper static function prototype
- Make the function 'static' since it's only used within exportd.c

This resolves both the linking error and the missing prototype warning,
allowing exportd to build successfully in OpenWrt's cross-compilation
environment.

Co-authored-by: Maxim Storchak <m.storchak@gmail.com>
Co-authored-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: John Audia <therealgraysky@proton.me>
2025-09-27 17:46:14 +01:00
John Audia
b606b58ac2 nfs-kernel-server: fix build
Add nls.mk and patch to avoid the build ending in an error:
In function 'write_table',
    inlined from 'write_tables' at rpc_tblout.c:73:4,
    inlined from 't_output.constprop' at rpc_main.c:841:3:
rpc_tblout.c:91:26: error: '%s' directive writing likely 1 or more bytes into a region of size between 0 and 99 [-Werror=format-overflow=]
   91 |       s_print (progvers, "%s_%s",
      |                          ^
rpc_tblout.c:91:26: note: assuming directive output of 1 byte
In function 'sprintf',
    inlined from 'write_table' at rpc_tblout.c:91:7,
    inlined from 'write_tables' at rpc_tblout.c:73:4,
    inlined from 't_output.constprop' at rpc_main.c:841:3:
/scratch/union/staging_dir/toolchain-x86_64_gcc-15.1.0_glibc/include/bits/stdio2.h:30:10: note: '__builtin___sprintf_chk' output 2 or more bytes (assuming 102) into a destination of size 100
   30 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^
lto1: some warnings being treated as errors
make[6]: *** [/scratch/union/tmp/ccHfYNRX.mk:2: /scratch/union/tmp/ccudJcWZ.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
mold: fatal: lto-wrapper failed

Build system: x86/64
Build-tested: x86/64-glibc
Run-tested: x86/64-glibc

Co-developed-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: John Audia <therealgraysky@proton.me>
2025-08-01 10:05:08 +08:00
John Audia
c851cf35c5 nfs-kernel-server: update to v2.8.3
Update to v2.8.3
Removed upstreamed: 210-patch-for-broken-libnfsimapd-static-and-regex-plugins.patch
Added: 210-nfsdctl.c-add-missing-basename.patch

Build system: x86/64
Build-tested: x86/64
Run-tested: x86/64

Signed-off-by: John Audia <therealgraysky@proton.me>
2025-05-10 09:00:41 +03:00
John Audia
f2030e6256 nfs-kernel-server: update to v2.8.2
Update to latest release and change URL to official upstream mirror.

Removed upstreamed patch: 130-musl-svcgssd-sysconf.patch

Added new patch to correct host build error as we do not build with
gss enabled anyway: 100-fix-host-build.patch

Build system: x86/64
Build-tested: bcm27xx/bcm2712
Run-tested: bcm27xx/bcm2712

Signed-off-by: John Audia <therealgraysky@proton.me>
2025-05-10 09:00:41 +03:00
Oskari Rauta
a1c80c1f37 nfs-kernel-server: update to v2.6.2
Also added patch that is from alpine's same package to assist building on musl.
Hostpkg build on musl also kept failing, so I added few more overrides, which
made it work perfectly.

Signed-off-by: Oskari Rauta <oskari.rauta@gmail.com>
2023-03-01 17:02:42 +08:00
Sergey V. Lobanov
8457944e61 nfs-kernel-server: fix build on macos arm64
1. prctl() check is not required for host-compile on any OS due to prctl
is not used in rpcgen which is only one is compiled during host-compile
phase. prctl() check is disabled via HOST_CONFIGURE_VARS in OpenWrt makefile

2. __DARWIN_ONLY_64_BIT_INO_T is true on macos arm64 so struct stat64
and stat64() are not available. This patch defines stat64 as stat if
__DARWIN_ONLY_64_BIT_INO_T is true

Signed-off-by: Sergey V. Lobanov <sergey@lobanov.in>
2021-12-13 19:57:18 -08:00
Daniel Golle
ded4ab79b2 nfs-kernel-server: move hardcoded /run to /tmp/run
statd currently fails to start due to missing /run which doesn't exist
on OpenWrt.

Add a patch moving /run to /tmp/run as the path is hardcoded in several
places and cannot be configured neither at buildtime nor at runtime.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-11-13 01:11:34 +00:00
Rosen Penev
d09d428c2e nfs-kernel-server: update to 2.5.2
Remove uClibc-ng patch as it was upstreamed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-01-17 15:05:19 -08:00
Javier Marcet
c48bae07be nfs-kernel-server: update to 2.5.1
Signed-off-by: Javier Marcet <javier@marcet.info>
2020-06-29 17:50:31 +02:00
Rosen Penev
732b1c4c0e nfs-kernel-server: Fix compile with uClibc-ng
NS_MAXMSG is not defined.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-06-28 20:12:15 +02:00
Peter Wagner
c01f3bf0ba nfs-kernel-server: update to 2.3.4
Signed-off-by: Peter Wagner <tripolar@gmx.at>
2019-05-12 21:12:55 +02:00
Rosen Penev
46fc281e9e nfs-utils: Fix compilation on some platforms
Added a patch sent upstream.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-04-20 13:17:50 +02:00
Peter Wagner
edbac15a55 nfs-kernel-server: update patches
Signed-off-by: Peter Wagner <tripolar@gmx.at>
2019-02-19 20:14:42 +01:00
Peter Wagner
274ce493eb nfs-kernel-server: fix freeaddrinfo usage in nfs-kernel-server, because freeaddrinfo in musl after the 1.1.21
update, doesn't handly NULL pointers (which seems to spec conform) see
https://www.openwall.com/lists/musl/2019/02/03/3 for more info

Signed-off-by: Peter Wagner <tripolar@gmx.at>
2019-02-17 00:17:03 +01:00
Peter Wagner
274eb1e720 nfs-kernel-server: update to 2.2.1
Signed-off-by: Peter Wagner <tripolar@gmx.at>
2017-11-06 12:21:12 +01:00
Maxim Storchak
ed81839e52 nfs-kernel-server: add workaround for getservbyport
Fixes https://dev.openwrt.org/ticket/20038

Patch is based on http://git.alpinelinux.org/cgit/aports/plain/main/nfs-utils/musl-getservbyport.patch?id=3579df3582b5e5ea53be8cd8eef240f3f0cabb10

Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
2016-06-13 22:57:45 +03:00
Peter Wagner
ad4da82a8e nfs-kernel-server: update to 1.3.1
Signed-off-by: Peter Wagner <tripolar@gmx.at>
2014-10-18 15:34:22 +02:00
Peter Wagner
7fedc0c35b nfs-kernel-server: import from packages
Signed-off-by: Peter Wagner <tripolar@gmx.at>
2014-06-16 11:45:28 +02:00