Skip to contentSkip to conversation

ipset: allow a 0 netmask with hash_netiface type

PATCH Applied Florian Westphal 3 participants 7 messages Jan 12, 2016 – Jan 13, 2016

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 ipset: allow a 0 netmask with hash_netiface type

Jozsef says:
The correct behaviour is that if we have ipset create test1 hash:net,iface
ipset add test1 0.0.0.0/0,eth0
iptables -A INPUT -m set --match-set test1 src,src

then the rule should match for any traffic coming in through eth0.

This removes the -EINVAL runtime test to make matching work in case packet arrived via the specified interface.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1297092

---

net/netfilter/ipset/ip_set_hash_netiface.c +0 -4
index 43d8c98..f0f688d 100644
@@ -164,8 +164,6 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb,
 	};
 	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
 
-	if (e.cidr == 0)
-		return -EINVAL;
 	if (adt == IPSET_TEST)
 		e.cidr = HOST_MASK;
 
@@ -377,8 +375,6 @@ hash_netiface6_kadt(struct ip_set *set, const struct sk_buff *skb,
 	};
 	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
 
-	if (e.cidr == 0)
-		return -EINVAL;
 	if (adt == IPSET_TEST)
 		e.cidr = HOST_MASK;
 
Signature · 1 line
2.4.10
#1 lore raw

Hi Florian,

Quoted 10 lines · Florian Westphal

Jozsef says:
The correct behaviour is that if we have ipset create test1 hash:net,iface
ipset add test1 0.0.0.0/0,eth0
iptables -A INPUT -m set --match-set test1 src,src

then the rule should match for any traffic coming in through eth0.

This removes the -EINVAL runtime test to make matching work in case packet arrived via the specified interface.

No, the patch actually would break the set type. In order to support /0 prefixes, cidr + 1 is stored internally. Zero value means "empty slot/bucket".

Quoted 3 lines

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1297092

From the bugreport we neither know the kernel version nor the exact

iptables command. It might be that the rule is added to a chain from where the input interface is not available.

Best regards,
Jozsef

Quoted 32 lines

---

net/netfilter/ipset/ip_set_hash_netiface.c +0 -4
index 43d8c98..f0f688d 100644
@@ -164,8 +164,6 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb,
 	};
 	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
 
-	if (e.cidr == 0)
-		return -EINVAL;
 	if (adt == IPSET_TEST)
 		e.cidr = HOST_MASK;
 
@@ -377,8 +375,6 @@ hash_netiface6_kadt(struct ip_set *set, const struct sk_buff *skb,
 	};
 	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
 
-	if (e.cidr == 0)
-		return -EINVAL;
 	if (adt == IPSET_TEST)
 		e.cidr = HOST_MASK;
 
Signature · 6 lines
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

-
E-mail : [email protected], [email protected] 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
author maintainer
#2 lore raw
Quoted 10 lines · Jozsef Kadlecsik

Hi Florian,

Quoted 6 lines · Florian Westphal

Jozsef says:
The correct behaviour is that if we have ipset create test1 hash:net,iface
ipset add test1 0.0.0.0/0,eth0
iptables -A INPUT -m set --match-set test1 src,src

Quoted 8 lines
Quoted 4 lines

then the rule should match for any traffic coming in through eth0.

This removes the -EINVAL runtime test to make matching work in case packet arrived via the specified interface.

No, the patch actually would break the set type. In order to support /0 prefixes, cidr + 1 is stored internally. Zero value means "empty slot/bucket".

Hmm, but matching is broken currently, the rule quoted above never matches. And its exaclty because of if (e.cidr == 0) is true.

Tested with nf-next tree.
Before patch: never matches
After patch: matches for all packets from eth0

#3 lore raw
Quoted 19 lines · Florian Westphal
Quoted 9 lines · Jozsef Kadlecsik
Quoted 6 lines · Florian Westphal

