I have a question regarding overlapping elements in nft firewall sets. Let's have a set:
table ip filter {
set iponly {
type iface_index . ipv4_addr
flags interval
elements = {
eth0 . 10.1.1.100,
eth0 . 10.1.1.4/30,
eth0 . 10.1.1.0/24,
}
}
}
This works. But if I use sub-networks with the same network numbers or broadcast:
eth0 . 10.1.1.100,
eth0 . 10.1.1.0/30,
eth0 . 10.1.1.252/30,
eth0 . 10.1.1.0/24,
I get an error:
x.nft:13:21-38: Error: Could not process rule: File exists
eth0 . 10.1.1.0/24,
^^^^^^^^^^^^^^^^^^
Networks 10.1.1.0/30 and 10.1.1.0/24 have the same network number, networks 10.1.1.252/30 and 10.1.1.0/24 have the same broadcast. And I can't insert this into a set.
But if I use network "fully inside", like 10.1.1.4/30 and 10.1.1.0/24 from 1st example, this works. Also 10.1.1.100 is "fully inside" of 10.1.1.0/24 and works too.
(For the record, 10.1.1.0/32 doesn't work too but I don't want to use that ;) )
So the question is: is this intended behavior and I should live with that, or am I doing something wrong?
2nd question: About nft processing internals: Event the 1st example doesn't work if I place 10.1.1.4/30 after 10.1.1.0/24. Does it mean that comparing packets against set elements is sequential? I thought there would be some hash table for this.
Update
Kernel version: 6.18.34
nftables v1.1.6 (Commodore Bullmoose #7)