#4475 assigned task

Add NFSv4 client support to libbsd

Reported by: Chris Johns Owned by: Chris Johns
Priority: normal Milestone: 6.1
Component: network/libbsd Version: 6
Severity: normal Keywords: nfs-v4
Cc: Blocked By:
Blocking:

Description (last modified by Chris Johns)

Add NFSv4 client support to libbsd. The client support is part of kernel and provides support for a range of the NFS protocol version including version 4.

The task is made of the following:

  1. Update the locks and locking to support the lock manager. VFS requires this be supported
  2. Add support for the FreeBSD Virtual File System (VFS)
  3. Add the kernel RPC implementation
  4. Add NFS client support

VFS

VFS is built around the FB's file structure and file descriptor structure. These need to be supported. The file struct and file descriptor form the basis for all fd based interactions with the FB kernel code such as files, devices and sockets.

LibIO and FB fd

The FB fd and file support clashes with the existing libio implementations used for things like socket, kqueue and select. The work to port the VFS requires:

  1. socket, kqueue, select support FB fd support. This is closer to the kernel. No direct libio access
  2. Provide an interface to libio mapping the iop descriptors to FB descriptors.

This approach nests the FB file descriptors inside the libio support. This is not optimal in terms of some activities but the hot paths in the code should not see a significant change in performance. Some paths like open are not optimal because the RTEMS file system op handlers imply a specific implementation that does not match up well with the FB namei interface. The long term approach is to look at libio and the handlers and consider allowing closer integration of FB's fd support.

BIO and Paging

The bio layer is required for VFS. No paging support other than the calls needed to have VFS link are provided. No VM paging is need and none of that code need be ported.

System Calls

Collect all the syscall functionality exported to RTEMS into a single place. Currently the calls are spread around the code and this:

  1. Does not centralize the code
  2. Add a lot of code to FB being ported

Proc0

FreeBSD's initialization creates the initial process called proc0. Add support to create proc0 and let all thread' reference it. This allow the creds to be managed, kernel trace to work and it removes a number of changes that do not need to be made.

File Descripter Reuse

The libio functionality of cycling across the fd range rather than reusing lower fd numbers is not compatible with the select call. Not reusing fd numbers once closed until the range as been used provides some protection against bugs where a user does not cleanly handle the fd they own however this is not compatible with FB and makes supporting select harder.

The select interface should not be used on RTEMS and users should be encourages to use threads for concurrent IO or kqueue. The means select may exist for legacy code porting reasons however the cycling fd count reduces how well the code ported will actually work. For example port a piece of select code, open a socket and use, it may work. Then open and close a file 64 times then run the same code. It will fail.

FB fd's are reused.

RPC

The legacy NFSv2 client the the NFSv4 cannot be built at the same time.

The kernel RPC and the user land RPC cannot exist in the same build. I have not looked extensively into this but I was seeing clashes with headers for the same types but different contents. The legacy NFSv2 client uses the user land RPC code while the kernel NFSv4 uses the kernel's RPC.

Module support is already in libbsd to handle the separate building of each piece.

Security

NFSv4 provides a number of extra security features. The code will be ported is possible but little or no security tested is planned at this point in time.

Testing

The NFSv4 stack will be tested against Linux and FreeBSD servers.

Change History (22)

comment:1 Changed on Jul 20, 2021 at 7:36:52 AM by Chris Johns

Description: modified (diff)

comment:2 Changed on Jul 20, 2021 at 2:51:34 PM by Joel Sherrill

Summary: Add NFSv4 client support to libbdsAdd NFSv4 client support to libbsd

comment:3 Changed on Sep 2, 2021 at 2:43:16 AM by Chris Johns <chrisj@…>

In 59f652fe/rtems-libbsd:

Implement portable kernel symbol namespace tool

  • The script's use of sort proved to not be portable
  • No need to check the commits as symbols are only added
  • Regenerated kernel header to reset the sort order

Update #4475

comment:4 Changed on Sep 2, 2021 at 2:43:19 AM by Chris Johns <chrisj@…>

In f700edc/rtems-libbsd:

waf: Fix clashing symbols in the user land symbols

Update #4475

comment:5 Changed on Sep 2, 2021 at 2:43:21 AM by Chris Johns <chrisj@…>

In 5ef23a2/rtems-libbsd:

