-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
wiznet: Reset mDNS when interface is brought up. #16011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wiznet: Reset mDNS when interface is brought up. #16011
Conversation
6f44da4
to
e3a68f9
Compare
Code size report:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #16011 +/- ##
=======================================
Coverage 98.57% 98.57%
=======================================
Files 164 164
Lines 21341 21341
=======================================
Hits 21036 21036
Misses 305 305 ☔ View full report in Codecov by Sentry. |
Does |
This is my patch on top of 1.23.0 for reference: diff --git a/extmod/network_wiznet5k.c b/extmod/network_wiznet5k.c
index 1eaabe9eb..5dc1e93e8 100644
--- a/extmod/network_wiznet5k.c
+++ b/extmod/network_wiznet5k.c
@@ -61,6 +61,7 @@
#include "lwip/err.h"
#include "lwip/dns.h"
#include "lwip/dhcp.h"
+#include "lwip/apps/mdns.h"
#include "netif/etharp.h"
#define TRACE_ETH_TX (0x0002)
@@ -198,6 +199,10 @@ static void wiznet5k_config_interrupt(bool enabled) {
}
void wiznet5k_deinit(void) {
+#if LWIP_MDNS_RESPONDER
+ mdns_resp_remove_netif(&wiznet5k_obj.netif);
+#endif
+
for (struct netif *netif = netif_list; netif != NULL; netif = netif->next) {
if (netif == &wiznet5k_obj.netif) {
netif_remove(netif);
@@ -243,6 +248,11 @@ static void wiznet5k_init(void) {
// register with network module
mod_network_register_nic(&wiznet5k_obj);
+
+#if LWIP_MDNS_RESPONDER
+ mdns_resp_add_netif(&wiznet5k_obj.netif, mod_network_hostname_data, 60);
+ // no need to call anything further as LWIP_NETIF_EXT_STATUS_CALLBACK == 1
+#endif
}
static void wiznet5k_send_ethernet(wiznet5k_obj_t *self, size_t len, const uint8_t *buf) { |
e3a68f9
to
eae17a5
Compare
@tpwrules thank you for your review. I really appreciate it. I added the call to remove it as you suggested. |
eae17a5
to
e8d9562
Compare
extmod/network_wiznet5k.c
Outdated
@@ -199,6 +200,10 @@ static void wiznet5k_config_interrupt(bool enabled) { | |||
} | |||
|
|||
void wiznet5k_deinit(void) { | |||
#if LWIP_MDNS_RESPONDER | |||
mdns_resp_remove_netif(&wiznet5k_obj.netif); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be moved down to just before the netif_remove(netif)
line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, @dpgeorge. I moved it as requested.
e8d9562
to
05da4c4
Compare
The LwIP interface is removed in wiznet5k_deinit() which is called as part of the init sequence. Therefore, if using mDNS, then the interface will need to be re-added when bringing the interface up. Additionally, this allows to set the hostname from MicroPython code prior to bringing the interface up and mDNS responding to the (new) hostname. This allows the hostname to be configured and saved on the flash or be based on dynamic information such as the MAC or unique_id(). Signed-off-by: Jared Hancock <jared.hancock@centeredsolutions.com>
05da4c4
to
078ead2
Compare
Summary
The LwIP interface is removed in wiznet5k_deinit() which is called as part of the init sequence. Therefore, if using mDNS, then the interface will need to be re-added when bringing the interface up.
Additionally, this allows to set the hostname from Micropython code prior to bringing the interface up and mDNS responding to the (new) hostname. This allows the hostname to be configured and saved on the flash or be based on dynamic information such as the MAC or unique_id().
Testing
This was tested with the W5100S_EVB_PICO board.
Trade-offs and Alternatives