Commit 23403cd8 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: nf_tables_offload: release flow_rule on error from commit path

If hardware offload commit path fails, release all flow_rule objects.

Fixes: c9626a2c ("netfilter: nf_tables: add hardware offload support")
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 6ca61c7a
...@@ -422,14 +422,14 @@ int nft_flow_rule_offload_commit(struct net *net) ...@@ -422,14 +422,14 @@ int nft_flow_rule_offload_commit(struct net *net)
continue; continue;
if (trans->ctx.flags & NLM_F_REPLACE || if (trans->ctx.flags & NLM_F_REPLACE ||
!(trans->ctx.flags & NLM_F_APPEND)) !(trans->ctx.flags & NLM_F_APPEND)) {
return -EOPNOTSUPP; err = -EOPNOTSUPP;
break;
}
err = nft_flow_offload_rule(trans->ctx.chain, err = nft_flow_offload_rule(trans->ctx.chain,
nft_trans_rule(trans), nft_trans_rule(trans),
nft_trans_flow_rule(trans), nft_trans_flow_rule(trans),
FLOW_CLS_REPLACE); FLOW_CLS_REPLACE);
nft_flow_rule_destroy(nft_trans_flow_rule(trans));
break; break;
case NFT_MSG_DELRULE: case NFT_MSG_DELRULE:
if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD)) if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))
...@@ -442,7 +442,23 @@ int nft_flow_rule_offload_commit(struct net *net) ...@@ -442,7 +442,23 @@ int nft_flow_rule_offload_commit(struct net *net)
} }
if (err) if (err)
return err; break;
}
list_for_each_entry(trans, &net->nft.commit_list, list) {
if (trans->ctx.family != NFPROTO_NETDEV)
continue;
switch (trans->msg_type) {
case NFT_MSG_NEWRULE:
if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))
continue;
nft_flow_rule_destroy(nft_trans_flow_rule(trans));
break;
default:
break;
}
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment