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

Improvements and fixes for test_alive_hosts_only feature #401

Merged
merged 5 commits into from
Sep 7, 2020
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 @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed
- Fix port list for tcp pings when using test_alive_hosts_only feature. [#392](https://github.com/greenbone/gvm-libs/pull/392)
- Set source address correctly and do not try to send ARP to unreachable destination. [#401](https://github.com/greenbone/gvm-libs/pull/401)

[20.8.1]: https://github.com/greenbone/gvm-libs/compare/v20.8.0...gvm-libs-20.08

Expand Down
17 changes: 13 additions & 4 deletions base/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
#define s6_addr32 __u6_addr.__u6_addr32
#endif

#undef G_LOG_DOMAIN
/**
* @brief GLib log domain.
*/
#define G_LOG_DOMAIN "base networking"

/* Global variables */

/* Source interface name eg. eth1. */
Expand Down Expand Up @@ -919,10 +925,13 @@ get_routes (void)
status = g_io_channel_read_line (file_channel, &line, NULL, NULL, &err);
if ((status != G_IO_STATUS_NORMAL) || !line || err)
{
g_warning (
"%s: %s", __func__,
err ? err->message
: "g_io_channel_read_line() status != G_IO_STATUS_NORMAL");
if (status == G_IO_STATUS_AGAIN)
g_warning ("%s: /proc/net/route unavailable.", __func__);
if (err || status == G_IO_STATUS_ERROR)
g_warning (
"%s: %s", __func__,
err ? err->message
: "g_io_channel_read_line() status == G_IO_STATUS_ERROR");
err = NULL;
g_free (line);
break;
Expand Down
17 changes: 11 additions & 6 deletions boreas/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,22 @@ send_arp_v4 (int soc, struct in_addr *dst_p)
sin_dst.sin_family = AF_INET;
sin_dst.sin_addr = *dst_p;
memcpy (&storage_dst, &sin_dst, sizeof (sin_dst));
memcpy (&storage_dst, &sin_src, sizeof (sin_src));
memcpy (&storage_src, &sin_src, sizeof (sin_src));

/* Get interface and set src addr. */
g_debug ("%s: Destination addr: %s", __func__, inet_ntoa (*dst_p));
gchar *interface = gvm_routethrough (&storage_dst, &storage_src);
memcpy (&src, &((struct sockaddr_in *) (&storage_src))->sin_addr,
sizeof (struct in_addr));
g_warning ("%s: %s", __func__, inet_ntoa (src));

if (!interface)
g_warning ("%s: no appropriate interface was found", __func__);
{
g_warning ("%s: No appropriate interface was found. Network may be "
"unreachable. No ARP ping send for host %s.",
__func__, inet_ntoa (*dst_p));
return;
}
g_debug ("%s: interface to use: %s", __func__, interface);
memcpy (&src, &((struct sockaddr_in *) (&storage_src))->sin_addr,
sizeof (struct in_addr));
g_debug ("%s: Source addr: %s", __func__, inet_ntoa (src));

/* Get interface index for sockaddr_ll. */
if ((ifaceindex = if_nametoindex (interface)) == 0)
Expand Down