From: Marcelo Ricardo Leitner <mleitner@redhat.com>
To: Roi Dayan <roid@mellanox.com>
Cc: netdev@vger.kernel.org, pablo@netfilter.org, davem@davemloft.net,
Jiri Pirko <jiri@mellanox.com>, Paul Blakey <paulb@mellanox.com>,
Oz Shlomo <ozsh@mellanox.com>, Alaa Hleihel <alaa@mellanox.com>
Subject: Re: [PATCH net 2/2] netfilter: flowtable: Make nf_flow_table_offload_add/del_cb inline
Date: Mon, 15 Jun 2020 11:24:34 -0300 [thread overview]
Message-ID: <20200615142434.GS47542@localhost.localdomain> (raw)
In-Reply-To: <20200614111249.6145-3-roid@mellanox.com>
On Sun, Jun 14, 2020 at 02:12:49PM +0300, Roi Dayan wrote:
> From: Alaa Hleihel <alaa@mellanox.com>
>
> Currently, nf_flow_table_offload_add/del_cb are exported by nf_flow_table
> module, therefore modules using them will have hard-dependency
> on nf_flow_table and will require loading it all the time.
>
> This can lead to an unnecessary overhead on systems that do not
> use this API.
>
> To relax the hard-dependency between the modules, we unexport these
> functions and make them static inline.
>
> Fixes: 978703f42549 ("netfilter: flowtable: Add API for registering to flow table events")
> Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
> Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> include/net/netfilter/nf_flow_table.h | 49 ++++++++++++++++++++++++++++++++---
> net/netfilter/nf_flow_table_core.c | 45 --------------------------------
> 2 files changed, 45 insertions(+), 49 deletions(-)
>
> diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h
> index c54a7f707e50..8a8f0e64edc3 100644
> --- a/include/net/netfilter/nf_flow_table.h
> +++ b/include/net/netfilter/nf_flow_table.h
> @@ -161,10 +161,51 @@ struct nf_flow_route {
> struct flow_offload *flow_offload_alloc(struct nf_conn *ct);
> void flow_offload_free(struct flow_offload *flow);
>
> -int nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
> - flow_setup_cb_t *cb, void *cb_priv);
> -void nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
> - flow_setup_cb_t *cb, void *cb_priv);
> +static inline int
> +nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
> + flow_setup_cb_t *cb, void *cb_priv)
> +{
> + struct flow_block *block = &flow_table->flow_block;
> + struct flow_block_cb *block_cb;
> + int err = 0;
> +
> + down_write(&flow_table->flow_block_lock);
> + block_cb = flow_block_cb_lookup(block, cb, cb_priv);
> + if (block_cb) {
> + err = -EEXIST;
> + goto unlock;
> + }
> +
> + block_cb = flow_block_cb_alloc(cb, cb_priv, cb_priv, NULL);
> + if (IS_ERR(block_cb)) {
> + err = PTR_ERR(block_cb);
> + goto unlock;
> + }
> +
> + list_add_tail(&block_cb->list, &block->cb_list);
> +
> +unlock:
> + up_write(&flow_table->flow_block_lock);
> + return err;
> +}
> +
> +static inline void
> +nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
> + flow_setup_cb_t *cb, void *cb_priv)
> +{
> + struct flow_block *block = &flow_table->flow_block;
> + struct flow_block_cb *block_cb;
> +
> + down_write(&flow_table->flow_block_lock);
> + block_cb = flow_block_cb_lookup(block, cb, cb_priv);
> + if (block_cb) {
> + list_del(&block_cb->list);
> + flow_block_cb_free(block_cb);
> + } else {
> + WARN_ON(true);
> + }
> + up_write(&flow_table->flow_block_lock);
> +}
>
> int flow_offload_route_init(struct flow_offload *flow,
> const struct nf_flow_route *route);
> diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
> index 42da6e337276..647680175213 100644
> --- a/net/netfilter/nf_flow_table_core.c
> +++ b/net/netfilter/nf_flow_table_core.c
> @@ -387,51 +387,6 @@ static void nf_flow_offload_work_gc(struct work_struct *work)
> queue_delayed_work(system_power_efficient_wq, &flow_table->gc_work, HZ);
> }
>
> -int nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
> - flow_setup_cb_t *cb, void *cb_priv)
> -{
> - struct flow_block *block = &flow_table->flow_block;
> - struct flow_block_cb *block_cb;
> - int err = 0;
> -
> - down_write(&flow_table->flow_block_lock);
> - block_cb = flow_block_cb_lookup(block, cb, cb_priv);
> - if (block_cb) {
> - err = -EEXIST;
> - goto unlock;
> - }
> -
> - block_cb = flow_block_cb_alloc(cb, cb_priv, cb_priv, NULL);
> - if (IS_ERR(block_cb)) {
> - err = PTR_ERR(block_cb);
> - goto unlock;
> - }
> -
> - list_add_tail(&block_cb->list, &block->cb_list);
> -
> -unlock:
> - up_write(&flow_table->flow_block_lock);
> - return err;
> -}
> -EXPORT_SYMBOL_GPL(nf_flow_table_offload_add_cb);
> -
> -void nf_flow_table_offload_del_cb(struct nf_flowtable *flow_table,
> - flow_setup_cb_t *cb, void *cb_priv)
> -{
> - struct flow_block *block = &flow_table->flow_block;
> - struct flow_block_cb *block_cb;
> -
> - down_write(&flow_table->flow_block_lock);
> - block_cb = flow_block_cb_lookup(block, cb, cb_priv);
> - if (block_cb) {
> - list_del(&block_cb->list);
> - flow_block_cb_free(block_cb);
> - } else {
> - WARN_ON(true);
> - }
> - up_write(&flow_table->flow_block_lock);
> -}
> -EXPORT_SYMBOL_GPL(nf_flow_table_offload_del_cb);
>
> static int nf_flow_nat_port_tcp(struct sk_buff *skb, unsigned int thoff,
> __be16 port, __be16 new_port)
> --
> 2.8.4
>
next prev parent reply other threads:[~2020-06-15 14:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-14 11:12 [PATCH net 0/2] remove dependency between mlx5, act_ct, nf_flow_table Roi Dayan
2020-06-14 11:12 ` [PATCH net 1/2] net/sched: act_ct: Make tcf_ct_flow_table_restore_skb inline Roi Dayan
2020-06-15 14:06 ` Marcelo Ricardo Leitner
2020-06-14 11:12 ` [PATCH net 2/2] netfilter: flowtable: Make nf_flow_table_offload_add/del_cb inline Roi Dayan
2020-06-15 14:24 ` Marcelo Ricardo Leitner [this message]
2020-06-16 1:07 ` [PATCH net 0/2] remove dependency between mlx5, act_ct, nf_flow_table David Miller
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=20200615142434.GS47542@localhost.localdomain \
--to=mleitner@redhat.com \
--cc=alaa@mellanox.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ozsh@mellanox.com \
--cc=pablo@netfilter.org \
--cc=paulb@mellanox.com \
--cc=roid@mellanox.com \
/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).