Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jun 2016 09:40:03 -0700
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        Julian Kornberger <jk@kornberger.name>
Subject:   Re: Usage of sosend() and its context
Message-ID:  <2110371.3nz8SNp04Y@ralph.baldwin.cx>
In-Reply-To: <575F20CF.1020103@kornberger.name>
References:  <575F20CF.1020103@kornberger.name>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, June 13, 2016 11:08:31 PM Julian Kornberger wrote:
> Hi,
> 
> I am building a kernel module for fastd [1] and have the problem, that 
> on one of three machines the sosend() call seems to block. I use 
> sosend() [2] in a tunneling function that is set by 
> udp_set_kernel_tunneling().
> 
> Since I don't know which thread to pass to sosend() I just use 
> curthread. Is it possible that I should not use sosend() in this context 
> and instead build the IP packet manually and pass it to ip_output()? Any 
> other hints?
> 
> [1] https://fastd.readthedocs.io/
> [2] 
> https://github.com/digineo/fastd/blob/97fd40b9992778a3bf11756f41aa7c2615bba2f3/kmod/fastd.c#L664

It's possible to ask sosend() to not block and fail with EWOULDBLOCK instead
by passing MSG_NOWAIT in flags.  However, you might still block on sblock(), so
you may need to defer your work to a sleepable context using something like a
taskqueue.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2110371.3nz8SNp04Y>