Commit Graph

12 Commits

Author SHA1 Message Date
Robert Wing
7c9948c2e9 skip test case nvlist_send_recv__send_many_fds__dgram
If I'm not mistaken, the underlying sendmsg() for nvlist_send() is
failing with ENOBUFS. In turn, nvlist_recv() returns NULL because it
didn't receive the expected number of file descriptors.

Adjusting net.local.dgram.recvspace worked on my local machine, but on
CI the test still fails consistently.

PR:     260891
2022-01-02 12:26:07 -09:00
Robert Wing
a7cb27ce1c libnv: bump sysctl for nvlist_send_recv__send_many_fds__dgram test
Increase sysctl net.local.dgram.recvspace to 1M.

Reported by:    Jenkins
2021-12-20 15:57:47 -09:00
Robert Wing
5916ae1fb1 libnv: read entire datagram in nvlist_recv()
When SOCK_DGRAM is used, a portion of the datagram is discarded during
the initial recv() when getting the nvlist_header.

To workaround this, use MSG_PEEK for the initial recv() when using a
datagram socket.

Add tests for SOCK_DGRAM with nvlist_send()/nvlist_recv().

Differential Revision:	https://reviews.freebsd.org/D32722
2021-12-06 09:54:55 -09:00
Mark Johnston
dd8bacfd4e Add a regression test which transfers varying number of rights.
This exercises the PKG_MAX_SIZE limit mentioned in r350054.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-07-16 16:33:44 +00:00
Mark Johnston
ccf7f8460b Convert the nvlist send/recv tests to ATF.
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-07-16 16:25:27 +00:00
Mariusz Zaborski
908d1eef0b libnv: extend the tests
Add cases for sending file descriptors.

Submitted by:	Mindaugas Rasiukevicius <rmind@noxt.eu>
MFC after:	2 weeks
2019-04-15 03:32:01 +00:00
Mariusz Zaborski
b5d787d93b libnv: fix memory leaks
nvpair_create_stringv: free the temporary string; this fix affects
nvlist_add_stringf() and nvlist_add_stringv().

nvpair_remove_nvlist_array (NV_TYPE_NVLIST_ARRAY case): free the chain
of nvpairs (as resetting it prevents nvlist_destroy() from freeing it).
Note: freeing the chain in nvlist_destroy() is not sufficient, because
it would still leak through nvlist_take_nvlist_array().  This affects
all nvlist_*_nvlist_array() use

Submitted by:	Mindaugas Rasiukevicius <rmind@netbsd.org>
Reported by:	clang/gcc ASAN
MFC after:	2 weeks
2019-02-10 23:28:55 +00:00
Mark Johnston
991666adc7 Ensure that libnv can be used when kern.trap_enotcap=1.
libnv used fcntl(fd, F_GETFL) to test whether fd is a valid file
descriptor.  Aside from being racy, this check requires CAP_FCNTL
rights on fd.  Instead, use fcntl(fd, F_GETFD), which does not require
any capability rights.

Also remove some redundant fd_is_valid() checks to avoid extra system
calls; in many cases we were performing this check immediately before
dup()ing the descriptor.

Reviewed by:	cem, oshogbo (previous version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17963
2018-11-13 20:07:55 +00:00
Mariusz Zaborski
c36e54bb32 Let the nv.h and dnv.h includes be only in sys directory.
Change consumers to include those files from sys.
Add duplicated files to ObsoleteFiles.

Approved by:	pjd (mentor)
2015-07-02 21:58:10 +00:00
Mariusz Zaborski
bd1da0a002 Approved, oprócz użycie RESTORE_ERRNO() do ustawiania errno.
Change the nvlist_recv() function to take additional argument that
specifies flags expected on the received nvlist. Receiving a nvlist with
different set of flags than the ones we expect might lead to undefined
behaviour, which might be potentially dangerous.

Update consumers of this and related functions and update the tests.

Approved by:	pjd (mentor)

Update man page for nvlist_unpack, nvlist_recv, nvlist_xfer, cap_recv_nvlist
and cap_xfer_nvlist.

Reviewed by:	AllanJude
Approved by:	pjd (mentor)
2015-05-02 17:45:52 +00:00
Ryan Stone
2dfd9979d8 Extend the unit test to fix the bug caught in r277925
Differential Revision:		https://reviews.freebsd.org/D1888
MFC After:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:22:09 +00:00
Enji Cooper
b236bcf168 Integrate lib/libnv into the build/kyua
Rename all of the TAP test applications from <test> to <test>_test
to match the convention described in the TestSuite wiki page

Phabric: D538
Approved by: jmmv (mentor)
Sponsored by: EMC / Isilon Storage Division
2014-08-05 18:41:27 +00:00