eclipse-kura / kura

Eclipse Kura™ is a versatile framework to supercharge your edge devices, streamlining the process of configuring your gateway, connecting sensors, and IoT devices to seamlessly collect, process, and send data to the cloud.
https://eclipse.dev/kura/
Eclipse Public License 2.0
506 stars 312 forks source link

fix(nm): Fixed dnsmasq behavior on configuration change #5295

Closed pierantoniomerlino closed 4 months ago

pierantoniomerlino commented 4 months ago

Note: We are using the Conventional Commits convention for our pull request titles. Please take a look at the PR title format document for the supported types and scopes.

This PR fixes a weird behaviour when dnsmasq is used as DHCP server with generic profiles and NM.

Related Issue: This PR fixes/closes N/A

Description of the solution adopted: During testing we found that the dnsmasq used as DHCP server doesn't listen on port 67 after a re-configuration. If the configuration was submitted again, the service starts working as aspected. After further investigations, we found that when the problem occours, the dnsmasq configuration file is not present in the filesystem. So, the service is running, but without any configuration of the given interface. As a consequence, the port 67 UDP is not used.

This is due to a wrong operation sequence during the DHCP server startup performed by Kura. The configuration file is written, but when the DHCP server activation is triggered, the code disable the service and then re-enable it. During the disable, the configuration file is removed. If a new configuration is submitted again, all works since the bundle doesn’t recognize the service as running and doesn’t disable it.

This PR fixes the issue changing the order of the operation when the DHCP server is configured. Now, the dnsmasq service is disable before that the configuration file is written.

Manual Tests: Using a generic profile, configure an AP with DHCP server enabled. Try to connect to the configured AP with another device (i.e. a laptop) and try to get an IP address. Change the AP configuration and apply it. Then try to connect again with the laptop. The laptop should be able to connect and get the address.

pierantoniomerlino commented 4 months ago

@sfiorani could you please check again the AP with generic profiles?

sfiorani commented 4 months ago

@sfiorani could you please check again the AP with generic profiles?

Tested on Raspberry Pi 5 with Kura generic aarch64 and everything seems to work. I tried different combinations of Security and Cipher.