Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp360828rdd; Tue, 9 Jan 2024 06:32:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzZ9nEJvAiWFl5jN9ClWTD8pSfko0ql5/I6wME05D2f4FFP1P0+YGIfchtH2i2oCMuUjRP X-Received: by 2002:a05:6a20:1445:b0:199:d847:ff8 with SMTP id a5-20020a056a20144500b00199d8470ff8mr1838428pzi.20.1704810759534; Tue, 09 Jan 2024 06:32:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704810759; cv=none; d=google.com; s=arc-20160816; b=qH3tT5QVojWhTMxhpPfggyQ+co/bfJbkOIGlnvwwXKXLjVByI4v8iJc9FyWJkkK4rU VToAs/JZZHnhaABB92NvYgfxNX+ijMkT6RvpwANGYBnNGca9F+Z5GC7u6vanMXEeX8SA ZwW6cfbHIZkm2zJGEEWc8YaD2Ah1vPNa3csjVwQ+SMOS7+W2OMSFSE5oYH8Tq1xXaVAI 835TIJdsoJ6FqmEsv29JUiGH0ZPMh9EV/jGaFCK0aYcnM5ut8tTZJJr34M97ye5xqNE6 B+3luJry9pXjnddgexh8FCABKQZKyJrPr3c4y1I+X4a2RShIS9HN8GlOQbSmRFwi7Be/ I3JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:to:from :organization:dkim-signature; bh=T4PbYrmacdkxUZGDudl2g58tiJlad9NdV+LI2jnLDRI=; fh=DQvOiaJ/Q4SQqfos+auASFTcoy4J9nIduW2VCayHwJM=; b=aPPrFy6KL/fkF9gkOiS5HnL+TGU2VJLbatYIACI5Hzu2UtS+FGmg/ppxQ2QIh/yW29 qLbHlHOA+n0aDeoDhVeD2+IGXJThXwAPEjf4GhuUbtD4EBM3EJjNXmn8pmZk4R+83MDh etH0m3C3keS2kKvMiZxQmlbIUztQr0e5OXFt6tcjnKf6vt5cykSo+G+Qnpd9i+DO+QcG SLAiwicbvu+N/cj8FWuVPswpxABO5/TWHjyATN3cI854DW0RgaFW26lPI3CWH6i4RlX0 gcXGuCsxLWpMxE1XzTLTAq9iDSzOkrxM1uyjdXzSFcgatRWkKjrf0/+N+hs+Ks1qpQlp Dpqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Eo6xdvC9; spf=pass (google.com: domain of linux-kernel+bounces-20987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s36-20020a635264000000b005cde435ff91si1458791pgl.878.2024.01.09.06.32.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 06:32:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Eo6xdvC9; spf=pass (google.com: domain of linux-kernel+bounces-20987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id ABB2AB223B6 for ; Tue, 9 Jan 2024 14:32:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A387B381B7; Tue, 9 Jan 2024 14:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Eo6xdvC9" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36F7A39E for ; Tue, 9 Jan 2024 14:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704810725; 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=T4PbYrmacdkxUZGDudl2g58tiJlad9NdV+LI2jnLDRI=; b=Eo6xdvC9+H/V77Bs9jYD+AVqBzssR1ekRw765GZvJr7lR770pcenPelX75alXJ/4xlC7Iz DLLlNQ6HEi2vLNSrmsG+LCkfCLfE2uHCiz3mvL9Pc1G3NeWkaKD2XUS0f6UlfLniIEunJK w8fLh3Sc3ZzkjTryoMuisNDID2Dxmhk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-Ia7ILSYLND2q9wuualNwBw-1; Tue, 09 Jan 2024 09:32:02 -0500 X-MC-Unique: Ia7ILSYLND2q9wuualNwBw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F9D2811E9E; Tue, 9 Jan 2024 14:32:01 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A85E2166B32; Tue, 9 Jan 2024 14:32:00 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Marc Dionne , dhowells@redhat.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-afs@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2] rxrpc: Fix use of Don't Fragment flag Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1580268.1704810719.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 09 Jan 2024 14:31:59 +0000 Message-ID: <1580269.1704810719@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 = rxrpc normally has the Don't Fragment flag set on the UDP packets it transmits, except when it has decided that DATA packets aren't getting through - in which case it turns it off just for the DATA transmissions. This can be a problem, however, for RESPONSE packets that convey authentication and crypto data from the client to the server as ticket may be larger than can fit in the MTU. In such a case, rxrpc gets itself into an infinite loop as the sendmsg returns an error (EMSGSIZE), which causes rxkad_send_response() to return -EAGAIN - and the CHALLENGE packet is put back on the Rx queue to retry, leading to the I/O thread endlessly attempting to perform the transmission= . Fix this by disabling DF on RESPONSE packets for now. The use of DF and best data MTU determination needs reconsidering at some point in the future. Reported-by: Marc Dionne Signed-off-by: David Howells cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: linux-afs@lists.infradead.org cc: netdev@vger.kernel.org --- net/rxrpc/ar-internal.h | 1 + net/rxrpc/local_object.c | 13 ++++++++++++- net/rxrpc/output.c | 6 ++---- net/rxrpc/rxkad.c | 2 ++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index e8e14c6f904d..e8b43408136a 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -1076,6 +1076,7 @@ void rxrpc_send_version_request(struct rxrpc_local *= local, /* * local_object.c */ +void rxrpc_local_dont_fragment(const struct rxrpc_local *local, bool set)= ; struct rxrpc_local *rxrpc_lookup_local(struct net *, const struct sockadd= r_rxrpc *); struct rxrpc_local *rxrpc_get_local(struct rxrpc_local *, enum rxrpc_loca= l_trace); struct rxrpc_local *rxrpc_get_local_maybe(struct rxrpc_local *, enum rxrp= c_local_trace); diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c index c553a30e9c83..7a3150482e37 100644 --- a/net/rxrpc/local_object.c +++ b/net/rxrpc/local_object.c @@ -36,6 +36,17 @@ static void rxrpc_encap_err_rcv(struct sock *sk, struct= sk_buff *skb, int err, return ipv6_icmp_error(sk, skb, err, port, info, payload); } = +/* + * Set or clear the Don't Fragment flag on a socket. + */ +void rxrpc_local_dont_fragment(const struct rxrpc_local *local, bool set) +{ + if (set) + ip_sock_set_mtu_discover(local->socket->sk, IP_PMTUDISC_DONT); + else + ip_sock_set_mtu_discover(local->socket->sk, IP_PMTUDISC_DO); +} + /* * Compare a local to an address. Return -ve, 0 or +ve to indicate less = than, * same or greater than. @@ -203,7 +214,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local= , struct net *net) ip_sock_set_recverr(usk); = /* we want to set the don't fragment bit */ - ip_sock_set_mtu_discover(usk, IP_PMTUDISC_DO); + rxrpc_local_dont_fragment(local, true); = /* We want receive timestamps. */ sock_enable_timestamps(usk); diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c index 5e53429c6922..a0906145e829 100644 --- a/net/rxrpc/output.c +++ b/net/rxrpc/output.c @@ -494,14 +494,12 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, = struct rxrpc_txbuf *txb) switch (conn->local->srx.transport.family) { case AF_INET6: case AF_INET: - ip_sock_set_mtu_discover(conn->local->socket->sk, - IP_PMTUDISC_DONT); + rxrpc_local_dont_fragment(conn->local, false); rxrpc_inc_stat(call->rxnet, stat_tx_data_send_frag); ret =3D do_udp_sendmsg(conn->local->socket, &msg, len); conn->peer->last_tx_at =3D ktime_get_seconds(); = - ip_sock_set_mtu_discover(conn->local->socket->sk, - IP_PMTUDISC_DO); + rxrpc_local_dont_fragment(conn->local, true); break; = default: diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index 1bf571a66e02..b52dedcebce0 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c @@ -724,7 +724,9 @@ static int rxkad_send_response(struct rxrpc_connection= *conn, serial =3D atomic_inc_return(&conn->serial); whdr.serial =3D htonl(serial); = + rxrpc_local_dont_fragment(conn->local, false); ret =3D kernel_sendmsg(conn->local->socket, &msg, iov, 3, len); + rxrpc_local_dont_fragment(conn->local, true); if (ret < 0) { trace_rxrpc_tx_fail(conn->debug_id, serial, ret, rxrpc_tx_point_rxkad_response);