From: Florian Westphal <fw@strlen.de>
To: Joe Stringer <joestringer@nicira.com>
Cc: pablo@netfilter.org, fw@strlen.de, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next] netfilter: connlabels: Export setting connlabel length
Date: Sat, 1 Aug 2015 02:40:34 +0200 [thread overview]
Message-ID: <20150801004034.GC20471@breakpoint.cc> (raw)
In-Reply-To: <1438386624-52057-1-git-send-email-joestringer@nicira.com>
Joe Stringer <joestringer@nicira.com> wrote:
> diff --git a/net/netfilter/nf_conntrack_labels.c b/net/netfilter/nf_conntrack_labels.c
> index bb53f12..00df4e71 100644
> --- a/net/netfilter/nf_conntrack_labels.c
> +++ b/net/netfilter/nf_conntrack_labels.c
> @@ -91,6 +91,30 @@ int nf_connlabels_replace(struct nf_conn *ct,
> EXPORT_SYMBOL_GPL(nf_connlabels_replace);
> #endif
>
> +int nf_connlabels_get(struct net *net, unsigned int n_bits)
> +{
> + size_t words;
> +
> + if (n_bits > XT_CONNLABEL_MAXBIT + 1)
Perhaps use
if (n_bits >= (NF_CT_LABELS_MAX_SIZE * BITS_PER_BYTE)))
To avoid the XT_CONNLABEL_MAXBIT in the nf_* part.
> + return -ERANGE;
> +
> + net->ct.labels_used++;
> + words = BITS_TO_LONGS(n_bits);
> + if (words > net->ct.label_words)
> + net->ct.label_words = words;
> +
> + return 0;
> +}
I think we should add a lock here, currently this is protected by the
xtables mutex -- I'd suggest to just add a spinlock for this.
> return ret;
> }
>
> - par->net->ct.labels_used++;
> - words = BITS_TO_LONGS(info->bit+1);
> - if (words > par->net->ct.label_words)
> - par->net->ct.label_words = words;
> -
> - return ret;
> + return nf_connlabels_get(par->net, info->bit + 1);
This can leak the refcnt on l3_proto_module we obtained earlier.
Other than that, this looks good.
Thanks,
Florian
next prev parent reply other threads:[~2015-08-01 0:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 23:50 [PATCH nf-next] netfilter: connlabels: Export setting connlabel length Joe Stringer
2015-08-01 0:40 ` Florian Westphal [this message]
2015-08-03 17:58 ` Joe Stringer
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=20150801004034.GC20471@breakpoint.cc \
--to=fw@strlen.de \
--cc=joestringer@nicira.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.