Re: [PATCH v2] Add hash:net,net ipset for storage of v4/v6 CIDR pairs.

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

 



On Tue, 3 Sep 2013, Oliver wrote:

> > > +static inline void
> > > +hash_netnet4_data_reset_elem(struct hash_netnet4_elem *elem, struct
> > > hash_netnet4_elem *orig) +{
> > > +	elem->ip2 = orig->ip2;
> > > +}
> > 
> > Shouldn't elem->cidr2 be reset to the original value too?
> 
> No, that's not necessary since cidr2 is never overwritten. The reason 
> this function was added is because when we iterate over ip2, it is 
> successively ANDed in-place with each CIDR we test, which means that the 
> address bits are destroyed. Once we do a new iteration of ip1, we have 
> to first restore ip2, the cidr values don't get touched so they're fine.

mtype_data_reset_elem is called to undo what mtype_data_netmask did. And 
that sets cidr2 too.

A tiny optimization in mtype_test_cidrs is to split up mtype_data_netmask 
into two functions, so that ip/cidr is set in the first loop and ip2/cidr2 
in the second loop. Currently ip/cidr is unnecessarily set in the second 
loop again and again.
 
Best regards,
Jozsef
-
E-mail  : kadlec@xxxxxxxxxxxxxxxxx, kadlecsik.jozsef@xxxxxxxxxxxxx
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
          H-1525 Budapest 114, POB. 49, Hungary
--
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