]> git.ipfire.org Git - thirdparty/libvirt.git/commit
nwfilter: save error from DHCP snoop thread to report in main thread
authorLaine Stump <laine@laine.org>
Fri, 23 Feb 2018 01:29:20 +0000 (20:29 -0500)
committerLaine Stump <laine@laine.org>
Tue, 27 Feb 2018 17:32:46 +0000 (12:32 -0500)
commit1297db741434b9e6f8096c5a5481594cfdedf12a
tree63dceb3328fc8e386ee9f21045156f62ccadf48b
parente1ab81b339c4d631b704290c26caa0af6882527c
nwfilter: save error from DHCP snoop thread to report in main thread

A problem encountered due to a bug in libpcap was reported to the
caller as:

   An error occurred, but the cause is unknown

This was because the error had been logged in the DHCPSnoop
thread. The worker thread handling the API call to start a domain
spins up the DHCPSnoop thread which watches for dhcp packets with
libpcap, then uses virCondSignal() to notify the worker thread (which
has been waiting with virCondWait()). The worker thread knows that
there was an error (because threadStatus != THREAD_STATUS_OK), but the
error info had been stored in thread-specific storage for the other
thread, so the worker thread can only report that there was a failure,
but it doesn't know why.

The solution is to save the error that was logged (with
virErrorPreserveLast() into the object the is used to share info
between the threads, then we can set the error in the worker thread
using virErrorRestore().

In the case of the error I was looking at, this changed the "unknown"
message into:

    internal error: pcap_setfilter: can't remove kernel filter:
    Bad file descriptor

Signed-off-by: Laine Stump <laine@laine.org>
src/nwfilter/nwfilter_dhcpsnoop.c