From nobody Sun May 3 23:27:37 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g81Cg2pslz6cN8J for ; Sun, 03 May 2026 23:27:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g81Cf5xwHz3dY2 for ; Sun, 03 May 2026 23:27:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777850862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lXCQaoDKOUJwaO+3Qh9nifXeKQTY/u8JW2uDQDOS6ag=; b=mR8KCEPz/tNdyvVDS47O5p539m+0MhO+jt+LGDY/wfpFW6FNZtp7R2tHh4NWfQHukmK9E4 pwRJ7LiZIbmeIzHJQdKSoCmAS5Ncaos7osiFUV5OJBEiCgwUfuT2GRuCwLAtfsuXh75Hfm gT3PVXFtGqXeXTvvdZO4B84ScbJN51Zk/HQ7b4QNBJdhsjzirrzqm5WpjV0Pal5xNi10Qd 4GyDVt9bGRxn+8vgS2l6q87aKnoi08KL97x5MWqNous6eRkBfqOIHdl7rj9a3tG9JpLEkM Sb0OyecSLIpFQ1jAb33p6LPsOgWUreLVtiVPMahauKmunAxOtRgRTzl7rqP3kQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777850862; a=rsa-sha256; cv=none; b=CVapzDKmSSgGsq1vwB9MR/Y/dljSoQ6nhvA9jOaIFdWjALS4Q/VN0XtKZXugvGKl1EJXpP SQBgVlvqVmb5JmHciuDsBWO21mv7yMyE0Ohc1FpxqtB+Bm8MckRviY5NaKaSS7eBHytMFN X6m2TZCoz/Ws5xCKZH84EsSy4u+7scfE9Lxw69sqP/yQaMGqKIGuKYxDF6L7z6ITCBcv03 3D91P3FN7/Y/eq8dWTmhzZ2uN8YsdOPdeDPljT8U315JbsXWWS6rPAOsHMWIgNqM/5I8NO 8QnQqXt3vXWgAlLhVxM9RocD/s7tRr1zdRK/Mqz2Zeb2MeSrpvHaHsLAO7S7Cw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777850862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lXCQaoDKOUJwaO+3Qh9nifXeKQTY/u8JW2uDQDOS6ag=; b=CL3FGTSAIJiWj2G6JpyIs5kn+JMgN6Vq5vexghjE4DySP16S5FIHD1BDrwiPeESIWfKnTb jnN19RB3Jkz4cG3Ubyxb4ebRP75276eZwawPgU8QH05f+TFdxS81cZGevuJkE2dhlgDWoF 6v26ss9wIbRiotl3mwlNnMrthRogwzim7J6NREuf2PE4kmXiBqWIrfAENaYftfyLuYHoS5 9nexyH0hFeXKBTFKJ2iRAlfbbuzFA+fZlVsaFldoYkQUBS8KUczH3ko9X/PQC1HlV3Z6ks 1uVaMuqQFh38HHqjtRbGFAa0JZhsxcIVjcIb38N1z6HbTOInD/L0FvbJPH2JBg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g81Cf2L0WztcM for ; Sun, 03 May 2026 23:27:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2677a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 03 May 2026 23:27:37 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 457c621add0a - main - nfsd: Disable use of callbacks for NFSv4.0 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 457c621add0a531273ee27798c924c6aaeacc4c1 Auto-Submitted: auto-generated Date: Sun, 03 May 2026 23:27:37 +0000 Message-Id: <69f7d9e9.2677a.243bc206@gitrepo.freebsd.org> The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=457c621add0a531273ee27798c924c6aaeacc4c1 commit 457c621add0a531273ee27798c924c6aaeacc4c1 Author: Rick Macklem AuthorDate: 2026-05-03 23:25:45 +0000 Commit: Rick Macklem CommitDate: 2026-05-03 23:25:45 +0000 nfsd: Disable use of callbacks for NFSv4.0 Commit 71ac1ec5c9d9 disabled callbacks for the NFS client for NFSv4.0. This patch does the same for the NFSv4.0 server. The only use for callbacks for NFSv4.0 is delegations and delegations rarely work well for NFSv4.0 anyhow. Therefore, this patch disables callbacks for the NFSv4.0 server. This is the same behavior as occurs when vfs.nfsd.issue_delegations is 0. This change allowed the functions called nfsrv_getclientipaddr() and nfsrv_getipnumber() to be removed from the kernel. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdstate.c | 269 +++++---------------------------------- 1 file changed, 31 insertions(+), 238 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 4f4aff342872..22e702b001c0 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -165,7 +165,6 @@ static void nfsrv_insertlock(struct nfslock *new_lop, struct nfslock *insert_lop, struct nfsstate *stp, struct nfslockfile *lfp); static void nfsrv_updatelock(struct nfsstate *stp, struct nfslock **new_lopp, struct nfslock **other_lopp, struct nfslockfile *lfp); -static int nfsrv_getipnumber(u_char *cp); static int nfsrv_checkrestart(nfsquad_t clientid, u_int32_t flags, nfsv4stateid_t *stateidp, int specialid); static int nfsrv_checkgrace(struct nfsrv_descript *nd, struct nfsclient *clp, @@ -4079,279 +4078,73 @@ out: } /* - * Get the client ip address for callbacks. If the strings can't be parsed, - * just set lc_program to 0 to indicate no callbacks are possible. - * (For cases where the address can't be parsed or is 0.0.0.0.0.0, set - * the address to the client's transport address. This won't be used - * for callbacks, but can be printed out by nfsstats for info.) + * Just set lc_program to 0 to indicate no callbacks are possible. + * Set the address to the client's transport address. This won't be used + * for callbacks, but can be printed out by nfsstats for info. * Return error if the xdr can't be parsed, 0 otherwise. */ int nfsrv_getclientipaddr(struct nfsrv_descript *nd, struct nfsclient *clp) { - u_int32_t *tl; - u_char *cp, *cp2; - int i, j, maxalen = 0, minalen = 0; - sa_family_t af; + uint32_t *tl; + int error = 0, i; #ifdef INET - struct sockaddr_in *rin = NULL, *sin; + struct sockaddr_in *rin, *sin; #endif #ifdef INET6 - struct sockaddr_in6 *rin6 = NULL, *sin6; -#endif - u_char *addr; - int error = 0, cantparse = 0; -#ifdef INET - union { - in_addr_t ival; - u_char cval[4]; - } ip; -#endif -#if defined(INET6) || defined(INET) - union { - in_port_t sval; - u_char cval[2]; - } port; + struct sockaddr_in6 *rin6, *sin6; #endif - /* 8 is the maximum length of the port# string. */ - addr = malloc(INET6_ADDRSTRLEN + 8, M_TEMP, M_WAITOK); clp->lc_req.nr_client = NULL; clp->lc_req.nr_lock = 0; - af = AF_UNSPEC; - NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); + NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED); i = fxdr_unsigned(int, *tl); - if (i >= 3 && i <= 4) { - error = nfsrv_mtostr(nd, addr, i); + if (i < 0) { + error = NFSERR_BADXDR; + goto nfsmout; + } else if (i > 0) { + error = nfsm_advance(nd, NFSM_RNDUP(i), -1); if (error) goto nfsmout; -#ifdef INET - if (!strcmp(addr, "tcp")) { - clp->lc_flags |= LCL_TCPCALLBACK; - clp->lc_req.nr_sotype = SOCK_STREAM; - clp->lc_req.nr_soproto = IPPROTO_TCP; - af = AF_INET; - } else if (!strcmp(addr, "udp")) { - clp->lc_req.nr_sotype = SOCK_DGRAM; - clp->lc_req.nr_soproto = IPPROTO_UDP; - af = AF_INET; - } -#endif -#ifdef INET6 - if (af == AF_UNSPEC) { - if (!strcmp(addr, "tcp6")) { - clp->lc_flags |= LCL_TCPCALLBACK; - clp->lc_req.nr_sotype = SOCK_STREAM; - clp->lc_req.nr_soproto = IPPROTO_TCP; - af = AF_INET6; - } else if (!strcmp(addr, "udp6")) { - clp->lc_req.nr_sotype = SOCK_DGRAM; - clp->lc_req.nr_soproto = IPPROTO_UDP; - af = AF_INET6; - } - } -#endif - if (af == AF_UNSPEC) { - cantparse = 1; - } - } else { - cantparse = 1; - if (i > 0) { - error = nfsm_advance(nd, NFSM_RNDUP(i), -1); - if (error) - goto nfsmout; - } } - /* - * The caller has allocated clp->lc_req.nr_nam to be large enough - * for either AF_INET or AF_INET6 and zeroed out the contents. - * maxalen is set to the maximum length of the host IP address string - * plus 8 for the maximum length of the port#. - * minalen is set to the minimum length of the host IP address string - * plus 4 for the minimum length of the port#. - * These lengths do not include NULL termination, - * so INET[6]_ADDRSTRLEN - 1 is used in the calculations. - */ - switch (af) { + NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED); + i = fxdr_unsigned(int, *tl); + if (i < 0) { + error = NFSERR_BADXDR; + goto nfsmout; + } else if (i > 0) { + error = nfsm_advance(nd, NFSM_RNDUP(i), -1); + if (error) + goto nfsmout; + } + switch (nd->nd_nam->sa_family) { #ifdef INET case AF_INET: + sin = (struct sockaddr_in *)nd->nd_nam; rin = (struct sockaddr_in *)clp->lc_req.nr_nam; rin->sin_family = AF_INET; rin->sin_len = sizeof(struct sockaddr_in); - maxalen = INET_ADDRSTRLEN - 1 + 8; - minalen = 7 + 4; + rin->sin_addr.s_addr = sin->sin_addr.s_addr; + rin->sin_port = 0x0; break; #endif #ifdef INET6 case AF_INET6: + sin6 = (struct sockaddr_in6 *)nd->nd_nam; rin6 = (struct sockaddr_in6 *)clp->lc_req.nr_nam; rin6->sin6_family = AF_INET6; rin6->sin6_len = sizeof(struct sockaddr_in6); - maxalen = INET6_ADDRSTRLEN - 1 + 8; - minalen = 3 + 4; + rin6->sin6_addr = sin6->sin6_addr; + rin6->sin6_port = 0x0; break; #endif } - NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); - i = fxdr_unsigned(int, *tl); - if (i < 0) { - error = NFSERR_BADXDR; - goto nfsmout; - } else if (i == 0) { - cantparse = 1; - } else if (!cantparse && i <= maxalen && i >= minalen) { - error = nfsrv_mtostr(nd, addr, i); - if (error) - goto nfsmout; - - /* - * Parse out the address fields. We expect 6 decimal numbers - * separated by '.'s for AF_INET and two decimal numbers - * preceded by '.'s for AF_INET6. - */ - cp = NULL; - switch (af) { -#ifdef INET6 - /* - * For AF_INET6, first parse the host address. - */ - case AF_INET6: - cp = strchr(addr, '.'); - if (cp != NULL) { - *cp++ = '\0'; - if (inet_pton(af, addr, &rin6->sin6_addr) == 1) - i = 4; - else { - cp = NULL; - cantparse = 1; - } - } - break; -#endif -#ifdef INET - case AF_INET: - cp = addr; - i = 0; - break; -#endif - } - while (cp != NULL && *cp && i < 6) { - cp2 = cp; - while (*cp2 && *cp2 != '.') - cp2++; - if (*cp2) - *cp2++ = '\0'; - else if (i != 5) { - cantparse = 1; - break; - } - j = nfsrv_getipnumber(cp); - if (j >= 0) { - if (i < 4) -#ifdef INET - ip.cval[3 - i] = j; -#else - ; -#endif -#if defined(INET6) || defined(INET) - else - port.cval[5 - i] = j; -#endif - } else { - cantparse = 1; - break; - } - cp = cp2; - i++; - } - if (!cantparse) { - /* - * The host address INADDR_ANY is (mis)used to indicate - * "there is no valid callback address". - */ - switch (af) { -#ifdef INET6 - case AF_INET6: - if (!IN6_ARE_ADDR_EQUAL(&rin6->sin6_addr, - &in6addr_any)) - rin6->sin6_port = htons(port.sval); - else - cantparse = 1; - break; -#endif -#ifdef INET - case AF_INET: - if (ip.ival != INADDR_ANY) { - rin->sin_addr.s_addr = htonl(ip.ival); - rin->sin_port = htons(port.sval); - } else { - cantparse = 1; - } - break; -#endif - } - } - } else { - cantparse = 1; - if (i > 0) { - error = nfsm_advance(nd, NFSM_RNDUP(i), -1); - if (error) - goto nfsmout; - } - } - if (cantparse) { - switch (nd->nd_nam->sa_family) { -#ifdef INET - case AF_INET: - sin = (struct sockaddr_in *)nd->nd_nam; - rin = (struct sockaddr_in *)clp->lc_req.nr_nam; - rin->sin_family = AF_INET; - rin->sin_len = sizeof(struct sockaddr_in); - rin->sin_addr.s_addr = sin->sin_addr.s_addr; - rin->sin_port = 0x0; - break; -#endif -#ifdef INET6 - case AF_INET6: - sin6 = (struct sockaddr_in6 *)nd->nd_nam; - rin6 = (struct sockaddr_in6 *)clp->lc_req.nr_nam; - rin6->sin6_family = AF_INET6; - rin6->sin6_len = sizeof(struct sockaddr_in6); - rin6->sin6_addr = sin6->sin6_addr; - rin6->sin6_port = 0x0; - break; -#endif - } - clp->lc_program = 0; - } + clp->lc_program = 0; nfsmout: - free(addr, M_TEMP); NFSEXITCODE2(error, nd); return (error); } -/* - * Turn a string of up to three decimal digits into a number. Return -1 upon - * error. - */ -static int -nfsrv_getipnumber(u_char *cp) -{ - int i = 0, j = 0; - - while (*cp) { - if (j > 2 || *cp < '0' || *cp > '9') - return (-1); - i *= 10; - i += (*cp - '0'); - cp++; - j++; - } - if (i < 256) - return (i); - return (-1); -} - /* * This function checks for restart conditions. */