Date: Sun, 4 May 2025 01:11:10 GMT From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 70369e4c2c1a - stable/13 - mountd: Fix updating the network/host(s) for an exports line Message-ID: <202505040111.5441BAHw064101@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=70369e4c2c1a882fcf9abf293b305f4f8a0b0c16 commit 70369e4c2c1a882fcf9abf293b305f4f8a0b0c16 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2025-05-01 23:17:20 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2025-05-04 01:08:24 +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 251b36e39d8b..575d1dc69079 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -239,6 +239,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 *); @@ -2298,7 +2299,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; @@ -2311,6 +2313,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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505040111.5441BAHw064101>