From nobody Sun May 04 01:07:06 2025 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 4Zqmhq352rz5tyFP; Sun, 04 May 2025 01:07:07 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Zqmhq0xS7z41Xt; Sun, 04 May 2025 01:07:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746320827; 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=cnHH8BcOupeNTHdFvqJNU57nW5mDI6aGgILTUt6qo9s=; b=X1i5bsmwFGfUBWvXNOsVxOVeGhsH4BG7EYpW9b46uz3QR9Ybke2wsrZe5WE2UwO6oTi3Mi vJPqCmSnsdDvvqTeDIJPXXYGsI130jVg9jF6V91Q2mLWnA4HCx7iATsg8DtEb1vczHr7LB 7HlK1lJc0IIEotzyB+4Qdv9XkpmqORlm+bII4CCd7VAQdteU0qEFpBC+ifHlTTtBqssb6J Zz9e6mx5D4G4Zin2FSfIxkSTb6QsueyufyvC8XfvhoCbKBfJNafAgyDA7wzwAFBQ15E9hf /Feu7RnoaX5zoksnDhwWl4yPAAj1miLGt0+VxM8u1NsVz9LNkWWgdopXzJPkLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746320827; 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=cnHH8BcOupeNTHdFvqJNU57nW5mDI6aGgILTUt6qo9s=; b=lY/ss9OVlgCL10LmUf4Fu40LDHnBJjUgAmgH7/j09r450y/PQcUFmHXrB+zXFvfXrTuh1D dHrn8qZ+aq+XZq8nTsug19tr7Ffcq5nqlRtXmUO1tqcdOCnc63GzCDfle2LrYQjHaCCXjL F1xf0AA66FbNHmAodRrRiAJaR4h1ZSHWu81o83yJwqGg2ppEpH6XnjYH9onlQQbTU5xe5m axVDCMD1w/NP3c2w5nmBGM99F0iy7Pb1+F6jRtClp2jaykGuNeQT6BbLqdZOFxvbcBrwTM 9GzCFC4ctF4hJoRFqQpEvLq5nXRKds2k/AsvigYkJikYatj0fV7zotpalNWO0A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746320827; a=rsa-sha256; cv=none; b=K0zMB5g8pdrfFUXyylwFFbhsEHK27ssD+vqNnEO+rXbGwwl8tdxQPk7W/KTkU8gmfsqDTc KGnDkxpqu9zDGZ+iJ81gI8ylKJBlSCPvmmNpkYDIlfwzlEO/QktgzQmIy+ZWk9cAIuDXsC /7WWh4qq3Kt6e7ly+HbSiyWOvtTOnyyz0g9NcKkKddsI3bX6NHfCtOaToYD5/WV/0bpUzg ckx1FgE8WGqRwdHng/rV1ULhH9uRBJ1X/HkixAlEW2SnYTLFPSgOFhqnC5EQiBpfjgSa4T +vRsTtJ7TJt30RYe6ywg1QIXMY/k+EWQJz3OCByhw5mBG25shz1LVKXXhAFu9g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Zqmhq0GMgz16DT; Sun, 04 May 2025 01:07:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 544176HC052953; Sun, 4 May 2025 01:07:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 544176CS052950; Sun, 4 May 2025 01:07:06 GMT (envelope-from git) Date: Sun, 4 May 2025 01:07:06 GMT Message-Id: <202505040107.544176CS052950@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 37abcf06f210 - stable/14 - mountd: Fix updating the network/host(s) for an exports line 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 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 37abcf06f2100eeca41dbd67f8ca8228903ce5e8 Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=37abcf06f2100eeca41dbd67f8ca8228903ce5e8 commit 37abcf06f2100eeca41dbd67f8ca8228903ce5e8 Author: Rick Macklem AuthorDate: 2025-05-01 23:17:20 +0000 Commit: Rick Macklem CommitDate: 2025-05-04 01:04:27 +0000 mountd: Fix updating the network/host(s) for an exports line Mountd reloads the exports(5) file(s) when it receives a SIGHUP and then compares the old and new exports, updating any ones that have changed in the kernel. Without this patch, mountd failed to recognize that a network/host(s) had changed, if there was no other change to the exports line. As such, the change of network/hosts(s) did not take effect until the mountd daemon was (re)started. This patch fixes the code so that it checks for changes in the network/host(s) list for an exports line. PR: 286260 (cherry picked from commit 68daa781c1f12e1cfef768030eaff970c3d35543) --- usr.sbin/mountd/mountd.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index f412adbe741e..62d618069c8b 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -244,6 +244,7 @@ static void free_exports(struct exportlisthead *); static void read_exportfile(int); static int compare_nmount_exportlist(struct iovec *, int, char *); static int compare_export(struct exportlist *, struct exportlist *); +static int compare_addr(struct grouplist *, struct grouplist *); static int compare_cred(struct expcred *, struct expcred *); static int compare_secflavor(int *, int *, int); static void delete_export(struct iovec *, int, struct statfs *, char *); @@ -2350,7 +2351,8 @@ compare_export(struct exportlist *ep, struct exportlist *oep) grp->gr_exflags == ogrp->gr_exflags && compare_cred(&grp->gr_anon, &ogrp->gr_anon) == 0 && compare_secflavor(grp->gr_secflavors, - ogrp->gr_secflavors, grp->gr_numsecflavors) == 0) + ogrp->gr_secflavors, grp->gr_numsecflavors) == 0 && + compare_addr(grp, ogrp) == 0) break; if (ogrp != NULL) ogrp->gr_flag |= GR_FND; @@ -2363,6 +2365,46 @@ compare_export(struct exportlist *ep, struct exportlist *oep) return (0); } +/* + * Compare the addresses in the group. It is safe to return they are not + * the same when the are, so only return they are the same when they are + * exactly the same. + */ +static int +compare_addr(struct grouplist *grp, struct grouplist *ogrp) +{ + struct addrinfo *ai, *oai; + + if (grp->gr_type != ogrp->gr_type) + return (1); + switch (grp->gr_type) { + case GT_HOST: + ai = grp->gr_ptr.gt_addrinfo; + oai = ogrp->gr_ptr.gt_addrinfo; + for (; ai != NULL && oai != NULL; ai = ai->ai_next, + oai = oai->ai_next) { + if (sacmp(ai->ai_addr, oai->ai_addr, NULL) != 0) + return (1); + } + if (ai != NULL || oai != NULL) + return (1); + break; + case GT_NET: + /* First compare the masks and then the nets. */ + if (sacmp((struct sockaddr *)&grp->gr_ptr.gt_net.nt_mask, + (struct sockaddr *)&ogrp->gr_ptr.gt_net.nt_mask, NULL) != 0) + return (1); + if (sacmp((struct sockaddr *)&grp->gr_ptr.gt_net.nt_net, + (struct sockaddr *)&ogrp->gr_ptr.gt_net.nt_net, + (struct sockaddr *)&grp->gr_ptr.gt_net.nt_mask) != 0) + return (1); + break; + default: + return (1); + } + return (0); +} + /* * This algorithm compares two arrays of "n" items. It returns 0 if they are * the "same" and 1 otherwise. Although suboptimal, it is always safe to