PktFilterInet6::receive() - fetch SO_TIMESTAMP via CMSG,
add SOCKET_RECEIVED and BUFFER_READ events
PktFilterInet::send() - add RESPONSE_SENT event
src/lib/dhcp/pkt_filter_lpf.cc
PktFilterLPF::openSocket() - enable SO_TIMESTAMP socket option
PktFilterLPF::receive() - added conditonal compilation version based
on WITH_CMSG macro that fetches SO_TIMESTAMP and add SOCKET_RECEIVED
and BUFFER_READ events
PktFilterLPF::send() - add RESPONSE_SENT event
src/lib/dhcp/tests/pkt4_unittest.cc
TEST_F(Pkt4Test, PktEvents) - new test
src/lib/dhcp/tests/pkt6_unittest.cc
TEST_F(Pkt6Test, PktEvents) - new test
src/lib/dhcp/tests/pkt_filter_bpf_unittest.cc
src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc
Updated tests to check PktEvent stack contents,
Changed DISABLED_ tests to use SKIP_IF(notRoot)
Andrei Pavel [Fri, 15 Dec 2023 10:36:24 +0000 (12:36 +0200)]
[#2788] reset optarg
optarg is not reset in musl's getopt and it leaks values to other flags.
Reset it for all systems because it cannot hurt. If you remove the
optarg reset, you should see the bug in action on alpine systems in
DstubControllerTest.commandLineArgs when parsing argv2:
```
[ RUN ] DStubControllerTest.commandLineArgs
d_controller_unittests.cc:102: Failure
Expected equality of these values:
std::string(ex.what())
Which is: "unsupported option: -b cfgName"
"unsupported option: -b"
[ FAILED ] DStubControllerTest.commandLineArgs (14 ms)
```
Andrei Pavel [Fri, 15 Dec 2023 10:07:30 +0000 (12:07 +0200)]
[#2788] exhaust options before throwing error
Prior to this change, if parseArgs() was called twice during the same
program lifetime and it stumbled on an unsupported option and throwed an
exception on the first call, the previous set of arguments lived on to
be parsed by the second call. This is a situation that likely arises
only in unit tests, but let us fix it properly to at least silence the unit
test failure on alpine, which was happening because of different
implementation of getopt from musl, and which motivated looking into how
getopt behaves. To make the bug evident even in a non-alpine environment, add an
EXPECT_THROW_MSG in DStubControllerTest.commandLineArgs when parsing argv3, and
see that it outputs "unsupported option: [s]" instead of
"extraneous command line information".
Andrei Pavel [Wed, 10 Jan 2024 09:46:00 +0000 (11:46 +0200)]
[#3198] ignore errors when regenerating hashes
The script complains about hashes missing, but that is only temporary until they
are regenerated. A second call to check-hashes.sh will now properly check them
at the end.
Andrei Pavel [Wed, 10 Jan 2024 09:20:26 +0000 (11:20 +0200)]
[#3198] make data a key for option-data in code
- Add ability to set list element that only has keys in Translator::setItem.
- Explicitly set list elements in case they contain only keys which can
be more common now that data is a key since it is likely one can have
entries that only have code, space, and data.
- Handle no data as empty data when setting, and empty data as no data
when getting. This avoids the need to add an empty "data" element to
all options that lack it in all-options.json so that the unit tests
pass. But this goes to show that data-less entries may be encountered
in production as well, so more importantly this caters to that
scenario.
- Adjust data in kea4/all-options.json to not contain singlequotes.
There was only one occurrence of it. This is a limitation related
to unit testing only. Opened issue 3216 about it.
- Add missing tests that are not strictly related to the data key, but
they are related to option data:
- TranslatorOptionDataListTestv6.getEmpty
- TranslatorOptionDataListTestv4.get
- TranslatorOptionDataListTestv6.setEmpty
- TranslatorOptionDataListTestv4.set
- Add unit tests:
- TranslatorOptionDataListTestv4.optionsSameCodeAndSpace
- TranslatorOptionDataListTestv6.optionsSameCodeAndSpace
- Add snippet that tests setting of list element with keys only in
TranslatorTest.setItem.
The subnet4_select and subnet6_select callouts are used when HA config
contains multiple relationships. In this case the logic filtering the
packets must be ran after subnet selection because the selected subnet
contains the info which relationship the packet belongs to.