Merge tag 'regmap-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[firefly-linux-kernel-4.4.55.git] / drivers / net / vxlan.c
index 942acc20d39408415dc8a9d23feb68a27bef6b67..026a313c2d2da4c3eb57d0c5f6a051bbbdc852b2 100644 (file)
@@ -1159,6 +1159,16 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
        if (!vs)
                goto drop;
 
+       /* If the NIC driver gave us an encapsulated packet
+        * with the encapsulation mark, the device checksummed it
+        * for us. Otherwise force the upper layers to verify it.
+        */
+       if ((skb->ip_summed != CHECKSUM_UNNECESSARY && skb->ip_summed != CHECKSUM_PARTIAL) ||
+           !skb->encapsulation)
+               skb->ip_summed = CHECKSUM_NONE;
+
+       skb->encapsulation = 0;
+
        vs->rcv(vs, skb, vxh->vx_vni);
        return 0;
 
@@ -1217,17 +1227,6 @@ static void vxlan_rcv(struct vxlan_sock *vs,
 
        skb_reset_network_header(skb);
 
-       /* If the NIC driver gave us an encapsulated packet with
-        * CHECKSUM_UNNECESSARY and Rx checksum feature is enabled,
-        * leave the CHECKSUM_UNNECESSARY, the device checksummed it
-        * for us. Otherwise force the upper layers to verify it.
-        */
-       if ((skb->ip_summed != CHECKSUM_UNNECESSARY && skb->ip_summed != CHECKSUM_PARTIAL) ||
-           !skb->encapsulation || !(vxlan->dev->features & NETIF_F_RXCSUM))
-               skb->ip_summed = CHECKSUM_NONE;
-
-       skb->encapsulation = 0;
-
        if (oip6)
                err = IP6_ECN_decapsulate(oip6, skb);
        if (oip)
@@ -2784,12 +2783,10 @@ static int vxlan_lowerdev_event(struct notifier_block *unused,
                                unsigned long event, void *ptr)
 {
        struct net_device *dev = netdev_notifier_info_to_dev(ptr);
-       struct vxlan_net *vn;
+       struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
 
-       if (event == NETDEV_UNREGISTER) {
-               vn = net_generic(dev_net(dev), vxlan_net_id);
+       if (event == NETDEV_UNREGISTER)
                vxlan_handle_lowerdev_unregister(vn, dev);
-       }
 
        return NOTIFY_DONE;
 }
@@ -2812,22 +2809,8 @@ static __net_init int vxlan_init_net(struct net *net)
        return 0;
 }
 
-static __net_exit void vxlan_exit_net(struct net *net)
-{
-       struct vxlan_net *vn = net_generic(net, vxlan_net_id);
-       struct vxlan_dev *vxlan, *next;
-       LIST_HEAD(list_kill);
-
-       rtnl_lock();
-       list_for_each_entry_safe(vxlan, next, &vn->vxlan_list, next)
-               vxlan_dellink(vxlan->dev, &list_kill);
-       unregister_netdevice_many(&list_kill);
-       rtnl_unlock();
-}
-
 static struct pernet_operations vxlan_net_ops = {
        .init = vxlan_init_net,
-       .exit = vxlan_exit_net,
        .id   = &vxlan_net_id,
        .size = sizeof(struct vxlan_net),
 };
@@ -2842,7 +2825,7 @@ static int __init vxlan_init_module(void)
 
        get_random_bytes(&vxlan_salt, sizeof(vxlan_salt));
 
-       rc = register_pernet_device(&vxlan_net_ops);
+       rc = register_pernet_subsys(&vxlan_net_ops);
        if (rc)
                goto out1;
 
@@ -2858,7 +2841,7 @@ static int __init vxlan_init_module(void)
 out3:
        unregister_netdevice_notifier(&vxlan_notifier_block);
 out2:
-       unregister_pernet_device(&vxlan_net_ops);
+       unregister_pernet_subsys(&vxlan_net_ops);
 out1:
        destroy_workqueue(vxlan_wq);
        return rc;
@@ -2870,8 +2853,8 @@ static void __exit vxlan_cleanup_module(void)
        rtnl_link_unregister(&vxlan_link_ops);
        unregister_netdevice_notifier(&vxlan_notifier_block);
        destroy_workqueue(vxlan_wq);
-       unregister_pernet_device(&vxlan_net_ops);
-       rcu_barrier();
+       unregister_pernet_subsys(&vxlan_net_ops);
+       /* rcu_barrier() is called by netns */
 }
 module_exit(vxlan_cleanup_module);