Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error from multiple adapters with same IP address
05-11-2017, 10:06 PM
Post: #1
Error from multiple adapters with same IP address
The ohNet device stack returns a fatal error when there are mutiple adapters with the same IP address and different subnet masks.

This problem has been reported by some MinimServer users running on unRAID but I am able to reproduce it on any Linux system. This configuration works:

Code:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
     inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether f0:ad:4e:00:a6:f4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.11/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::f2ad:4eff:fe00:a6f4/64 scope link
       valid_lft forever preferred_lft forever

and this configuration doesn't work:

Code:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet 127.0.0.1/32 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether f0:ad:4e:00:a6:f4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.11/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::f2ad:4eff:fe00:a6f4/64 scope link
       valid_lft forever preferred_lft forever

The failing configuration has an additional loopback adapter 127.0.0.1/32. Because this has a different subnet mask, the code in OsNetworkListAdapters in Os.c adds it to the adapter list and this causes an "address already in use" error when the device stack tries to bind a second server socket listener to the loopback adapter address. (MinimServer is calling initParams.setDvServerPort to fix the port number for server sockets.)

I can't think of any good reason for the same IP address to be configured with different subnet masks but I don't think ohNet should fail if this happens. I have created a patch for this and I have verified that it fixes the problem. The patch adds some code to OsNetworkListAdapters in Os.c to check for this situation and only adds the adapter with the least specific subnet mask as this is the effective result of such a configuration. The patch is attached and I have tested it using 1.17.2735.


Attached File(s)
.zip  multisubnet.zip (Size: 1.08 KB / Downloads: 2)
Find all posts by this user


Messages In This Thread
Error from multiple adapters with same IP address - simoncn - 05-11-2017 10:06 PM

Forum Jump: