openbmc / phosphor-networkd

Apache License 2.0
18 stars 49 forks source link

Failed to set gateway via ipmitool #42

Closed leiyu-bytedance closed 3 years ago

leiyu-bytedance commented 3 years ago

This issue could be reproduced in QEMU.

When the image is started in QEMU, it gets DHCP IP/gateway correctly, e.g.

ipmitool lan print
...
IP Address Source       : DHCP Address
IP Address              : 10.0.2.15
Subnet Mask             : 255.255.255.0
MAC Address             : 52:54:00:12:34:56
Default Gateway IP      : 10.0.2.2
...

Now let's set the static IP and a different gateway with below commands

ipmitool lan set 1 ipsrc static
sleep 10    # This is to avoid issue openbmc/phosphor-networkd#41
ipmitool lan set 1 ipaddr 10.0.2.15
ipmitool lan set 1 netmask 255.255.255.0
ipmitool lan set 1 defgw ipaddr 10.0.2.3

After the network is reloaded, check lan print again:

# ipmitool
...
IP Address Source       : Static Address
IP Address              : 10.0.2.15
Subnet Mask             : 255.255.255.0
MAC Address             : 52:54:00:12:34:56
Default Gateway IP      : 10.0.2.2
...

We could see that the default gateway is not updated.

The network config looks like below:

# cat /etc/systemd/network/00-bmc-eth0.network
[Match]
Name=eth0
[Link]
MACAddress=52:54:00:12:34:56
[Network]
LinkLocalAddressing=yes
IPv6AcceptRA=true
DHCP=ipv6
[Address]
Address=10.0.2.15/24
[Route]
Gateway=10.0.2.2
[Route]
Gateway=fe80::2
[Route]
Gateway=10.0.2.3
[Route]
Gateway=fe80::2
[DHCP]
ClientIdentifier=mac
UseDNS=true
UseNTP=true
UseHostname=true
SendHostname=true

We could see that there are two IPv4 gateways and it could be the root cause of the issue. So this issue is very similar to https://github.com/openbmc/phosphor-networkd/issues/40

leiyu-bytedance commented 3 years ago

The route table when the issue occurs:

# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.0.2.3        0.0.0.0         UG        0 0          0 eth0
0.0.0.0         10.0.2.2        0.0.0.0         UG        0 0          0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
leiyu-bytedance commented 3 years ago

Submitted a patch to ipmid: https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-host-ipmid/+/45806

And together with https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-networkd/+/45634, the issue could be fixed.

leiyu-bytedance commented 3 years ago

Fixed by the above commits.