Merge tag 'ceph-for-4.21-rc1' of git://github.com/ceph/ceph-client
[linux] / net / netfilter / nft_chain_filter.c
index ea5b7c4..3fd540b 100644 (file)
@@ -293,6 +293,13 @@ static void nft_netdev_event(unsigned long event, struct net_device *dev,
                if (strcmp(basechain->dev_name, dev->name) != 0)
                        return;
 
+               /* UNREGISTER events are also happpening on netns exit.
+                *
+                * Altough nf_tables core releases all tables/chains, only
+                * this event handler provides guarantee that
+                * basechain.ops->dev is still accessible, so we cannot
+                * skip exiting net namespaces.
+                */
                __nft_release_basechain(ctx);
                break;
        case NETDEV_CHANGENAME:
@@ -318,10 +325,6 @@ static int nf_tables_netdev_event(struct notifier_block *this,
            event != NETDEV_CHANGENAME)
                return NOTIFY_DONE;
 
-       ctx.net = maybe_get_net(ctx.net);
-       if (!ctx.net)
-               return NOTIFY_DONE;
-
        mutex_lock(&ctx.net->nft.commit_mutex);
        list_for_each_entry(table, &ctx.net->nft.tables, list) {
                if (table->family != NFPROTO_NETDEV)
@@ -338,7 +341,6 @@ static int nf_tables_netdev_event(struct notifier_block *this,
                }
        }
        mutex_unlock(&ctx.net->nft.commit_mutex);
-       put_net(ctx.net);
 
        return NOTIFY_DONE;
 }
@@ -392,7 +394,7 @@ int __init nft_chain_filter_init(void)
        return 0;
 }
 
-void __exit nft_chain_filter_fini(void)
+void nft_chain_filter_fini(void)
 {
        nft_chain_filter_bridge_fini();
        nft_chain_filter_inet_fini();