Page MenuHomeFreeBSD

nfs: skip bootpc when vfs.root.mountfrom is other than nfs
ClosedPublic

Authored by alfredo on Apr 29 2022, 9:22 PM.
Referenced Files
F82236652: D35098.id.diff
Fri, Apr 26, 8:13 PM
Unknown Object (File)
Tue, Apr 23, 11:40 AM
Unknown Object (File)
Mar 17 2024, 12:58 AM
Unknown Object (File)
Mar 17 2024, 12:57 AM
Unknown Object (File)
Mar 17 2024, 12:54 AM
Unknown Object (File)
Mar 14 2024, 8:02 AM
Unknown Object (File)
Mar 14 2024, 7:57 AM
Unknown Object (File)
Jan 17 2024, 3:21 PM

Details

Summary

If "vfs.root.mountfrom" is set and the value is something other
than "nfs:*", it means the user doesn't want to mount root via nfs,
there's no reason to continue with bootpc

The powerpcspe kernel (MPC85XXSPE), compiled with BOOTP_NFSROOT
by default, gets stuck on bootpc/dhcp request loop when no DHCP
server is available on the network, even when user specifies a
local disk via "vfs.root.mountfrom" kernel parameter.

MFC after: 2 weeks
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)

Test Plan

test powerpcspe kernel under QEMU:

with "vfs.root.mountfrom" set to NFS
with "vfs.root.mountfrom" set to local partition (virtio-scsi)
without "vfs.root.mountfrom" and DHCP server on network
without "vfs.root.mountfrom" and without DHCP server on network

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

alfredo added a reviewer: rmacklem.
alfredo added a project: PowerPC.
sjg added inline comments.
sys/nfs/bootp_subr.c
1537

Where might nfs: appear if not at the start of the string?

Beyond changing strstr() to a check for "nfs:" at the beginning of the
string, as suggested by sjg@, I don't see a problem with this.

However, I do not do diskless booting or know anything about
how vfs.root.mountroot is used, so I do not feel qualified to
review this. Maybe sjg@ could do so?

use strncmp instead of strstr in order to match only the beginning of the string

updated, thanks!

@rmacklem, 'vfs.root.mountroot' is used as a kernel parameter to specify (or override) where is the root filesystem to be mounted and its partition type. It's usually something like "vfs.root.mountroot=ufs:/dev/da0s1a" if you use a local disk, or "vfs.root.mountroot=nfs:192.168.0.1:/tftpboot/root" if using nfs.

It really needs someone familiar with bootstrapping to review this.
(Except for being the nfs case, it really has nothing to do with nfs.)

I think this is fine as is.
There's no need to check for nfs in the middle of a string, unless there's some use case I'm unaware of...

sys/nfs/bootp_subr.c
1537

I'm agnostic on strncmp vs strstr. What would be fore nfs:?

This revision is now accepted and ready to land.May 30 2022, 6:27 PM
alfredo added inline comments.
sys/nfs/bootp_subr.c
1537

yes, it's expected to have "nfs:" right in the beginning. thanks!