^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 "ipvlan.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/if_vlan.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/if_tap.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.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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) NETIF_F_TSO6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static dev_t ipvtap_major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static struct cdev ipvtap_cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static const void *ipvtap_net_namespace(struct device *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct net_device *dev = to_net_dev(d->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) return dev_net(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static struct class ipvtap_class = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) .name = "ipvtap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .ns_type = &net_ns_type_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .namespace = ipvtap_net_namespace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct ipvtap_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct ipvl_dev vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct tap_dev tap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static void ipvtap_count_tx_dropped(struct tap_dev *tap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct ipvtap_dev *vlantap = container_of(tap, struct ipvtap_dev, tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct ipvl_dev *vlan = &vlantap->vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) this_cpu_inc(vlan->pcpu_stats->tx_drps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static void ipvtap_count_rx_dropped(struct tap_dev *tap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct ipvtap_dev *vlantap = container_of(tap, struct ipvtap_dev, tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct ipvl_dev *vlan = &vlantap->vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ipvlan_count_rx(vlan, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static void ipvtap_update_features(struct tap_dev *tap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) netdev_features_t features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct ipvtap_dev *vlantap = container_of(tap, struct ipvtap_dev, tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct ipvl_dev *vlan = &vlantap->vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) vlan->sfeatures = features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) netdev_update_features(vlan->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static int ipvtap_newlink(struct net *src_net, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct nlattr *tb[], struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct ipvtap_dev *vlantap = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) INIT_LIST_HEAD(&vlantap->tap.queue_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /* Since macvlan supports all offloads by default, make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * tap support all offloads also.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) vlantap->tap.tap_features = TUN_OFFLOADS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) vlantap->tap.count_tx_dropped = ipvtap_count_tx_dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) vlantap->tap.update_features = ipvtap_update_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) vlantap->tap.count_rx_dropped = ipvtap_count_rx_dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) err = netdev_rx_handler_register(dev, tap_handle_frame, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* Don't put anything that may fail after macvlan_common_newlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * because we can't undo what it does.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) err = ipvlan_link_new(src_net, dev, tb, data, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) netdev_rx_handler_unregister(dev);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) vlantap->tap.dev = vlantap->vlan.dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static void ipvtap_dellink(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct list_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct ipvtap_dev *vlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) netdev_rx_handler_unregister(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) tap_del_queues(&vlan->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ipvlan_link_delete(dev, head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static void ipvtap_setup(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ipvlan_link_setup(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) dev->tx_queue_len = TUN_READQ_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) dev->priv_flags &= ~IFF_NO_QUEUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static struct rtnl_link_ops ipvtap_link_ops __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) .kind = "ipvtap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) .setup = ipvtap_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) .newlink = ipvtap_newlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) .dellink = ipvtap_dellink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) .priv_size = sizeof(struct ipvtap_dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static int ipvtap_device_event(struct notifier_block *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct net_device *dev = netdev_notifier_info_to_dev(ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct ipvtap_dev *vlantap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct device *classdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) dev_t devt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) char tap_name[IFNAMSIZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (dev->rtnl_link_ops != &ipvtap_link_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) snprintf(tap_name, IFNAMSIZ, "tap%d", dev->ifindex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) vlantap = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) case NETDEV_REGISTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* Create the device node here after the network device has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * been registered but before register_netdevice has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * finished running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) err = tap_get_minor(ipvtap_major, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return notifier_from_errno(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) devt = MKDEV(MAJOR(ipvtap_major), vlantap->tap.minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) classdev = device_create(&ipvtap_class, &dev->dev, devt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) dev, tap_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (IS_ERR(classdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) tap_free_minor(ipvtap_major, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return notifier_from_errno(PTR_ERR(classdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) err = sysfs_create_link(&dev->dev.kobj, &classdev->kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) tap_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return notifier_from_errno(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) case NETDEV_UNREGISTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /* vlan->minor == 0 if NETDEV_REGISTER above failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (vlantap->tap.minor == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) sysfs_remove_link(&dev->dev.kobj, tap_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) devt = MKDEV(MAJOR(ipvtap_major), vlantap->tap.minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) device_destroy(&ipvtap_class, devt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) tap_free_minor(ipvtap_major, &vlantap->tap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) case NETDEV_CHANGE_TX_QUEUE_LEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (tap_queue_resize(&vlantap->tap))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) return NOTIFY_BAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static struct notifier_block ipvtap_notifier_block __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) .notifier_call = ipvtap_device_event,
^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) static int ipvtap_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) err = tap_create_cdev(&ipvtap_cdev, &ipvtap_major, "ipvtap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) THIS_MODULE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) goto out1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) err = class_register(&ipvtap_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) goto out2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) err = register_netdevice_notifier(&ipvtap_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) goto out3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) err = ipvlan_link_register(&ipvtap_link_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) goto out4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) out4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) unregister_netdevice_notifier(&ipvtap_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) out3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) class_unregister(&ipvtap_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) out2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) tap_destroy_cdev(ipvtap_major, &ipvtap_cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) out1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) module_init(ipvtap_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static void ipvtap_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) rtnl_link_unregister(&ipvtap_link_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) unregister_netdevice_notifier(&ipvtap_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) class_unregister(&ipvtap_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) tap_destroy_cdev(ipvtap_major, &ipvtap_cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) module_exit(ipvtap_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) MODULE_ALIAS_RTNL_LINK("ipvtap");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) MODULE_AUTHOR("Sainath Grandhi <sainath.grandhi@intel.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) MODULE_LICENSE("GPL");