From 871305ca0c430b6122f31ea7047c636e8241330d Mon Sep 17 00:00:00 2001 From: Alexandr Ilenko Date: Mon, 1 Aug 2022 17:30:24 +0300 Subject: SILABMC-172: Fix: enable DHCP back, and WebUI --- .../0001-Fix-enable-DHCP-back.patch | 87 ++++++++++++++++++++++ .../network/phosphor-network_%.bbappend | 5 ++ 2 files changed, 92 insertions(+) create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0001-Fix-enable-DHCP-back.patch create mode 100644 meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0001-Fix-enable-DHCP-back.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0001-Fix-enable-DHCP-back.patch new file mode 100644 index 0000000000..c8a364a42f --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network/0001-Fix-enable-DHCP-back.patch @@ -0,0 +1,87 @@ +From 73592ccbe666a53b748017b8e65ed158fb6ef296 Mon Sep 17 00:00:00 2001 +From: Alexandr Ilenko +Date: Fri, 29 Jul 2022 09:01:38 +0300 +Subject: [PATCH] Fix: enable DHCP back + +--- + src/ethernet_interface.cpp | 37 +++++++++++++++++++++++++++++++++++++ + src/ethernet_interface.hpp | 6 ++++++ + 2 files changed, 43 insertions(+) + +diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp +index 1e63a48..d082153 100644 +--- a/src/ethernet_interface.cpp ++++ b/src/ethernet_interface.cpp +@@ -164,6 +164,32 @@ void EthernetInterface::disableDHCP(IP::Protocol protocol) + } + } + ++void EthernetInterface::enableDHCP(IP::Protocol protocol) ++{ ++ DHCPConf dhcpState = EthernetInterfaceIntf::dhcpEnabled(); ++ if (dhcpState == EthernetInterface::DHCPConf::none) ++ { ++ if (protocol == IP::Protocol::IPv4) ++ { ++ dhcpEnabled(EthernetInterface::DHCPConf::v4); ++ } ++ else if (protocol == IP::Protocol::IPv6) ++ { ++ dhcpEnabled(EthernetInterface::DHCPConf::v6); ++ } ++ } ++ else if ((dhcpState == EthernetInterface::DHCPConf::v4) && ++ (protocol == IP::Protocol::IPv6)) ++ { ++ dhcpEnabled(EthernetInterface::DHCPConf::both); ++ } ++ else if ((dhcpState == EthernetInterface::DHCPConf::v6) && ++ (protocol == IP::Protocol::IPv4)) ++ { ++ dhcpEnabled(EthernetInterface::DHCPConf::both); ++ } ++} ++ + bool EthernetInterface::dhcpIsEnabled(IP::Protocol family) + { + const auto cur = EthernetInterfaceIntf::dhcpEnabled(); +@@ -436,8 +462,19 @@ void EthernetInterface::deleteObject(const std::string& ipaddress) + log("DeleteObject:Unable to find the object."); + return; + } ++ auto protocol = it->second->type(); + this->addrs.erase(it); + ++ if (std::none_of( ++ addrs.cbegin(), addrs.cend(), ++ [&](const auto& elem_pair) { ++ return originIsManuallyAssigned(elem_pair.second->origin()); ++ } ++ )) ++ { ++ enableDHCP(protocol); ++ } ++ + writeConfigurationFile(); + manager.reloadConfigs(); + } +diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp +index 8928455..e0e3390 100644 +--- a/src/ethernet_interface.hpp ++++ b/src/ethernet_interface.hpp +@@ -166,6 +166,12 @@ class EthernetInterface : public Ifaces + */ + void disableDHCP(IP::Protocol protocol); + ++ /** @brief Selectively enables DHCP ++ * @param[in] protocol - The IPv4 or IPv6 protocol to return from static ++ * addressing mode ++ */ ++ void enableDHCP(IP::Protocol protocol); ++ + /** Retrieve Link State */ + bool linkUp() const override; + +-- +2.35.1 + diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend new file mode 100644 index 0000000000..4283da0ff6 --- /dev/null +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-network_%.bbappend @@ -0,0 +1,5 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI += " \ + file://0001-Fix-enable-DHCP-back.patch \ + " -- cgit v1.2.3