Skip to content
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

Don't reset default route when something else had changed it #52

Closed
mcspr opened this issue Oct 9, 2021 · 1 comment
Closed

Don't reset default route when something else had changed it #52

mcspr opened this issue Oct 9, 2021 · 1 comment

Comments

@mcspr
Copy link
Collaborator

mcspr commented Oct 9, 2021

ref. esp8266/Arduino#7148 esp8266/Arduino#8317

Current implementation resets default route regardless of it's contents:

if ( netif->flags & NETIF_FLAG_UP
&& netif == netif_sta)
{
// this is our default route
netif_set_default(netif);

But, it does respect un-setting it:

if (netif_default == &netif_git[netif_idx])
netif_set_default(NULL);

Should it respect the already-set netif?

diff --git a/glue-lwip/lwip-git.c b/glue-lwip/lwip-git.c
index 4cf133f..b3afc4d 100644
--- a/glue-lwip/lwip-git.c
+++ b/glue-lwip/lwip-git.c
@@ -322,8 +322,10 @@ static void netif_sta_status_callback (struct netif* netif)
        if (   netif->flags & NETIF_FLAG_UP
            && netif == netif_sta)
        {
-               // this is our default route
-               netif_set_default(netif);
+               // this is our default route, but only when there is nothing else
+               if (netif_default == NULL) {
+                       netif_set_default(netif);
+               }

                // If we have a valid address of any type restart SNTP
                bool valid_address = ip_2_ip4(&netif->ip_addr)->addr;

If yes, Core's Lwip class also needs a patch of the same nature

@d-a-v
Copy link
Owner

d-a-v commented Jan 3, 2022

fixed by #54

if ((netif_default == NULL) && !ip_addr_isany(&netif->gw)) {

@d-a-v d-a-v closed this as completed Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants