core: Update IID every time netdevice is brought down

This is done to randomize the IPv6 address generation.
This also assigns a different IID to every rmnet interface.

CRs-Fixed: 2771389
Change-Id: I427481f1eeda098a2ebbd0c8ce88030eb0cd6cfd
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
This commit is contained in:
Subash Abhinov Kasiviswanathan 2020-09-10 21:32:55 -07:00
commit 7360fe16c5
3 changed files with 14 additions and 3 deletions

View file

@ -331,7 +331,9 @@ static int rmnet_config_notify_cb(struct notifier_block *nb,
netdev_dbg(dev, "Kernel unregister\n");
rmnet_force_unassociate_device(dev);
break;
case NETDEV_DOWN:
rmnet_vnd_reset_mac_addr(dev);
break;
default:
break;
}

View file

@ -357,7 +357,7 @@ void rmnet_vnd_setup(struct net_device *rmnet_dev)
rmnet_dev->netdev_ops = &rmnet_vnd_ops;
rmnet_dev->mtu = RMNET_DFLT_PACKET_SIZE;
rmnet_dev->needed_headroom = RMNET_NEEDED_HEADROOM;
random_ether_addr(rmnet_dev->dev_addr);
random_ether_addr(rmnet_dev->perm_addr);
rmnet_dev->tx_queue_len = RMNET_TX_QUEUE_LEN;
/* Raw IP mode */
@ -444,3 +444,11 @@ int rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable)
return 0;
}
void rmnet_vnd_reset_mac_addr(struct net_device *dev)
{
if (dev->netdev_ops != &rmnet_vnd_ops)
return;
random_ether_addr(dev->perm_addr);
}

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2018, 2020 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -27,4 +27,5 @@ void rmnet_vnd_rx_fixup(struct net_device *dev, u32 skb_len);
void rmnet_vnd_tx_fixup(struct net_device *dev, u32 skb_len);
u8 rmnet_vnd_get_mux(struct net_device *rmnet_dev);
void rmnet_vnd_setup(struct net_device *dev);
void rmnet_vnd_reset_mac_addr(struct net_device *dev);
#endif /* _RMNET_VND_H_ */