Skip to content

Commit 886503f

Browse files
Eric Westbrookummakynes
authored andcommitted
netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net
Allow /0 as advertised for hash:net,port,net sets. For "hash:net,port,net", ipset(8) says that "either subnet is permitted to be a /0 should you wish to match port between all destinations." Make that statement true. Before: # ipset create cidrzero hash:net,port,net # ipset add cidrzero 0.0.0.0/0,12345,0.0.0.0/0 ipset v6.34: The value of the CIDR parameter of the IP address is invalid # ipset create cidrzero6 hash:net,port,net family inet6 # ipset add cidrzero6 ::/0,12345,::/0 ipset v6.34: The value of the CIDR parameter of the IP address is invalid After: # ipset create cidrzero hash:net,port,net # ipset add cidrzero 0.0.0.0/0,12345,0.0.0.0/0 # ipset test cidrzero 192.168.205.129,12345,172.16.205.129 192.168.205.129,tcp:12345,172.16.205.129 is in set cidrzero. # ipset create cidrzero6 hash:net,port,net family inet6 # ipset add cidrzero6 ::/0,12345,::/0 # ipset test cidrzero6 fe80::1,12345,ff00::1 fe80::1,tcp:12345,ff00::1 is in set cidrzero6. See also: https://bugzilla.kernel.org/show_bug.cgi?id=200897 ewestbrook/linux@df7ff6e Signed-off-by: Eric Westbrook <[email protected]> Signed-off-by: Jozsef Kadlecsik <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 439cd39 commit 886503f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/netfilter/ipset/ip_set_hash_netportnet.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
213213

214214
if (tb[IPSET_ATTR_CIDR]) {
215215
e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
216-
if (!e.cidr[0] || e.cidr[0] > HOST_MASK)
216+
if (e.cidr[0] > HOST_MASK)
217217
return -IPSET_ERR_INVALID_CIDR;
218218
}
219219

220220
if (tb[IPSET_ATTR_CIDR2]) {
221221
e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
222-
if (!e.cidr[1] || e.cidr[1] > HOST_MASK)
222+
if (e.cidr[1] > HOST_MASK)
223223
return -IPSET_ERR_INVALID_CIDR;
224224
}
225225

@@ -493,13 +493,13 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
493493

494494
if (tb[IPSET_ATTR_CIDR]) {
495495
e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
496-
if (!e.cidr[0] || e.cidr[0] > HOST_MASK)
496+
if (e.cidr[0] > HOST_MASK)
497497
return -IPSET_ERR_INVALID_CIDR;
498498
}
499499

500500
if (tb[IPSET_ATTR_CIDR2]) {
501501
e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
502-
if (!e.cidr[1] || e.cidr[1] > HOST_MASK)
502+
if (e.cidr[1] > HOST_MASK)
503503
return -IPSET_ERR_INVALID_CIDR;
504504
}
505505

0 commit comments

Comments
 (0)