Skip to content

Commit

Permalink
fix(nm): load dhcp server configuration after change (#5018)
Browse files Browse the repository at this point in the history
* fix(nm): reload dhcp server after configuration change

* fix: make the code build

* docs: fix comment wording
  • Loading branch information
mattdibi authored Nov 23, 2023
1 parent aa87f66 commit a626f44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ private void writeDhcpServerConfiguration(Set<String> interfaceNames) {
try {
dhcpServerConfigWriter.writeConfiguration();
this.dhcpServerMonitor.putDhcpServerInterfaceConfiguration(interfaceName, true);
this.dhcpServerMonitor.disable(interfaceName); // Side effect: we rely on the monitor bringing the
// server back up so that the configuration change
// takes effect

} catch (UnknownHostException | KuraException e) {
logger.error("Failed to write DHCP Server configuration", e);
this.dhcpServerMonitor.putDhcpServerInterfaceConfiguration(interfaceName, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public void clear() {
this.dhcpServerInterfaceConfiguration.clear();
}

public void disable(String interfaceName) {
try {
if (this.dhcpServerManager.isRunning(interfaceName)) {
stopDhcpServer(interfaceName);
}
} catch (KuraException e) {
logger.warn("Failed to stop DHCP server for the interface " + interfaceName, e);
}
}

private void monitor() {
this.dhcpServerInterfaceConfiguration.entrySet().forEach(entry -> {
String interfaceName = entry.getKey();
Expand Down

0 comments on commit a626f44

Please sign in to comment.