Does sosend() need CURVNET_SET/CURVNET_RESTORE?

Kristof Provost kp at FreeBSD.org
Mon Feb 3 23:46:12 UTC 2020


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


More information about the freebsd-net mailing list