From owner-freebsd-net@freebsd.org Mon Feb 3 23:46:12 2020 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E061E2334B9 for ; Mon, 3 Feb 2020 23:46:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48BPbm5Mkxz4Kc6; Mon, 3 Feb 2020 23:46:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 992001EEE; Mon, 3 Feb 2020 23:46:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [10.4.7.234] (c-24-4-212-61.hsd1.ca.comcast.net [24.4.212.61]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id D0CE4CED5; Tue, 4 Feb 2020 00:46:10 +0100 (CET) From: "Kristof Provost" To: "Rick Macklem" Cc: freebsd-net Subject: Re: Does sosend() need CURVNET_SET/CURVNET_RESTORE? Date: Mon, 03 Feb 2020 15:46:08 -0800 X-Mailer: MailMate (1.13.1r5671) Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Feb 2020 23:46:12 -0000 On 3 Feb 2020, at 14:59, Rick Macklem wrote: > Kristof Provost wrote: >> On 2 Feb 2020, at 13:22, Rick Macklem wrote: >>> The current krpc code calls sosend() and soreceive() without any >>> CURVNET_SET()/CURVNET_RESTORE() wrapped around them. >>> >> sosend() and soreceive() do the CURVENT_SET()/CURVNET_RESTORE() dance >> for you. > Duh, I'm getting old. When I looked at sosend(), I didn't spot the > CURVNET calls > in it. > >>> When I recently used sosend_generic(), it panic'd without them. >>> >> sosend_generic() does not, because usually sosend() calls it, so >> it’d >> already be set. > Ok, I had thought the > error = so->so_proto->pr_usrreqs->pru_sosend(so, addr, > uio, > 1706 top, control, flags, td); > call in sosend() was calling tcp_usr_send(). > tcp_usr_send() seems to be called through pru_send, not pru_sosend, so sosend_dgram() (or sosend_generic()) is in between there. > If it is just calling sosend_generic(), then I can just call sosend() > for the > KERN_TLS case. I'll check to see if sosend() is calling > sosend_generic(). > That’ll presumably depend on what your socket is. It’s assigned in uipc_domain.c, but it could also be sctp_sosend(), sosend_dgram() or pru_sosend_notsupp(). Regards, Kristof