Skip to content

Fix getprotobyname missing on Android preventing use#470

Open
Paliak wants to merge 9 commits into
schweikert:developfrom
Paliak:fix-getprotobyname-android
Open

Fix getprotobyname missing on Android preventing use#470
Paliak wants to merge 9 commits into
schweikert:developfrom
Paliak:fix-getprotobyname-android

Conversation

@Paliak

@Paliak Paliak commented May 17, 2026

Copy link
Copy Markdown

getprotobyname is stubbed out on Android causing crash_and_burn to be called. This commit removes the ICMP support check when compiling for Android and adds a configuration option to compile without getprotobyname check.

getprotobyname is stubbed out on Android causing crash_and_burn to be
called. This commit removes the icmp support check when compiling for
Android and adds a configuration option to compile without the check.

Signed-off-by: Paliak <91493239+Paliak@users.noreply.github.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a configuration option to disable the use of getprotobyname and switches to using hardcoded protocol constants (IPPROTO_ICMP and IPPROTO_ICMPV6) for socket initialization. This change improves compatibility with environments like Android where these lookups may fail. A review comment identifies formatting issues in src/socket6.c, specifically the use of tabs instead of spaces and a minor syntax typo in an if condition.

Comment thread src/socket6.c Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Comment thread src/socket4.c Outdated
Comment thread configure.ac Outdated
Paliak added 4 commits May 31, 2026 20:51
Signed-off-by: Paliak <91493239+Paliak@users.noreply.github.com>
Signed-off-by: Paliak <91493239+Paliak@users.noreply.github.com>
Signed-off-by: Paliak <91493239+Paliak@users.noreply.github.com>
@Paliak

Paliak commented May 31, 2026

Copy link
Copy Markdown
Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces conditional compilation to bypass getprotobyname on platforms like Android, falling back to default protocol constants (IPPROTO_ICMP and IPPROTO_ICMPV6). The reviewer suggests a more robust and idiomatic approach using Autoconf's standard feature detection (AC_CHECK_FUNCS([getprotobyname])) to define HAVE_GETPROTOBYNAME automatically, rather than hardcoding platform-specific checks and using a custom USE_GETPROTOBYNAME variable.

Comment thread configure.ac Outdated
Comment thread configure.ac Outdated
Comment thread configure.ac Outdated
Comment thread src/socket4.c Outdated
Comment thread src/socket6.c Outdated
@coveralls

coveralls commented Jun 7, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 88.08% (+0.08%) from 88.0% — Paliak:fix-getprotobyname-android into schweikert:develop

@gsnw-sebast gsnw-sebast requested a review from schweikert June 10, 2026 05:30
Comment thread src/socket4.c Outdated
struct protoent* proto;
int s;
int s = -1;
int p_proto = IPPROTO_ICMP;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can't we just use this on all platforms? It seems to me that maybe we don't need getprotobyname at all.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That was my thinking too. @gsnw-sebast suggested there may be situations where IPPROTO_ICMP differs from the return value of getprotobyname, so I added it back per that suggestion.

If we really want to check whether ICMP is supported on a given platform maybe we could just check for the define?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I looked into it, and you're actually right. The value could be set statically without the check via getprotobyname(). The numbers are assigned by the IANA [1], and even if fping were to support TCP or UDP in the future, these numbers would remain unchanged with TCP = 6 and UDP = 17.

It would even keep fping running if an incorrect protocol file were stored on the system

[1] https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed getprotobyname altogether in 4cd0304.

Paliak added 2 commits June 13, 2026 15:48
Signed-off-by: Paliak <91493239+Paliak@users.noreply.github.com>
@Paliak Paliak requested review from gsnw-sebast and schweikert June 13, 2026 14:00

@gsnw-sebast gsnw-sebast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I'm concerned, we can go ahead with that. We just need to update the changelog and prepare for a rebase merge.

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.

4 participants