The defaultGateway is empty after set IPv4 Static Address
Is this the right place to submit this?
- [x] This is not a security vulnerability or a crashing bug
- [x] This is not a question about how to use OpenBMC
- [x] This is not a bug in an OpenBMC fork or a bug in code still under code review.
- [x] This is not a request for a new feature.
Bug Description
I'm testing on bmcweb revision : 4d7b5ddb3a2b6cc42b7bbc0c710f297e6df4fd55 (Commits on Mar 14, 2025).
I tried to use Redfish command to set a static IPv4 address and defaultGateway. After that, I saw the defaultGateway is empty.
Step to reproduce: Step 1: Check the defaultGateway is valid and DHCP v4 mode is Enable
root@board:~# busctl introspect xyz.openbmc_project.Network /xyz/openbmc_project/network/eth0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.Peer interface - - -
.GetMachineId method - s -
.Ping method - - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
xyz.openbmc_project.Collection.DeleteAll interface - - -
.DeleteAll method - - -
xyz.openbmc_project.Network.EthernetInterface interface - - -
.AutoNeg property b true emits-change
.DHCP4 property b true emits-change writable
.DHCP6 property b true emits-change writable
.DHCPEnabled property s "xyz.openbmc_project.Network.Ethernet... emits-change writable
.DefaultGateway property s "10.39.122.1" emits-change writable
.DefaultGateway6 property s "" emits-change writable
.DomainName property as 0 emits-change writable
.EmitLLDP property b false emits-change writable
.IPv6AcceptRA property b true emits-change writable
.InterfaceName property s "eth0" const
.LinkLocalAutoConf property s "xyz.openbmc_project.Network.Ethernet... emits-change writable
.LinkUp property b true emits-change
.MTU property u 1500 emits-change writable
.NICEnabled property b true emits-change writable
.NTPServers property as 0 emits-change writable
.Nameservers property as 3 "10.38.20.10" "10.38.18.70" "10.38.... emits-change
.Speed property u 1000 emits-change
.StaticNTPServers property as 0 emits-change writable
.StaticNameServers property as 0 emits-change writable
xyz.openbmc_project.Network.IP.Create interface - - -
.IP method ssys o -
xyz.openbmc_project.Network.MACAddress interface - - -
.MACAddress property s "9c:c2:66:77:88:99" emits-change writable
xyz.openbmc_project.Network.Neighbor.CreateStatic interface - - -
.Neighbor method ss o -
xyz.openbmc_project.Network.StaticGateway.Create interface - - -
.StaticGateway
Step 2: Add a staic IPv4 address by redfish command with IPv4 address and defaultGateway is valid.
curl -X PATCH --user root:0penBmc -H "Content-Type: application/json" -H "If-match: *" --insecure https://${BMC_IP}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 -d '{"IPv4StaticAddresses": [{"Address": "10.39.122.50", "Gateway": "10.39.122.1", "SubnetMask": "255.255.255.0"}]}'
Step 3: Check the defaultGateway => The defaultGateway is empty
root@board:~# busctl introspect xyz.openbmc_project.Network /xyz/openbmc_project/network/eth0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.Peer interface - - -
.GetMachineId method - s -
.Ping method - - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
xyz.openbmc_project.Collection.DeleteAll interface - - -
.DeleteAll method - - -
xyz.openbmc_project.Network.EthernetInterface interface - - -
.AutoNeg property b true emits-change
.DHCP4 property b true emits-change writable
.DHCP6 property b true emits-change writable
.DHCPEnabled property s "xyz.openbmc_project.Network.Ethernet... emits-change writable
.DefaultGateway property s "" emits-change writable
.DefaultGateway6 property s "" emits-change writable
.DomainName property as 0 emits-change writable
.EmitLLDP property b false emits-change writable
.IPv6AcceptRA property b true emits-change writable
.InterfaceName property s "eth0" const
.LinkLocalAutoConf property s "xyz.openbmc_project.Network.Ethernet... emits-change writable
.LinkUp property b true emits-change
.MTU property u 1500 emits-change writable
.NICEnabled property b true emits-change writable
.NTPServers property as 0 emits-change writable
.Nameservers property as 3 "10.38.20.10" "10.38.18.70" "10.38.... emits-change
.Speed property u 1000 emits-change
.StaticNTPServers property as 0 emits-change writable
.StaticNameServers property as 0 emits-change writable
xyz.openbmc_project.Network.IP.Create interface - - -
.IP method ssys o -
xyz.openbmc_project.Network.MACAddress interface - - -
.MACAddress property s "9c:c2:66:77:88:99" emits-change writable
xyz.openbmc_project.Network.Neighbor.CreateStatic interface - - -
.Neighbor method ss o -
xyz.openbmc_project.Network.StaticGateway.Create interface - - -
.StaticGateway method ss o -
Version
I'm testing on bmcweb revision : 4d7b5dd (Commits on Mar 14, 2025).
Additional Information
Other observations, I checked the source code of the bmcweb. It seems when we patch a redfish command to update IPv4StaticAddresses then the handleDHCPPatch also is called before https://github.com/openbmc/bmcweb/blob/master/redfish-core/lib/ethernet.hpp#L2416
That makes the defaultGateway is removed in the handleDHCPPatch.
But in handleIPv4StaticPatch function, the defaultGateway can not be added again because the ethData.defaultGateway can be not updated after the handleDHCPPatch removed the defaultGateway.
I am seeing this issue for multiple use cases
- When Invalid static IP is provided in PATCH request Gateway is getting cleared 2)When hostname is patched Gateway is getting cleared
- when PATCH name servers Gateway is getting cleared 3)when NIC has both static and DHCP ip address but NIC is in DHCP mode. If I delete the static IP the gateway is getting cleared
etc .. .....