From: Flavio Leitner <fbl@redhat.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netdev@vger.kernel.org, Joe Stringer <joe@ovn.org>,
Pravin B Shelar <pshelar@ovn.org>,
dev@openvswitch.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/8] netfilter: add API to manage NAT helpers.
Date: Mon, 15 Apr 2019 11:04:04 -0300 [thread overview]
Message-ID: <20190415140404.GF3319@p50.lan> (raw)
In-Reply-To: <20190415054820.p2vbw7itmr7gwmq5@salvia>
On Mon, Apr 15, 2019 at 07:48:20AM +0200, Pablo Neira Ayuso wrote:
> Sorry I didn't see this in the first review.
>
> On Sat, Apr 13, 2019 at 08:17:10PM -0300, Flavio Leitner wrote:
> [...]
> > +int
> > +nf_nat_helper_try_module_get(const char *name, u16 l3num, u8 protonum)
> > +{
> > + struct nf_conntrack_helper *h;
> > + struct nf_conntrack_nat_helper *nat;
> > + char mod_name[NF_CT_HELPER_NAME_LEN];
> > + int ret = 0;
> > +
> > + rcu_read_lock();
> > + h = __nf_conntrack_helper_find(name, l3num, protonum);
> > + if (h == NULL) {
> > + rcu_read_unlock();
> > + return -EINVAL;
> > + }
> > +
> > + if (!strlen(h->nat_mod_name)) {
> > + rcu_read_unlock();
> > + return -EOPNOTSUPP;
>
> Probably check for this at registration?
I thought to have a list of all helpers in use and then use
nat_mod_name to indicate if a NAT helper is supported or not.
I will change that to list only ones with NAT helper available
as I don't have a strong preference.
> > + }
> > +
> > + nat = nf_conntrack_nat_helper_find(h->nat_mod_name);
> > + if (nat == NULL) {
> > + snprintf(mod_name, sizeof(mod_name), "%s", h->nat_mod_name);
> > + rcu_read_unlock();
> > + ret = request_module(mod_name);
> > + if (ret != 0)
> > + return ret;
>
> Not sure it is worth checking for request_module() return value, the
> code just below already is doing this.
Well, the above returns a more accurate error which helps
debugging/tracing problems. But since you said that, I checked
other cases calling request_module() and I am going to fix the
above.
> > +
> > + rcu_read_lock();
> > + nat = nf_conntrack_nat_helper_find(mod_name);
> > + if (nat == NULL) {
> > + rcu_read_unlock();
> > + return -EINVAL;
>
> ENOENT?
Makes sense.
> > + }
> > + }
> > +
> > + if (!try_module_get(nat->module))
> > + ret = -EINVAL;
>
> ENOENT?
>
> Telling this because we will at some point propagate this error value
> to userspace by when we start using this infrastructure you're working
> on. EINVAL is already very overload in netlink and we'll use it from
> there.
Sounds good, thanks for the review!
fbl
>
> > +
> > + rcu_read_unlock();
> > + return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(nf_nat_helper_try_module_get);
next prev parent reply other threads:[~2019-04-15 14:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-13 23:17 [PATCH net-next v2 0/8] openvswitch: load and reference the NAT helper Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 1/8] netfilter: use macros to create module aliases Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 2/8] netfilter: add API to manage NAT helpers Flavio Leitner
2019-04-15 5:48 ` Pablo Neira Ayuso
2019-04-15 14:04 ` Flavio Leitner [this message]
2019-04-15 5:50 ` Pablo Neira Ayuso
2019-04-15 14:05 ` Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 3/8] netfilter: nf_nat: register amanda NAT helper Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 4/8] netfilter: nf_nat: register ftp " Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 5/8] netfilter: nf_nat: register irc " Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 6/8] netfilter: nf_nat: register sip " Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 7/8] netfilter: nf_nat: register tftp " Flavio Leitner
2019-04-13 23:17 ` [PATCH net-next v2 8/8] openvswitch: load and reference the " Flavio Leitner
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=20190415140404.GF3319@p50.lan \
--to=fbl@redhat.com \
--cc=dev@openvswitch.org \
--cc=joe@ovn.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=pshelar@ovn.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).