Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2014830lqt; Sun, 21 Apr 2024 20:45:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDa8BWDQWLfJW6QoyymwkVfkf6P+lcnU/7PlAzUTpffGqUSyYJusWqqx5cBgfJvhQItGCrWQvqNlBfjqesqDwgY+rijuadt2K8CHcTBA== X-Google-Smtp-Source: AGHT+IEIMR4Mnq1SYhuUnTzjiis+IYgJfjH1lbZ7YJradTOWq49WI/QOHagRK6lAXraNL51ZNT9b X-Received: by 2002:a17:902:ec81:b0:1de:f93f:4410 with SMTP id x1-20020a170902ec8100b001def93f4410mr9858545plg.8.1713757510635; Sun, 21 Apr 2024 20:45:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713757510; cv=pass; d=google.com; s=arc-20160816; b=CiCyxQBY5LJvrhZm1SCz8z2CVrFGaCLk/SZlaHWC7Cvh7JZkfyrjkyxHmOmZ3CYVAx lvbfnDWlB4ZoGZBrORrI1FdpDlH1xMpZPEaVNEw2QOZMyH4FPa7TRla3vciFCVv4PTtv KjAyuvPtmAs5YzcOYo7Is9NPuGYOesbvGiXjNnbEPOp/zkbMgLW2VbDQru1RsRnNFf49 VZgeoppHZzYOlzH82PdfUKaokGuSHJvh9JuGL+GXSHHEYiNRP3xho0KY1lGwnyw6e1ne 2eQ2WSC5TzPTQOmgep3LAfxcTZTIximb+m1CIpU8G6jl7blDpthjopDuCNvYlJUKRgYJ 7vbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:references:in-reply-to:subject:cc:to:from :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=SdzU1hv8xkzQkP0Voc7ZJKo+cz0pH/lZ8F7iWLkQ2E8=; fh=nl1pij7IhD/BETmTgbdYCdYM7dWZPDmZO026NkmJmVY=; b=BUuLOAMQYayrJITRUPXJ0T0OXnLWCL12DtRF4dHWmf4ifmVqdH6l4XZcg42mmDg/9k UsoeTJEDVeazwNTmQOoaNkB3WFU1kbpmh1lZx95ShtP2iyJJPPieK4Jao6WYUyxUZX4x 36lU7Zq6ng/H9bUjUDcnJg4mTOj0GBN+avFjHK0nj+uCVJgEZS/hGBzMZMtTbSKSutPi O40j9BPnqrfOK6ess3EByyq0PTTPzpIySjJ7L8WpiSQO0rBBYF1R6jp8VRFwEe6S6Ve2 ccFKHK22SyBJwBz/TXrwOsqzr4lRTfUsDxx1xVQ80ct4Nm7p5EpmWCUX5HgOGJbBxGmy vSSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=YNFGQJ5d; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="FHThv/+A"; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=YNFGQJ5d; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-2913-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2913-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j16-20020a170903029000b001e23e133a76si7459177plr.575.2024.04.21.20.45.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 20:45:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2913-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=YNFGQJ5d; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="FHThv/+A"; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=YNFGQJ5d; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-nfs+bounces-2913-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2913-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4078328120A for ; Mon, 22 Apr 2024 03:45:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 44FE3F9EB; Mon, 22 Apr 2024 03:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="YNFGQJ5d"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="FHThv/+A"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="YNFGQJ5d"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="FHThv/+A" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F412E542; Mon, 22 Apr 2024 03:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713757507; cv=none; b=cCv0+QVtAkILKnWlzEQFt7MNfRZOLdiMD5qn7FCR+7JD3ckE96QDvxPvQ3Kq+oCpwHpkHTJn/431k/tnP4WowEkFOfSjkpzePM4ZMWokJdH7ZnlSDvqEKqmOXQry3lluOHYtILYEUL22IQZ85CXYKy7RgMo1O9W7ubktkiAh2sc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713757507; c=relaxed/simple; bh=08JXntusgK41+ycFBthAXi0xoPBt/thnoLFKZQXR61c=; h=Content-Type:MIME-Version:From:To:Cc:Subject:In-reply-to: References:Date:Message-id; b=noSsFO0rAz6wu5t41t6udkZFmWbFbhatvsQh0mVWLWihsvgYeajAzi2iLaGKoZmZw6C2V0cCZ1e74ROKJ8EAurAz+RjMJHO7hYDGN+sRtfStOzWKRyRSYgKRihykmqiKpQju4W3AXXAUXzbcj9H7mTry9KaUj39icVzO2vioPyI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=YNFGQJ5d; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=FHThv/+A; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=YNFGQJ5d; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=FHThv/+A; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (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) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7F1F95C849; Mon, 22 Apr 2024 03:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713757503; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdzU1hv8xkzQkP0Voc7ZJKo+cz0pH/lZ8F7iWLkQ2E8=; b=YNFGQJ5dJbJkYPh2nYz8QEqGXYVy2wYftPNbZX4DNyJTPbC/VIju0v7wPuA+wod1eZ4uCL EnhKGvnskGjylCkVIDcee0fjGOmwfT2Pkzabl3qbH0jpZTC1UWEisb6DSddb5860GzNCOE oG/OUhKHKjNx/jBK28VP9TnxqAxYCRw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713757503; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdzU1hv8xkzQkP0Voc7ZJKo+cz0pH/lZ8F7iWLkQ2E8=; b=FHThv/+AznOXKLSIRBqC1PLEBtwZWbrDd5lF8ZPMCwR4vsKeUy+qzaNWbuT3FhHWHMqTu1 HsnuQObNvr8PPNBQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713757503; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdzU1hv8xkzQkP0Voc7ZJKo+cz0pH/lZ8F7iWLkQ2E8=; b=YNFGQJ5dJbJkYPh2nYz8QEqGXYVy2wYftPNbZX4DNyJTPbC/VIju0v7wPuA+wod1eZ4uCL EnhKGvnskGjylCkVIDcee0fjGOmwfT2Pkzabl3qbH0jpZTC1UWEisb6DSddb5860GzNCOE oG/OUhKHKjNx/jBK28VP9TnxqAxYCRw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713757503; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdzU1hv8xkzQkP0Voc7ZJKo+cz0pH/lZ8F7iWLkQ2E8=; b=FHThv/+AznOXKLSIRBqC1PLEBtwZWbrDd5lF8ZPMCwR4vsKeUy+qzaNWbuT3FhHWHMqTu1 HsnuQObNvr8PPNBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 274A113687; Mon, 22 Apr 2024 03:44:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id LOmcLjjdJWbeLgAAD6G6ig (envelope-from ); Mon, 22 Apr 2024 03:44:56 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "NeilBrown" To: "Lex Siegel" Cc: "Chuck Lever" , "Jeff Layton" , "Olga Kornievskaia" , "Dai Ngo" , "Tom Talpey" , "Trond Myklebust" , "Anna Schumaker" , "David S. Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH] xprtsock: Fix a loop in xs_tcp_setup_socket() In-reply-to: References: <>, Date: Mon, 22 Apr 2024 13:44:45 +1000 Message-id: <171375748540.7600.5672163982570379489@noble.neil.brown.name> X-Spam-Flag: NO X-Spam-Score: -4.30 X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[16]; MISSING_XM_UA(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email] On Mon, 22 Apr 2024, Lex Siegel wrote: > > Better still would be for kernel_connect() to return a more normal error > > code - not EPERM. If that cannot be achieved, then I think it would be > > best for the sunrpc code to map EPERM to something else at the place > > where kernel_connect() is called - catch it early. >=20 > The question is whether a permission error, EPERM, should cause a retry or > return. Currently xs_tcp_setup_socket() is retrying. For the retry to clear, > the connect call will have to not return a permission error to halt the ret= ry > attempts. >=20 > This is a default behavior because EPERM is not an explicit case of the swi= tch > statement. Because bpf appropriately uses EPERM to show that the kernel_con= nect > was not permitted, it highlights the return handling for this case is missi= ng. > It is unlikely that retry was ever the intended result. >=20 > Upstream, the bpf that caused this is at: > https://github.com/cilium/cilium/blob/v1.15/bpf/bpf_sock.c#L336 >=20 > This cilium bpf code has two return statuses, EPERM and ENXIO, that fall > through to the default case of retrying. Here, cilium expects both of these > statuses to indicate the connect failed. A retry is not the intended result. >=20 > Handling this case without a retry aligns this code with the udp behavior. = This > precedence for passing EPERM back up the stack was set in 3dedbb5ca10ef. >=20 > I will amend my patch to include an explicit case for ENXIO as well, as thi= s is > also in cilium's bpf and will cause the same bug to occur. >=20 I think it should be up to cilium to report an errno that the kernel understands, not up to the kernel to understand whatever errno cilium chooses to return. I don't think EPERM or ENXIO are appropriate errors for network problems. EHOSTUNREACH or ECONNREFUSED would make much more sense. NeilBrown >=20 > On Mon, Apr 22, 2024 at 8:22=E2=80=AFAM NeilBrown wrote: > > > > On Sat, 20 Apr 2024, Lex Siegel wrote: > > > When using a bpf on kernel_connect(), the call can return -EPERM. > > > This causes xs_tcp_setup_socket() to loop forever, filling up the > > > syslog and causing the kernel to freeze up. > > > > > > Signed-off-by: Lex Siegel > > > --- > > > net/sunrpc/xprtsock.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c > > > index bb9b747d58a1..47b254806a08 100644 > > > --- a/net/sunrpc/xprtsock.c > > > +++ b/net/sunrpc/xprtsock.c > > > @@ -2446,6 +2446,8 @@ static void xs_tcp_setup_socket(struct work_struc= t *work) > > > /* Happens, for instance, if the user specified a link > > > * local IPv6 address without a scope-id. > > > */ > > > + case -EPERM: > > > + /* Happens, for instance, if a bpf is preventing the conn= ect */ > > > > This will propagate -EPERM up into other layers which might not be ready > > to handle it. > > It might be safer to map EPERM to an error we would be more likely to > > expect from the network system - such as ECONNREFUSED or ENETDOWN. > > > > Better still would be for kernel_connect() to return a more normal error > > code - not EPERM. If that cannot be achieved, then I think it would be > > best for the sunrpc code to map EPERM to something else at the place > > where kernel_connect() is called - catch it early. > > > > NeilBrown > > > > > > > case -ECONNREFUSED: > > > case -ECONNRESET: > > > case -ENETDOWN: > > > -- > > > 2.39.3 > > > > > > > > >=20