79 lines
3.2 KiB
Diff
79 lines
3.2 KiB
Diff
|
|
From 8095b90a438aebeba61721b30f0f7bd5f865c666 Mon Sep 17 00:00:00 2001
|
||
|
|
From: "Chen.Zhao" <zhao.chen@luxshare-ict.com>
|
||
|
|
Date: Tue, 26 Aug 2025 11:01:18 +0800
|
||
|
|
Subject: [PATCH] Fix ipv4 and ipv6 ip issue Openbmc use dbus property to
|
||
|
|
control ipv4/ipv6 ip mode: .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
|
||
|
|
|
||
|
|
DHCP4=true, DHCP6=true, set DHCPEnabled to xyz.openbmc_project.Network.EthernetInterface.DHCPConf.both
|
||
|
|
DHCP4=true, DHCP6=false, set DHCPEnabled to xyz.openbmc_project.Network.EthernetInterface.DHCPConf.v4
|
||
|
|
DHCP4=false, DHCP6=true, set DHCPEnabled to xyz.openbmc_project.Network.EthernetInterface.DHCPConf.v6
|
||
|
|
DHCP4=false, DHCP6=false, set DHCPEnabled to xyz.openbmc_project.Network.EthernetInterface.DHCPConf.none
|
||
|
|
|
||
|
|
re-write the EthernetInterface::dhcp4 and EthernetInterface::dhcp6 function to get current value and set value
|
||
|
|
---
|
||
|
|
src/ethernet_interface.cpp | 24 ++++++++++++++++++++----
|
||
|
|
1 file changed, 20 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
|
||
|
|
index 31c6145..43a68a8 100644
|
||
|
|
--- a/src/ethernet_interface.cpp
|
||
|
|
+++ b/src/ethernet_interface.cpp
|
||
|
|
@@ -388,8 +388,10 @@ bool EthernetInterface::ipv6AcceptRA(bool value)
|
||
|
|
|
||
|
|
bool EthernetInterface::dhcp4(bool value)
|
||
|
|
{
|
||
|
|
- if (dhcp4() != EthernetInterfaceIntf::dhcp4(value))
|
||
|
|
+ bool oldValue = dhcp4(); // get current value
|
||
|
|
+ if (value != oldValue) // compare current value and set value
|
||
|
|
{
|
||
|
|
+ EthernetInterfaceIntf::dhcp4(value); //set new value
|
||
|
|
writeConfigurationFile();
|
||
|
|
manager.get().reloadConfigs();
|
||
|
|
}
|
||
|
|
@@ -398,8 +400,10 @@ bool EthernetInterface::dhcp4(bool value)
|
||
|
|
|
||
|
|
bool EthernetInterface::dhcp6(bool value)
|
||
|
|
{
|
||
|
|
- if (dhcp6() != EthernetInterfaceIntf::dhcp6(value))
|
||
|
|
+ bool oldValue = dhcp6(); // get current value
|
||
|
|
+ if (value != oldValue) // compare current value and set value
|
||
|
|
{
|
||
|
|
+ EthernetInterfaceIntf::dhcp6(value); //set new value
|
||
|
|
writeConfigurationFile();
|
||
|
|
manager.get().reloadConfigs();
|
||
|
|
}
|
||
|
|
@@ -684,11 +688,23 @@ void EthernetInterface::writeConfigurationFile()
|
||
|
|
auto& network = config.map["Network"].emplace_back();
|
||
|
|
auto& lla = network["LinkLocalAddressing"];
|
||
|
|
#ifdef LINK_LOCAL_AUTOCONFIGURATION
|
||
|
|
- lla.emplace_back("yes");
|
||
|
|
+ if (dhcp4() && dhcp6())
|
||
|
|
+ {
|
||
|
|
+ lla.emplace_back("yes");
|
||
|
|
+ }
|
||
|
|
+ else if (dhcp4())
|
||
|
|
+ {
|
||
|
|
+ lla.emplace_back("ipv4");
|
||
|
|
+ }
|
||
|
|
+ else if (dhcp6())
|
||
|
|
+ {
|
||
|
|
+ lla.emplace_back("ipv6");
|
||
|
|
+ }
|
||
|
|
#else
|
||
|
|
lla.emplace_back("no");
|
||
|
|
#endif
|
||
|
|
- network["IPv6AcceptRA"].emplace_back(ipv6AcceptRA() ? "true" : "false");
|
||
|
|
+ network["IPv6AcceptRA"].emplace_back(
|
||
|
|
+ (ipv6AcceptRA() && dhcp6()) ? "true" : "false");
|
||
|
|
network["DHCP"].emplace_back(dhcp4() ? (dhcp6() ? "true" : "ipv4")
|
||
|
|
: (dhcp6() ? "ipv6" : "false"));
|
||
|
|
{
|
||
|
|
--
|
||
|
|
2.25.1
|
||
|
|
|