Hi Hurd,
These patches improve routing RPCs and ioctls in lwip, to make them behave consistently and according to expectations. The first patch is about the pfinet_getroutes RPC. In previous patches, I added some ioctls that translate between the limited lwip routing and standard routing. However, the pfinet_getroutes RPC was not following that logic and was just returning the existing configuration for each interface. This patch adapts it to make in consistent with the ioctls. The second patch modifies SIOCADDRT to ensure there's only one default gateway configured in the system. This is to fix a bug I observed when testing with dhcpcp. Sometimes, when there are multiple interfaces, this sequence of events happen: ``` lo: using static address 127.0.0.1/8 lo: adding route to 127.0.0.0/8 /dev/eth2: soliciting a DHCP lease /dev/eth1: soliciting a DHCP lease /dev/eth2: offered 192.168.124.250 from 192.168.124.1 /dev/eth2: ignoring offer of 192.168.124.250 from 192.168.124.1 /dev/eth2: probing address 192.168.124.250/24 /dev/eth1: offered 192.168.123.172 from 192.168.123.1 /dev/eth1: ignoring offer of 192.168.123.172 from 192.168.123.1 /dev/eth1: probing address 192.168.123.172/24 /dev/eth2: leased 192.168.124.250 for 3600 seconds /dev/eth2: adding route to 192.168.124.0/24 /dev/eth2: adding default route via 192.168.124.1 /dev/eth1: leased 192.168.123.172 for 3600 seconds /dev/eth1: adding route to 192.168.123.0/24 /dev/eth1: changing default route via 192.168.123.1 ``` So first, the interface 124 is set as the default and gets a gateway, then the default interface and gateway is changed to interface 123. In this situation, the gateway at 124 must be deleted, because dhcpcd assumes it's gone and doesn't remove it when shutting down: ``` ^Creceived SIGINT, stopping /dev/eth2: removing interface /dev/eth2: deleting route to 192.168.124.0/24 /dev/eth1: removing interface /dev/eth1: deleting route to 192.168.123.0/24 /dev/eth1: deleting default route via 192.168.123.1 lo: removing interface lo: deleting route to 127.0.0.0/8 dhcpcd exited ``` So 124 ends up misconfigured with a "leaked" gateway.
