Commit 347b408d authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso
Browse files

netfilter: nf_tables: pass set description to ->privsize



The new non-resizable hashtable variant needs this to calculate the
size of the bucket array.

Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 2b664957
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -351,7 +351,8 @@ struct nft_set_ops {
						struct nft_set *set,
						struct nft_set *set,
						struct nft_set_iter *iter);
						struct nft_set_iter *iter);


	unsigned int			(*privsize)(const struct nlattr * const nla[]);
	unsigned int			(*privsize)(const struct nlattr * const nla[],
						    const struct nft_set_desc *desc);
	bool				(*estimate)(const struct nft_set_desc *desc,
	bool				(*estimate)(const struct nft_set_desc *desc,
						    u32 features,
						    u32 features,
						    struct nft_set_estimate *est);
						    struct nft_set_estimate *est);
+1 −1
Original line number Original line Diff line number Diff line
@@ -3052,7 +3052,7 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,


	size = 0;
	size = 0;
	if (ops->privsize != NULL)
	if (ops->privsize != NULL)
		size = ops->privsize(nla);
		size = ops->privsize(nla, &desc);


	err = -ENOMEM;
	err = -ENOMEM;
	set = kzalloc(sizeof(*set) + size + udlen, GFP_KERNEL);
	set = kzalloc(sizeof(*set) + size + udlen, GFP_KERNEL);
+2 −1
Original line number Original line Diff line number Diff line
@@ -236,7 +236,8 @@ static inline u32 nft_bitmap_total_size(u32 klen)
	return sizeof(struct nft_bitmap) + nft_bitmap_size(klen);
	return sizeof(struct nft_bitmap) + nft_bitmap_size(klen);
}
}


static unsigned int nft_bitmap_privsize(const struct nlattr * const nla[])
static unsigned int nft_bitmap_privsize(const struct nlattr * const nla[],
					const struct nft_set_desc *desc)
{
{
	u32 klen = ntohl(nla_get_be32(nla[NFTA_SET_KEY_LEN]));
	u32 klen = ntohl(nla_get_be32(nla[NFTA_SET_KEY_LEN]));


+2 −1
Original line number Original line Diff line number Diff line
@@ -321,7 +321,8 @@ schedule:
			   nft_set_gc_interval(set));
			   nft_set_gc_interval(set));
}
}


static unsigned int nft_rhash_privsize(const struct nlattr * const nla[])
static unsigned int nft_rhash_privsize(const struct nlattr * const nla[],
				       const struct nft_set_desc *desc)
{
{
	return sizeof(struct nft_rhash);
	return sizeof(struct nft_rhash);
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -251,7 +251,8 @@ cont:
	read_unlock_bh(&priv->lock);
	read_unlock_bh(&priv->lock);
}
}


static unsigned int nft_rbtree_privsize(const struct nlattr * const nla[])
static unsigned int nft_rbtree_privsize(const struct nlattr * const nla[],
					const struct nft_set_desc *desc)
{
{
	return sizeof(struct nft_rbtree);
	return sizeof(struct nft_rbtree);
}
}