openbmc / phosphor-networkd

Apache License 2.0
18 stars 48 forks source link

Gateway should be per-interface, ideally generalized to routes #26

Closed wak-google closed 3 years ago

wak-google commented 5 years ago

Currently, the daemon writes the gateway route out to all of the interface files. This causes systemd-networkd to load that route for each interface into the kernel, and allows the kernel to decide which route to keep. Thankfully, this works for IPv4 because the kernel able to filter out the requests which don't have addresses matching a network configured for an interface. Unfortunately, for IPv6 it is common to have routers in the local subnet, which all interfaces share. So the kernel tries to instantiate the gateway on all interfaces and ends up doing something weird. Simply by manually editing the configurations and using only a single gateway entry, we can get the system out of the broken state.

Ideally we would just generalize the whole thing to a routes interface and allow clients to specify arbitrary routes that map more closely to systemd-networkd / linux primitives.

00-bmc-eth0.network

[Match]
Name=eth0
[Link]
MACAddress=f4:f5:e8:7:94:10
[Network]
LinkLocalAddressing=yes
IPv6AcceptRA=false
DHCP=false
Address=10.244.20.103/26
Address=2002:af4:7480:1467::/128
Gateway=10.244.20.126
Gateway=fe80::1
[Neighbor]
Address=10.244.20.126
MACAddress=2:32:a:f4:14:7e
[Neighbor]
Address=fe80::1
MACAddress=2:32:0:0:0:0
[DHCP]
ClientIdentifier=mac
UseDNS=true
UseNTP=true
UseHostname=true
SendHostname=true

00-bmc-eth1.network

[Match]
Name=eth1
[Link]
MACAddress=52:55:c9:c4:dd:85
[Network]
LinkLocalAddressing=yes
IPv6AcceptRA=false
DHCP=false
Gateway=10.244.20.126
Gateway=fe80::1
[DHCP]
ClientIdentifier=mac
UseDNS=true
UseNTP=true
UseHostname=true
SendHostname=true

ip -6 route

2002:af4:7480:1467:: dev eth0  metric 256
fe80::/64 dev eth1  metric 256
fe80::/64 dev eth0  metric 256
default  metric 1024
ff00::/8 dev eth1  metric 256
ff00::/8 dev eth0  metric 256

Expected routes

2002:af4:7480:1467:: dev eth0  metric 256
fe80::/64 dev eth1  metric 256
fe80::/64 dev eth0  metric 256
default via fe80::1 dev eth0  metric 1024
ff00::/8 dev eth1  metric 256
ff00::/8 dev eth0  metric 256
ratagupt commented 5 years ago

Seems it is same as https://github.com/openbmc/openbmc/issues/2671

ratagupt commented 5 years ago

In that case this is a bug in the systemd-networkd, where if you have the gateway(Gateway=fe80::1) in eth0.network as well as eth1.network then we should have the following routes in the routing table.

2002:af4:7480:1467:: dev eth0 metric 256 fe80::/64 dev eth1 metric 256 fe80::/64 dev eth0 metric 256 default via fe80::1 dev eth0 metric 1024 default via fe80::1 dev eth1 metric 1024 ff00::/8 dev eth1 metric 256 ff00::/8 dev eth0 metric 256

ratagupt commented 3 years ago

@wak-google : Can we close this one as we have already implemented the interface specific gateway.