net/tun: Call type change netdev notifiers

Call netdev notifiers before and after changing the device type.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
Link: https://lore.kernel.org/r/20201118063919.29485-1-ms@dev.tdt.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Martin Schiller 2020-11-18 07:39:19 +01:00 committed by Jakub Kicinski
parent f9e425e99b
commit 8e1e33ffa6

View File

@ -3071,10 +3071,19 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
"Linktype set failed because interface is up\n");
ret = -EBUSY;
} else {
ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE,
tun->dev);
ret = notifier_to_errno(ret);
if (ret) {
netif_info(tun, drv, tun->dev,
"Refused to change device type\n");
break;
}
tun->dev->type = (int) arg;
netif_info(tun, drv, tun->dev, "linktype set to %d\n",
tun->dev->type);
ret = 0;
call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE,
tun->dev);
}
break;