clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: I335e0c726360eaae85b9b54c16b5dcbe4a3f182e
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
@@ -98,13 +98,14 @@
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
diff --git a/src/config_parser.cpp b/src/config_parser.cpp
index e73c889..e4886ec 100644
--- a/src/config_parser.cpp
+++ b/src/config_parser.cpp
@@ -54,9 +54,8 @@
return dir / stdplus::strCat(intf, ".netdev"sv);
}
-const std::string*
- SectionMap::getLastValueString(std::string_view section,
- std::string_view key) const noexcept
+const std::string* SectionMap::getLastValueString(
+ std::string_view section, std::string_view key) const noexcept
{
auto sit = find(section);
if (sit == end())
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index b818a59..da785cc 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -17,12 +17,10 @@
using namespace phosphor::network;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-Configuration::Configuration(sdbusplus::bus_t& bus,
- stdplus::const_zstring objPath,
- stdplus::PinnedRef<EthernetInterface> parent,
- DHCPType type) :
- Iface(bus, objPath.c_str(), Iface::action::defer_emit),
- parent(parent)
+Configuration::Configuration(
+ sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
+ stdplus::PinnedRef<EthernetInterface> parent, DHCPType type) :
+ Iface(bus, objPath.c_str(), Iface::action::defer_emit), parent(parent)
{
config::Parser conf(config::pathForIntfConf(
parent.get().manager.get().getConfDir(), parent.get().interfaceName()));
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index cd06003..6a34492 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -79,24 +79,20 @@
return a.isUnicast() && !a.isLoopback();
}
-EthernetInterface::EthernetInterface(stdplus::PinnedRef<sdbusplus::bus_t> bus,
- stdplus::PinnedRef<Manager> manager,
- const AllIntfInfo& info,
- std::string_view objRoot,
- const config::Parser& config,
- bool enabled) :
+EthernetInterface::EthernetInterface(
+ stdplus::PinnedRef<sdbusplus::bus_t> bus,
+ stdplus::PinnedRef<Manager> manager, const AllIntfInfo& info,
+ std::string_view objRoot, const config::Parser& config, bool enabled) :
EthernetInterface(bus, manager, info, makeObjPath(objRoot, *info.intf.name),
config, enabled)
{}
-EthernetInterface::EthernetInterface(stdplus::PinnedRef<sdbusplus::bus_t> bus,
- stdplus::PinnedRef<Manager> manager,
- const AllIntfInfo& info,
- std::string&& objPath,
- const config::Parser& config,
- bool enabled) :
- Ifaces(bus, objPath.c_str(), Ifaces::action::defer_emit),
- manager(manager), bus(bus), objPath(std::move(objPath))
+EthernetInterface::EthernetInterface(
+ stdplus::PinnedRef<sdbusplus::bus_t> bus,
+ stdplus::PinnedRef<Manager> manager, const AllIntfInfo& info,
+ std::string&& objPath, const config::Parser& config, bool enabled) :
+ Ifaces(bus, objPath.c_str(), Ifaces::action::defer_emit), manager(manager),
+ bus(bus), objPath(std::move(objPath))
{
interfaceName(*info.intf.name, true);
auto dhcpVal = getDHCPValue(config);
@@ -234,10 +230,10 @@
}
else
{
- staticNeighbors.emplace(*info.addr, std::make_unique<Neighbor>(
- bus, std::string_view(objPath),
- *this, *info.addr, *info.mac,
- Neighbor::State::Permanent));
+ staticNeighbors.emplace(
+ *info.addr, std::make_unique<Neighbor>(
+ bus, std::string_view(objPath), *this, *info.addr,
+ *info.mac, Neighbor::State::Permanent));
}
}
@@ -397,12 +393,12 @@
EthernetInterface::DHCPConf EthernetInterface::dhcpEnabled(DHCPConf value)
{
auto old4 = EthernetInterfaceIntf::dhcp4();
- auto new4 = EthernetInterfaceIntf::dhcp4(value == DHCPConf::v4 ||
- value == DHCPConf::v4v6stateless ||
- value == DHCPConf::both);
+ auto new4 = EthernetInterfaceIntf::dhcp4(
+ value == DHCPConf::v4 || value == DHCPConf::v4v6stateless ||
+ value == DHCPConf::both);
auto old6 = EthernetInterfaceIntf::dhcp6();
- auto new6 = EthernetInterfaceIntf::dhcp6(value == DHCPConf::v6 ||
- value == DHCPConf::both);
+ auto new6 = EthernetInterfaceIntf::dhcp6(
+ value == DHCPConf::v6 || value == DHCPConf::both);
auto oldra = EthernetInterfaceIntf::ipv6AcceptRA();
auto newra = EthernetInterfaceIntf::ipv6AcceptRA(
value == DHCPConf::v6stateless || value == DHCPConf::v4v6stateless ||
@@ -456,8 +452,9 @@
{
// We only need to bring down the interface, networkd will always bring
// up managed interfaces
- manager.get().addReloadPreHook(
- [ifname = interfaceName()]() { system::setNICUp(ifname, false); });
+ manager.get().addReloadPreHook([ifname = interfaceName()]() {
+ system::setNICUp(ifname, false);
+ });
}
manager.get().reloadConfigs();
@@ -513,9 +510,9 @@
ServerList EthernetInterface::getNTPServerFromTimeSyncd()
{
ServerList servers; // Variable to capture the NTP Server IPs
- auto method = bus.get().new_method_call(TIMESYNCD_SERVICE,
- TIMESYNCD_SERVICE_PATH,
- PROPERTY_INTERFACE, METHOD_GET);
+ auto method =
+ bus.get().new_method_call(TIMESYNCD_SERVICE, TIMESYNCD_SERVICE_PATH,
+ PROPERTY_INTERFACE, METHOD_GET);
method.append(TIMESYNCD_INTERFACE, "LinkNTPServers");
@@ -812,8 +809,8 @@
dhcp6["SendHostname"].emplace_back(
tfStr(dhcp6Conf->sendHostNameEnabled()));
}
- auto path = config::pathForIntfConf(manager.get().getConfDir(),
- interfaceName());
+ auto path =
+ config::pathForIntfConf(manager.get().getConfDir(), interfaceName());
config.writeFile(path);
lg2::info("Wrote networkd file: {CFG_FILE}", "CFG_FILE", path);
writeUpdatedTime(manager, path);
@@ -995,8 +992,9 @@
if (eth.get().ifIdx > 0)
{
// We need to forcibly delete the interface as systemd does not
- eth.get().manager.get().addReloadPostHook(
- [idx = eth.get().ifIdx]() { system::deleteIntf(idx); });
+ eth.get().manager.get().addReloadPostHook([idx = eth.get().ifIdx]() {
+ system::deleteIntf(idx);
+ });
// Ignore the interface so the reload doesn't re-query it
eth.get().manager.get().ignoredIntf.emplace(eth.get().ifIdx);
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.cpp b/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.cpp
index 8f5aac9..195b2c0 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.cpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.cpp
@@ -59,12 +59,12 @@
HypEthInterface::DHCPConf HypEthInterface::dhcpEnabled(DHCPConf value)
{
auto old4 = HypEthernetIntf::dhcp4();
- auto new4 = HypEthernetIntf::dhcp4(value == DHCPConf::v4 ||
- value == DHCPConf::v4v6stateless ||
- value == DHCPConf::both);
+ auto new4 = HypEthernetIntf::dhcp4(
+ value == DHCPConf::v4 || value == DHCPConf::v4v6stateless ||
+ value == DHCPConf::both);
auto old6 = HypEthernetIntf::dhcp6();
- auto new6 = HypEthernetIntf::dhcp6(value == DHCPConf::v6 ||
- value == DHCPConf::both);
+ auto new6 = HypEthernetIntf::dhcp6(
+ value == DHCPConf::v6 || value == DHCPConf::both);
auto oldra = HypEthernetIntf::ipv6AcceptRA();
auto newra = HypEthernetIntf::ipv6AcceptRA(
value == DHCPConf::v6stateless || value == DHCPConf::v4v6stateless ||
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.hpp b/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.hpp
index b2f4856..5fce963 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.hpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.hpp
@@ -53,8 +53,8 @@
*/
HypEthInterface(sdbusplus::bus_t& bus, const char* path,
std::string_view intfName, HypNetworkMgr& parent) :
- CreateIface(bus, path, CreateIface::action::defer_emit),
- bus(bus), objectPath(path), manager(parent)
+ CreateIface(bus, path, CreateIface::action::defer_emit), bus(bus),
+ objectPath(path), manager(parent)
{
HypEthernetIntf::interfaceName(intfName.data(), true);
emit_object_added();
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
index 16d3d29..2539b6b 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
@@ -104,8 +104,8 @@
interfaces.emplace_back(biosMgrIntf);
auto depth = 0;
- auto mapperCall = bus.new_method_call(mapperBus, mapperObj, mapperIntf,
- "GetSubTree");
+ auto mapperCall =
+ bus.new_method_call(mapperBus, mapperObj, mapperIntf, "GetSubTree");
mapperCall.append(biosMgrObj, depth, interfaces);
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.hpp b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.hpp
index 6501e86..f01a4b9 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.hpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.hpp
@@ -68,7 +68,7 @@
* @param[in] path - Path to attach at.
*/
HypNetworkMgr(sdbusplus::bus_t& bus, const char* path) :
- bus(bus), objectPath(path){};
+ bus(bus), objectPath(path) {};
/** @brief Get the BaseBiosTable attributes
*
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp b/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp
index 464ed64..5a6fd39 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.hpp
@@ -41,8 +41,8 @@
*/
HypSysConfig(sdbusplus::bus_t& bus, const std::string& objPath,
HypNetworkMgr& parent) :
- Iface(bus, objPath.c_str(), Iface::action::defer_emit),
- bus(bus), manager(parent){};
+ Iface(bus, objPath.c_str(), Iface::action::defer_emit), bus(bus),
+ manager(parent) {};
/** @brief set the hostname of the system.
* @param[in] name - host name of the system.
diff --git a/src/inventory_mac.cpp b/src/inventory_mac.cpp
index 8e0f3cb..b5fd5f7 100644
--- a/src/inventory_mac.cpp
+++ b/src/inventory_mac.cpp
@@ -86,8 +86,8 @@
auto depth = 0;
- auto mapperCall = bus.new_method_call(mapperBus, mapperObj, mapperIntf,
- "GetSubTree");
+ auto mapperCall =
+ bus.new_method_call(mapperBus, mapperObj, mapperIntf, "GetSubTree");
mapperCall.append(invRoot, depth, interfaces);
@@ -177,8 +177,8 @@
for (const auto& keys : configJson.items())
{
if (!(std::find(first_boot_status.begin(),
- first_boot_status.end(),
- keys.key()) != first_boot_status.end()))
+ first_boot_status.end(), keys.key()) !=
+ first_boot_status.end()))
{
lg2::info("Interface {NET_INTF} MAC is NOT set from VPD",
"NET_INTF", keys.key());
diff --git a/src/ncsi_util.cpp b/src/ncsi_util.cpp
index 826d7de..839c80d 100644
--- a/src/ncsi_util.cpp
+++ b/src/ncsi_util.cpp
@@ -69,8 +69,7 @@
Command(
int ncsiCmd, int operation = DEFAULT_VALUE,
std::span<const unsigned char> p = std::span<const unsigned char>()) :
- ncsi_cmd(ncsiCmd),
- operation(operation), payload(p)
+ ncsi_cmd(ncsiCmd), operation(operation), payload(p)
{}
int ncsi_cmd;
@@ -257,8 +256,8 @@
}
auto data_len = nla_len(tb[NCSI_ATTR_DATA]) - sizeof(NCSIPacketHeader);
- unsigned char* data = (unsigned char*)nla_data(tb[NCSI_ATTR_DATA]) +
- sizeof(NCSIPacketHeader);
+ unsigned char* data =
+ (unsigned char*)nla_data(tb[NCSI_ATTR_DATA]) + sizeof(NCSIPacketHeader);
// Dump the response to stdout. Enhancement: option to save response data
auto str = toHexStr(std::span<const unsigned char>(data, data_len));
@@ -347,8 +346,8 @@
if (cmd.operation != DEFAULT_VALUE)
{
- std::vector<unsigned char> pl(sizeof(NCSIPacketHeader) +
- cmd.payload.size());
+ std::vector<unsigned char> pl(
+ sizeof(NCSIPacketHeader) + cmd.payload.size());
NCSIPacketHeader* hdr = (NCSIPacketHeader*)pl.data();
std::copy(cmd.payload.begin(), cmd.payload.end(),
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index 089e0e7..c412923 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -48,32 +48,33 @@
systemdNetworkdEnabledMatch(
bus, enabledMatch,
[man = stdplus::PinnedRef(*this)](sdbusplus::message_t& m) {
- std::string intf;
- std::unordered_map<std::string, std::variant<std::string>> values;
- try
- {
- m.read(intf, values);
- auto it = values.find("AdministrativeState");
- if (it == values.end())
- {
- return;
- }
- const std::string_view obj = m.get_path();
- auto sep = obj.rfind('/');
- if (sep == obj.npos || sep + 3 > obj.size())
- {
- throw std::invalid_argument("Invalid obj path");
- }
- auto ifidx = stdplus::StrToInt<10, uint16_t>{}(obj.substr(sep + 3));
- const auto& state = std::get<std::string>(it->second);
- man.get().handleAdminState(state, ifidx);
- }
- catch (const std::exception& e)
- {
- lg2::error("AdministrativeState match parsing failed: {ERROR}", "ERROR",
- e);
- }
-})
+ std::string intf;
+ std::unordered_map<std::string, std::variant<std::string>> values;
+ try
+ {
+ m.read(intf, values);
+ auto it = values.find("AdministrativeState");
+ if (it == values.end())
+ {
+ return;
+ }
+ const std::string_view obj = m.get_path();
+ auto sep = obj.rfind('/');
+ if (sep == obj.npos || sep + 3 > obj.size())
+ {
+ throw std::invalid_argument("Invalid obj path");
+ }
+ auto ifidx =
+ stdplus::StrToInt<10, uint16_t>{}(obj.substr(sep + 3));
+ const auto& state = std::get<std::string>(it->second);
+ man.get().handleAdminState(state, ifidx);
+ }
+ catch (const std::exception& e)
+ {
+ lg2::error("AdministrativeState match parsing failed: {ERROR}",
+ "ERROR", e);
+ }
+ })
{
reload.get().setCallback([self = stdplus::PinnedRef(*this)]() {
for (auto& hook : self.get().reloadPreHooks)
@@ -139,8 +140,8 @@
{
unsigned ifidx = std::get<0>(link);
stdplus::ToStrHandle<stdplus::IntToStr<10, unsigned>> tsh;
- auto obj = stdplus::strCat("/org/freedesktop/network1/link/_3"sv,
- tsh(ifidx));
+ auto obj =
+ stdplus::strCat("/org/freedesktop/network1/link/_3"sv, tsh(ifidx));
auto req =
bus.get().new_method_call("org.freedesktop.network1", obj.c_str(),
"org.freedesktop.DBus.Properties", "Get");
@@ -362,34 +363,36 @@
{
std::visit(
[&](auto addr) {
- if constexpr (std::is_same_v<stdplus::In4Addr, decltype(addr)>)
- {
- it->second.defgw4.emplace(addr);
- }
- else
- {
- static_assert(std::is_same_v<stdplus::In6Addr, decltype(addr)>);
- it->second.defgw6.emplace(addr);
- }
- },
- addr);
- if (auto it = interfacesByIdx.find(ifidx); it != interfacesByIdx.end())
- {
- std::visit(
- [&](auto addr) {
if constexpr (std::is_same_v<stdplus::In4Addr, decltype(addr)>)
{
- it->second->EthernetInterfaceIntf::defaultGateway(
- stdplus::toStr(addr));
+ it->second.defgw4.emplace(addr);
}
else
{
static_assert(
std::is_same_v<stdplus::In6Addr, decltype(addr)>);
- it->second->EthernetInterfaceIntf::defaultGateway6(
- stdplus::toStr(addr));
+ it->second.defgw6.emplace(addr);
}
},
+ addr);
+ if (auto it = interfacesByIdx.find(ifidx); it != interfacesByIdx.end())
+ {
+ std::visit(
+ [&](auto addr) {
+ if constexpr (std::is_same_v<stdplus::In4Addr,
+ decltype(addr)>)
+ {
+ it->second->EthernetInterfaceIntf::defaultGateway(
+ stdplus::toStr(addr));
+ }
+ else
+ {
+ static_assert(
+ std::is_same_v<stdplus::In6Addr, decltype(addr)>);
+ it->second->EthernetInterfaceIntf::defaultGateway6(
+ stdplus::toStr(addr));
+ }
+ },
addr);
}
}
@@ -405,46 +408,52 @@
{
std::visit(
[&](auto addr) {
- if constexpr (std::is_same_v<stdplus::In4Addr, decltype(addr)>)
- {
- if (it->second.defgw4 == addr)
- {
- it->second.defgw4.reset();
- }
- }
- else
- {
- static_assert(std::is_same_v<stdplus::In6Addr, decltype(addr)>);
- if (it->second.defgw6 == addr)
- {
- it->second.defgw6.reset();
- }
- }
- },
- addr);
- if (auto it = interfacesByIdx.find(ifidx); it != interfacesByIdx.end())
- {
- std::visit(
- [&](auto addr) {
if constexpr (std::is_same_v<stdplus::In4Addr, decltype(addr)>)
{
- stdplus::ToStrHandle<stdplus::ToStr<stdplus::In4Addr>> tsh;
- if (it->second->defaultGateway() == tsh(addr))
+ if (it->second.defgw4 == addr)
{
- it->second->EthernetInterfaceIntf::defaultGateway("");
+ it->second.defgw4.reset();
}
}
else
{
static_assert(
std::is_same_v<stdplus::In6Addr, decltype(addr)>);
- stdplus::ToStrHandle<stdplus::ToStr<stdplus::In6Addr>> tsh;
- if (it->second->defaultGateway6() == tsh(addr))
+ if (it->second.defgw6 == addr)
{
- it->second->EthernetInterfaceIntf::defaultGateway6("");
+ it->second.defgw6.reset();
}
}
},
+ addr);
+ if (auto it = interfacesByIdx.find(ifidx); it != interfacesByIdx.end())
+ {
+ std::visit(
+ [&](auto addr) {
+ if constexpr (std::is_same_v<stdplus::In4Addr,
+ decltype(addr)>)
+ {
+ stdplus::ToStrHandle<stdplus::ToStr<stdplus::In4Addr>>
+ tsh;
+ if (it->second->defaultGateway() == tsh(addr))
+ {
+ it->second->EthernetInterfaceIntf::defaultGateway(
+ "");
+ }
+ }
+ else
+ {
+ static_assert(
+ std::is_same_v<stdplus::In6Addr, decltype(addr)>);
+ stdplus::ToStrHandle<stdplus::ToStr<stdplus::In6Addr>>
+ tsh;
+ if (it->second->defaultGateway6() == tsh(addr))
+ {
+ it->second->EthernetInterfaceIntf::defaultGateway6(
+ "");
+ }
+ }
+ },
addr);
}
}
diff --git a/src/rtnetlink_server.cpp b/src/rtnetlink_server.cpp
index 1e3ac71..4a211d5 100644
--- a/src/rtnetlink_server.cpp
+++ b/src/rtnetlink_server.cpp
@@ -123,8 +123,8 @@
Server::Server(sdeventplus::Event& event, Manager& manager) :
sock(makeSock()),
io(event, sock.get(), EPOLLIN | EPOLLET, [&](auto&&... args) {
- return eventHandler(manager, std::forward<decltype(args)>(args)...);
-})
+ return eventHandler(manager, std::forward<decltype(args)>(args)...);
+ })
{
auto cb = [&](const nlmsghdr& hdr, std::string_view data) {
handler(manager, hdr, data);
diff --git a/src/system_configuration.cpp b/src/system_configuration.cpp
index b008dba..ee6cdb7 100644
--- a/src/system_configuration.cpp
+++ b/src/system_configuration.cpp
@@ -26,34 +26,35 @@
SystemConfiguration::SystemConfiguration(
stdplus::PinnedRef<sdbusplus::bus_t> bus, stdplus::const_zstring objPath) :
- Iface(bus, objPath.c_str(), Iface::action::defer_emit),
- bus(bus), hostnamePropMatch(
- bus, propMatch,
- [sc = stdplus::PinnedRef(*this)](sdbusplus::message_t& m) {
- std::string intf;
- std::unordered_map<std::string, std::variant<std::string>> values;
- try
- {
- m.read(intf, values);
- auto it = values.find("Hostname");
- if (it == values.end())
- {
- return;
- }
- sc.get().Iface::hostName(std::get<std::string>(it->second));
- }
- catch (const std::exception& e)
- {
- lg2::error("Hostname match parsing failed: {ERROR}", "ERROR", e);
- }
-})
+ Iface(bus, objPath.c_str(), Iface::action::defer_emit), bus(bus),
+ hostnamePropMatch(
+ bus, propMatch,
+ [sc = stdplus::PinnedRef(*this)](sdbusplus::message_t& m) {
+ std::string intf;
+ std::unordered_map<std::string, std::variant<std::string>> values;
+ try
+ {
+ m.read(intf, values);
+ auto it = values.find("Hostname");
+ if (it == values.end())
+ {
+ return;
+ }
+ sc.get().Iface::hostName(std::get<std::string>(it->second));
+ }
+ catch (const std::exception& e)
+ {
+ lg2::error("Hostname match parsing failed: {ERROR}", "ERROR",
+ e);
+ }
+ })
{
try
{
std::variant<std::string> name;
- auto req = bus.get().new_method_call(HOSTNAMED_SVC, HOSTNAMED_OBJ,
- "org.freedesktop.DBus.Properties",
- "Get");
+ auto req =
+ bus.get().new_method_call(HOSTNAMED_SVC, HOSTNAMED_OBJ,
+ "org.freedesktop.DBus.Properties", "Get");
req.append(HOSTNAMED_INTF, "Hostname");
auto reply = req.call();
diff --git a/src/system_queries.cpp b/src/system_queries.cpp
index 87ba4aa..712fc08 100644
--- a/src/system_queries.cpp
+++ b/src/system_queries.cpp
@@ -27,8 +27,8 @@
static stdplus::Fd& getIFSock()
{
using namespace stdplus::fd;
- static auto fd = socket(SocketDomain::INet, SocketType::Datagram,
- SocketProto::IP);
+ static auto fd =
+ socket(SocketDomain::INet, SocketType::Datagram, SocketProto::IP);
return fd;
}
@@ -88,8 +88,9 @@
return optionalIFReq(
ifname, SIOCETHTOOL, "ETHTOOL"sv,
[&](const ifreq&) {
- return EthInfo{.autoneg = edata.autoneg != 0, .speed = edata.speed};
- },
+ return EthInfo{.autoneg = edata.autoneg != 0,
+ .speed = edata.speed};
+ },
&edata)
.value_or(EthInfo{});
}
@@ -120,16 +121,17 @@
ifinfomsg msg = {};
msg.ifi_family = AF_UNSPEC;
msg.ifi_index = idx;
- netlink::performRequest(NETLINK_ROUTE, RTM_DELLINK, NLM_F_REPLACE, msg,
- [&](const nlmsghdr& hdr, std::string_view data) {
- int err = 0;
- if (hdr.nlmsg_type == NLMSG_ERROR)
- {
- err = netlink::extractRtData<nlmsgerr>(data).error;
- }
- throw std::runtime_error(
- std::format("Failed to delete `{}`: {}", idx, strerror(err)));
- });
+ netlink::performRequest(
+ NETLINK_ROUTE, RTM_DELLINK, NLM_F_REPLACE, msg,
+ [&](const nlmsghdr& hdr, std::string_view data) {
+ int err = 0;
+ if (hdr.nlmsg_type == NLMSG_ERROR)
+ {
+ err = netlink::extractRtData<nlmsgerr>(data).error;
+ }
+ throw std::runtime_error(
+ std::format("Failed to delete `{}`: {}", idx, strerror(err)));
+ });
}
} // namespace phosphor::network::system
diff --git a/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp b/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp
index f44de21..8898b31 100644
--- a/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp
+++ b/test/ibm/hypervisor-network-mgr-test/mock_hyp_sys_config.hpp
@@ -15,8 +15,7 @@
{
public:
MockHypSysConfig(sdbusplus::bus_t& bus, const std::string& objPath,
- HypNetworkMgr& parent) :
- HypSysConfig(bus, objPath, parent)
+ HypNetworkMgr& parent) : HypSysConfig(bus, objPath, parent)
{}
void setHostname(std::string hn)
diff --git a/test/mock_syscall.cpp b/test/mock_syscall.cpp
index fa2ae2d..85ea38f 100644
--- a/test/mock_syscall.cpp
+++ b/test/mock_syscall.cpp
@@ -105,8 +105,8 @@
const auto nlbegin = msgBuf.size();
msgBuf.append(NLMSG_SPACE(sizeof(ifinfomsg)), '\0');
{
- auto& info = *reinterpret_cast<ifinfomsg*>(msgBuf.data() + nlbegin +
- NLMSG_HDRLEN);
+ auto& info = *reinterpret_cast<ifinfomsg*>(
+ msgBuf.data() + nlbegin + NLMSG_HDRLEN);
info.ifi_index = i.idx;
info.ifi_flags = i.flags;
}
diff --git a/test/test_ethernet_interface.cpp b/test/test_ethernet_interface.cpp
index 27d9b1e..72579f3 100644
--- a/test/test_ethernet_interface.cpp
+++ b/test/test_ethernet_interface.cpp
@@ -39,9 +39,8 @@
{}
- static MockEthernetInterface
- makeInterface(stdplus::PinnedRef<sdbusplus::bus_t> bus,
- TestManager& manager)
+ static MockEthernetInterface makeInterface(
+ stdplus::PinnedRef<sdbusplus::bus_t> bus, TestManager& manager)
{
AllIntfInfo info{InterfaceInfo{
.type = ARPHRD_ETHER, .idx = 1, .flags = 0, .name = "test0"}};
@@ -76,12 +75,13 @@
constexpr stdplus::EtherAddr mac{0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
constexpr unsigned mtu = 150;
- AllIntfInfo info{InterfaceInfo{.type = ARPHRD_ETHER,
- .idx = 2,
- .flags = IFF_RUNNING,
- .name = "test1",
- .mac = mac,
- .mtu = mtu}};
+ AllIntfInfo info{InterfaceInfo{
+ .type = ARPHRD_ETHER,
+ .idx = 2,
+ .flags = IFF_RUNNING,
+ .name = "test1",
+ .mac = mac,
+ .mtu = mtu}};
MockEthernetInterface intf(bus, manager, info,
"/xyz/openbmc_test/network"sv, config::Parser());
diff --git a/test/test_network_manager.hpp b/test/test_network_manager.hpp
index e8b9fcc..a9a7985 100644
--- a/test/test_network_manager.hpp
+++ b/test/test_network_manager.hpp
@@ -24,8 +24,8 @@
{
EXPECT_CALL(mockReload, setCallback(testing::_))
.WillOnce([&](fu2::unique_function<void()>&& cb) {
- reloadCb = std::move(cb);
- });
+ reloadCb = std::move(cb);
+ });
return mockReload;
}
};
diff --git a/test/test_rtnetlink.cpp b/test/test_rtnetlink.cpp
index 795dcdc..14bec3c 100644
--- a/test/test_rtnetlink.cpp
+++ b/test/test_rtnetlink.cpp
@@ -55,12 +55,13 @@
msg.mtu_hdr.rta_len = RTA_LENGTH(sizeof(msg.mtu));
auto info = intfFromRtm(stdplus::raw::asView<char>(msg));
- auto expected = InterfaceInfo{.type = 4,
- .idx = 1,
- .flags = 2,
- .name = "eth0",
- .mac = ether_addr{0, 1, 2, 3, 4, 5},
- .mtu = 50};
+ auto expected = InterfaceInfo{
+ .type = 4,
+ .idx = 1,
+ .flags = 2,
+ .name = "eth0",
+ .mac = ether_addr{0, 1, 2, 3, 4, 5},
+ .mtu = 50};
EXPECT_EQ(info, expected);
}