Skip to content

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

Closed
@mcspr

Description

@mcspr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions