From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org,
jakub.kicinski@netronome.com, jiri@resnulli.us,
marcelo.leitner@gmail.com, saeedm@mellanox.com, wenxu@ucloud.cn,
gerlitz.or@gmail.com, paulb@mellanox.com
Subject: [PATCH net-next 2/3] netfilter: nf_tables_offload: add offload field to basechain
Date: Fri, 2 Aug 2019 15:28:45 +0200 [thread overview]
Message-ID: <20190802132846.3067-3-pablo@netfilter.org> (raw)
In-Reply-To: <20190802132846.3067-1-pablo@netfilter.org>
Wrap offload objects in struct nft_base_chain around structure.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
v1: initial patch version.
include/net/netfilter/nf_tables.h | 6 ++++--
include/net/netfilter/nf_tables_offload.h | 5 +++++
net/netfilter/nf_tables_api.c | 2 +-
net/netfilter/nf_tables_offload.c | 7 ++++---
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 9b624566b82d..87dbe62c0f27 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -952,7 +952,7 @@ struct nft_stats {
* @stats: per-cpu chain stats
* @chain: the chain
* @dev_name: device name that this base chain is attached to (if any)
- * @flow_block: flow block (for hardware offload)
+ * @offload: hardware offload data
*/
struct nft_base_chain {
struct nf_hook_ops ops;
@@ -962,7 +962,9 @@ struct nft_base_chain {
struct nft_stats __percpu *stats;
struct nft_chain chain;
char dev_name[IFNAMSIZ];
- struct flow_block flow_block;
+ struct {
+ struct flow_block flow_block;
+ } offload;
};
static inline struct nft_base_chain *nft_base_chain(const struct nft_chain *chain)
diff --git a/include/net/netfilter/nf_tables_offload.h b/include/net/netfilter/nf_tables_offload.h
index 3196663a10e3..fb3db391ade8 100644
--- a/include/net/netfilter/nf_tables_offload.h
+++ b/include/net/netfilter/nf_tables_offload.h
@@ -73,4 +73,9 @@ int nft_flow_rule_offload_commit(struct net *net);
(__reg)->key = __key; \
memset(&(__reg)->mask, 0xff, (__reg)->len);
+static inline void nft_basechain_offload_init(struct nft_base_chain *basechain)
+{
+ flow_block_init(&basechain->offload.flow_block);
+}
+
#endif
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 605a7cfe7ca7..a07d764c3555 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1662,7 +1662,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
chain->flags |= NFT_BASE_CHAIN | flags;
basechain->policy = NF_ACCEPT;
- flow_block_init(&basechain->flow_block);
+ nft_basechain_offload_init(basechain);
} else {
chain = kzalloc(sizeof(*chain), GFP_KERNEL);
if (chain == NULL)
diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index 64f5fd5f240e..84615381b06f 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -113,10 +113,11 @@ static void nft_flow_offload_common_init(struct flow_cls_common_offload *common,
static int nft_setup_cb_call(struct nft_base_chain *basechain,
enum tc_setup_type type, void *type_data)
{
+ struct flow_block *flow_block = &basechain->offload.flow_block;
struct flow_block_cb *block_cb;
int err;
- list_for_each_entry(block_cb, &basechain->flow_block.cb_list, list) {
+ list_for_each_entry(block_cb, &flow_block->cb_list, list) {
err = block_cb->cb(type, type_data, block_cb->cb_priv);
if (err < 0)
return err;
@@ -154,7 +155,7 @@ static int nft_flow_offload_rule(struct nft_trans *trans,
static int nft_flow_offload_bind(struct flow_block_offload *bo,
struct nft_base_chain *basechain)
{
- list_splice(&bo->cb_list, &basechain->flow_block.cb_list);
+ list_splice(&bo->cb_list, &basechain->offload.flow_block.cb_list);
return 0;
}
@@ -198,7 +199,7 @@ static int nft_flow_offload_chain(struct nft_trans *trans,
return -EOPNOTSUPP;
bo.command = cmd;
- bo.block = &basechain->flow_block;
+ bo.block = &basechain->offload.flow_block;
bo.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
bo.extack = &extack;
INIT_LIST_HEAD(&bo.cb_list);
--
2.11.0
next prev parent reply other threads:[~2019-08-02 13:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-02 13:28 [PATCH net-next 0/3,v2] flow_offload hardware priority fixes Pablo Neira Ayuso
2019-08-02 13:28 ` [PATCH net-next 1/3,v2] net: sched: use major priority number as hardware priority Pablo Neira Ayuso
2019-08-05 8:36 ` Jiri Pirko
2019-08-02 13:28 ` Pablo Neira Ayuso [this message]
2019-08-02 13:28 ` [PATCH net-next 3/3] filter: nf_tables_offload: set priority field for rules Pablo Neira Ayuso
2019-08-02 20:48 ` [PATCH net-next 0/3,v2] flow_offload hardware priority fixes Jakub Kicinski
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=20190802132846.3067-3-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=gerlitz.or@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=jiri@resnulli.us \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=paulb@mellanox.com \
--cc=saeedm@mellanox.com \
--cc=wenxu@ucloud.cn \
/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).