sys/netinet/libalias: Fix symbols clashes

Update #4475

comment:6 Changed on Sep 2, 2021 at 2:43:24 AM by Chris Johns <chrisj@…>

In 974742d/rtems-libbsd:

kern-symbols: Add symbols from the everything build set

Update #4475

comment:7 Changed on Sep 2, 2021 at 2:43:27 AM by Chris Johns <chrisj@…>

In 684cf3c/rtems-libbsd:

rtemsbsd: Add FrreBSD's clang-format style

Update #4475

comment:8 Changed on Sep 2, 2021 at 2:43:29 AM by Chris Johns <chrisj@…>

In 2a01430/rtems-libbsd:

rtemsbsd: Catch timeout overflows

Update #4475

comment:9 Changed on Sep 2, 2021 at 2:43:32 AM by Chris Johns <chrisj@…>

In e1ca99b/rtems-libbsd:

testsuite: Optionally allow all command in a shell

Update #4475

comment:10 Changed on Sep 2, 2021 at 2:43:35 AM by Chris Johns <chrisj@…>

In 46a15fa/rtems-libbsd:

sys/kern: Add lockmgr support

  • See man lockmgr
  • Implement the lock_object and move the RTEMS mutex to that object
  • Add debug support to track the locks with gdb

Update #4475

comment:11 Changed on Sep 2, 2021 at 2:43:38 AM by Chris Johns <chrisj@…>

In 761fd693/rtems-libbsd:

kern: Import kern_prot.c fnd kern_resource.c for proc0

Update #4475

comment:12 Changed on Sep 2, 2021 at 2:43:40 AM by Chris Johns <chrisj@…>

In c7427fc/rtems-libbsd:

kern: Add a proc0

  • Provides the thread's proc pointer and with that access to creds

Update #4475

comment:13 Changed on Sep 2, 2021 at 2:43:43 AM by Chris Johns <chrisj@…>

In 9800a0f/rtems-libbsd:

kern: Import kern_ktr.c

Update #4475

comment:14 Changed on Sep 2, 2021 at 2:43:46 AM by Chris Johns <chrisj@…>

In e56b5cb/rtems-libbsd:

kern: Add kernel trace support (KTR)

Update #4475

comment:15 Changed on Sep 2, 2021 at 2:43:48 AM by Chris Johns <chrisj@…>

In 1739d74/rtems-libbsd:

freebsd/sys: Import VFS support

Update #4475

comment:16 Changed on Sep 2, 2021 at 2:43:51 AM by Chris Johns <chrisj@…>

In ac4db4c/rtems-libbsd:

rtemsbsd: Remove DHCP init wrapper

  • Object files cannot config init and resided in libbsd.a

Update #4475

comment:17 Changed on Sep 2, 2021 at 2:43:53 AM by Chris Johns <chrisj@…>

In 6514d56/rtems-libbsd:

sys/kern: Add VFS support

  • Refactor the libio interface
  • Move syscalls into an rtemsbsd location
  • Provide a root directory mount point

Update #4475

comment:18 Changed on Sep 2, 2021 at 2:43:56 AM by Chris Johns <chrisj@…>

In 3da45ae/rtems-libbsd:

freebsd/sys: Import RPC and XDR support

Update #4475

comment:19 Changed on Sep 2, 2021 at 2:43:59 AM by Chris Johns <chrisj@…>

In c6dbc96/rtems-libbsd:

kern/sys: Add the kernel RPC and XDR support

Updates #4475

comment:20 Changed on Sep 2, 2021 at 2:44:01 AM by Chris Johns <chrisj@…>

In 6138f24/rtems-libbsd:

kern/sys: Import NFS and NFS file system client

Update #4475

comment:21 Changed on Sep 2, 2021 at 2:44:04 AM by Chris Johns <chrisj@…>

In 882425f/rtems-libbsd:

kern/sys: Add NFSv4 client

Update #4475

comment:22 Changed on Sep 2, 2021 at 2:44:07 AM by Chris Johns <chrisj@…>

In 7e282d2/rtems-libbsd:

rtemsbsd/nfs: Add support to mount NFSv2

  • NFSv2 requires userland RPC calls to determine the version of NFS and the FH. This is passed to the kernel.
  • Port more libc/rpc.

Update #4475

Note: See TracTickets for help on using tickets.