From 637bce91b45c855964f549f91bc41a32317eac4c Mon Sep 17 00:00:00 2001 From: Joel Cunningham Date: Wed, 8 Nov 2017 12:55:33 -0600 Subject: [PATCH] netif: ensure link and admin states are up in issue reports (bug #52353) This fixes a bug where some callers of netif_issue_reports were not checking that both link and admin states were up, leading to extraneous reports when calling one of the following 1) netif_set_ipaddr 2) netif_ip6_addr_set_parts 3) netif_ip6_addr_set_state The bug has been fixed by placing link and admin state checks in netif_issue_reports and not requiring the callers to perform this checking --- CHANGELOG | 3 +++ src/core/netif.c | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index db504c43..c43ece38 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -81,6 +81,9 @@ HISTORY ++ Bugfixes: + 2017-11-08: Joel Cunningham + * netif: ensure link and admin states are up in issue reports (bug #52353) + 2017-09-12: David Lockyer * select: allocate select_cb from memp for LWIP_MPU_COMPATIBLE = 1 (bug #51990) diff --git a/src/core/netif.c b/src/core/netif.c index 3e9f399f..d056a19f 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -742,9 +742,7 @@ netif_set_up(struct netif *netif) } #endif - if (netif->flags & NETIF_FLAG_LINK_UP) { - netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6); - } + netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6); } } @@ -753,6 +751,12 @@ netif_set_up(struct netif *netif) static void netif_issue_reports(struct netif *netif, u8_t report_type) { + /* Only send reports when both link and admin states are up */ + if (!(netif->flags & NETIF_FLAG_LINK_UP) || + !(netif->flags & NETIF_FLAG_UP)) { + return; + } + #if LWIP_IPV4 if ((report_type & NETIF_REPORT_TYPE_IPV4) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) { @@ -865,9 +869,8 @@ netif_set_link_up(struct netif *netif) autoip_network_changed(netif); #endif /* LWIP_AUTOIP */ - if (netif->flags & NETIF_FLAG_UP) { - netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6); - } + netif_issue_reports(netif, NETIF_REPORT_TYPE_IPV4 | NETIF_REPORT_TYPE_IPV6); + NETIF_LINK_CALLBACK(netif); #if LWIP_NETIF_EXT_STATUS_CALLBACK {