rtnetlink_server: Don't refresh for addresses
We can dynamically add and remove addresses without having to recreate
all of the objects.
Change-Id: Ic510263cc6ba5d2ec228ce94fa83cf5fe4664c6d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index a0c6193..3df966d 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -173,31 +173,35 @@
);
}
+void EthernetInterface::addAddr(const AddressInfo& info)
+{
+ if (info.flags & IFA_F_DEPRECATED)
+ {
+ return;
+ }
+ IP::AddressOrigin origin = IP::AddressOrigin::Static;
+ if (dhcpIsEnabled(info.ifaddr.getAddr()))
+ {
+ origin = IP::AddressOrigin::DHCP;
+ }
+#ifdef LINK_LOCAL_AUTOCONFIGURATION
+ if (info.scope == RT_SCOPE_LINK)
+ {
+ origin = IP::AddressOrigin::LinkLocal;
+ }
+#endif
+
+ this->addrs.insert_or_assign(
+ info.ifaddr, std::make_unique<IPAddress>(bus, std::string_view(objPath),
+ *this, info.ifaddr, origin));
+}
+
void EthernetInterface::createIPAddressObjects()
{
addrs.clear();
for (const auto& addr : system::getAddresses({.ifidx = ifIdx}))
{
- if (addr.flags & IFA_F_DEPRECATED)
- {
- continue;
- }
- IP::AddressOrigin origin = IP::AddressOrigin::Static;
- if (dhcpIsEnabled(addr.ifaddr.getAddr()))
- {
- origin = IP::AddressOrigin::DHCP;
- }
-#ifdef LINK_LOCAL_AUTOCONFIGURATION
- if (addr.scope == RT_SCOPE_LINK)
- {
- origin = IP::AddressOrigin::LinkLocal;
- }
-#endif
-
- this->addrs.insert_or_assign(
- addr.ifaddr,
- std::make_unique<IPAddress>(bus, std::string_view(objPath), *this,
- addr.ifaddr, origin));
+ addAddr(addr);
}
}
@@ -270,7 +274,7 @@
ifaddr, IP::AddressOrigin::Static));
writeConfigurationFile();
- manager.reloadConfigs();
+ manager.reloadConfigsNoRefresh();
return it->second->getObjPath();
}