Re: git: b44cc1b479fe - main - loader: do not try to open directories with TFTP

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Thu, 21 Aug 2025 06:40:27 UTC
On Thu, 21 Aug 2025, A FreeBSD User wrote:

> Am Tage des Herren Wed, 20 Aug 2025 22:48:38 GMT
> "Simon J. Gerraty" <sjg@FreeBSD.org> schrieb:
>
>> The branch main has been updated by sjg:
>>
>> URL: https://cgit.FreeBSD.org/src/commit/?id=b44cc1b479fefc8570611309c3f5a6966fb26e3b
>>
>> commit b44cc1b479fefc8570611309c3f5a6966fb26e3b
>> Author:     Simon J. Gerraty <sjg@FreeBSD.org>
>> AuthorDate: 2025-08-20 22:45:54 +0000
>> Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
>> CommitDate: 2025-08-20 22:45:54 +0000
>>
>>     loader: do not try to open directories with TFTP
>>
>>     Attempting to mount or even open / with some tftp servers
>>     causes a several minute delay in boot.
>>
>>     Since opening a directory via TFTP does not make sense, we
>>     avoid it.  We don't know if using TFTP until after net_open()
>>     has been called.
>>
>>     Add an is_tftp() accessor to avoid everyone having to include
>>     all the net* headers.
>>
>>     Sponsored by:   Juniper Networks, Inc.
>>     Differential Revision:  https://reviews.freebsd.org/D51447
>> ---
>>  stand/common/dev_net.c | 9 ++++++++-
>>  stand/libsa/mount.c    | 5 ++++-
>>  stand/libsa/open.c     | 8 ++++++++
>>  stand/libsa/stand.h    | 3 +++
>>  4 files changed, 23 insertions(+), 2 deletions(-)
>
> Build of world/kernel fails with the error below:
>
> [...]
>
> --- all_subdir_stand/i386 ---
> --- all_subdir_stand/i386/gptzfsboot ---
> ld: error: undefined symbol: is_tftp
>>>> referenced by open.c
>>>>               open.o:(open) in archive /usr/obj/usr/src/amd64.amd64/stand/libsa32/libsa32.a
>>>> referenced by mount.c
>>>>               mount.o:(mount) in archive
>>>> /usr/obj/usr/src/amd64.amd64/stand/libsa32/libsa32.a
> --- all_subdir_usr.sbin ---
> -function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member
> -Qunused-arguments      -c /usr/src/contrib/tcpdump/print-ntp.c -o print-ntp.pieo ---
> all_subdir_stand --- *** [gptzfsboot.out] Error code 1

shot in the dark (haven't checked that LOADER_NET_SUPPORT would be defined for these files):

diff --git stand/libsa/mount.c stand/libsa/mount.c
index c866dc9c7055..4b579c17a782 100644
--- stand/libsa/mount.c
+++ stand/libsa/mount.c
@@ -109,8 +109,10 @@ mount(const char *dev, const char *path, int flags __unused, void *data)
                         continue;
                 DEBUG_PRINTF(1,("%s: fs=%s path=%s\n",
                         __func__, fs->fs_name, path));
+#ifdef LOADER_NET_SUPPORT
                 if (is_tftp())
                         break;
+#endif
                 if (fs->fo_mount(dev, path, &data) != 0)
                         continue;

diff --git stand/libsa/open.c stand/libsa/open.c
index 91848aca7dbe..0e44dc7b0942 100644
--- stand/libsa/open.c
+++ stand/libsa/open.c
@@ -138,8 +138,10 @@ open(const char *fname, int mode)
         struct fs_ops *fs;
         struct open_file *f;
         int fd, i, error, besterror;
+#ifdef LOADER_NET_SUPPORT
         bool is_dir;
         size_t n;
+#endif
         const char *file;

         TSENTER();
@@ -184,14 +186,18 @@ open(const char *fname, int mode)

         /* pass file name to the different filesystem open routines */
         besterror = ENOENT;
+#ifdef LOADER_NET_SUPPORT
         n = strlen(file);
         is_dir = (n > 0 && file[n - 1] == '/');
+#endif
         for (i = 0; file_system[i] != NULL; i++) {
                 fs = file_system[i];
+#ifdef LOADER_NET_SUPPORT
                 if (is_dir && is_tftp()) {
                         error = EOPNOTSUPP;
                         goto err;
                 }
+#endif
                 error = (fs->fo_open)(file, f);
                 if (error == 0)
                         goto ok;


-- 
Bjoern A. Zeeb                                                     r15:7