From: wenxu@ucloud.cn
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH nf-next v3 2/4] netfilter: nf_tables_offload: refactor the nft_flow_offload_rule function
Date: Thu, 5 Sep 2019 12:00:17 +0800 [thread overview]
Message-ID: <1567656019-6881-3-git-send-email-wenxu@ucloud.cn> (raw)
In-Reply-To: <1567656019-6881-1-git-send-email-wenxu@ucloud.cn>
From: wenxu <wenxu@ucloud.cn>
Refactor nft_flow_offload_rule and make it more common
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
v3: no change
net/netfilter/nf_tables_offload.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index 9419486..9657001 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -134,20 +134,20 @@ int nft_chain_offload_priority(struct nft_base_chain *basechain)
return 0;
}
-static int nft_flow_offload_rule(struct nft_trans *trans,
+static int nft_flow_offload_rule(struct nft_chain *chain,
+ struct nft_rule *rule,
+ struct nft_flow_rule *flow,
enum flow_cls_command command)
{
- struct nft_flow_rule *flow = nft_trans_flow_rule(trans);
- struct nft_rule *rule = nft_trans_rule(trans);
struct flow_cls_offload cls_flow = {};
struct nft_base_chain *basechain;
struct netlink_ext_ack extack;
__be16 proto = ETH_P_ALL;
- if (!nft_is_base_chain(trans->ctx.chain))
+ if (!nft_is_base_chain(chain))
return -EOPNOTSUPP;
- basechain = nft_base_chain(trans->ctx.chain);
+ basechain = nft_base_chain(chain);
if (flow)
proto = flow->proto;
@@ -162,6 +162,16 @@ static int nft_flow_offload_rule(struct nft_trans *trans,
return nft_setup_cb_call(basechain, TC_SETUP_CLSFLOWER, &cls_flow);
}
+static int nft_flow_offload_rule_commit(struct nft_trans *trans,
+ enum flow_cls_command command)
+{
+ struct nft_flow_rule *flow = nft_trans_flow_rule(trans);
+ struct nft_rule *rule = nft_trans_rule(trans);
+ struct nft_chain *chain = trans->ctx.chain;
+
+ return nft_flow_offload_rule(chain, rule, flow, command);
+}
+
static int nft_flow_offload_bind(struct flow_block_offload *bo,
struct nft_base_chain *basechain)
{
@@ -337,14 +347,14 @@ int nft_flow_rule_offload_commit(struct net *net)
!(trans->ctx.flags & NLM_F_APPEND))
return -EOPNOTSUPP;
- err = nft_flow_offload_rule(trans, FLOW_CLS_REPLACE);
+ err = nft_flow_offload_rule_commit(trans, FLOW_CLS_REPLACE);
nft_flow_rule_destroy(nft_trans_flow_rule(trans));
break;
case NFT_MSG_DELRULE:
if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))
continue;
- err = nft_flow_offload_rule(trans, FLOW_CLS_DESTROY);
+ err = nft_flow_offload_rule_commit(trans, FLOW_CLS_DESTROY);
break;
}
--
1.8.3.1
next prev parent reply other threads:[~2019-09-05 4:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 4:00 [PATCH nf-next v3 0/4] netfilter: nf_tables_offload: clean offload things when the device unregister wenxu
2019-09-05 4:00 ` [PATCH nf-next v3 1/4] netfilter: nf_tables_offload: refactor the nft_flow_offload_chain function wenxu
2019-09-05 4:00 ` wenxu [this message]
2019-09-05 4:00 ` [PATCH nf-next v3 3/4] netfilter: nf_tables_offload: add nft_offload_netdev_iterate function wenxu
2019-09-06 0:34 ` Pablo Neira Ayuso
2019-09-06 3:25 ` wenxu
2019-09-05 4:00 ` [PATCH nf-next v3 4/4] netfilter: nf_tables_offload: clean offload things when the device unregister wenxu
2019-09-06 0:27 ` [PATCH nf-next v3 0/4] " Pablo Neira Ayuso
2019-09-06 3:09 ` wenxu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1567656019-6881-3-git-send-email-wenxu@ucloud.cn \
--to=wenxu@ucloud.cn \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).