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

Fix v6_routethrough misplaced technique switch #636

Conversation

ArnoStiefvater
Copy link
Member

What:

procroutetechnique is the default technique for getting the interface we want to use for some given destination addr. This technique is represented as a static enum. Previously the technique was set to fallback method connectsockettechnique even though an appropriate interface was found because the fallback method was activated after the first route in /proc/net/ipv6_route was checked and not after all routes were checked. Every additional invocation of the function therefore used the fallback method as new default.

Why:

Fix issue, improve performance.

How:

Add the following code at the beginning of openvas.c/openvas() and add some prints in misc/pcap.c/v6_routethrough() for printing out what method we are using.

  char *interface;
  struct in6_addr dest;
  inet_pton(AF_INET6, <ipv6 addr with matching route in /proc/net/ipv6_route>, &dest);
  interface = v6_routethrough (&dest, NULL);
  g_warning("%s: interface: %s",__func__, interface);
  interface = v6_routethrough (&dest, NULL);
  g_warning("%s: interface: %s",__func__, interface);
  inet_pton(AF_INET6, <ipv6 addr with NO matching route in /proc/net/ipv6_route>, &dest);
  interface = v6_routethrough (&dest, NULL);
  g_warning("%s: interface: %s",__func__, interface);
  exit (0);

Result should be something like the following with the PR:

>> using procroutetechnique
>> interface: enp0s3
>> using procroutetechnique
>> interface: enp0s3
>> using connectsockettechnique
>> interface: enp0s9

And something like the following without the PR:

>> using procroutetechnique
>> interface: enp0s3
>> using connectsockettechnique
>> interface: enp0s3
>> using connectsockettechnique
>> interface: enp0s9

Checklist:

procroutetechnique is the default technique for
getting the interface we want to use for some given
destination addr.
This technique is represented as a static enum.
Previously the technique was set to fallback
method connectsockettechnique even though an
appropriate interface was found because
the fallback method was activated after the first
route in /proc/net/ipv6_route was checked and not
after all routes were checked. Every additional
invocation of the function therefore used the
fallback method as new default.
@ArnoStiefvater ArnoStiefvater changed the base branch from master to openvas-20.08 January 8, 2021 15:23
jjnicola
jjnicola previously approved these changes Jan 11, 2021
@ArnoStiefvater ArnoStiefvater merged commit f5fe050 into greenbone:openvas-20.08 Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants