ethernet_interface: Merge VLAN into EthernetInterface
This simplifies the ethernet interface as it codepended on the vlan
interface to make VLANs. It also removes the naming dependency and
tracks VLANs by adapter type and parent indexes.
Change-Id: I8db09cc2474472e6d4a06c6be5cf0440ee48d132
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index 4db338e..462937f 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -14,6 +14,8 @@
#include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
#include <xyz/openbmc_project/Network/EthernetInterface/server.hpp>
#include <xyz/openbmc_project/Network/MACAddress/server.hpp>
+#include <xyz/openbmc_project/Network/VLAN/server.hpp>
+#include <xyz/openbmc_project/Object/Delete/server.hpp>
namespace phosphor
{
@@ -27,6 +29,12 @@
sdbusplus::xyz::openbmc_project::Network::Neighbor::server::CreateStatic,
sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
+using VlanIfaces = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Object::server::Delete,
+ sdbusplus::xyz::openbmc_project::Network::server::VLAN>;
+
+using VlanIntf = sdbusplus::xyz::openbmc_project::Network::server::VLAN;
+
using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
using EthernetInterfaceIntf =
@@ -40,8 +48,7 @@
class Manager;
class TestEthernetInterface;
-
-class VlanInterface;
+class TestNetworkManager;
namespace config
{
@@ -73,6 +80,7 @@
* @param[in] info - Interface information.
* @param[in] objRoot - Path to attach at.
* @param[in] config - The parsed configuation file.
+ * @param[in] vlan - The id of the vlan if configured
* @param[in] emitSignal - true if the object added signal needs to be
* send.
* @param[in] enabled - Override the lookup of nicEnabled
@@ -119,12 +127,6 @@
*/
void deleteStaticNeighborObject(std::string_view ipAddress);
- /* @brief delete the vlan dbus object of the given interface.
- * Also deletes the device file and the network file.
- * @param[in] interface - VLAN Interface.
- */
- void deleteVLANObject(stdplus::zstring_view interface);
-
/* @brief creates the dbus object(IPaddres) given in the address list.
* @param[in] addrs - address list for which dbus objects needs
* to create.
@@ -204,13 +206,6 @@
*/
ObjectPath createVLAN(uint16_t id);
- /** @brief load the vlan info from the system
- * and creates the ip address dbus objects.
- * @param[in] vlanID- VLAN identifier.
- */
- void loadVLAN(std::string_view objRoot, uint16_t vlanID,
- system::InterfaceInfo&& info);
-
/** @brief write the network conf file with the in-memory objects.
*/
void writeConfigurationFile();
@@ -239,11 +234,6 @@
using EthernetInterfaceIntf::defaultGateway6;
protected:
- /* @brief delete the vlan interface from system.
- * @param[in] interface - vlan Interface.
- */
- void deleteVLANFromSystem(stdplus::zstring_view interface);
-
/** @brief construct the ip address dbus object path.
* @param[in] addressType - Type of ip address.
* @param[in] ipAddress - IP address.
@@ -283,16 +273,25 @@
/** @brief Persistent map of Neighbor dbus objects and their names */
string_umap<std::unique_ptr<Neighbor>> staticNeighbors;
- /** @brief Persistent map of VLAN interface dbus objects and their names */
- string_umap<std::unique_ptr<VlanInterface>> vlanInterfaces;
-
/** @brief Dbus object path */
std::string objPath;
/** @brief Interface index */
unsigned ifIdx;
+ struct VlanProperties : VlanIfaces
+ {
+ VlanProperties(sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
+ const system::InterfaceInfo& info,
+ EthernetInterface& eth, bool emitSignal = true);
+ void delete_() override;
+ unsigned parentIdx;
+ EthernetInterface& eth;
+ };
+ std::optional<VlanProperties> vlan;
+
friend class TestEthernetInterface;
+ friend class TestNetworkManager;
private:
EthernetInterface(sdbusplus::bus_t& bus, Manager& manager,
@@ -316,8 +315,6 @@
* @returns true/false value if the NIC is enabled
*/
bool queryNicEnabled() const;
-
- std::string vlanIntfName(uint16_t id) const;
};
} // namespace network