summaryrefslogtreecommitdiffstats
path: root/ethernet_interface.cpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-07-25 18:29:57 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-08-13 11:32:44 +0000
commitbc8862927b05030b249175891dc338d044eb17dd (patch)
treedbc2289ff0c31d98f210565042206a2529f1f688 /ethernet_interface.cpp
parent92bc2fe4663b8a9e2a38084692dc9587762926f9 (diff)
downloadphosphor-networkd-bc8862927b05030b249175891dc338d044eb17dd.tar.gz
phosphor-networkd-bc8862927b05030b249175891dc338d044eb17dd.zip
vlan: implement delete interface
Delete the in-memory vlan object,Also deletes the associated device file and the network file. Change-Id: I613e31aaa4fa9172c6226765ac044481ffbd88ec Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'ethernet_interface.cpp')
-rw-r--r--ethernet_interface.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 30927f6..5eb6aa7 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -275,6 +275,56 @@ void EthernetInterface::deleteObject(const std::string& ipaddress)
writeConfigurationFile();
}
+void EthernetInterface::deleteVLANObject(const std::string& interface)
+{
+ using namespace std::string_literals;
+
+ auto it = vlanInterfaces.find(interface);
+ if (it == vlanInterfaces.end())
+ {
+ log<level::ERR>("DeleteVLANObject:Unable to find the object",
+ entry("INTERFACE=%s",interface.c_str()));
+ return;
+ }
+
+ auto confDir = manager.getConfDir();
+ fs::path networkFile = confDir;
+ networkFile /= systemd::config::networkFilePrefix + interface +
+ systemd::config::networkFileSuffix;
+
+ fs::path deviceFile = confDir;
+ deviceFile /= interface + systemd::config::deviceFileSuffix;
+
+ // delete the vlan network file
+ if (fs::is_regular_file(networkFile))
+ {
+ fs::remove(networkFile);
+ }
+
+ // delete the vlan device file
+ if (fs::is_regular_file(deviceFile))
+ {
+ fs::remove(deviceFile);
+ }
+ // delete the interface
+ vlanInterfaces.erase(it);
+ // restart the systemd-networkd
+
+ restartSystemdUnit("systemd-networkd.service");
+
+ // TODO systemd doesn't delete the virtual network interface
+ // even after deleting all the related configuartion.
+ // https://github.com/systemd/systemd/issues/6600
+ try
+ {
+ deleteInterface(interface);
+ }
+ catch (InternalFailure& e)
+ {
+ commit<InternalFailure>();
+ }
+}
+
std::string EthernetInterface::generateObjectPath(IP::Protocol addressType,
const std::string& ipaddress,
uint8_t prefixLength,
@@ -371,7 +421,8 @@ void EthernetInterface::writeConfigurationFile()
namespace fs = std::experimental::filesystem;
fs::path confPath = manager.getConfDir();
- std::string fileName = "00-bmc-"s + interfaceName() + ".network"s;
+ std::string fileName = systemd::config::networkFilePrefix + interfaceName() +
+ systemd::config::networkFileSuffix;
confPath /= fileName;
std::fstream stream;
OpenPOWER on IntegriCloud