commit | 8d26c0d3a9bf14f5ad36b89db3fd3ce0d428655c | [log] [tgz] |
---|---|---|
author | Chandramohan Harkude <chandramohan.harkude@gmail.com> | Thu Aug 07 00:17:11 2025 +0530 |
committer | Chandra Harkude <Chandramohan.harkude@gmail.com> | Tue Aug 26 04:22:58 2025 +0000 |
tree | 16c8c807964208d369807e96c7ef0f89701171c3 | |
parent | 42448d977c7c31709f13314440281493c2885766 [diff] |
ethernet: Fix premature gateway clearing on static IP validation fail When a PATCH request contains invalid IPv4 static addresses, the gateway was being incorrectly cleared even though the static IP configuration failed validation. This occurred because HandleDHCPPatch function would clear the gateway based on the current DHCP state without validating the static addresses first. ``` Problem: - handleDHCPPatch() runs before handleIPv4StaticPatch() - If DHCP was currently active, gateway got cleared immediately - When static IP validation later failed, gateway remained cleared - This caused working DHCP configurations to lose their gateway Example scenario: 1. System has working DHCP: IP=10.0.2.15, Gateway=10.0.2.2 2. User sends PATCH with invalid static IP: Gateway="10.3.36" 3. handleDHCPPatch() clears gateway because DHCP is currently active 4. handleIPv4StaticPatch() fails validation and returns early 5. Result: Gateway lost (shows as 0.0.0.0), network potentially broken "IPv4Addresses": [ { "Address": "10.0.2.15", "AddressOrigin": "DHCP", "Gateway": "0.0.0.0", "SubnetMask": "255.255.255.0" } ] Solution: - Add pre-validation of IPv4 static addresses before handleDHCPPatch() - Only clear gateway when DHCP is currently active AND IPv4 static addresses are valid - This handles the implicit DHCP→Static transition correctly - Preserve existing gateway when static IP validation fails - Ensure failed requests don't have side effects on working config Logic: - If system uses DHCP AND user provides valid static addresses: Clear DHCP gateway to prepare for clean transition to static - If static addresses are invalid: Preserve existing DHCP gateway - If system already uses static config: No gateway clearing needed Changes: - Modified handleDHCPPatch() to accept hasValidIPv4StaticAddresses parameter - Added pre-validation step in main PATCH handler using parseAddresses() - Changed gateway clearing condition from dhcpBeingEnabled to ipv4Active - Added safety check to prevent clearing gateway on validation failures Testing: - PATCH with invalid static IPs no longer affects working DHCP gateway - PATCH with valid static IPs on DHCP system properly clears gateway for clean transition - Mixed requests handle validation failures gracefully - Static-to-static updates work without unnecessary gateway clearing ~$ curl -k -N -X GET https://root:0penBmc@127.0.0.1:2443/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 { "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0", "@odata.type": "#EthernetInterface.v1_9_0.EthernetInterface", "DHCPv4": { "DHCPEnabled": true, "UseDNSServers": true, "UseDomainName": true, "UseNTPServers": true }, "DHCPv6": { "OperatingMode": "Enabled", "UseDNSServers": true, "UseDomainName": true, "UseNTPServers": true }, "Description": "Management Network Interface", "EthernetInterfaceType": "Physical", "FQDN": "gb200nvl-bmc", "HostName": "gb200nvl-bmc", "IPv4Addresses": [ { "Address": "10.0.2.15", "AddressOrigin": "DHCP", "Gateway": "10.0.2.2", "SubnetMask": "255.255.255.0" } ], "IPv4StaticAddresses": [], "IPv6AddressPolicyTable": [], "IPv6Addresses": [ { "Address": "fe80::86:6cff:feb4:1b3b", "AddressOrigin": "LinkLocal", "PrefixLength": 64 }, { "Address": "fec0::86:6cff:feb4:1b3b", "AddressOrigin": "DHCPv6", "PrefixLength": 64 } ], "IPv6DefaultGateway": "fe80::2", "IPv6StaticAddresses": [], "IPv6StaticDefaultGateways": [], "Id": "eth0", "InterfaceEnabled": true, "LinkStatus": "LinkUp", "MACAddress": "02:86:6c:b4:1b:3b", "MTUSize": 1500, "Name": "Manager Ethernet Interface", "NameServers": [ "10.0.2.3" ], "SpeedMbps": 100, "StatelessAddressAutoConfig": { "IPv6AutoConfigEnabled": true }, "StaticNameServers": [], "Status": { "Health": "OK", "State": "Enabled" } } ~$ curl -k -N -X PATCH https://root:0penBmc@127.0.0.1:2443/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 -H "Content-Type: application/json" -d '{"IPv4StaticAddresses": [{"Address": "10.7.7.7", "SubnetMask": "255.255.0.0", "Gateway": "10.3.36"}]}' -v < HTTP/1.1 400 Bad Request < Allow: DELETE, GET, PATCH < OData-Version: 4.0 < Strict-Transport-Security: max-age=31536000; includeSubdomains < Pragma: no-cache < Cache-Control: no-store, max-age=0 < X-Content-Type-Options: nosniff < Content-Type: application/json < Date: Wed, 06 Aug 2025 17:50:08 GMT < Content-Length: 1138 < { "IPv4StaticAddresses/0/Address@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value '\"\"' for the property IPv4StaticAddresses/0/Address is not a format that the property can accept.", "MessageArgs": [ "\"\"", "IPv4StaticAddresses/0/Address" ], "MessageId": "Base.1.19.PropertyValueFormatError", "MessageSeverity": "Warning", "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed." } ], "IPv4StaticAddresses/0/Gateway@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value '\"10.3.36\"' for the property IPv4StaticAddresses/0/Gateway is not a format that the property can accept.", "MessageArgs": [ "\"10.3.36\"", "IPv4StaticAddresses/0/Gateway" ], "MessageId": "Base.1.19.PropertyValueFormatError", "MessageSeverity": "Warning", "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed." } ] } $ curl -k -N -X GET https://root:0penBmc@127.0.0.1:2443/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 { "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0", "@odata.type": "#EthernetInterface.v1_9_0.EthernetInterface", "DHCPv4": { "DHCPEnabled": true, "UseDNSServers": true, "UseDomainName": true, "UseNTPServers": true }, "DHCPv6": { "OperatingMode": "Enabled", "UseDNSServers": true, "UseDomainName": true, "UseNTPServers": true }, "Description": "Management Network Interface", "EthernetInterfaceType": "Physical", "FQDN": "gb200nvl-bmc", "HostName": "gb200nvl-bmc", "IPv4Addresses": [ { "Address": "10.0.2.15", "AddressOrigin": "DHCP", "Gateway": "10.0.2.2", "SubnetMask": "255.255.255.0" } ], "IPv4StaticAddresses": [], "IPv6AddressPolicyTable": [], "IPv6Addresses": [ { "Address": "fe80::86:6cff:feb4:1b3b", "AddressOrigin": "LinkLocal", "PrefixLength": 64 }, { "Address": "fec0::86:6cff:feb4:1b3b", "AddressOrigin": "DHCPv6", "PrefixLength": 64 } ], "IPv6DefaultGateway": "fe80::2", "IPv6StaticAddresses": [], "IPv6StaticDefaultGateways": [], "Id": "eth0", "InterfaceEnabled": true, "LinkStatus": "LinkUp", "MACAddress": "02:86:6c:b4:1b:3b", "MTUSize": 1500, "Name": "Manager Ethernet Interface", "NameServers": [ "10.0.2.3" ], "SpeedMbps": 100, "StatelessAddressAutoConfig": { "IPv6AutoConfigEnabled": true }, "StaticNameServers": [], "Status": { "Health": "OK", "State": "Enabled" } } ``` Change-Id: Ic841344051681896bb6a0d3f8552ea9dfd92de9f Signed-off-by: Chandramohan Harkude <chandramohan.harkude@gmail.com>
This component attempts to be a "do everything" embedded webserver for OpenBMC.
The webserver implements a few distinct interfaces:
bmcweb at a protocol level supports http and https. TLS is supported through OpenSSL. Http1 and http2 are supported using ALPN registration for TLS connections and h2c upgrade header for http connections.
Bmcweb supports multiple authentication protocols:
Each of these types of authentication is able to be enabled or disabled both via runtime policy changes (through the relevant Redfish APIs) or via configure time options. All authentication mechanisms supporting username/password are routed to libpam, to allow for customization in authentication implementations.
All authorization in bmcweb is determined at routing time, and per route, and conform to the Redfish PrivilegeRegistry.
*Note: Non-Redfish functions are mapped to the closest equivalent Redfish privilege level.
bmcweb is configured per the meson build files. Available options are documented in meson_options.txt
meson setup builddir ninja -C builddir
If any of the dependencies are not found on the host system during configuration, meson will automatically download them via its wrap dependencies mentioned in bmcweb/subprojects
.
bmcweb relies on some on-system data for storage of persistent data that is internal to the process. Details on the exact data stored and when it is read/written can seen from the persistent_data
namespace.
When SSL support is enabled and a usable certificate is not found, bmcweb will generate a self-signed a certificate before launching the server. Please see the bmcweb source code for details on the parameters this certificate is built with.
bmcweb supports various forms of http compression, including zstd and gzip. Client headers are observed to determine whether compressed payloads are supported.
bmcweb is capable of aggregating resources from satellite BMCs. Refer to AGGREGATION.md for more information on how to enable and use this feature.