Linux NFS development
 help / color / mirror / Atom feed
From: Scott Mayhew <smayhew@redhat.com>
To: steved@redhat.com
Cc: jlayton@kernel.org, linux-nfs@vger.kernel.org
Subject: [nfs-utils PATCH 3/3] mountd/exportd: disable netlink when falling back to /proc
Date: Tue,  7 Jul 2026 16:57:52 -0400	[thread overview]
Message-ID: <20260707205752.313031-4-smayhew@redhat.com> (raw)
In-Reply-To: <20260707205752.313031-1-smayhew@redhat.com>

If cache_flush() has to fall back to the /proc interface, then there's a
good chance that the netlink interface isn't going to work, so go ahead
and disable it.

The netlink interface requires CAP_NET_ADMIN, which requires a policy
update on systems running SELinux.  If SELinux blocks mountd from using
the netlink interface and there's no fallback, then mount requests just
hang.

Also, when falling back, close both the sunrpc and the nfsd netlink
sockets.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 support/export/cache.c       | 7 +++++++
 support/export/cache_flush.c | 1 +
 2 files changed, 8 insertions(+)

diff --git a/support/export/cache.c b/support/export/cache.c
index 65008f51..059f48a7 100644
--- a/support/export/cache.c
+++ b/support/export/cache.c
@@ -3072,6 +3072,8 @@ void cache_open(void)
 			 * were queued before we opened the socket.
 			 */
 			auth_reload();
+			if (no_netlink)
+				goto fallback;
 			cache_nl_process_export();
 			cache_nl_process_expkey();
 			cache_nl_process_ip_map();
@@ -3079,11 +3081,16 @@ void cache_open(void)
 				cache_nl_process_unix_gid();
 			return;
 		}
+fallback:
 		xlog(L_NOTICE, "sunrpc netlink family unavailable, falling back to /proc");
 		nl_socket_free(nfsd_nl_notify_sock);
 		nfsd_nl_notify_sock = NULL;
 		nl_socket_free(nfsd_nl_cmd_sock);
 		nfsd_nl_cmd_sock = NULL;
+		nl_socket_free(sunrpc_nl_notify_sock);
+		sunrpc_nl_notify_sock = NULL;
+		nl_socket_free(sunrpc_nl_cmd_sock);
+		sunrpc_nl_cmd_sock = NULL;
 	}
 
 	for (i=0; cachelist[i].cache_name; i++ ) {
diff --git a/support/export/cache_flush.c b/support/export/cache_flush.c
index 2a24dec7..046e6917 100644
--- a/support/export/cache_flush.c
+++ b/support/export/cache_flush.c
@@ -164,5 +164,6 @@ cache_flush(void)
 		return;
 	}
 	/* Fallback: /proc path */
+	no_netlink = 1;
 	cache_proc_flush();
 }
-- 
2.55.0


  parent reply	other threads:[~2026-07-07 20:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 20:57 [nfs-utils PATCH 0/3] mountd netlink fixes Scott Mayhew
2026-07-07 20:57 ` [nfs-utils PATCH 1/3] configure: update check of system netlink headers Scott Mayhew
2026-07-07 20:57 ` [nfs-utils PATCH 2/3] nfs.conf: add no-netlink option to exportd and mountd stanzas Scott Mayhew
2026-07-07 20:57 ` Scott Mayhew [this message]
2026-07-07 21:12 ` [nfs-utils PATCH 0/3] mountd netlink fixes Jeff Layton
2026-07-11 16:19 ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260707205752.313031-4-smayhew@redhat.com \
    --to=smayhew@redhat.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox