Commit 9cfbd10a authored by Lu Wei's avatar Lu Wei
Browse files

Revert "netfilter: nf_tables: skip immediate deactivate in _PREPARE_ERROR"

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I86JB6



-------------------------------

This reverts commit 12d448d8.

Backport the dependency patch and then re-backport this patch.

Signed-off-by: default avatarLu Wei <luwei32@huawei.com>
parent 7ed3bf10
Loading
Loading
Loading
Loading
+9 −18
Original line number Diff line number Diff line
@@ -125,27 +125,15 @@ static void nft_immediate_activate(const struct nft_ctx *ctx,
	return nft_data_hold(&priv->data, nft_dreg_to_type(priv->dreg));
}

static void nft_immediate_chain_deactivate(const struct nft_ctx *ctx,
					   struct nft_chain *chain,
					   enum nft_trans_phase phase)
{
	struct nft_ctx chain_ctx;
	struct nft_rule *rule;

	chain_ctx = *ctx;
	chain_ctx.chain = chain;

	list_for_each_entry(rule, &chain->rules, list)
		nft_rule_expr_deactivate(&chain_ctx, rule, phase);
}

static void nft_immediate_deactivate(const struct nft_ctx *ctx,
				     const struct nft_expr *expr,
				     enum nft_trans_phase phase)
{
	const struct nft_immediate_expr *priv = nft_expr_priv(expr);
	const struct nft_data *data = &priv->data;
	struct nft_ctx chain_ctx;
	struct nft_chain *chain;
	struct nft_rule *rule;

	if (priv->dreg == NFT_REG_VERDICT) {
		switch (data->verdict.code) {
@@ -155,17 +143,20 @@ static void nft_immediate_deactivate(const struct nft_ctx *ctx,
			if (!nft_chain_binding(chain))
				break;

			chain_ctx = *ctx;
			chain_ctx.chain = chain;

			list_for_each_entry(rule, &chain->rules, list)
				nft_rule_expr_deactivate(&chain_ctx, rule, phase);

			switch (phase) {
			case NFT_TRANS_PREPARE_ERROR:
				nf_tables_unbind_chain(ctx, chain);
				nft_deactivate_next(ctx->net, chain);
				break;
				fallthrough;
			case NFT_TRANS_PREPARE:
				nft_immediate_chain_deactivate(ctx, chain, phase);
				nft_deactivate_next(ctx->net, chain);
				break;
			default:
				nft_immediate_chain_deactivate(ctx, chain, phase);
				nft_chain_del(chain);
				chain->bound = false;
				chain->table->use--;