All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mr Dash Four <mr.dash.four@googlemail.com>
To: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Netfilter Core Team <netfilter-devel@vger.kernel.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Patrick McHardy <kaber@trash.net>
Subject: Re: [PATCH v2 3/3] ipset: change 'iface' part in hash:net,iface set
Date: Wed, 11 Jul 2012 00:41:44 +0100	[thread overview]
Message-ID: <4FFCBDB8.9080101@googlemail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1207101721510.24998@blackhole.kfki.hu>

>> +	IPSET_DIM_IFACE = 7, 
>>  };
> 
> It's not a dimension, please give it some other name,
> like IPSET_IFACE_INOUT_FLAG.
A bit like you then. Unless you think that including IPSET_DUMP_LAST in the "features" enum list describes an actual feature. Point taken though, will change it to something more appropriate.

>> +struct ip_set_req_get_features {
>> +	unsigned int op;
>> +	unsigned int version;
>> +	__u8 features;
>> +	union ip_set_name_index set;
>> +};
>> +
> 
> In spite of stuffing a u8 sized value into features, please make it an
> unsigned int. We don't spare anything with __u8 here.
We do. In ip_set.h, "features" is defines as u8 (a byte), so I am not "stuffing" anything up - I just use the same type of variable. Besides, you are well-aware that I store this in info->flags, which is also __u8 (a byte). If I use unsigned int (a word), then I have to do extra jiggling to get rid of the bits I don't need. 

Not to mention, that "features" as defined above currently contains a single bit (the IFACE feature), so to me, given the potential hazards I just described, it wasn't warranting unsigned int, unless you plan on expanding the "features" variable and use the same struct above.


