Re: [PATCH RFC nf-next 07/12] netfilter: ipset: add rhashtable boilerplate stubs

Florian Westphal <[email protected]> Thu, 16 Jul 2026 15:00:09 +0200
Newsgroups gmane.comp.security.firewalls.netfilter.devel
Message-ID <[email protected]>
Jozsef Kadlecsik <[email protected]> wrote:
> > Preparation patch.  Adds an rhashtable to the set and initialised
> > and destroys it.  No elements are ever added to this hashtable.
> > 
> > This change is supposed to be devoid of side effects and is
> > separate to reduce size of the conversion patch.
> > +/* 0 = key matches object (equal), non-zero = not equal */
> > +static int mtype_rht_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
> > +{
> > +	const struct mtype_rht_elem *e = obj;
> > +	u32 multi = 0;
> > +
> > +	return !mtype_data_equal(&e->elem,
> > +				 (const struct mtype_elem *)arg->key, &multi);
> > +}
> 
> It does not belong to this patch, but the "multi" arg of mtype_data_equal()
> is needed only for the netiface type: it supports the same ip/cidr behind
> multiple interfaces but the element can store a single interface only. The
> "multi" flag made possible to take into account multiple interfaces properly
> when growing the array in the hash.

Thanks for providing context, Jozsef.

> The interfaces should be stored in a linked list at element level and the
> "multi" arg of mtype_data_equal() can be removed, which is not needed in
> rhashtable anyway.

Great, I will do this in next version.  This should make things much
simpler.