Jozsef says:
The correct behaviour is that if we have ipset create test1 hash:net,iface
ipset add test1 0.0.0.0/0,eth0
iptables -A INPUT -m set --match-set test1 src,src

Quoted 8 lines
Quoted 4 lines

then the rule should match for any traffic coming in through eth0.

This removes the -EINVAL runtime test to make matching work in case packet arrived via the specified interface.

No, the patch actually would break the set type. In order to support /0 prefixes, cidr + 1 is stored internally. Zero value means "empty slot/bucket".

Quoted 6 lines

Hmm, but matching is broken currently, the rule quoted above never matches. And its exaclty because of if (e.cidr == 0) is true.

Tested with nf-next tree.
Before patch: never matches
After patch: matches for all packets from eth0

I'll look into it, then something just resurfaces this way.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] 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
#4 lore raw
In reply to Florian Westphal
Quoted 19 lines · Florian Westphal
Quoted 9 lines · Jozsef Kadlecsik
Quoted 6 lines · Florian Westphal

Jozsef says:
The correct behaviour is that if we have ipset create test1 hash:net,iface
ipset add test1 0.0.0.0/0,eth0
iptables -A INPUT -m set --match-set test1 src,src

Quoted 8 lines
Quoted 4 lines

then the rule should match for any traffic coming in through eth0.

This removes the -EINVAL runtime test to make matching work in case packet arrived via the specified interface.

No, the patch actually would break the set type. In order to support /0 prefixes, cidr + 1 is stored internally. Zero value means "empty slot/bucket".

Quoted 6 lines

Hmm, but matching is broken currently, the rule quoted above never matches. And its exaclty because of if (e.cidr == 0) is true.

Tested with nf-next tree.
Before patch: never matches
After patch: matches for all packets from eth0

I was wrong and the patch is correct, the removed condition is just unnecessary and breaks to match /0. I have already applied the patch in the ipset tree and added a new test to verify the case. Thanks, Florian!

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] 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
Acked-by on v1 1/1
#5 lore raw
In reply to Florian Westphal

Hi Pablo,

Please apply the patch to the nf tree, thanks!

Quoted 6 lines · Florian Westphal

Jozsef says:
The correct behaviour is that if we have ipset create test1 hash:net,iface
ipset add test1 0.0.0.0/0,eth0
iptables -A INPUT -m set --match-set test1 src,src

Quoted 7 lines

then the rule should match for any traffic coming in through eth0.

This removes the -EINVAL runtime test to make matching work in case packet arrived via the specified interface.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1297092

Best regards,
Jozsef

Quoted 31 lines

---

net/netfilter/ipset/ip_set_hash_netiface.c +0 -4
index 43d8c98..f0f688d 100644
@@ -164,8 +164,6 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb,
 	};
 	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
 
-	if (e.cidr == 0)
-		return -EINVAL;
 	if (adt == IPSET_TEST)
 		e.cidr = HOST_MASK;
 
@@ -377,8 +375,6 @@ hash_netiface6_kadt(struct ip_set *set, const struct sk_buff *skb,
 	};
 	struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
 
-	if (e.cidr == 0)
-		return -EINVAL;
 	if (adt == IPSET_TEST)
 		e.cidr = HOST_MASK;
 
Signature · 6 lines
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

-
E-mail : [email protected], [email protected] 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
maintainer Applied
#6 lore raw
Quoted 14 lines · Jozsef Kadlecsik

Hi Pablo,

Please apply the patch to the nf tree, thanks!

Quoted 8 lines · Florian Westphal

Jozsef says:
The correct behaviour is that if we have ipset create test1 hash:net,iface
ipset add test1 0.0.0.0/0,eth0
iptables -A INPUT -m set --match-set test1 src,src

then the rule should match for any traffic coming in through eth0.

Quoted 7 lines
Quoted 5 lines

This removes the -EINVAL runtime test to make matching work in case packet arrived via the specified interface.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1297092

Applied, thanks!

This applies cleanly to 4.3 and 4.4, so will be requesting -stable for these two.