From: Laura Garcia <nevola@gmail.com>
To: Liping Zhang <zlpnobody@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v2] netfilter: nf_tables: add hash expression
Date: Wed, 10 Aug 2016 09:21:53 +0200 [thread overview]
Message-ID: <20160810072152.GA11256@sonyv> (raw)
In-Reply-To: <CAML_gOfwxzPqVRtBjQFa5aAX1wDAXPMebjwpEspXqF_Lzyh5oQ@mail.gmail.com>
On Wed, Aug 10, 2016 at 10:38:08AM +0800, Liping Zhang wrote:
> Hi Laura,
>
> 2016-08-10 2:22 GMT+08:00 Laura Garcia Liebana <nevola@gmail.com>:
> > This patch adds a new hash expression, this provides jhash support but
> > this can be extended to support for other hash functions.
> >
> > The modulus and seed already comes embedded into this new expression.
> >
> > Use case example:
> > meta mark set hash ip saddr mod 10
> >
> > +static int nft_hash_init(const struct nft_ctx *ctx,
> > + const struct nft_expr *expr,
> > + const struct nlattr * const tb[])
> > +{
> > + struct nft_hash *priv = nft_expr_priv(expr);
> > + u32 len;
> > +
> > + if (!tb[NFTA_HASH_SREG] ||
> > + !tb[NFTA_HASH_DREG] ||
> > + !tb[NFTA_HASH_LEN])
> > + return -EINVAL;
>
> I think tb[NFTA_HASH_MODULUS] and tb[NFTA_HASH_SEED] should also be
> checked is NULL or not? :)
>
tb[NFTA_HASH_MODULUS] is not optional now so we can check it here, but
tb[NFTA_HASH_SEED] is optional so we can check and if it's null, then
assign 0 to the seed value.
> > +
> > + priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]);
> > + priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
>
> Should we use nft_validate_register_load and
> nft_validate_register_store here to check the validity ?
>
Yes, I'll include that.
Thank you Liping.
prev parent reply other threads:[~2016-08-10 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-09 18:22 [PATCH v2] netfilter: nf_tables: add hash expression Laura Garcia Liebana
2016-08-10 2:38 ` Liping Zhang
2016-08-10 7:21 ` Laura Garcia [this message]
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=20160810072152.GA11256@sonyv \
--to=nevola@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=zlpnobody@gmail.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).