Fix to set ipaddress on VLAN
- d0679f9bb46670c593061c4aaebec2a577cdd5c3 commit has introduced a
boolean property nICEnabled() to check if the corresponding
interface is enabled.
- As this property has not been passed down to VLAN interface, the
`Unmanaged=yes` is being set in the VLAN network configuration file
beacuse of which the ipaddress objects for VLAN are not being
populated.
Tested By:
==========
1. Create new VLAN
-XPOST -H "Content-type: application/json" -d '{"data": ["eth0",50]}'
httpsbmcip://<>/xyz/openbmc_project/network/action/VLAN
2. Set an IP address on the VLAN interface and make sure the ip address
is being populated in the Network Configuration file and also make
sure that the vlan interface is now managed.
-XPOST -H "Content-type: application/json" -d
'{"data": ["xyz.openbmc_project.Network.IP.Protocol.IPv4","10.6.6.10",24,"0.0.0.0"] }'
https://<bmcip>/xyz/openbmc_project/network/eth0_50/action/IP
3. Enumerate the VLAN Interface to check if it populates the above set
ip address of the VLAN interface as well.
-X GET https://<bmcip>/xyz/openbmc_project/network/eth0_50/enumerate
4. Create a VLAN(1),set an IP(2) then disable the VLAN using the busctl
call on the NICEnabled Property, and restart the network service and
make sure the VLAN comes back disabled.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I892a8c1c1126631a494d42656eeb5be47b4e5bd4
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 2c8bbd4..648595c 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -685,7 +685,6 @@
auto dhcpEnabled =
getDHCPValue(manager.getConfDir().string(), vlanInterfaceName);
-
auto vlanIntf = std::make_unique<phosphor::network::VlanInterface>(
bus, path.c_str(), dhcpEnabled, id, *this, manager);
@@ -704,8 +703,12 @@
std::string path = objPath;
path += "_" + std::to_string(id);
+ // Pass the parents nICEnabled property, so that the child
+ // VLAN interface can inherit.
+
auto vlanIntf = std::make_unique<phosphor::network::VlanInterface>(
- bus, path.c_str(), false, id, *this, manager);
+ bus, path.c_str(), false, EthernetInterfaceIntf::nICEnabled(), id,
+ *this, manager);
// write the device file for the vlan interface.
vlanIntf->writeDeviceFile();
diff --git a/vlan_interface.cpp b/vlan_interface.cpp
index 73de4e8..7a1caf7 100644
--- a/vlan_interface.cpp
+++ b/vlan_interface.cpp
@@ -23,6 +23,23 @@
VlanInterface::VlanInterface(sdbusplus::bus::bus& bus,
const std::string& objPath, bool dhcpEnabled,
+ bool nICEnabled, uint32_t vlanID,
+ EthernetInterface& intf, Manager& parent) :
+ VlanIface(bus, objPath.c_str()),
+ DeleteIface(bus, objPath.c_str()),
+ EthernetInterface(bus, objPath, dhcpEnabled, parent, false),
+ parentInterface(intf)
+{
+ id(vlanID);
+ EthernetInterfaceIntf::nICEnabled(nICEnabled);
+ VlanIface::interfaceName(EthernetInterface::interfaceName());
+ MacAddressIntf::mACAddress(parentInterface.mACAddress());
+
+ emit_object_added();
+}
+
+VlanInterface::VlanInterface(sdbusplus::bus::bus& bus,
+ const std::string& objPath, bool dhcpEnabled,
uint32_t vlanID, EthernetInterface& intf,
Manager& parent) :
VlanIface(bus, objPath.c_str()),
diff --git a/vlan_interface.hpp b/vlan_interface.hpp
index a994d05..2c2f48e 100644
--- a/vlan_interface.hpp
+++ b/vlan_interface.hpp
@@ -43,10 +43,28 @@
* @param[in] vlanID - vlan identifier.
* @param[in] intf - ethernet interface object.
* @param[in] manager - network manager object.
+ *
+ * This constructor is called during creation of VLAN Interface
+ * so that the VLAN interface can inherit the nICEnabled property
+ * from the parent interface.
+ */
+ VlanInterface(sdbusplus::bus::bus& bus, const std::string& objPath,
+ bool dhcpEnabled, bool nICEnabled, uint32_t vlanID,
+ EthernetInterface& intf, Manager& manager);
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] objPath - Path to attach at.
+ * @param[in] dhcpEnabled - DHCP enable value.
+ * @param[in] vlanID - vlan identifier.
+ * @param[in] intf - ethernet interface object.
+ * @param[in] manager - network manager object.
+ *
+ * This constructor is called during loading the VLAN Interface
*/
VlanInterface(sdbusplus::bus::bus& bus, const std::string& objPath,
bool dhcpEnabled, uint32_t vlanID, EthernetInterface& intf,
- Manager& manager);
+ Manager& parent);
/** @brief Delete this d-bus object.
*/