Commit 104031ac authored by Phil Sutter's avatar Phil Sutter Committed by Pablo Neira Ayuso
Browse files

netfilter: nf_tables: Prepare for handling NETDEV_REGISTER events



Put NETDEV_UNREGISTER handling code into a switch, no functional change
intended as the function is only called for that event yet.

Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 73319a8e
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -9696,16 +9696,21 @@ static void nft_flowtable_event(unsigned long event, struct net_device *dev,
	struct nft_hook *hook;

	list_for_each_entry(hook, &flowtable->hook_list, list) {
		switch (event) {
		case NETDEV_UNREGISTER:
			ops = nft_hook_find_ops(hook, dev);
			if (!ops)
				continue;

			/* flow_offload_netdev_event() cleans up entries for us. */
		nft_unregister_flowtable_ops(dev_net(dev), flowtable, ops);
			nft_unregister_flowtable_ops(dev_net(dev),
						     flowtable, ops);
			list_del_rcu(&ops->list);
			kfree_rcu(ops, rcu);
			break;
		}
		break;
	}
}

static int nf_tables_flowtable_event(struct notifier_block *this,
+12 −7
Original line number Diff line number Diff line
@@ -321,21 +321,26 @@ static const struct nft_chain_type nft_chain_filter_netdev = {
static void nft_netdev_event(unsigned long event, struct net_device *dev,
			     struct nft_base_chain *basechain)
{
	struct nft_table *table = basechain->chain.table;
	struct nf_hook_ops *ops;
	struct nft_hook *hook;

	list_for_each_entry(hook, &basechain->hook_list, list) {
		switch (event) {
		case NETDEV_UNREGISTER:
			ops = nft_hook_find_ops(hook, dev);
			if (!ops)
				continue;

		if (!(basechain->chain.table->flags & NFT_TABLE_F_DORMANT))
			if (!(table->flags & NFT_TABLE_F_DORMANT))
				nf_unregister_net_hook(dev_net(dev), ops);

			list_del_rcu(&ops->list);
			kfree_rcu(ops, rcu);
			break;
		}
		break;
	}
}

static int nf_tables_netdev_event(struct notifier_block *this,