netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Liping Zhang <zlpnobody@gmail.com>
Cc: Laura Garcia Liebana <nevola@gmail.com>,
	Netfilter Developer Mailing List
	<netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nf-next v2 2/2] netfilter: nft_hash: support of symmetric hash
Date: Wed, 1 Mar 2017 12:49:37 +0100	[thread overview]
Message-ID: <20170301114937.GA8511@salvia> (raw)
In-Reply-To: <CAML_gOc8AAQ6ijDS65c1Qb6cYhBWFbEs814yDH5_27m1t6hsQw@mail.gmail.com>

On Wed, Mar 01, 2017 at 12:11:54PM +0800, Liping Zhang wrote:
> Hi,
> 
> 2017-03-01 1:38 GMT+08:00 Laura Garcia Liebana <nevola@gmail.com>:
> [...]
> > +static const struct nft_expr_ops *
> > +nft_hash_select_ops(const struct nft_ctx *ctx,
> > +                   const struct nlattr * const tb[])
> > +{
> > +       u32 type;
> > +
> > +       if (!tb[NFTA_HASH_TYPE])
> > +               return ERR_PTR(-EINVAL);
> 
> For compatibility reason, if tb[NFTA_HASH_TYPE] is NULL, maybe it's better
> to return &nft_jhash_ops instead of reporting error.

Right.

I think this function should end up looking like this:

static const struct nft_expr_ops *
nft_hash_select_ops(const struct nft_ctx *ctx,
                    const struct nlattr * const tb[])
{
       u32 type;

       if (!tb[NFTA_HASH_TYPE])
               return &nft_jhash_ops;

       type = ntohl(nla_get_be32(tb[NFTA_HASH_TYPE]));
       switch (type) {
       case NFT_HASH_SYM:
               return &nft_symhash_ops;
       case NFT_HASH_JENKINS:
               return &nft_jhash_ops;
       default:
               break;
       }
       return ERR_PTR(-EOPNOTSUPP);
}

So, this returns nft_jhash_ops if not NFTA_HASH_TYPE is set.

Then, if NFTA_HASH_TYPE is set, select the type according to what
userspace requests.

If userspace request a hash type we don't support, then bail out with
"operation not supported".

Thanks.

      reply	other threads:[~2017-03-01 12:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-28 17:38 [PATCH nf-next v2 2/2] netfilter: nft_hash: support of symmetric hash Laura Garcia Liebana
2017-03-01  4:11 ` Liping Zhang
2017-03-01 11:49   ` Pablo Neira Ayuso [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=20170301114937.GA8511@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=nevola@gmail.com \
    --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).