From nobody Wed Mar 20 22:34:39 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4V0Ngh0tFlz5F6dw; Wed, 20 Mar 2024 22:34:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4V0Ngg5nyZz4fNs; Wed, 20 Mar 2024 22:34:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710974079; 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=0DwnG7CV1zDB4Wh125Uk2qJqj1wxd9JdpzPJdIZvTzc=; b=SoVmGdF85y7GixP2gCUuRE8omFtqbjvOR6hiEQjjUzN5srNFy5Dgo9a3LNqth+zXRnSY3R lYheOzpg4og+CSZtwyU9VONFeya2NzdfkknssDUn9zsGgMPdJFQLgORy07PYpkXcLAKQ1R AzCX/VGtrl2h4fb5VVHY+Msd3aW91FIzymOGcopT0wzb+sTijicdMDgY1k2vBomXdhKcwo lmcKtnGGZlN8JpPWploD7WXGKGHnMEuDf2XSj1E4Tu05+MruGfgKicrcuuswCDD2mX3c/T yCh6VXk0jTtpgIdgfLQ5DJ140Ex8w5DL6C8VDMvmx4F11AkHzboak2yjZteivw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710974079; a=rsa-sha256; cv=none; b=ofmRfEuGh0l/NOwXi26Wg05Q2G8nkxQHAjNkMTnJZZEjh4wifMdurjeVkTFNA5OBPpDPBG Txy1s8bmQvw9U40WYLncFrBSeG/x5T0vFV8tHsFDI9owqxKQwJsbqIVkr/C7mJLFqXc8XK pv+F5C8Uvzej7zfInWDSnbRQuK7VGHQomkGKNnSyGsfxBQxRLnye4zOuJtaY9EP3ExPxNn 2jwqDT607DnhzMolEjocO/TVBMCSZugZUpL9UaEI5XLglhzYz+MpG7TPDIKDso59DaxeDt xdezV0MnXiFsZ3rVEoo0cGRJX3+II6DaQ2tqd0iYrsKmELA6rWgHeBkOD7zmIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710974079; 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=0DwnG7CV1zDB4Wh125Uk2qJqj1wxd9JdpzPJdIZvTzc=; b=xyNpZpyvuHeRNqYpI7q77ESYmWlhGvsq959S3RdwZegjm/hmOolqgZTwoV+FhHMM5v9dR8 6P2iL/Jwj3tAJHk77PHAkK3bsUoFUeffIYH78t9Yts3VDVDCt4BAMirUquudZLMxFPKuhH V+tzp96Vr6grtFTvr7X2AFtfipn4lCtSjWp1Ix18Irt7+INE6QgEiZLcTETVa6JNwTcJb2 G098U1LsDzV1fRLAsmGrRiGEzzmJ2XwYPkn1J8Ba2W5+wff8bYfYWKzk/ajXEObP++ay+O 67u3fzuEnwLr+ZMU/Jfnv7aED+YKbZ9rL0hYz7skxNCZSx3vocWdXIR09ESK/g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4V0Ngg56MQz18Zx; Wed, 20 Mar 2024 22:34:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42KMYdDG047956; Wed, 20 Mar 2024 22:34:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42KMYdvE047953; Wed, 20 Mar 2024 22:34:39 GMT (envelope-from git) Date: Wed, 20 Mar 2024 22:34:39 GMT Message-Id: <202403202234.42KMYdvE047953@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: a16ff32f04b5 - main - NFS: Request use of TCP_USE_DDP for in-kernel TCP sockets List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a16ff32f04b5b891a2d9b0427a2fd9c48e866da3 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a16ff32f04b5b891a2d9b0427a2fd9c48e866da3 commit a16ff32f04b5b891a2d9b0427a2fd9c48e866da3 Author: John Baldwin AuthorDate: 2024-03-20 22:29:51 +0000 Commit: John Baldwin CommitDate: 2024-03-20 22:29:51 +0000 NFS: Request use of TCP_USE_DDP for in-kernel TCP sockets Since this is an optimization, ignore failures to enable the option. For the server side, defer enabling DDP until the first non-NULLPROC RPC is received. This allows TLS handling (which uses NULLPROC RPCs) to enable TLS offload first. Reviewed by: rmacklem Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44002 --- sys/rpc/clnt_rc.c | 8 ++++++++ sys/rpc/svc.c | 20 ++++++++++++++++++++ sys/rpc/svc.h | 1 + 3 files changed, 29 insertions(+) diff --git a/sys/rpc/clnt_rc.c b/sys/rpc/clnt_rc.c index b2ee4551149b..ebd52d305a4b 100644 --- a/sys/rpc/clnt_rc.c +++ b/sys/rpc/clnt_rc.c @@ -42,6 +42,8 @@ #include #include +#include + #include #include #include @@ -212,6 +214,12 @@ clnt_reconnect_connect(CLIENT *cl) goto out; } } + if (newclient != NULL) { + int optval = 1; + + (void)so_setsockopt(so, IPPROTO_TCP, TCP_USE_DDP, + &optval, sizeof(optval)); + } if (newclient != NULL && rc->rc_reconcall != NULL) (*rc->rc_reconcall)(newclient, rc->rc_reconarg, rc->rc_ucred); diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c index f96c00dd2f2a..99678f693a3e 100644 --- a/sys/rpc/svc.c +++ b/sys/rpc/svc.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,8 @@ #include #include +#include + #include #include #include @@ -987,6 +990,23 @@ svc_getreq(SVCXPRT *xprt, struct svc_req **rqstp_ret) goto call_done; } + /* + * Defer enabling DDP until the first non-NULLPROC RPC + * is received to allow STARTTLS authentication to + * enable TLS offload first. + */ + if (xprt->xp_doneddp == 0 && r->rq_proc != NULLPROC && + atomic_cmpset_int(&xprt->xp_doneddp, 0, 1)) { + if (xprt->xp_socket->so_proto->pr_protocol == + IPPROTO_TCP) { + int optval = 1; + + (void)so_setsockopt(xprt->xp_socket, + IPPROTO_TCP, TCP_USE_DDP, &optval, + sizeof(optval)); + } + } + /* * Everything checks out, return request to caller. */ diff --git a/sys/rpc/svc.h b/sys/rpc/svc.h index 87862d4b9001..cfeb2a92c54e 100644 --- a/sys/rpc/svc.h +++ b/sys/rpc/svc.h @@ -185,6 +185,7 @@ typedef struct __rpc_svcxprt { int xp_ngrps; /* Cred. from TLS cert. */ uid_t xp_uid; gid_t *xp_gidp; + int xp_doneddp; #else int xp_fd; u_short xp_port; /* associated port number */