Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796136585; b=Ay2XzC6rU0QUtyevy+Dd2iW/l/Ma5ZJP8zRUGI3Mxx5lIKiBPhcZo851j8WTqnSKWtKy ++3O+sPtrgSTMYNYcJI/NjHQwe5qXW2gOK6dWT+PUbEA/HoEyGpN65b/zMLnlTTdgG03W Ofmig16vX48JMF0pMp1lIUjknh0VgVnYmuQGUtgVT3l0w1A2md18OcfrErTTa/leH94d2 Lt0WvLwJqgyKdRsA8QqruGRumhbzX8A3q3XT6KseKng/73h8v2mdwnobHU2Kb8pgrY1eP o3kN7tjYQKxtnP9ZSjyeJeJoHYaxPqxuLAmy3e8DQkamMZrd0j9vEGHFoHZBF9j6suA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796136585; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Received:From:To:Cc:Subject: Date:Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=asNA97wMFfO/75eiJrcc/ktwrakicnnA7UHSeVP/cg4=; b=lnyeAtP7OR9XeM2B6mzm8xITw7SoAJNG4RD2K7SAuGOXjbioyTPg2SyGtM8ClHLdUfti 1Dw7Iy+ORBYVigfb/wrB3T9WSmB/0bXr73/t8triaQtlQ2bXdl6Wo+3qCsruPP+Sqvzu3 KKMcw21RHQgKuGi7KwRIDeqOhk+jRjEU3f+VrWe8bpRgGNBcEF92EX3EpDQ3oRQC5Sk9A FtbXJC4iSOkHdSpyzKtu8e1Vb8hOQsre2Ey1F8kq8oJJkKheOM7K3mp1tqnmeX8koGZxb IasTZAgUxN/AG36/oHPAVtnDI8KaiHFEyoDxPRRwBN7KuCoQ2gTPBWTVvOwp96pQi7g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=azJJ4egP; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1A7D606A32D for ; Tue, 1 Dec 2026 14:49:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A1A7D606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=azJJ4egP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796136584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=asNA97wMFfO/75eiJrcc/ktwrakicnnA7UHSeVP/cg4=; b=azJJ4egPDeENlkUhPtGVgHg2RJc8EN7mSe3lD3QJZdckI0hrtpdW3zf0tD0K4bE1hdZlXo 9LmxYcDQ0ws++Ow9qss59mMnhiv2rCkD7bzQWcDbzI+GuPVlcVTx2gJ71R1WWDe4FxKp9P f9kWha04NFRXljochsdPJK4LEpaKCE8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-J4rkgPACP0SYRNdcpfFLGw-1; Tue, 1 Dec 2026 14:49:40 +0000 X-MC-Unique: J4rkgPACP0SYRNdcpfFLGw-1 X-Mimecast-MFC-AGG-ID: J4rkgPACP0SYRNdcpfFLGw_1796136578 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6B1DB19773C9; Tue, 1 Dec 2026 14:49:38 +0000 (UTC) Received: from smayhew-thinkpadp1gen4i.remote.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1E70130002F8; Tue, 1 Dec 2026 14:49:38 +0000 (UTC) Received: from smayhew-thinkpadp1gen4i.redhat.corp (localhost [IPv6:::1]) by smayhew-thinkpadp1gen4i.remote.csb (Postfix) with ESMTP id 246B45D1DBD9; Tue, 01 Dec 2026 09:49:31 -0500 (EST) From: Scott Mayhew To: steved@redhat.com Cc: jlayton@kernel.org, linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH 5/6] sm-notify: fix multihomed address rotation and first-attempt address choice Date: Tue, 1 Dec 2026 09:49:29 -0500 Message-ID: <20261201144930.369297-6-smayhew@redhat.com> In-Reply-To: <20261201144930.369297-1-smayhew@redhat.com> References: <20261201144930.369297-1-smayhew@redhat.com> X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 notify_host() rotates through a host's addresses after 4 retransmits so that all addresses of a multihomed peer are tried. Two defects prevented this from working for dual-stack hosts: 1. The "find the end of the list" loop started from &first->ai_next, which had just been set to NULL, so instead of appending the removed head to the tail of the (new) list it set first->ai_next = first, orphaning that address. For a 2-address host this collapsed the list to a single entry after the first rotation, after which the ai_next != NULL guard was never true again and no further rotation could occur. Walk from &host->ai so the removed head is re-appended. 2. smn_alloc_host() initialized host->retries to 100 to "force address retry" on the first notify_host() call. That made sense when the code transmitted to 'first' (the original head) after rotating, but since commit e132bb5d ("sm-notify: Replace RPC code") the transmit uses host->ai->ai_addr (the new head). As a result the very first packet was sent to the second address returned by getaddrinfo(3), skipping the preferred first address. Combined with defect #1, a host whose name resolved to both an IPv6 and an IPv4 address had its IPv6 address rotated out and orphaned before any packet was sent, pinning sm-notify to an unreachable IPv4 address. Initialize retries to 0; a freshly resolved addrinfo already has port 0, so the first call still performs an rpcbind lookup without forcing a rotation. Fixes: e132bb5d ("sm-notify: Replace RPC code") Assisted-by: LLM Signed-off-by: Scott Mayhew --- utils/statd/sm-notify.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c index ed82b8f2..affaea28 100644 --- a/utils/statd/sm-notify.c +++ b/utils/statd/sm-notify.c @@ -235,7 +235,7 @@ smn_alloc_host(const char *hostname, const char *mon_name, host->last_used = timestamp; host->timeout = NSM_TIMEOUT; - host->retries = 100; /* force address retry */ + host->retries = 0; return host; @@ -722,13 +722,13 @@ notify_host(int sock, struct nsm_host *host) /* don't rotate if there is only one addrinfo */ if (host->ai->ai_next != NULL) { struct addrinfo *first = host->ai; - struct addrinfo **next = &host->ai; + struct addrinfo **next; /* remove the first entry from the list */ host->ai = first->ai_next; first->ai_next = NULL; - /* find the end of the list */ - next = &first->ai_next; + /* find the end of the (new) list */ + next = &host->ai; while ( *next ) next = & (*next)->ai_next; /* put first entry at end */ -- 2.56.1