From 0ddc58c44d2af863aa3ce9be059af2c657700e02 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 30 Sep 2026 20:44:36 +0000 Subject: [PATCH] 3ds, vita, switch: the built-in SMB client The 3DS, Vita and Switch build smb://: the SMB and Kerberos clients reach the network only through libretro-common's socket helpers, and the crypto they rest on draws on each console's hardware random number generator. The Wii U, whose crypto has only a clock to stir, is left out: SMB derives its signing and sealing keys from that randomness. The 3DS keeps its SMB transfers at 64 KiB, as it does NFS's. The compile matrix builds the SMB client, the Kerberos client and the SMB VFS backend for each of the three under their Makefiles' defines. --- .github/workflows/scripts/compile-matrix.sh | 7 +++++++ CHANGES.md | 1 + Makefile.ctr | 2 ++ Makefile.libnx | 2 ++ Makefile.vita | 2 ++ docs/network-stack.md | 4 ++++ libretro-common/net/net_smb2.c | 6 ++++++ 7 files changed, 24 insertions(+) diff --git a/.github/workflows/scripts/compile-matrix.sh b/.github/workflows/scripts/compile-matrix.sh index e9932ed445..ed05b3e1c9 100755 --- a/.github/workflows/scripts/compile-matrix.sh +++ b/.github/workflows/scripts/compile-matrix.sh @@ -190,6 +190,13 @@ console_set "3ds nfs" "-Itools/platform_stubs/ctr $NFSD" "-D_3DS -DARM11 console_set "vita nfs" "-Itools/platform_stubs/vita $NFSD" "-DVITA -DRARCH_CONSOLE -DHAVE_SOCKET_LEGACY" $NFS_SET console_set "switch nfs" "-I$STUBS/libnx $NFSD" "-DHAVE_LIBNX -DSWITCH -D__SWITCH__ -DRARCH_CONSOLE" $NFS_SET console_set "wiiu nfs" "-Iwiiu/include -Itools/platform_stubs/wiiu $NFSD" "-DWIIU -D__WUT__ -DHW_WUP -D__wiiu__ -DRARCH_CONSOLE" $NFS_SET +# The built-in SMB and Kerberos clients, which the 3DS, Vita and Switch +# build on their crypto (the Wii U has no kernel RNG for it to draw on). +SMB_SET="libretro-common/net/net_smb2.c libretro-common/net/net_krb5.c libretro-common/vfs/vfs_implementation_smb.c" +SMBD="-DHAVE_RETROSMB -DHAVE_SMBCLIENT" +console_set "3ds smb" "-Itools/platform_stubs/ctr $SMBD" "-D_3DS -DARM11 -DRARCH_CONSOLE" $SMB_SET +console_set "vita smb" "-Itools/platform_stubs/vita $SMBD" "-DVITA -DRARCH_CONSOLE -DHAVE_SOCKET_LEGACY" $SMB_SET +console_set "switch smb" "-I$STUBS/libnx $SMBD" "-DHAVE_LIBNX -DSWITCH -D__SWITCH__ -DRARCH_CONSOLE" $SMB_SET # Every platform makefile on Makefile.common, without its toolchain: the # graph's own DEFINES checked for consistency (TLS, SMB, NFS need the diff --git a/CHANGES.md b/CHANGES.md index 7088579e48..dd09439396 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -98,6 +98,7 @@ - NETWORK: Built-in NFSv3 and NFSv4 (4.0, 4.1, 4.2) client for loading content from nfs:// exports - NETWORK: NFS files stay usable across a server restart, a dropped connection or a long pause: the client reconnects and reopens what it needs - 3DS/VITA/SWITCH/WIIU: nfs:// content through the built-in NFS client +- 3DS/VITA/SWITCH: smb:// content through the built-in SMB client - NETWORK: SMB files stay usable across a server restart: the connection is mended and the file opened again where it was - NETWORK: NFSv4.2 reads use READ_PLUS: holes in sparse files no longer cross the network - 3DS/SWITCH: nfs:// content through the built-in NFS client diff --git a/Makefile.ctr b/Makefile.ctr index 7d16765d07..3c7a19e7d5 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -106,6 +106,8 @@ else HAVE_RETROSSL = 1 # the built-in NFS client (nfs://); it needs no crypto HAVE_RETRONFS = 1 + # the built-in SMB client (smb://), on the crypto above + HAVE_RETROSMB = 1 HAVE_CORE_INFO_CACHE = 1 HAVE_CLOUDSYNC = 1 diff --git a/Makefile.libnx b/Makefile.libnx index c809d73a3c..72553e0643 100644 --- a/Makefile.libnx +++ b/Makefile.libnx @@ -64,6 +64,8 @@ HAVE_KEYCHAIN = 1 HAVE_RETROSSL = 1 # The built-in NFS client (nfs://); it needs no crypto. HAVE_RETRONFS = 1 +# The built-in SMB client (smb://), on the crypto above. +HAVE_RETROSMB = 1 # RetroArch libnx useful flags HAVE_THREADS = 1 diff --git a/Makefile.vita b/Makefile.vita index 4f9c1a6b0c..4ce77eb906 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -84,6 +84,8 @@ else HAVE_SOCKET_LEGACY := 1 # the built-in NFS client (nfs://); it needs no crypto HAVE_RETRONFS := 1 + # the built-in SMB client (smb://), on the crypto above + HAVE_RETROSMB := 1 HAVE_MENU := 1 HAVE_MENU_COMMON := 1 HAVE_GFX_WIDGETS := 1 diff --git a/docs/network-stack.md b/docs/network-stack.md index e66f6949d1..e5b3db2968 100644 --- a/docs/network-stack.md +++ b/docs/network-stack.md @@ -65,6 +65,10 @@ other cores have the file copied to local storage first. Changes to these settings apply the next time a share is browsed; content already running keeps its connection. A wired connection is more reliable than Wi-Fi. +Besides the desktop and mobile builds, the 3DS, Vita and Switch carry the +SMB client, on their hardware random number generators. The Wii U does +not: it has no kernel source of randomness for the keys SMB derives. + ## Loading content from NFS exports The NFS client supports NFSv3, which finds the NFS and MOUNT services diff --git a/libretro-common/net/net_smb2.c b/libretro-common/net/net_smb2.c index 866eb865e4..cbaff09904 100644 --- a/libretro-common/net/net_smb2.c +++ b/libretro-common/net/net_smb2.c @@ -78,7 +78,13 @@ * SMB2_LARGE_IO once the server has granted the credits; the * connection's buffers are sized to what it negotiated. */ #define SMB2_MAX_IO (64 * 1024) +/* The 3DS keeps the 64 KiB start: its RAM is small, four connections + * at 1 MiB would hold 8 MiB of buffers, and its Wi-Fi gains nothing. */ +#ifdef _3DS +#define SMB2_LARGE_IO (64 * 1024) +#else #define SMB2_LARGE_IO (1024 * 1024) +#endif #define SMB2_BUF_SIZE(io) (SMB2_TRANSFORM_HDR_SIZE + SMB2_HDR_SIZE + (io) + 4096) #define SMB2_RX_SIZE SMB2_BUF_SIZE(SMB2_MAX_IO)