> 
>>  #define IP_SET_OP_VERSION	0x00000100	/* Ask kernel version */
>>  struct ip_set_req_version {
>>  	unsigned int op;
>> diff --git a/net/netfilter/ipset/ip_set_bitmap_ipmac.c b/net/netfilter/ipset/ip_set_bitmap_ipmac.c
>> index d7eaf10..1d8d754 100644
>> --- a/net/netfilter/ipset/ip_set_bitmap_ipmac.c
>> +++ b/net/netfilter/ipset/ip_set_bitmap_ipmac.c
>> @@ -348,6 +348,10 @@ bitmap_ipmac_kadt(struct ip_set *set, const struct sk_buff *skb,
>>  	ipset_adtfn adtfn = set->variant->adt[adt];
>>  	struct ipmac data;
>>  
>> +	/* in|out not allowed in this set type, only src|dst */
>> +	if (opt->flags & IPSET_DIM_IFACE_INOUT)
>> +		return -EINVAL;
>> +
> 
> Drop this unnecessary checking: ipset doesn't care about iptables syntax.
This was a left-over from v1 of the patch and served to restrict matching when 'in' or 'out' is used in a list:set, or, when 'in' or 'out' was entered in 2+ dimensional sets as I didn't have the means to see what type of set I am dealing with in iptables. 

Now that the latter is being resolved via the get_set_byname_with_features function, I would still like to keep this and relax the restriction for 'in' and 'out' on the list:set as I am yet to get a reasonable and adequate explanation as to why that should not be allowed (the use of 'in' and 'out' in list:set)?

It gives me, as a user, a choice when I have a list:set with many different set types in it to apply that restriction (checking on in/out interfaces only) and use it when needed, instead of being restricted to just src/dst and have ipset reiterate through all members of each set - unnecessarily, when in practice I would have liked a match on the iface-type sets only. 

It also forces me to use two separate list:sets with duplicate members: one for the occasion when I want to use src/dst and match against all members of the set, and another, duplicate copy, which contains just the iface sets so that I could get a match just on them. Wasteful!

If I have a choice to use in/out, in addition to src/dst, I can deploy a single set (saves on memory and scanning is faster) and use this - it is much more elegant. 

The use of in/out is not in any way restrictive as whoever deploys it, clearly has a choice (I'd argue that the use of just src/dst is more restrictive as it doesn't give me that choice). That use of in/out can't be "confusing" either as the definition of it and what it matches against is pretty clear for everyone.

Just a couple of days ago you wanted to introduce in/out direction parameters everywhere - in every set and in every direction parameter. I would argue that was more confusing and hardly appropriate, if anything.

>> +static ip_set_id_t
>> +find_set_features(const char *name, __u8 *features)
>> +{
>> +	ip_set_id_t i, index = IPSET_INVALID_ID;
>> +	const struct ip_set *set;
>> +
>> +	for (i = 0; index == IPSET_INVALID_ID && i < ip_set_max; i++) {
>> +		set = ip_set_list[i];
>> +		if (set != NULL && STREQ(set->name, name)) {
>> +			index = i;
>> +			/* In theory, we could return the entire set of features
>> +			 * for a given set, though, for now, we only return 
>> +			 * the IPSET_TYPE_IFACE bit
>> +			 */
>> +			*features = set->type->features & IPSET_TYPE_IFACE;
> 
> I believe it's better to return the entire feature, not just 
> IPSET_TYPE_IFACE.
Agreed, though with the added caveat about versioning and the use of new parse/print etc functions - see my comments on this in the other email (about the iptables patch).

>> -	if (!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC,
>> +	if ((opt->flags & IPSET_DIM_IFACE_INOUT) || /* in|out not allowed in this set type, only src|dst */
>> +		!ip_set_get_ip4_port(skb, opt->flags & IPSET_DIM_TWO_SRC,
>>  				 &data.port, &data.proto))
>>  		return -EINVAL;
> 
> Drop this and all other checkings below:
See above - I'd like to keep it and relax the restrictions placed upon the list:set.


  reply	other threads:[~2012-07-10 23:41 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-09 22:23 [PATCH v2 0/3] iptables: change 'iface' part in hash:net,iface set Mr Dash Four
2012-07-09 22:23 ` [PATCH v2 1/3] " Mr Dash Four
2012-07-10 15:54   ` Jozsef Kadlecsik
2012-07-10 23:41     ` Mr Dash Four
2012-07-12  7:11       ` Jozsef Kadlecsik
2012-07-13  0:41         ` Mr Dash Four
2012-07-13  8:11           ` Jozsef Kadlecsik
2012-07-13 13:56             ` Mr Dash Four
2012-07-09 22:23 ` [PATCH v2 2/3] ipset: " Mr Dash Four
2012-07-10 15:35   ` Jozsef Kadlecsik
2012-07-09 22:23 ` [PATCH v2 3/3] " Mr Dash Four
2012-07-10 15:32   ` Jozsef Kadlecsik
2012-07-10 23:41     ` Mr Dash Four [this message]
2012-07-11 20:25       ` Jozsef Kadlecsik
2012-07-13  0:42         ` Mr Dash Four
2012-07-13  8:02           ` Jozsef Kadlecsik
2012-07-13 13:57             ` Mr Dash Four
2012-07-13 14:16               ` Jozsef Kadlecsik
2012-07-13 14:22                 ` Mr Dash Four
2012-07-14  8:45                   ` Jozsef Kadlecsik
2012-07-14 12:35                     ` Mr Dash Four
2012-07-14 16:37                       ` Jozsef Kadlecsik
2012-07-15 11:54                         ` Mr Dash Four
2012-07-15 15:02                           ` Jozsef Kadlecsik
2012-07-15 16:32                             ` Mr Dash Four
2012-07-15 19:21                               ` Jozsef Kadlecsik
2012-07-15 19:39                                 ` Jozsef Kadlecsik
2012-07-15 22:14                                 ` Mr Dash Four
2012-07-16  8:03                                   ` Jozsef Kadlecsik
2012-07-16 12:39                                     ` Mr Dash Four
2012-07-16 13:58                                       ` Jozsef Kadlecsik
2012-07-17 23:29                                         ` Mr Dash Four
2012-07-18 12:54                                           ` Jozsef Kadlecsik
2012-07-19 22:52                                             ` Mr Dash Four
2012-07-19 22:52                                           ` Mr Dash Four
2012-07-15 22:48                                 ` Mr Dash Four

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=4FFCBDB8.9080101@googlemail.com \
    --to=mr.dash.four@googlemail.com \
    --cc=kaber@trash.net \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.