From: Michael Tremer Date: Wed, 2 Mar 2022 10:18:16 +0000 (+0000) Subject: ipset: Set maxelem to a fixed size X-Git-Tag: 0.9.11~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52176cc7d5da625fcc3141afdcc2281b87fa5cb9;p=location%2Flibloc.git ipset: Set maxelem to a fixed size When we try to load a changed set which might have more entries, a previous maxelem could have been smaller preventing us from adding new entries. We also cannot run the "create" command with a changed maxelem parameter which is why this patch set the value to something that should be large enough for everything. The downside of this is also, that we cannot modify the hashsize when we reload a set, which is probably okay, since sets should not change too much in size and therefore will only run *slightly* less efficient - if at all. Signed-off-by: Michael Tremer --- diff --git a/src/python/export.py b/src/python/export.py index 10cf2b7..10f84f4 100644 --- a/src/python/export.py +++ b/src/python/export.py @@ -131,22 +131,13 @@ class IpsetOutputWriter(OutputWriter): # Return the size of the hash return 2 ** math.ceil(exponent) - @property - def maxelem(self): - """ - Tells ipset how large the set will be. - - Since these are considered immutable, we will use the total number of networks. - """ - return self.networks - def _write_header(self): # This must have a fixed size, because we will write the header again in the end self.f.write("create %s hash:net family inet%s" % ( self.prefix, "6" if self.family == socket.AF_INET6 else "" )) - self.f.write(" hashsize %8d maxelem %8d -exist\n" % (self.hashsize, self.maxelem)) + self.f.write(" hashsize %8d maxelem 1048576 -exist\n" % self.hashsize) self.f.write("flush %s\n" % self.prefix) def write(self, network):