Re: [PATCH nf-next v2 2/2] netfilter: nft_hash: support of symmetric hash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>:
> [...]
> > +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.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux