Skip to content

Use interface with default route on Linux#733

Merged
phillip-stephens merged 2 commits intozmap:mainfrom
Tim---:fix-default-gw
Nov 30, 2023
Merged

Use interface with default route on Linux#733
phillip-stephens merged 2 commits intozmap:mainfrom
Tim---:fix-default-gw

Conversation

@Tim---
Copy link
Contributor

@Tim--- Tim--- commented Oct 13, 2023

It seems that patch bf5ed24 changed the way zmap finds the default interface.

It used to use get_default_gw to find the interface with the default route. Now it uses pcap_lookupdev which takes the first interface suitable for packet capture, but does not ensure that it has the default route.

This patch reverts to the old behavior and is consistent with get_gateway-bsd.h.

@zakird zakird added this to the ZMap 4.1 milestone Nov 4, 2023
Copy link
Contributor

@phillip-stephens phillip-stephens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks good.
The one issue I see is that when I ran Valgrind against main without and with this code change, with had an extra 16 bytes still reachable.

We have over 4 MB of total memory still reachable according to Valgrind in main, so this is relatively a small issue (that this issue was raised to address), but we shouldn't introduce more still reachable memory, IMO.

Valgrind Comparison

Alex's PR - (tested his fix applied to main)

==13== LEAK SUMMARY:
==13==    definitely lost: 8 bytes in 1 blocks
==13==    indirectly lost: 0 bytes in 0 blocks
==13==      possibly lost: 0 bytes in 0 blocks
==13==    still reachable: 4,343,736 bytes in 304 blocks
==13==         suppressed: 0 bytes in 0 blocks

Default main

==13== LEAK SUMMARY:
==13==    definitely lost: 8 bytes in 1 blocks
==13==    indirectly lost: 0 bytes in 0 blocks
==13==      possibly lost: 0 bytes in 0 blocks
==13==    still reachable: 4,343,720 bytes in 303 blocks
==13==         suppressed: 0 bytes in 0 blocks

@phillip-stephens phillip-stephens self-requested a review November 30, 2023 18:32
Copy link
Contributor

@phillip-stephens phillip-stephens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @Tim--- for the contribution!

@phillip-stephens phillip-stephens merged commit 6b4945f into zmap:main Nov 30, 2023
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.

3 participants