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

ipme does not detect multiple network addresses on the same interface #95

Closed
DerDakon opened this issue Aug 29, 2019 · 3 comments · Fixed by #96
Closed

ipme does not detect multiple network addresses on the same interface #95

DerDakon opened this issue Aug 29, 2019 · 3 comments · Fixed by #96
Assignees
Labels
bug Something isn't working
Milestone

Comments

@DerDakon
Copy link
Member

Test setup: have multiple ip addresses configured on the same interface:

$ ip addr list | grep -e 'inet ' -e ^[0-9]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 172.16.198.3/16 brd 172.16.255.255 scope global noprefixroute dynamic wlan0
    inet 192.168.18.19/24 scope global wlan0

Ask ipmeprint about this:

$ ./ipmeprint 
0.0.0.0
127.0.0.1
172.16.198.3
172.16.198.3

Found here: https://bugs.gentoo.org/566826

I'm working on a patch.

@DerDakon DerDakon added the bug Something isn't working label Aug 29, 2019
@DerDakon DerDakon added this to the 1.08 milestone Aug 29, 2019
@DerDakon DerDakon self-assigned this Aug 29, 2019
@schmonz
Copy link
Member

schmonz commented Aug 30, 2019

A few amd64 results:

macOS 10.14

$ sudo ifconfig lo0 inet 23.45.67.89 alias
$ sudo ifconfig en0 inet 12.34.56.78 alias

$ for i in lo0 en0; do ifconfig $i | egrep -v 'ether|options|media|inet6|nd6|status'; done
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	inet 127.0.0.1 netmask 0xff000000
	inet 23.45.67.89 netmask 0xff000000
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	inet 192.168.1.153 netmask 0xffffff00 broadcast 192.168.1.255
	inet 12.34.56.78 netmask 0xff000000 broadcast 12.255.255.255

$ git co master && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
23.45.67.89
192.168.1.153
12.34.56.78

$ git co Dakon-ipme && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
23.45.67.89
192.168.1.153
12.34.56.78

Can't reproduce the bug. Code path: sa_len. If I #undef HASSALEN to get the #if 1 output, it gives 0.0.0.0 and that's it.

CentOS 6

$ sudo ip a add 23.45.67.89 dev lo
$ sudo ip a add 12.34.56.78 dev eth0

$ ip addr list | grep -e 'inet ' -e ^[0-9]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    inet 127.0.0.1/8 scope host lo
    inet 23.45.67.89/32 scope global lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
    inet 12.34.56.78/32 scope global eth0

$ git co master && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
127.0.0.1
10.0.2.15
10.0.2.15

$ git co Dakon-ipme && make ipmeprint && ./ipmeprint
ipme.c:56: error: ‘NULL’ undeclared (first use in this function)

(change it to 0, try again)

0.0.0.0
127.0.0.1
23.45.67.89
10.0.2.15
12.34.56.78

Code path: non-sa_len. #if 1 output looks correct.

CentOS 7

$ sudo ip a add 23.45.67.89 dev lo
$ sudo ip a add 12.34.56.78 dev enp0s3

$ ip addr list | grep -e 'inet ' -e ^[0-9]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
    inet 23.45.67.89/32 scope global lo
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic enp0s3
    inet 12.34.56.78/32 scope global enp0s3

$ git co master && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
127.0.0.1
10.0.2.15
10.0.2.15
$ git co Dakon-ipme && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
23.45.67.89
10.0.2.15
12.34.56.78

Code path: non-sa_len. #if 1 output looks correct.

Tribblix m21.0

$ sudo ifconfig lo0 addif 23.45.67.89 up
$ sudo ifconfig e1000g0 addif 12.34.56.78 up

I think autoconfig is preventing the second additional IP from persisting:

$ ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 23.45.67.89 netmask ff000000
e1000g0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 3
        inet 10.0.2.15 netmask ffffff00 broadcast 10.0.2.255

$ git co master && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
23.45.67.89
10.0.2.15

$ git co Dakon-ipme && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
23.45.67.89
10.0.2.15

Can't reproduce the bug. Code path: non-sa_len. #if 1 output looks correct.

FreeBSD 12

$ sudo ifconfig lo0 inet 23.45.67.89 alias
$ sudo ifconfig em0 inet 12.34.56.78 alias

$ for i in lo0 em0; do ifconfig $i | egrep -v 'ether|options|media|inet6|nd6|status|groups'; done
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	inet 127.0.0.1 netmask 0xff000000
	inet 23.45.67.89 netmask 0xff000000
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255
	inet 12.34.56.78 netmask 0xff000000 broadcast 12.255.255.255

$ git co master && make ipmeprint && ./ipmeprint
0.0.0.0
10.0.2.15
12.34.56.78
127.0.0.1
23.45.67.89

$ git co Dakon-ipme && make ipmeprint && ./ipmeprint
0.0.0.0
10.0.2.15
12.34.56.78
127.0.0.1
23.45.67.89

Can't reproduce the bug. Code path: sa_len.

NetBSD 8 and -current

$ sudo ifconfig lo0 inet 23.45.67.89 alias
$ sudo ifconfig wm0 inet 12.34.56.78 alias

$ for i in lo0 wm0; do ifconfig $i | egrep -v 'ether|options|media|inet6|nd6|status|groups|capabilities|enabled|address'; done
lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33624
        inet 127.0.0.1/8 flags 0x0
        inet 23.45.67.89/8 flags 0x0
wm0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 10.0.2.15/24 broadcast 10.0.2.255 flags 0x0
        inet 12.34.56.78/8 broadcast 12.255.255.255 flags 0x0

$ git co master && make ipmeprint && ./ipmeprint
0.0.0.0
10.0.2.15
12.34.56.78
127.0.0.1
23.45.67.89

$ git co Dakon-ipme && make ipmeprint && ./ipmeprint
0.0.0.0
10.0.2.15
12.34.56.78
127.0.0.1
23.45.67.89

Can't reproduce the bug. Code path: sa_len.

OpenBSD 6.5

$ sudo ifconfig lo0 inet 23.45.67.89 alias
$ sudo ifconfig em0 inet 12.34.56.78 alias

$ for i in lo0 em0; do ifconfig $i | egrep -v 'ether|options|media|inet6|nd6|status|groups|index|lladdr'; done
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768
	inet 127.0.0.1 netmask 0xff000000
	inet 23.45.67.89 netmask 0xff000000
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255
	inet 12.34.56.78 netmask 0xff000000 broadcast 12.255.255.255

$ git co master && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
23.45.67.89
10.0.2.15
12.34.56.78

$ git co Dakon-ipme && make ipmeprint && ./ipmeprint
0.0.0.0
127.0.0.1
23.45.67.89
10.0.2.15
12.34.56.78

Can't reproduce the bug. Code path: sa_len.

@schmonz
Copy link
Member

schmonz commented Aug 30, 2019

I'm assured by someone who understands Illumos that there is only ever a one-to-one mapping between IPs and logical interfaces, and the system creates logical interfaces as needed to keep this true. So I think we can be sure the code works correctly on Illumos.

@schmonz
Copy link
Member

schmonz commented Sep 2, 2019

See #96 for the proposed fix.

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 a pull request may close this issue.

2 participants