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

fping when ipv6 is disabled on a server #118

Closed
pezz opened this issue Jul 12, 2017 · 21 comments
Closed

fping when ipv6 is disabled on a server #118

pezz opened this issue Jul 12, 2017 · 21 comments

Comments

@pezz
Copy link

pezz commented Jul 12, 2017

Hi there,

I was just curious if fping is working as intended when ipv6 is disabled on a box?

I get some very strange behaviour:

% fping -4 www.google.com
(null): can't create raw socket (must run as root?) : Address family not supported by protocol

% sudo fping -4 www.google.com
(null): can't create raw socket (must run as root?) : Address family not supported by protocol

% ls -al /usr/bin/fping
-r-sr-xr-x 1 root root 47796 Apr 29 03:28 /usr/bin/fping

% pacman -Qs fping
local/fping 4.0-1
    A utility to ping multiple hosts at once

% fping -h
(null): can't create raw socket (must run as root?) : Address family not supported by protocol

% sudo fping -h
(null): can't create raw socket (must run as root?) : Address family not supported by protocol

I can't even print the help page.

This is on Arch Linux ARM and is built with the options contained in this PKGBUILD:

https://archlinuxarm.org/packages/armv7h/fping/files/PKGBUILD

Any thoughts?

Cheers.

@bodsch
Copy link

bodsch commented Sep 10, 2017

The same here.
With docker and Alpine Linux.

fping -4 8.8.8.8
(null): can't create raw socket (must run as root?) : Address family not supported by protocol

fping Version:

apk info fping
fping-4.0-r0 description:
A utility to ping multiple hosts at once

fping-4.0-r0 webpage:
http://fping.org/

fping-4.0-r0 installed size:
53248

@NetworkEng
Copy link

NetworkEng commented Sep 10, 2017

@bodsch - I am not able to reproduce your results using alpine:latest (3.6)

