net: ipv6: Fix net_set_mac function
The ethernet driver calls net_set_mac before net_init is called (ie before the uip stack has been fully initialized). Unfortunately net_set_mac calls the function uip_ds6_set_lladdr. Therefore this function is called before uip_ds6_init: this is an issue as uip_ds6_set_lladdr is setting some static data which are going to be erased by uip_ds6_init. In some case it could even lead to a system hang due to a timer set twice. To fix this issue net_set_mac should check whether net_init has been already called. If not net_set_mac should simply copies the mac address into uip_lladdr. Indeed uip_ds6_init automatically calls uip_ds6_set_lladdr for the address stored into uip_lladdr. Change-Id: Ifbcb07e7cd493b6284a85d70f2439d434cebbb00 Signed-off-by: Sebastien Griffoul <sebastien.griffoul@intel.com>
This commit is contained in:
parent
57cd9939d6
commit
fb8d7625d1
1 changed files with 5 additions and 3 deletions
|
@ -97,6 +97,8 @@ static char __noinit __stack tx_fiber_stack[CONFIG_IP_TX_STACK_SIZE];
|
|||
static char __noinit __stack timer_fiber_stack[CONFIG_IP_TIMER_STACK_SIZE];
|
||||
static nano_thread_id_t timer_fiber_id, tx_fiber_id;
|
||||
|
||||
static uint8_t initialized;
|
||||
|
||||
static struct net_dev {
|
||||
/* Queue for incoming packets from driver */
|
||||
struct nano_fifo rx_queue;
|
||||
|
@ -999,7 +1001,9 @@ int net_set_mac(uint8_t *mac, uint8_t len)
|
|||
NET_DBG("MAC "); PRINTLLADDR((uip_lladdr_t *)&linkaddr_node_addr); PRINTF("\n");
|
||||
|
||||
#ifdef CONFIG_NETWORKING_WITH_IPV6
|
||||
{
|
||||
if (!initialized) {
|
||||
memcpy(&uip_lladdr, mac, len);
|
||||
} else {
|
||||
uip_ds6_addr_t *lladdr;
|
||||
|
||||
uip_ds6_set_lladdr((uip_lladdr_t *)mac);
|
||||
|
@ -1104,8 +1108,6 @@ void net_unregister_driver(struct net_driver *drv)
|
|||
|
||||
int net_init(void)
|
||||
{
|
||||
static uint8_t initialized;
|
||||
|
||||
if (initialized)
|
||||
return -EALREADY;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue