Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do no start sniffer thread unnecessarily #466

Merged
merged 3 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[#447](https://github.com/greenbone/gvm-libs/pull/447)
[#451](https://github.com/greenbone/gvm-libs/pull/451)
- Fix openvas preference name. The option was rename to "allow_simultaneous_ips". [#461](https://github.com/greenbone/gvm-libs/pull/461)
- Do not start the sniffer thread when only consider alive is chosen for alive test. [#466](https://github.com/greenbone/gvm-libs/pull/466)]

### Fixed
- Fix finish_signal_on_queue for boreas. [#464](https://github.com/greenbone/gvm-libs/pull/464)
Expand Down
32 changes: 21 additions & 11 deletions boreas/alivedetection.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ scan (alive_test_t alive_test)
g_message ("Alive scan %s started: Target has %d hosts", scan_id,
number_of_targets);

sniffer_thread_id = 0;
start_sniffer_thread (&scanner, &sniffer_thread_id);
/* Sniffer thread needed if any alive test besides ALIVE_TEST_CONSIDER_ALIVE
* was chosen. */
if (alive_test != ALIVE_TEST_CONSIDER_ALIVE)
{
sniffer_thread_id = 0;
start_sniffer_thread (&scanner, &sniffer_thread_id);
}

/* Continuously send dead hosts to ospd if only ICMP was chosen instead of
* sending all at once at the end. This is done for displaying a progressbar
Expand Down Expand Up @@ -217,17 +222,22 @@ scan (alive_test_t alive_test)
}
}

g_debug (
"%s: all ping packets have been sent, wait a bit for rest of replies.",
__func__);
/* Stop sniffer thread if any alive test besides ALIVE_TEST_CONSIDER_ALIVE was
* chosen. */
if (alive_test != ALIVE_TEST_CONSIDER_ALIVE)
{
g_debug (
"%s: all ping packets have been sent, wait a bit for rest of replies.",
__func__);

/* If all targets are already identified as alive we do not need to wait for
* replies anymore.*/
if (number_of_targets
!= (int) g_hash_table_size (scanner.hosts_data->alivehosts))
sleep (WAIT_FOR_REPLIES_TIMEOUT);
/* If all targets are already identified as alive we do not need to wait
* for replies anymore.*/
if (number_of_targets
!= (int) g_hash_table_size (scanner.hosts_data->alivehosts))
sleep (WAIT_FOR_REPLIES_TIMEOUT);

stop_sniffer_thread (&scanner, sniffer_thread_id);
stop_sniffer_thread (&scanner, sniffer_thread_id);
}

/* If only ICMP was specified we continuously send updates about dead hosts to
* ospd while checking the hosts. We now only have to send the dead hosts of
Expand Down
3 changes: 1 addition & 2 deletions boreas/boreas_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ finish_signal_on_queue (kb_t main_kb)

/* Check if it was already set throught the whole items under the key.
If so, set the static variable to avoid querying redis unnecessarily. */
queue_items =
kb_item_get_all (main_kb, ALIVE_DETECTION_QUEUE);
queue_items = kb_item_get_all (main_kb, ALIVE_DETECTION_QUEUE);
if (queue_items)
{
while (queue_items)
Expand Down
8 changes: 4 additions & 4 deletions util/ldaputils.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ ldap_enable_debug ()
ret = ber_set_option (NULL, LBER_OPT_LOG_PRINT_FN, ldap_log);
if (ret != LBER_OPT_SUCCESS)
{
g_warning ("%s: Failed to set LDAP debug print function: %s",
__func__, ldap_err2string (ret));
g_warning ("%s: Failed to set LDAP debug print function: %s", __func__,
ldap_err2string (ret));
return -1;
}

ret = ldap_set_option (NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level);
if (ret != LDAP_OPT_SUCCESS)
{
g_warning ("%s: Failed to set LDAP debug level: %s",
__func__, ldap_err2string (ret));
g_warning ("%s: Failed to set LDAP debug level: %s", __func__,
ldap_err2string (ret));
return -1;
}

Expand Down