From 8e1e33ffa696b2d779dd5cd422a80960b88e508c Mon Sep 17 00:00:00 2001 From: Martin Schiller Date: Wed, 18 Nov 2020 07:39:19 +0100 Subject: net/tun: Call type change netdev notifiers Call netdev notifiers before and after changing the device type. Signed-off-by: Martin Schiller Link: https://lore.kernel.org/r/20201118063919.29485-1-ms@dev.tdt.de Signed-off-by: Jakub Kicinski --- drivers/net/tun.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/net/tun.c') diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 3d45d56172cb..7c62d82c57db 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -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; -- cgit v1.2.3-58-ga151