^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright (c) 2014 Mahesh Bandewar <maheshb@google.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include "ipvlan.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct ipvl_dev *ipvlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) ASSERT_RTNL();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) if (port->mode != nval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) flags = ipvlan->dev->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) err = dev_change_flags(ipvlan->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) flags | IFF_NOARP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) err = dev_change_flags(ipvlan->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) flags & ~IFF_NOARP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (unlikely(err))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if (nval == IPVLAN_MODE_L3S) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /* New mode is L3S */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) err = ipvlan_l3s_register(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) } else if (port->mode == IPVLAN_MODE_L3S) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* Old mode was L3S */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ipvlan_l3s_unregister(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) port->mode = nval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* Undo the flags changes that have been done so far. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) list_for_each_entry_continue_reverse(ipvlan, &port->ipvlans, pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) flags = ipvlan->dev->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (port->mode == IPVLAN_MODE_L3 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) port->mode == IPVLAN_MODE_L3S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) dev_change_flags(ipvlan->dev, flags | IFF_NOARP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return err;
^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 int ipvlan_port_create(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct ipvl_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int err, idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) port = kzalloc(sizeof(struct ipvl_port), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if (!port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) write_pnet(&port->pnet, dev_net(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) port->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) port->mode = IPVLAN_MODE_L3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) INIT_LIST_HEAD(&port->ipvlans);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) for (idx = 0; idx < IPVLAN_HASH_SIZE; idx++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) INIT_HLIST_HEAD(&port->hlhead[idx]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) skb_queue_head_init(&port->backlog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) INIT_WORK(&port->wq, ipvlan_process_multicast);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ida_init(&port->ida);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) port->dev_id_start = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) err = netdev_rx_handler_register(dev, ipvlan_handle_frame, port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) kfree(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static void ipvlan_port_destroy(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct ipvl_port *port = ipvlan_port_get_rtnl(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (port->mode == IPVLAN_MODE_L3S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ipvlan_l3s_unregister(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) netdev_rx_handler_unregister(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) cancel_work_sync(&port->wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) while ((skb = __skb_dequeue(&port->backlog)) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (skb->dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) dev_put(skb->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ida_destroy(&port->ida);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) kfree(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define IPVLAN_ALWAYS_ON_OFLOADS \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) (NETIF_F_SG | NETIF_F_HW_CSUM | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) NETIF_F_GSO_ROBUST | NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define IPVLAN_ALWAYS_ON \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) (IPVLAN_ALWAYS_ON_OFLOADS | NETIF_F_LLTX | NETIF_F_VLAN_CHALLENGED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define IPVLAN_FEATURES \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) NETIF_F_GSO | NETIF_F_ALL_TSO | NETIF_F_GSO_ROBUST | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) NETIF_F_GRO | NETIF_F_RXCSUM | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* NETIF_F_GSO_ENCAP_ALL NETIF_F_GSO_SOFTWARE Newly added */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define IPVLAN_STATE_MASK \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int ipvlan_init(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct net_device *phy_dev = ipvlan->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct ipvl_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) dev->state = (dev->state & ~IPVLAN_STATE_MASK) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) (phy_dev->state & IPVLAN_STATE_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) dev->features = phy_dev->features & IPVLAN_FEATURES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) dev->features |= IPVLAN_ALWAYS_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) dev->hw_enc_features |= dev->features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) dev->gso_max_size = phy_dev->gso_max_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) dev->gso_max_segs = phy_dev->gso_max_segs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) dev->hard_header_len = phy_dev->hard_header_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) netdev_lockdep_set_classes(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ipvlan->pcpu_stats = netdev_alloc_pcpu_stats(struct ipvl_pcpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (!ipvlan->pcpu_stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (!netif_is_ipvlan_port(phy_dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) err = ipvlan_port_create(phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) free_percpu(ipvlan->pcpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) port = ipvlan_port_get_rtnl(phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) port->count += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static void ipvlan_uninit(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct net_device *phy_dev = ipvlan->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct ipvl_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) free_percpu(ipvlan->pcpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) port = ipvlan_port_get_rtnl(phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) port->count -= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (!port->count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) ipvlan_port_destroy(port->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static int ipvlan_open(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct ipvl_addr *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (ipvlan->port->mode == IPVLAN_MODE_L3 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ipvlan->port->mode == IPVLAN_MODE_L3S)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) dev->flags |= IFF_NOARP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) dev->flags &= ~IFF_NOARP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) list_for_each_entry_rcu(addr, &ipvlan->addrs, anode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) ipvlan_ht_addr_add(ipvlan, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static int ipvlan_stop(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct net_device *phy_dev = ipvlan->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct ipvl_addr *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) dev_uc_unsync(phy_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) dev_mc_unsync(phy_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) list_for_each_entry_rcu(addr, &ipvlan->addrs, anode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ipvlan_ht_addr_del(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static netdev_tx_t ipvlan_start_xmit(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) const struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int skblen = skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) ret = ipvlan_queue_xmit(skb, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct ipvl_pcpu_stats *pcptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) pcptr = this_cpu_ptr(ipvlan->pcpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) u64_stats_update_begin(&pcptr->syncp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) pcptr->tx_pkts++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) pcptr->tx_bytes += skblen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) u64_stats_update_end(&pcptr->syncp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) this_cpu_inc(ipvlan->pcpu_stats->tx_drps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static netdev_features_t ipvlan_fix_features(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) netdev_features_t features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) features |= NETIF_F_ALL_FOR_ALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) features = netdev_increment_features(ipvlan->phy_dev->features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) features, features);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) features |= IPVLAN_ALWAYS_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static void ipvlan_change_rx_flags(struct net_device *dev, int change)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) struct net_device *phy_dev = ipvlan->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if (change & IFF_ALLMULTI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) dev_set_allmulti(phy_dev, dev->flags & IFF_ALLMULTI? 1 : -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static void ipvlan_set_multicast_mac_filter(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) bitmap_fill(ipvlan->mac_filters, IPVLAN_MAC_FILTER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct netdev_hw_addr *ha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) DECLARE_BITMAP(mc_filters, IPVLAN_MAC_FILTER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) bitmap_zero(mc_filters, IPVLAN_MAC_FILTER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) netdev_for_each_mc_addr(ha, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) __set_bit(ipvlan_mac_hash(ha->addr), mc_filters);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) /* Turn-on broadcast bit irrespective of address family,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * since broadcast is deferred to a work-queue, hence no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * impact on fast-path processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) __set_bit(ipvlan_mac_hash(dev->broadcast), mc_filters);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) bitmap_copy(ipvlan->mac_filters, mc_filters,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) IPVLAN_MAC_FILTER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) dev_uc_sync(ipvlan->phy_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) dev_mc_sync(ipvlan->phy_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static void ipvlan_get_stats64(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct rtnl_link_stats64 *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if (ipvlan->pcpu_stats) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct ipvl_pcpu_stats *pcptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) u64 rx_pkts, rx_bytes, rx_mcast, tx_pkts, tx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u32 rx_errs = 0, tx_drps = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) u32 strt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) for_each_possible_cpu(idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) pcptr = per_cpu_ptr(ipvlan->pcpu_stats, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) strt= u64_stats_fetch_begin_irq(&pcptr->syncp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) rx_pkts = pcptr->rx_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) rx_bytes = pcptr->rx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) rx_mcast = pcptr->rx_mcast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) tx_pkts = pcptr->tx_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) tx_bytes = pcptr->tx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) } while (u64_stats_fetch_retry_irq(&pcptr->syncp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) strt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) s->rx_packets += rx_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) s->rx_bytes += rx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) s->multicast += rx_mcast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) s->tx_packets += tx_pkts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) s->tx_bytes += tx_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /* u32 values are updated without syncp protection. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) rx_errs += pcptr->rx_errs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) tx_drps += pcptr->tx_drps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) s->rx_errors = rx_errs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) s->rx_dropped = rx_errs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) s->tx_dropped = tx_drps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static int ipvlan_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) struct net_device *phy_dev = ipvlan->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) return vlan_vid_add(phy_dev, proto, vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static int ipvlan_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) struct net_device *phy_dev = ipvlan->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) vlan_vid_del(phy_dev, proto, vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static int ipvlan_get_iflink(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) return ipvlan->phy_dev->ifindex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) static const struct net_device_ops ipvlan_netdev_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) .ndo_init = ipvlan_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) .ndo_uninit = ipvlan_uninit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) .ndo_open = ipvlan_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) .ndo_stop = ipvlan_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) .ndo_start_xmit = ipvlan_start_xmit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) .ndo_fix_features = ipvlan_fix_features,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) .ndo_change_rx_flags = ipvlan_change_rx_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) .ndo_set_rx_mode = ipvlan_set_multicast_mac_filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) .ndo_get_stats64 = ipvlan_get_stats64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) .ndo_vlan_rx_add_vid = ipvlan_vlan_rx_add_vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) .ndo_vlan_rx_kill_vid = ipvlan_vlan_rx_kill_vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) .ndo_get_iflink = ipvlan_get_iflink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) static int ipvlan_hard_header(struct sk_buff *skb, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) unsigned short type, const void *daddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) const void *saddr, unsigned len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) const struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) struct net_device *phy_dev = ipvlan->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* TODO Probably use a different field than dev_addr so that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * mac-address on the virtual device is portable and can be carried
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * while the packets use the mac-addr on the physical device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) return dev_hard_header(skb, phy_dev, type, daddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) saddr ? : phy_dev->dev_addr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) static const struct header_ops ipvlan_header_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) .create = ipvlan_hard_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) .parse = eth_header_parse,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) .cache = eth_header_cache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) .cache_update = eth_header_cache_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) static void ipvlan_adjust_mtu(struct ipvl_dev *ipvlan, struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) ipvlan->dev->mtu = dev->mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) static bool netif_is_ipvlan(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) /* both ipvlan and ipvtap devices use the same netdev_ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) return dev->netdev_ops == &ipvlan_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) static int ipvlan_ethtool_get_link_ksettings(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) struct ethtool_link_ksettings *cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) const struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) return __ethtool_get_link_ksettings(ipvlan->phy_dev, cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) static void ipvlan_ethtool_get_drvinfo(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) struct ethtool_drvinfo *drvinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) strlcpy(drvinfo->driver, IPVLAN_DRV, sizeof(drvinfo->driver));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) strlcpy(drvinfo->version, IPV_DRV_VER, sizeof(drvinfo->version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) static u32 ipvlan_ethtool_get_msglevel(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) const struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) return ipvlan->msg_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) static void ipvlan_ethtool_set_msglevel(struct net_device *dev, u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) ipvlan->msg_enable = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) static const struct ethtool_ops ipvlan_ethtool_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) .get_link = ethtool_op_get_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) .get_link_ksettings = ipvlan_ethtool_get_link_ksettings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) .get_drvinfo = ipvlan_ethtool_get_drvinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) .get_msglevel = ipvlan_ethtool_get_msglevel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) .set_msglevel = ipvlan_ethtool_set_msglevel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) static int ipvlan_nl_changelink(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) struct nlattr *tb[], struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) struct ipvl_port *port = ipvlan_port_get_rtnl(ipvlan->phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) if (!ns_capable(dev_net(ipvlan->phy_dev)->user_ns, CAP_NET_ADMIN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if (data[IFLA_IPVLAN_MODE]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) u16 nmode = nla_get_u16(data[IFLA_IPVLAN_MODE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) err = ipvlan_set_port_mode(port, nmode, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) if (!err && data[IFLA_IPVLAN_FLAGS]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) u16 flags = nla_get_u16(data[IFLA_IPVLAN_FLAGS]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) if (flags & IPVLAN_F_PRIVATE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) ipvlan_mark_private(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) ipvlan_clear_private(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) if (flags & IPVLAN_F_VEPA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) ipvlan_mark_vepa(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) ipvlan_clear_vepa(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) static size_t ipvlan_nl_getsize(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) return (0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) + nla_total_size(2) /* IFLA_IPVLAN_MODE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) + nla_total_size(2) /* IFLA_IPVLAN_FLAGS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) static int ipvlan_nl_validate(struct nlattr *tb[], struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (data[IFLA_IPVLAN_MODE]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) u16 mode = nla_get_u16(data[IFLA_IPVLAN_MODE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (mode >= IPVLAN_MODE_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) if (data[IFLA_IPVLAN_FLAGS]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) u16 flags = nla_get_u16(data[IFLA_IPVLAN_FLAGS]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) /* Only two bits are used at this moment. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) if (flags & ~(IPVLAN_F_PRIVATE | IPVLAN_F_VEPA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /* Also both flags can't be active at the same time. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) if ((flags & (IPVLAN_F_PRIVATE | IPVLAN_F_VEPA)) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) (IPVLAN_F_PRIVATE | IPVLAN_F_VEPA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) static int ipvlan_nl_fillinfo(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) struct ipvl_port *port = ipvlan_port_get_rtnl(ipvlan->phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) if (!port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) ret = -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) if (nla_put_u16(skb, IFLA_IPVLAN_MODE, port->mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) if (nla_put_u16(skb, IFLA_IPVLAN_FLAGS, port->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) int ipvlan_link_new(struct net *src_net, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) struct nlattr *tb[], struct nlattr *data[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) struct netlink_ext_ack *extack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) struct ipvl_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) struct net_device *phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) u16 mode = IPVLAN_MODE_L3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) if (!tb[IFLA_LINK])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) phy_dev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) if (!phy_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) if (netif_is_ipvlan(phy_dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) struct ipvl_dev *tmp = netdev_priv(phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) phy_dev = tmp->phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) if (!ns_capable(dev_net(phy_dev)->user_ns, CAP_NET_ADMIN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) } else if (!netif_is_ipvlan_port(phy_dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) /* Exit early if the underlying link is invalid or busy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (phy_dev->type != ARPHRD_ETHER ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) phy_dev->flags & IFF_LOOPBACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) netdev_err(phy_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) "Master is either lo or non-ether device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) if (netdev_is_rx_handler_busy(phy_dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) netdev_err(phy_dev, "Device is already in use.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) ipvlan->phy_dev = phy_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) ipvlan->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) ipvlan->sfeatures = IPVLAN_FEATURES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) if (!tb[IFLA_MTU])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) ipvlan_adjust_mtu(ipvlan, phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) INIT_LIST_HEAD(&ipvlan->addrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) spin_lock_init(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) /* TODO Probably put random address here to be presented to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * world but keep using the physical-dev address for the outgoing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) * packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) memcpy(dev->dev_addr, phy_dev->dev_addr, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) dev->priv_flags |= IFF_NO_RX_HANDLER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) err = register_netdevice(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) /* ipvlan_init() would have created the port, if required */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) port = ipvlan_port_get_rtnl(phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) ipvlan->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) /* If the port-id base is at the MAX value, then wrap it around and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) * begin from 0x1 again. This may be due to a busy system where lots
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * of slaves are getting created and deleted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) if (port->dev_id_start == 0xFFFE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) port->dev_id_start = 0x1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) /* Since L2 address is shared among all IPvlan slaves including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * master, use unique 16 bit dev-ids to diffentiate among them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * Assign IDs between 0x1 and 0xFFFE (used by the master) to each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * slave link [see addrconf_ifid_eui48()].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) err = ida_simple_get(&port->ida, port->dev_id_start, 0xFFFE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) err = ida_simple_get(&port->ida, 0x1, port->dev_id_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) goto unregister_netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) dev->dev_id = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) /* Increment id-base to the next slot for the future assignment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) port->dev_id_start = err + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) err = netdev_upper_dev_link(phy_dev, dev, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) goto remove_ida;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) /* Flags are per port and latest update overrides. User has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) * to be consistent in setting it just like the mode attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) if (data && data[IFLA_IPVLAN_FLAGS])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) port->flags = nla_get_u16(data[IFLA_IPVLAN_FLAGS]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) if (data && data[IFLA_IPVLAN_MODE])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) mode = nla_get_u16(data[IFLA_IPVLAN_MODE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) err = ipvlan_set_port_mode(port, mode, extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) goto unlink_netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) list_add_tail_rcu(&ipvlan->pnode, &port->ipvlans);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) netif_stacked_transfer_operstate(phy_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) unlink_netdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) netdev_upper_dev_unlink(phy_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) remove_ida:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) ida_simple_remove(&port->ida, dev->dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) unregister_netdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) unregister_netdevice(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) EXPORT_SYMBOL_GPL(ipvlan_link_new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) struct ipvl_addr *addr, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) spin_lock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) ipvlan_ht_addr_del(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) list_del_rcu(&addr->anode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) kfree_rcu(addr, rcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) spin_unlock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) ida_simple_remove(&ipvlan->port->ida, dev->dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) list_del_rcu(&ipvlan->pnode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) unregister_netdevice_queue(dev, head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) netdev_upper_dev_unlink(ipvlan->phy_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) EXPORT_SYMBOL_GPL(ipvlan_link_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) void ipvlan_link_setup(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) ether_setup(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) dev->max_mtu = ETH_MAX_MTU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) dev->netdev_ops = &ipvlan_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) dev->needs_free_netdev = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) dev->header_ops = &ipvlan_header_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) dev->ethtool_ops = &ipvlan_ethtool_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) EXPORT_SYMBOL_GPL(ipvlan_link_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) static const struct nla_policy ipvlan_nl_policy[IFLA_IPVLAN_MAX + 1] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) [IFLA_IPVLAN_MODE] = { .type = NLA_U16 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) [IFLA_IPVLAN_FLAGS] = { .type = NLA_U16 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) static struct net *ipvlan_get_link_net(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) return dev_net(ipvlan->phy_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) static struct rtnl_link_ops ipvlan_link_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) .kind = "ipvlan",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) .priv_size = sizeof(struct ipvl_dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) .setup = ipvlan_link_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) .newlink = ipvlan_link_new,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) .dellink = ipvlan_link_delete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) .get_link_net = ipvlan_get_link_net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) int ipvlan_link_register(struct rtnl_link_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) ops->get_size = ipvlan_nl_getsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) ops->policy = ipvlan_nl_policy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) ops->validate = ipvlan_nl_validate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) ops->fill_info = ipvlan_nl_fillinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) ops->changelink = ipvlan_nl_changelink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) ops->maxtype = IFLA_IPVLAN_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) return rtnl_link_register(ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) EXPORT_SYMBOL_GPL(ipvlan_link_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) static int ipvlan_device_event(struct notifier_block *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) struct netdev_notifier_pre_changeaddr_info *prechaddr_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) struct net_device *dev = netdev_notifier_info_to_dev(ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) struct ipvl_dev *ipvlan, *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) struct ipvl_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) LIST_HEAD(lst_kill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) if (!netif_is_ipvlan_port(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) port = ipvlan_port_get_rtnl(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) case NETDEV_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) list_for_each_entry(ipvlan, &port->ipvlans, pnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) netif_stacked_transfer_operstate(ipvlan->phy_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) ipvlan->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) case NETDEV_REGISTER: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) struct net *oldnet, *newnet = dev_net(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) oldnet = read_pnet(&port->pnet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) if (net_eq(newnet, oldnet))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) write_pnet(&port->pnet, newnet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) ipvlan_migrate_l3s_hook(oldnet, newnet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) case NETDEV_UNREGISTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) if (dev->reg_state != NETREG_UNREGISTERING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) list_for_each_entry_safe(ipvlan, next, &port->ipvlans, pnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) ipvlan->dev->rtnl_link_ops->dellink(ipvlan->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) &lst_kill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) unregister_netdevice_many(&lst_kill);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) case NETDEV_FEAT_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) ipvlan->dev->gso_max_size = dev->gso_max_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) ipvlan->dev->gso_max_segs = dev->gso_max_segs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) netdev_update_features(ipvlan->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) case NETDEV_CHANGEMTU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) list_for_each_entry(ipvlan, &port->ipvlans, pnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) ipvlan_adjust_mtu(ipvlan, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) case NETDEV_PRE_CHANGEADDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) prechaddr_info = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) err = dev_pre_changeaddr_notify(ipvlan->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) prechaddr_info->dev_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) extack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) return notifier_from_errno(err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) case NETDEV_CHANGEADDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) ether_addr_copy(ipvlan->dev->dev_addr, dev->dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) call_netdevice_notifiers(NETDEV_CHANGEADDR, ipvlan->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) case NETDEV_PRE_TYPE_CHANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) /* Forbid underlying device to change its type. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) return NOTIFY_BAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) /* the caller must held the addrs lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) static int ipvlan_add_addr(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) struct ipvl_addr *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) addr = kzalloc(sizeof(struct ipvl_addr), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) if (!addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) addr->master = ipvlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) if (!is_v6) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) memcpy(&addr->ip4addr, iaddr, sizeof(struct in_addr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) addr->atype = IPVL_IPV4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) memcpy(&addr->ip6addr, iaddr, sizeof(struct in6_addr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) addr->atype = IPVL_IPV6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) list_add_tail_rcu(&addr->anode, &ipvlan->addrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) /* If the interface is not up, the address will be added to the hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) * list by ipvlan_open.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) if (netif_running(ipvlan->dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) ipvlan_ht_addr_add(ipvlan, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) static void ipvlan_del_addr(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) struct ipvl_addr *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) spin_lock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) addr = ipvlan_find_addr(ipvlan, iaddr, is_v6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) if (!addr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) spin_unlock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) ipvlan_ht_addr_del(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) list_del_rcu(&addr->anode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) spin_unlock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) kfree_rcu(addr, rcu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) static bool ipvlan_is_valid_dev(const struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) if (!netif_is_ipvlan(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) if (!ipvlan || !ipvlan->port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) spin_lock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) if (ipvlan_addr_busy(ipvlan->port, ip6_addr, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) netif_err(ipvlan, ifup, ipvlan->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) "Failed to add IPv6=%pI6c addr for %s intf\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) ip6_addr, ipvlan->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) ret = ipvlan_add_addr(ipvlan, ip6_addr, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) spin_unlock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) return ipvlan_del_addr(ipvlan, ip6_addr, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) static int ipvlan_addr6_event(struct notifier_block *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) struct inet6_ifaddr *if6 = (struct inet6_ifaddr *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) struct net_device *dev = (struct net_device *)if6->idev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) if (!ipvlan_is_valid_dev(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) case NETDEV_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) if (ipvlan_add_addr6(ipvlan, &if6->addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) return NOTIFY_BAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) case NETDEV_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) ipvlan_del_addr6(ipvlan, &if6->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) return NOTIFY_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) static int ipvlan_addr6_validator_event(struct notifier_block *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) struct in6_validator_info *i6vi = (struct in6_validator_info *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) struct net_device *dev = (struct net_device *)i6vi->i6vi_dev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) if (!ipvlan_is_valid_dev(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) case NETDEV_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) if (ipvlan_addr_busy(ipvlan->port, &i6vi->i6vi_addr, true)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) NL_SET_ERR_MSG(i6vi->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) "Address already assigned to an ipvlan device");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) return notifier_from_errno(-EADDRINUSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) return NOTIFY_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) spin_lock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) if (ipvlan_addr_busy(ipvlan->port, ip4_addr, false))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) netif_err(ipvlan, ifup, ipvlan->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) "Failed to add IPv4=%pI4 on %s intf.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) ip4_addr, ipvlan->dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) ret = ipvlan_add_addr(ipvlan, ip4_addr, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) spin_unlock_bh(&ipvlan->addrs_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) return ipvlan_del_addr(ipvlan, ip4_addr, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) static int ipvlan_addr4_event(struct notifier_block *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) struct in_ifaddr *if4 = (struct in_ifaddr *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) struct net_device *dev = (struct net_device *)if4->ifa_dev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) struct in_addr ip4_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) if (!ipvlan_is_valid_dev(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) case NETDEV_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) ip4_addr.s_addr = if4->ifa_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) if (ipvlan_add_addr4(ipvlan, &ip4_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) return NOTIFY_BAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) case NETDEV_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) ip4_addr.s_addr = if4->ifa_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) ipvlan_del_addr4(ipvlan, &ip4_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) return NOTIFY_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) static int ipvlan_addr4_validator_event(struct notifier_block *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) unsigned long event, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) struct in_validator_info *ivi = (struct in_validator_info *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) struct net_device *dev = (struct net_device *)ivi->ivi_dev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) struct ipvl_dev *ipvlan = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) if (!ipvlan_is_valid_dev(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) case NETDEV_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) if (ipvlan_addr_busy(ipvlan->port, &ivi->ivi_addr, false)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) NL_SET_ERR_MSG(ivi->extack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) "Address already assigned to an ipvlan device");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) return notifier_from_errno(-EADDRINUSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) return NOTIFY_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) static struct notifier_block ipvlan_addr4_notifier_block __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) .notifier_call = ipvlan_addr4_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) static struct notifier_block ipvlan_addr4_vtor_notifier_block __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) .notifier_call = ipvlan_addr4_validator_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) static struct notifier_block ipvlan_notifier_block __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) .notifier_call = ipvlan_device_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) static struct notifier_block ipvlan_addr6_notifier_block __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) .notifier_call = ipvlan_addr6_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) static struct notifier_block ipvlan_addr6_vtor_notifier_block __read_mostly = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) .notifier_call = ipvlan_addr6_validator_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) static int __init ipvlan_init_module(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) ipvlan_init_secret();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) register_netdevice_notifier(&ipvlan_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) register_inet6addr_notifier(&ipvlan_addr6_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) register_inet6addr_validator_notifier(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) &ipvlan_addr6_vtor_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) register_inetaddr_notifier(&ipvlan_addr4_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) register_inetaddr_validator_notifier(&ipvlan_addr4_vtor_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) err = ipvlan_l3s_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) err = ipvlan_link_register(&ipvlan_link_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) ipvlan_l3s_cleanup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) unregister_inetaddr_notifier(&ipvlan_addr4_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) unregister_inetaddr_validator_notifier(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) &ipvlan_addr4_vtor_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) unregister_inet6addr_notifier(&ipvlan_addr6_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) unregister_inet6addr_validator_notifier(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) &ipvlan_addr6_vtor_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) unregister_netdevice_notifier(&ipvlan_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) static void __exit ipvlan_cleanup_module(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) rtnl_link_unregister(&ipvlan_link_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) ipvlan_l3s_cleanup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) unregister_netdevice_notifier(&ipvlan_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) unregister_inetaddr_notifier(&ipvlan_addr4_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) unregister_inetaddr_validator_notifier(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) &ipvlan_addr4_vtor_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) unregister_inet6addr_notifier(&ipvlan_addr6_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) unregister_inet6addr_validator_notifier(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) &ipvlan_addr6_vtor_notifier_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) module_init(ipvlan_init_module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) module_exit(ipvlan_cleanup_module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) MODULE_AUTHOR("Mahesh Bandewar <maheshb@google.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) MODULE_DESCRIPTION("Driver for L3 (IPv6/IPv4) based VLANs");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) MODULE_ALIAS_RTNL_LINK("ipvlan");