Skip to content

correctly detect multiple IP addresses on the same interface - #96

Merged
schmonz merged 2 commits into
masterfrom
Dakon-ipme
Sep 22, 2019
Merged

schmonz merged 2 commits into
masterfrom
Dakon-ipme

Conversation

@DerDakon

@DerDakon DerDakon commented Aug 31, 2019 •

Copy link
Copy Markdown
Member

This affects only platforms where struct sockaddr has no member sa_len. The only system family that we found so far where this is the case and where you indeed can configure multiple IP addresses on the same interface is Linux.

Historically this has not been the case, back in the days of Linux 2.0 and 2.2 you had to create virtual interfaces per physical interface (I remember having "eth0:0" around).

Reason for this is that the code overwrites the IP address in the buffer when checking if the interface is actually up. The code for the sa_len case copied the IP address out to a different buffer first. Moving that code out of the #ifdef and deleting the wrong code is enough for the fix.

Unrelated to the bug is a change to use a better algorithm to get the needed buffer size in the first place. If you pass an empty buffer to SIOCGIFCONF it will tell you the needed buffer size, but the current code tried to scale it in a look until it is big enough.

Fixes #95.

@DerDakon DerDakon added the bug Something isn't working label Aug 31, 2019
@DerDakon DerDakon added this to the 1.08 milestone Aug 31, 2019
Comment thread ipme.c Resolved
Comment thread ipme.c Resolved
Comment thread ipme.c Resolved
Comment thread ipme.c Resolved
The problem was that the code did another ioctl() to check if the link is
actually up, and when doing this overwrites the information it is currently
looking at. The code when sa_len is available copies the current IP address out
before checking if the link is up. Reorder the code so both branches share more
code and both work.
@schmonz
schmonz merged commit b8fb15d into master Sep 22, 2019
@schmonz
schmonz deleted the Dakon-ipme branch September 22, 2019 15:27
@DerDakon DerDakon modified the milestones: 1.09, 1.08 Dec 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ipme does not detect multiple network addresses on the same interface

3 participants