^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/if_macvlan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/if_tap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/if_vlan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/nsproxy.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/if_tun.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/cache.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/cdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/idr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/uio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <net/net_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <net/rtnetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/virtio_net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/skb_array.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct macvtap_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct macvlan_dev vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct tap_dev tap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * Variables for dealing with macvtaps device numbers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static dev_t macvtap_major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static const void *macvtap_net_namespace(struct device *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct net_device *dev = to_net_dev(d->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return dev_net(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static struct class macvtap_class = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) .name = "macvtap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) .ns_type = &net_ns_type_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) .namespace = macvtap_net_namespace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static struct cdev macvtap_cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) NETIF_F_TSO6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static void macvtap_count_tx_dropped(struct tap_dev *tap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct macvtap_dev *vlantap = container_of(tap, struct macvtap_dev, tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct macvlan_dev *vlan = &vlantap->vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) this_cpu_inc(vlan->pcpu_stats->tx_dropped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static void macvtap_count_rx_dropped(struct tap_dev *tap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct macvtap_dev *vlantap = container_of(tap, struct macvtap_dev, tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct macvlan_dev *vlan = &vlantap->vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) macvlan_count_rx(vlan, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static void macvtap_update_features(struct tap_dev *tap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) netdev_features_t features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct macvtap_dev *vlantap = container_of(tap, struct macvtap_dev, tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct macvlan_dev *vlan = &vlantap->vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) vlan->set_features = features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) netdev_update_features(vlan->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static int macvtap_newlink(struct net *src_net, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct nlattr *tb[], struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct macvtap_dev *vlantap = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) INIT_LIST_HEAD(&vlantap->tap.queue_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* Since macvlan supports all offloads by default, make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * tap support all offloads also.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) vlantap->tap.tap_features = TUN_OFFLOADS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* Register callbacks for rx/tx drops accounting and updating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * net_device features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) vlantap->tap.count_tx_dropped = macvtap_count_tx_dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) vlantap->tap.count_rx_dropped = macvtap_count_rx_dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) vlantap->tap.update_features = macvtap_update_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) err = netdev_rx_handler_register(dev, tap_handle_frame, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* Don't put anything that may fail after macvlan_common_newlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * because we can't undo what it does.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) err = macvlan_common_newlink(src_net, dev, tb, data, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) netdev_rx_handler_unregister(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) vlantap->tap.dev = vlantap->vlan.dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static void macvtap_dellink(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct list_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct macvtap_dev *vlantap = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) netdev_rx_handler_unregister(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) tap_del_queues(&vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) macvlan_dellink(dev, head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static void macvtap_setup(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) macvlan_common_setup(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) dev->tx_queue_len = TUN_READQ_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static struct rtnl_link_ops macvtap_link_ops __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) .kind = "macvtap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) .setup = macvtap_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) .newlink = macvtap_newlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) .dellink = macvtap_dellink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .priv_size = sizeof(struct macvtap_dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static int macvtap_device_event(struct notifier_block *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct net_device *dev = netdev_notifier_info_to_dev(ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct macvtap_dev *vlantap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct device *classdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) dev_t devt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) char tap_name[IFNAMSIZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (dev->rtnl_link_ops != &macvtap_link_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) snprintf(tap_name, IFNAMSIZ, "tap%d", dev->ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) vlantap = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) case NETDEV_REGISTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* Create the device node here after the network device has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * been registered but before register_netdevice has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * finished running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) err = tap_get_minor(macvtap_major, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return notifier_from_errno(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) devt = MKDEV(MAJOR(macvtap_major), vlantap->tap.minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) classdev = device_create(&macvtap_class, &dev->dev, devt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) dev, tap_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (IS_ERR(classdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) tap_free_minor(macvtap_major, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) return notifier_from_errno(PTR_ERR(classdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) err = sysfs_create_link(&dev->dev.kobj, &classdev->kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) tap_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return notifier_from_errno(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) case NETDEV_UNREGISTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) /* vlan->minor == 0 if NETDEV_REGISTER above failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (vlantap->tap.minor == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) sysfs_remove_link(&dev->dev.kobj, tap_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) devt = MKDEV(MAJOR(macvtap_major), vlantap->tap.minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) device_destroy(&macvtap_class, devt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) tap_free_minor(macvtap_major, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) case NETDEV_CHANGE_TX_QUEUE_LEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (tap_queue_resize(&vlantap->tap))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return NOTIFY_BAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static struct notifier_block macvtap_notifier_block __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) .notifier_call = macvtap_device_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static int macvtap_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) err = tap_create_cdev(&macvtap_cdev, &macvtap_major, "macvtap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) THIS_MODULE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) goto out1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) err = class_register(&macvtap_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) goto out2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) err = register_netdevice_notifier(&macvtap_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) goto out3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) err = macvlan_link_register(&macvtap_link_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) goto out4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) out4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) unregister_netdevice_notifier(&macvtap_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) out3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) class_unregister(&macvtap_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) out2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) tap_destroy_cdev(macvtap_major, &macvtap_cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) out1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) module_init(macvtap_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static void macvtap_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) rtnl_link_unregister(&macvtap_link_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) unregister_netdevice_notifier(&macvtap_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) class_unregister(&macvtap_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) tap_destroy_cdev(macvtap_major, &macvtap_cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) module_exit(macvtap_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) MODULE_ALIAS_RTNL_LINK("macvtap");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) MODULE_LICENSE("GPL");