From f83a16db92a0a138e6e5cc5b3aa7275e1c1548d1 Mon Sep 17 00:00:00 2001 From: Ravi Teja Date: Sun, 8 Dec 2024 22:48:21 -0600 Subject: [PATCH] Add LLDP configuration support This commit implements EmitLLDP D-bus property to support configuration of enable/disable LLDP of each ethernet interface. Tested by: Set EmitLLDP D-bus property on xyz.openbmc_project.Network.EthernetInterface Change-Id: I4ebedff9d3f914219f2f84c861fdee126584a94b Signed-off-by: Ravi Teja --- src/network_manager.cpp | 16 ++++++++++++++++ src/network_manager.hpp | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/network_manager.cpp b/src/network_manager.cpp index 860be069..f2af1c38 100644 --- a/src/network_manager.cpp +++ b/src/network_manager.cpp @@ -210,6 +210,7 @@ void Manager::createInterface(const AllIntfInfo& info, bool enabled) auto ptr = intf.get(); interfaces.insert_or_assign(*info.intf.name, std::move(intf)); interfacesByIdx.insert_or_assign(info.intf.idx, ptr); + loadDefaultLLDPConfig(); } void Manager::addInterface(const InterfaceInfo& info) @@ -529,6 +530,21 @@ void Manager::handleAdminState(std::string_view state, unsigned ifidx) } } +void Manager::loadDefaultLLDPConfig() +{ + std::ofstream lldpdConfig(lldpFilePath); + + lldpdConfig << "configure system description BMC" << std::endl; + + for (const auto& intf : interfaces) + { + lldpdConfig << "configure ports " << intf.second->interfaceName() + << " lldp status disabled" << std::endl; + } + + lldpdConfig.close(); +} + void Manager::writeLLDPDConfigurationFile() { std::ofstream lldpdConfig(lldpFilePath); diff --git a/src/network_manager.hpp b/src/network_manager.hpp index 3bc8ad25..a80b15be 100644 --- a/src/network_manager.hpp +++ b/src/network_manager.hpp @@ -110,6 +110,10 @@ class Manager : public ManagerIface */ void reloadLLDPService(); + /** Load default LLDP configuration + */ + void loadDefaultLLDPConfig(); + /** @brief Persistent map of EthernetInterface dbus objects and their names */ stdplus::string_umap> interfaces;