Skip to content

Commit

Permalink
net/af_iucv: always register net_device notifier
Browse files Browse the repository at this point in the history
[ Upstream commit 06996c1d4088a0d5f3e7789d7f96b4653cc947cc ]

Even when running as VM guest (ie pr_iucv != NULL), af_iucv can still
open HiperTransport-based connections. For robust operation these
connections require the af_iucv_netdev_notifier, so register it
unconditionally.

Also handle any error that register_netdevice_notifier() returns.

Fixes: 9fbd87d ("af_iucv: handle netdev events")
Signed-off-by: Julian Wiedmann <[email protected]>
Reviewed-by: Ursula Braun <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
julianwiedmann authored and gregkh committed Jan 27, 2020
1 parent 9cbefb0 commit b977cc3
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions net/iucv/af_iucv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,13 @@ static int afiucv_iucv_init(void)
return err;
}

static void afiucv_iucv_exit(void)
{
device_unregister(af_iucv_dev);
driver_unregister(&af_iucv_driver);
pr_iucv->iucv_unregister(&af_iucv_handler, 0);
}

static int __init afiucv_init(void)
{
int err;
Expand Down Expand Up @@ -2498,11 +2505,18 @@ static int __init afiucv_init(void)
err = afiucv_iucv_init();
if (err)
goto out_sock;
} else
register_netdevice_notifier(&afiucv_netdev_notifier);
}

err = register_netdevice_notifier(&afiucv_netdev_notifier);
if (err)
goto out_notifier;

dev_add_pack(&iucv_packet_type);
return 0;

out_notifier:
if (pr_iucv)
afiucv_iucv_exit();
out_sock:
sock_unregister(PF_IUCV);
out_proto:
Expand All @@ -2516,12 +2530,11 @@ static int __init afiucv_init(void)
static void __exit afiucv_exit(void)
{
if (pr_iucv) {
device_unregister(af_iucv_dev);
driver_unregister(&af_iucv_driver);
pr_iucv->iucv_unregister(&af_iucv_handler, 0);
afiucv_iucv_exit();
symbol_put(iucv_if);
} else
unregister_netdevice_notifier(&afiucv_netdev_notifier);
}

unregister_netdevice_notifier(&afiucv_netdev_notifier);
dev_remove_pack(&iucv_packet_type);
sock_unregister(PF_IUCV);
proto_unregister(&iucv_proto);
Expand Down

0 comments on commit b977cc3

Please sign in to comment.