Menu

#729 lwipthread.c incorrectly calls netif_add

trunk
closed
None
lwIP
Medium
16.1.4
True
2018-01-16
2016-03-28
No

The ChibiOS LwIP bindings include lwipthread.c, which first calls tcpip_init, then adds the MAC interface with netif_add.

netif_add is part of the raw API and should be called only from the internal LwIP worker thread context. Calling it from a different thread poses all sorts of race conditions, although such issues might not have arised due to the thread priorities used in the ChibiOS demos.

There are at least two possible workarounds:

1- Use netifapi_netif_add. This function will post a message for the internal LwIP thread to perform the actual netif_add operation.

2- Use the callback function passed to tcpip_init(). This callback function will be called once initialization is complete from the internal LwIP thread context, hence it can safely call any LwIP function including netif_add.

Discussion

  • Ignacio García Pérez

    Please change the "component" field of this bug to "lwip".

     
  • Giovanni Di Sirio

    • Component: Other --> lwIP
     
  • Giovanni Di Sirio

    Fixed by lwIP 2.0 merge.

     
  • Giovanni Di Sirio

    • assigned_to: Giovanni Di Sirio
    • Milestone: 16.1.5 --> trunk
    • Fixed in Repository: False --> True
     
  • Giovanni Di Sirio

    • status: open --> closed
     

Log in to post a comment.