Merge tag 'for-5.18/64bit-pi-2022-03-25' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / drivers / net / macvlan.c
index 6ef5f77..069e882 100644 (file)
@@ -285,7 +285,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
                if (likely(nskb))
                        err = macvlan_broadcast_one(nskb, vlan, eth,
                                        mode == MACVLAN_MODE_BRIDGE) ?:
-                             netif_rx_ni(nskb);
+                             netif_rx(nskb);
                macvlan_count_rx(vlan, skb->len + ETH_HLEN,
                                 err == NET_RX_SUCCESS, true);
        }
@@ -371,7 +371,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
 free_nskb:
        kfree_skb(nskb);
 err:
-       atomic_long_inc(&skb->dev->rx_dropped);
+       dev_core_stats_rx_dropped_inc(skb->dev);
 }
 
 static void macvlan_flush_sources(struct macvlan_port *port,
@@ -410,7 +410,7 @@ static void macvlan_forward_source_one(struct sk_buff *skb,
        if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest, dev->dev_addr))
                nskb->pkt_type = PACKET_HOST;
 
-       ret = netif_rx(nskb);
+       ret = __netif_rx(nskb);
        macvlan_count_rx(vlan, len, ret == NET_RX_SUCCESS, false);
 }
 
@@ -468,7 +468,7 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb)
                        /* forward to original port. */
                        vlan = src;
                        ret = macvlan_broadcast_one(skb, vlan, eth, 0) ?:
-                             netif_rx(skb);
+                             __netif_rx(skb);
                        handle_res = RX_HANDLER_CONSUMED;
                        goto out;
                }
@@ -889,7 +889,7 @@ static void macvlan_set_lockdep_class(struct net_device *dev)
 static int macvlan_init(struct net_device *dev)
 {
        struct macvlan_dev *vlan = netdev_priv(dev);
-       const struct net_device *lowerdev = vlan->lowerdev;
+       struct net_device *lowerdev = vlan->lowerdev;
        struct macvlan_port *port = vlan->port;
 
        dev->state              = (dev->state & ~MACVLAN_STATE_MASK) |
@@ -911,6 +911,9 @@ static int macvlan_init(struct net_device *dev)
 
        port->count += 1;
 
+       /* Get macvlan's reference to lowerdev */
+       dev_hold_track(lowerdev, &vlan->dev_tracker, GFP_KERNEL);
+
        return 0;
 }
 
@@ -1173,6 +1176,14 @@ static const struct net_device_ops macvlan_netdev_ops = {
        .ndo_features_check     = passthru_features_check,
 };
 
+static void macvlan_dev_free(struct net_device *dev)
+{
+       struct macvlan_dev *vlan = netdev_priv(dev);
+
+       /* Get rid of the macvlan's reference to lowerdev */
+       dev_put_track(vlan->lowerdev, &vlan->dev_tracker);
+}
+
 void macvlan_common_setup(struct net_device *dev)
 {
        ether_setup(dev);
@@ -1184,6 +1195,7 @@ void macvlan_common_setup(struct net_device *dev)
        dev->priv_flags        |= IFF_UNICAST_FLT | IFF_CHANGE_PROTO_DOWN;
        dev->netdev_ops         = &macvlan_netdev_ops;
        dev->needs_free_netdev  = true;
+       dev->priv_destructor    = macvlan_dev_free;
        dev->header_ops         = &macvlan_hard_header_ops;
        dev->ethtool_ops        = &macvlan_ethtool_ops;
 }