$ docker run -it --rm alpine
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.2-118-g57a88ee6b0 [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.2-119-ga84f2c0b45 [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
OK: 8441 distinct packages available
/ # apk add fping
(1/1) Installing fping (4.0-r0)
Executing busybox-1.26.2-r5.trigger
OK: 4 MiB in 12 packages
/ # apk info fping
fping-4.0-r0 description:
A utility to ping multiple hosts at once

fping-4.0-r0 webpage:
http://fping.org/

fping-4.0-r0 installed size:
53248

/ # fping -v
fping: Version 4.0
fping: comments to david@schweikert.ch
/ # fping -4 8.8.8.8
8.8.8.8 is alive
/ #

Are you using a different version/flavor of Alpine?

/ # cat /etc/alpine-release
3.6.2

Or perhaps some other Alpine based image that has v6 disabled? I did also try daemonizing an Alpine container and followed steps here on disabling v6, restarted the container and then installed the fping package and results were the same as above. I.e. no issues.

Edit: Never mind on this last paragraph as it seems that v6 is NOT enabled by default in Alpine Linux, and is also the case in the alpine:latest Docker image.

@NetworkEng
Copy link

NetworkEng commented Sep 10, 2017

@pezz - Have you tried reaching out to the package maintainers or opened an issue on the Arch Linux ARM forum? Not saying that their build options are at fault (could be, but I just don't know), but they should at least know that the "--enable-ipv4 --enable-ipv6" options are no longer needed as both v4 and v6 are integrated into a single binary and are enabled by default. Check the CANGELOG here: https://github.com/schweikert/fping/blob/develop/CHANGELOG.md

@pezz
Copy link
Author

pezz commented Sep 10, 2017

@NetworkEng Sure mate, I can let them know.

However I just downloaded and modified the PKGBUILD then built and get the same behaviour.

Edit: I also just built it from git, same result as well.

Cheers.

@NetworkEng
Copy link

@pezz - No worries. My main point is that it's probably best to have the Arch experts have a look into why it's not working in your specific case, as I am unable to reproduce it on other OS (Centos, Ubuntu, Alpine - though all are x86_64). I am not familiar with Arch and don't have any ARM boards to in order to check it out.

Just a few thoughts for troubleshooting when posting on the Arch forum:
If you enable IPv6, does it work? Does it also fail for an Arch x86_64 install with no v6? Are there some build config or other dependencies that are missing (or incompatibilities) in the build specific to Arch ARM? Is it just your system or are all Arch ARM users experiencing the same?

Just FYI - I am not a maintainer of the fping source, just and avid user. Here's to hoping that @schweikert or any of the other experts here may have some familiarity with this issue and able to provide direction. :)

@pezz
Copy link
Author

pezz commented Sep 11, 2017

@NetworkEng I just did those two exact tests! 😄

  • Re-enabling ipv6 on the Pi = fping works
  • Disabling ipv6 on one my x86_64 boxes = fping fails as per the original report

@NetworkEng
Copy link

@pezz I was poking around the Arch wiki re. disabling IPv6. Out of curiosity, what method are you using to disable v6?

@pezz
Copy link
Author

pezz commented Sep 11, 2017

ipv6.disable=1 on the kernel command line.

@NetworkEng
Copy link

NetworkEng commented Sep 11, 2017

@pezz - Does this alternate kernel command line option work, or does it cause other issues?

Alternatively, adding ipv6.disable_ipv6=1 instead will keep the IPv6 stack functional but will not assign IPv6 addresses to any of your network devices.

That wiki has the following warning, which I suspect may be why you are having this issue:

Warning: Disabling the IPv6 stack can break certain programs which expect it to be enabled. FS#46297

@pezz
Copy link
Author

pezz commented Sep 11, 2017

@NetworkEng That does work, however I still think there's something not quite right with fping.

@bodsch
Copy link

bodsch commented Sep 14, 2017

@NetworkEng

Here comes my container:

# docker run -it --rm alpine
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
88286f41530e: Already exists 
Digest: sha256:f006ecbb824d87947d0b51ab8488634bf69fe4094959d935c0c103f4820a417d
Status: Downloaded newer image for alpine:latest
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.2-124-gec71fc07e1 [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.2-119-ga84f2c0b45 [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
OK: 8441 distinct packages available
/ # apk add fping
(1/1) Installing fping (4.0-r0)
Executing busybox-1.26.2-r5.trigger
OK: 4 MiB in 12 packages
/ # apk info fping
fping-4.0-r0 description:
A utility to ping multiple hosts at once

fping-4.0-r0 webpage:
http://fping.org/

fping-4.0-r0 installed size:
53248

/ # fping -v
(null): can't create raw socket (must run as root?) : Address family not supported by protocol
/ # fping -4 8.8.8.8
(null): can't create raw socket (must run as root?) : Address family not supported by protocol
/ # 

I have no IPv6 Support on the Hostsystem (gentoo based).
Is'nt needed there

@ggossett
Copy link

ggossett commented Dec 4, 2017

@NetworkEng Hello, I would like to mention that the kernel command-line option you have suggested ipv6.disable_ipv6=1 instead of ipv6.disable=1 doesn't do the same thing. With this change, network interfaces still receive IPv6 multicast related addresses (ff02:xxxx) and also IPv6 related multicast layer 2 MAC addresses (33:33:xxxx). I would very much prefer these don't have to be enabled in order to ping an IPv4 address with fping. I can reproduce this problem with fedora 27 and the kernel comman-line set with ipv6.disable=1. fping doesn't complain with ipv6.disble_ipv6=1, however, this is not ideal. I have to reboot and change my kernel command line just to use fping to look at ipv4

@realsimix
Copy link

If IPv6 is not available on the host, but fping is built with IPv6 support, then calling fping fails even if --ipv4 is used. Somehow the man page confirms this with "Restrict name resolution and IPs to IPv4 addresses."

It says name resolution is only done for IPv4, but inside it still uses IPv6 functions. Those fail in case IPv6 is disabled on the host.

I'll try to come up with a fix tomorrow.

@realsimix
Copy link

Attached patch seems to fix it for me.
fping-4.0-ipv6_disabled_socket_error.patch.txt

@realsimix
Copy link

realsimix commented Feb 22, 2018

Unfortunately the committed patch doesn't fix the problem and dies with a SEGFAULT:

[root@zbx ~]# strace fping --ipv4 127.0.0.1
execve("/usr/sbin/fping", ["fping", "--ipv4", "127.0.0.1"], [/* 31 vars */]) = 0
brk(0)                                  = 0x9f55000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f40000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=29604, ...}) = 0
mmap2(NULL, 29604, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f38000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 @g\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1706204, ...}) = 0
mmap2(0x65e000, 1422788, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x65e000
mmap2(0x7b4000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x156) = 0x7b4000
mmap2(0x7b7000, 9668, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7b7000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f37000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7f376c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0x7b4000, 8192, PROT_READ)     = 0
mprotect(0x65a000, 4096, PROT_READ)     = 0
munmap(0xb7f38000, 29604)               = 0
brk(0)                                  = 0x9f55000
brk(0x9f76000)                          = 0x9f76000
open("/etc/nsswitch.conf", O_RDONLY)    = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1717, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f3f000
read(3, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 1717
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0xb7f3f000, 4096)                = 0
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=29604, ...}) = 0
mmap2(NULL, 29604, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f38000
close(3)                                = 0
open("/lib/libnss_files.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340\30\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=50848, ...}) = 0
mmap2(NULL, 45712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x8b3000
mmap2(0x8bd000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9) = 0x8bd000
close(3)                                = 0
mprotect(0x8bd000, 4096, PROT_READ)     = 0
munmap(0xb7f38000, 29604)               = 0
open("/etc/protocols", O_RDONLY)        = 3
fcntl64(3, F_GETFD)                     = 0
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=6108, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f3f000
read(3, "# /etc/protocols:\n# $Id: protoco"..., 4096) = 4096
close(3)                                = 0
munmap(0xb7f3f000, 4096)                = 0
socket(PF_INET, SOCK_RAW, IPPROTO_ICMP) = 3
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
open("/etc/protocols", O_RDONLY)        = 4
fcntl64(4, F_GETFD)                     = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
fstat64(4, {st_mode=S_IFREG|0644, st_size=6108, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f3f000
read(4, "# /etc/protocols:\n# $Id: protoco"..., 4096) = 4096
close(4)                                = 0
munmap(0xb7f3f000, 4096)                = 0
socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6) = -1 EAFNOSUPPORT (Address family not supported by protocol)
socket(PF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6) = -1 EAFNOSUPPORT (Address family not supported by protocol)
getuid32()                              = 0
getpid()                                = 17900
setsockopt(3, SOL_SOCKET, SO_TIMESTAMP, [1], 4) = 0
rt_sigaction(SIGINT, {0x804a3e0, [INT], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
gettimeofday({1519307139, 227880}, {4294967236, 0}) = 0
mmap2(NULL, 1052672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e36000
gettimeofday({1519307139, 228279}, {4294967236, 0}) = 0
sendto(3, "\10\0\262\23E\354\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 64, 0, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, 16) = 64
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

My version of the code works for me 👍

Regards,
Simon

@schweikert schweikert reopened this Feb 22, 2018
@schweikert
Copy link
Owner

Thanks Simon for testing and reporting the issue. The reason why I adapted your fix (and apparently introduced a bug), is that theoretically a filedescriptor number 0 is valid (see #125), so even if in this case it can’t happen to have a socket fd 0, it seemed cleaner to use -1 instead of 0. I will check and try to find out why it crashes now.

@schweikert
Copy link
Owner

@realsimix : I can’t reproduce the problem. Did you test with the code in the develop branch? Did you do a “make clean” before building again? Can you create a stracktrace maybe?

@realsimix
Copy link

realsimix commented Feb 23, 2018

@schweikert : Here's the trace of my test, and yes it's from the develop branch:

Core was generated by `./fping --ipv4 127.0.0.1'.
Program terminated with signal 11, Segmentation fault.
#0  0x0804a88f in socket_can_read (timeout=0xbfccc568) at fping.c:1698
1698	    FD_SET(socket6, &readset);
(gdb) bt
#0  0x0804a88f in socket_can_read (timeout=0xbfccc568) at fping.c:1698
#1  0x0804a9a9 in wait_for_reply (wait_time=0) at fping.c:2011
#2  0x0804b9a8 in main_loop () at fping.c:1247
#3  0x0804cbcd in main (argc=3, argv=0x0) at fping.c:998

On a first sight the FD_SET(socket6, &readset); seems wrong - at least socket6, right?

Regards,
Simon

@schweikert
Copy link
Owner

@realsimix : sorry for the slow reaction on my part... It should be fixed in the develop branch now I hope

@realsimix
Copy link

Thanks, it works now in my case.

@v-zhuravlev
Copy link

v-zhuravlev commented Jul 19, 2018

That fixed it for me on raspberry w/o ipv6 support. Thanks

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

No branches or pull requests

7 participants