You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within netif_add, the netif_set_addr function is invoked, which subsequently calls netif_do_set_netmask. During the execution of netif_do_set_netmask, the following debug statement is executed (when NETIF_DEBUG is enabled):
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
netif->name[0], netif->name[1],
ip4_addr1_16(netif_ip4_netmask(netif)),
ip4_addr2_16(netif_ip4_netmask(netif)),
ip4_addr3_16(netif_ip4_netmask(netif)),
ip4_addr4_16(netif_ip4_netmask(netif))));
However, at this point, netif->name[0] and netif->name[1] have not yet been initialized, as their initialization happens later in the ethernetif_init function.
err_tethernetif_init(structnetif*netif)
{
LWIP_ASSERT("netif != NULL", (netif!=NULL));
#ifLWIP_NETIF_HOSTNAME/* Initialize interface hostname */netif->hostname="lwip";
#endif/* LWIP_NETIF_HOSTNAME *//* * Initialize the snmp variables and counters inside the struct netif. * The last argument should be replaced with your link speed, in units * of bits per second. */// MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);netif->name[0] =IFNAME0;
netif->name[1] =IFNAME1;
...
}
You can see, netif_set_addr is called before init function.
#ifLWIP_IPV4netif_set_addr(netif, ipaddr, netmask, gw);
#endif/* LWIP_IPV4 *//* call user specified initialization function for netif */if (init(netif) !=ERR_OK) {
returnNULL;
}
As a result, the debug output for netif->name produces incorrect or undefined values.
How To Reproduce
Application behavior: The application uses the default LwIP example generated by STM32CubeMX or provided in the CubeF4 software package.
Suspected modules: LwIP middleware and netif implementation.
Use case:
Enable the NETIF_DEBUG option in lwipopts.h.
Run the LwIP example on the provided board.
Observe the debug logs where netif->name is used before it is initialized.
Reproduction steps:
Generate a project with LwIP middleware enabled using STM32CubeMX.
Ensure NETIF_DEBUG is enabled.
Build and run the project.
Monitor the logs .
Additional context
Proposed Fix:
The issue can be resolved by ensuring that netif->name is initialized before calling netif_add.
Screenshots
The text was updated successfully, but these errors were encountered:
Hello @bricle
Thank you for your report. All our LwIP examples function correctly, even with the call to netif_set_addr before the initialization of netif->name. Could you please provide more details on why this caused an issue for you?
Caution
Describe the set-up
Describe the bug
There is a bug in the LwIP example provided in the STM32CubeF4 software package. In the lwip.c file, the
MX_LWIP_Init
function callsWithin
netif_add
, thenetif_set_addr
function is invoked, which subsequently callsnetif_do_set_netmask
. During the execution ofnetif_do_set_netmask
, the following debug statement is executed (whenNETIF_DEBUG
is enabled):However, at this point,
netif->name[0]
andnetif->name[1]
have not yet been initialized, as their initialization happens later in theethernetif_init
function.You can see,
netif_set_addr
is called beforeinit
function.As a result, the debug output for
netif->name
produces incorrect or undefined values.How To Reproduce
Additional context
Proposed Fix:
The issue can be resolved by ensuring that
netif->name
is initialized before callingnetif_add
.Screenshots
The text was updated successfully, but these errors were encountered: