]>
git.ipfire.org Git - people/ms/libloc.git/log
Michael Tremer [Tue, 23 Aug 2022 09:56:49 +0000 (09:56 +0000)]
database: Refactor checking magic
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 23 Aug 2022 09:50:27 +0000 (09:50 +0000)]
database: Break opening procedure into smaller parts
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 23 Aug 2022 09:46:33 +0000 (09:46 +0000)]
database: Refactor error handling on create
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 23 Aug 2022 09:40:34 +0000 (09:40 +0000)]
tests: database: Expand test coverage
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 23 Aug 2022 09:40:21 +0000 (09:40 +0000)]
python: Export DatabaseEnumerator type
This is useful for tests
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 23 Aug 2022 09:35:54 +0000 (09:35 +0000)]
database: country: Return better error codes
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 17:42:59 +0000 (17:42 +0000)]
stringpool: Drop function to find next offset
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 17:32:43 +0000 (17:32 +0000)]
tests: Add some simple database tests
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 17:28:30 +0000 (17:28 +0000)]
database: Fall back when mmap() isn't available
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 17:26:26 +0000 (17:26 +0000)]
stringpool: Implement mmap as optional
This patch will allow mmap() to fail and will make the reader
fall back to read from the given file descriptor.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 17:07:41 +0000 (17:07 +0000)]
python: Fix errors for Database.lookup()
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 14:06:53 +0000 (14:06 +0000)]
database: Improve error reporting when the magic cannot be read
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 13:45:44 +0000 (13:45 +0000)]
python: Correctly raise any errors when opening the database
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 10:37:29 +0000 (10:37 +0000)]
database: Increase page size to 64k
Since libloc is currently only using mmap() to map any databases into
memory, all mapped address range needs to be page aligned.
In the past, every database was aligned to a 4k page boundary. Some
architectures use 64k pages by default which could therefore not open
the database.
This patch changes the alignment to 64k which should hopefully be a
good common denominator. However, older database cannot be opened.
If we would ever have to support an architecture which's page size
is not evenly fitting into 64k, we will have to implement an
alternative to mmap.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 10:21:55 +0000 (10:21 +0000)]
database: Log any errors when mmap() fails
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 22 Aug 2022 10:20:08 +0000 (10:20 +0000)]
database: Do not try to unmap failed mappings
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 16 Aug 2022 10:58:53 +0000 (10:58 +0000)]
database: Use MAP_PRIVATE with mmap()
We do not have any changes that need to be propagated down to the file.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 16 Aug 2022 10:35:15 +0000 (10:35 +0000)]
writer: Check if stringpool has been initialized before free
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 16 Aug 2022 10:31:14 +0000 (10:31 +0000)]
configure: Replace obsolete AC_PROG_CC_STDC macro
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 16 Aug 2022 10:30:56 +0000 (10:30 +0000)]
Check return value of fread() when reading header
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 16 Aug 2022 09:20:44 +0000 (09:20 +0000)]
cron: Add a cronjob if systemd is not available
This will allow us to build this package when systemd is not available
(e.g. on Debian kfreebsd/hurd).
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 15 Aug 2022 18:42:45 +0000 (18:42 +0000)]
*_unref: Always expect a valid pointer
Those functions have been very inconsistent in that way that some
happily accepted a NULL pointer and others didn't.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 15 Aug 2022 18:38:02 +0000 (18:38 +0000)]
country: Refactor storing country code and continent code
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 15 Aug 2022 18:12:10 +0000 (18:12 +0000)]
Don't abuse errno as return code
errno is not either set properly, or left set properly by any function
that we have called.
Return codes should either be zero or non-zero for functions unless they
are some value.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 15 Aug 2022 17:45:12 +0000 (17:45 +0000)]
Replace strerror(errno) with %m in format string throughout
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Peter Müller [Sun, 14 Aug 2022 16:02:55 +0000 (16:02 +0000)]
location-importer.in: Fix dangling variable
This fixes:
Traceback (most recent call last):
File "/usr/bin/location-importer", line 1607, in <module>
main()
File "/usr/bin/location-importer", line 1605, in main
c.run()
File "/usr/bin/location-importer", line 140, in run
ret = args.func(args)
File "/usr/bin/location-importer", line 1234, in handle_update_overrides
self._update_overrides_for_spamhaus_drop()
File "/usr/bin/location-importer", line 1504, in _update_overrides_for_spamhaus_drop
for sline in t.readlines():
NameError: name 't' is not defined
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Sun, 14 Aug 2022 12:26:12 +0000 (12:26 +0000)]
configure: Bump release to 0.9.14
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Sun, 14 Aug 2022 12:23:30 +0000 (12:23 +0000)]
Makefile: Pack all debian files into the tarball
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 15:49:13 +0000 (15:49 +0000)]
importer: Import all sources in alphabetical order
To generate deterministic results
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 15:47:29 +0000 (15:47 +0000)]
importer: Tolerate that data might exist from other RIRs
Since we are breaking the import into smaller chunks now, it might be
that some data already exists in the database. This is now being
ignored and data won't be replaced.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 15:47:20 +0000 (15:47 +0000)]
python: Fix missing bracket
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 15:39:37 +0000 (15:39 +0000)]
importer: Import each source individually
When importing source data fails for one source, we won't import
anything at all.
This patch changes that behaviour so that we will import all data one
after the other but continue if there was a problem with one source.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 15:38:08 +0000 (15:38 +0000)]
importer: Try to make parsing blocks faster
This patch changes the order of some operations and drops a few
redundant ones (potentiall).
That should allow us to parse blocked data faster.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 15:37:32 +0000 (15:37 +0000)]
python: database: Return None if no description/vendor/license set
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 13:56:17 +0000 (13:56 +0000)]
importer: Move importing extended sources/ARIN into transaction
All imports should have been conducted in one large transaction so that
we can remove any previous data.
This was not the case because of an indentation issue and could have
caused that the transaction was commited without all data being
successfully re-imported.
Fixes: #12852
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 13:51:20 +0000 (13:51 +0000)]
importer: Change download behaviour
The downloader used to open a connection to the web server hosting our
content which would have been decompressed (if necessary) on the fly and
also been parsed on the fly so that it could have been fed into the
database easily.
Some webservers do not seem to be patient enough to keep the connection
open if things take a little bit longer than usual. That caused the
import to fail.
This patch changes the behaviour that we would download all content
first, store it locally, and then start processing it.
Fixes: #12852
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Cc: Peter Müller <peter.mueller@ipfire.org>
Michael Tremer [Fri, 12 Aug 2022 13:47:08 +0000 (13:47 +0000)]
importer: Actually perform the Spamhaus sanity check
The check block was indented incorrectly and would have never been
executed.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Jochen Sprickerhof [Fri, 8 Jul 2022 12:01:51 +0000 (14:01 +0200)]
Use buster_backport for new debhelper
Jochen Sprickerhof [Fri, 8 Jul 2022 11:47:39 +0000 (13:47 +0200)]
Improvements from Debian packaging
Jochen Sprickerhof [Wed, 6 Jul 2022 08:40:42 +0000 (10:40 +0200)]
Merge location-importer into location package
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Jochen Sprickerhof [Tue, 5 Jul 2022 21:30:29 +0000 (23:30 +0200)]
Rename Python package to python3-location
To comply with the Debian Python policy. Also add a transitional package
with the old name.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Peter Müller [Sun, 5 Jun 2022 09:25:45 +0000 (09:25 +0000)]
location-importer: AS names starting with "DNIC" actually are valid
These are all assigned to the US Department of Defense.
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Peter Müller [Sun, 5 Jun 2022 10:04:50 +0000 (10:04 +0000)]
location-importer: Only delete override data if we are sure to have a valid replacement
The current way of truncating all override data straight away leaves us
with no data at all, should a source turn out to be unreachable or
returning bogus files (yes, Cloudflare, I _am_ looking at you).
It is therefore better to only delete data we know to have a valid
replacement for, rather than just dropping the source altogether.
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Thu, 23 Jun 2022 13:04:59 +0000 (13:04 +0000)]
export: Don't fail when output stream isn't seekable
For the ipset format, we will rewrite the header after we know the total
number of entries that have been written in order to optimise the hash
table.
When the output stream isn't seekable, we cannot write the header again
which is being fixed in this patch.
Fixes: #12885
Reported-by: Jon Murphy <jon.murphy@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Thu, 23 Jun 2022 12:59:47 +0000 (12:59 +0000)]
verify: Show message on success
Fixes: #12887
Reported-by: Jon Murphy <jon.murphy@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Thu, 14 Apr 2022 20:45:23 +0000 (20:45 +0000)]
export: Drop using functools
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Thu, 14 Apr 2022 20:44:29 +0000 (20:44 +0000)]
downloader: Fetch __version__ from C module
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Thu, 14 Apr 2022 18:31:56 +0000 (18:31 +0000)]
Make sources around that we can run tests without location installed
In order to run the test suite, we need to make the Python module
loadable from the build directory so that we first of all test the right
code and that it just works without running "make install" first.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Thu, 14 Apr 2022 17:11:49 +0000 (17:11 +0000)]
Revert "configure: Require Python >= 3.9"
This reverts commit
643b8d062ac11efef6c74cf8af7281079e2533e9 .
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 12 Apr 2022 12:16:20 +0000 (12:16 +0000)]
configure: Bump version to 0.9.13
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 12 Apr 2022 12:26:02 +0000 (12:26 +0000)]
tests: Import test database
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Tue, 12 Apr 2022 12:25:40 +0000 (12:25 +0000)]
.gitignore: Ignore *.db files only in main directory
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 11 Apr 2022 17:57:22 +0000 (17:57 +0000)]
export: Enable flattening for everything
When performing checks, it is useful to be able to rely on a flat
network plan so that any larger parent networks in some countries/ASes
won't match any subnets.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 15:48:44 +0000 (15:48 +0000)]
configure: Require Python >= 3.9
We are using a couple of newer Python features which are only available
from 3.9 onwards.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 15:48:19 +0000 (15:48 +0000)]
tests: List Python test cases as scripts
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 15:29:49 +0000 (15:29 +0000)]
tests: Break after exporting 1000 networks
Otherwise this test runs for forever
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 15:19:10 +0000 (15:19 +0000)]
network: loc_network_subnets: Use correct prefix
The prefix is being stored as a total number of bits now since it is
easier for any bitwise maths later. This is however causing an incorrect
prefix being computed when splitting a network into two subnets for
IPv4.
To get the correct prefix, loc_network_prefix must be called.
Introduced in
1fd09d0b09756649968fec42c737c88b92e4f11f
Reported-by: Valter Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 15:18:35 +0000 (15:18 +0000)]
network: Add more debugging output when running exclude
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 15:15:00 +0000 (15:15 +0000)]
network: Log a more useful message on invalid prefix
If loc_network_subnets is being called with some invalid input, we just
fail without logging a useful message or setting errno accordingly.
This is being changed with this patch.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 14:58:36 +0000 (14:58 +0000)]
database: Allocate subnets list only once
This is a performance improvement when exporting networks flattened. For
the subnet search, we allocate an empty list many times which is often
not required.
This patch changes this behaviour that (if needed) the lists will be
allocated and will stay around and cleared if necessary.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 30 Mar 2022 14:57:13 +0000 (14:57 +0000)]
tests: Add a simple test that lists all networks
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 23 Mar 2022 20:13:06 +0000 (20:13 +0000)]
Bump version to 0.9.12
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 13:55:48 +0000 (13:55 +0000)]
address: Set default prefix if none is given
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 11:42:47 +0000 (11:42 +0000)]
Refactor parsing IP addresses
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 11:09:25 +0000 (11:09 +0000)]
writer: I forgot to initalize the country list
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 10:29:11 +0000 (10:29 +0000)]
importer: Improve performance of network export query
This patch moves the subqueries out of the large query, so that the
database will materialize them for faster lookup.
We also drop the "UNION ALL" and replace it with just "UNION" because we
do not want any duplicate networks. That will save us many iterations
later on.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 10:26:41 +0000 (10:26 +0000)]
writer: Use country list internally
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 10:19:10 +0000 (10:19 +0000)]
country-list: Grow like AS list
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 10:17:55 +0000 (10:17 +0000)]
network-list: Grow just like the AS list
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 10:17:26 +0000 (10:17 +0000)]
writer: Use AS list internally
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Wed, 9 Mar 2022 10:15:49 +0000 (10:15 +0000)]
as-list: Grow faster to avoid too many re-allocations
When we add a large number of ASes to the list, we will constantly
re-allocate the whole list because we are only growing it by 64 entries
at a time.
This patch changes that we will double the list in size every time we
run out of space and we will start with 1024 elements.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 16:26:16 +0000 (16:26 +0000)]
bogons: Skip any subnets of former networks
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 16:05:45 +0000 (16:05 +0000)]
bogons: Add gaps that are only one address wide
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 16:05:28 +0000 (16:05 +0000)]
address: Add some simple tests
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 16:01:21 +0000 (16:01 +0000)]
address: Fix buffer overwrite
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 16:00:49 +0000 (16:00 +0000)]
address: Fix decrementing IP addresses
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 15:23:34 +0000 (15:23 +0000)]
address: Simplify functions
This patch improves looping through the octets of an IP address and
avoids that we will read anything that isn't for us.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 14:48:33 +0000 (14:48 +0000)]
network-list: Remove debugging line
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 14:48:12 +0000 (14:48 +0000)]
network-list: summarize: Break when we exhausted the network range
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 14:47:44 +0000 (14:47 +0000)]
network-list: Simplify debugging output on summarize
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 14:47:12 +0000 (14:47 +0000)]
address: Prevent under/overflow when incrementing/decrementing
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 13:22:15 +0000 (13:22 +0000)]
address: Initialize all bits of IP addresses
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 13:21:29 +0000 (13:21 +0000)]
strings: Statically allocate all address/network strings
This helps us to write less code and spend less time allocating and
freeing memory.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 12:22:14 +0000 (12:22 +0000)]
network: Pass prefix in native length
When creating an IPv4 subnet, the prefix had to be mapped to the mapped
syntax (i.e. add 96). This doesn't seem too intuitive to me.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 12:02:06 +0000 (12:02 +0000)]
address: Rename increment/decrement functions and modify address in place
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:55:59 +0000 (11:55 +0000)]
addresses: Use loc_address_family which is now available
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:54:26 +0000 (11:54 +0000)]
address: Rename in6_addr_get_bit/in6_addr_set_bit to loc_address_*
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:51:17 +0000 (11:51 +0000)]
address: Rename in6_addr_cmp into loc_address_cmp
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:49:21 +0000 (11:49 +0000)]
Move all address convenience functions into their own header
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:33:53 +0000 (11:33 +0000)]
bogons: Don't consider a network legitimate without a country code
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:30:01 +0000 (11:30 +0000)]
bogons: Reset after we have reached the end
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:27:31 +0000 (11:27 +0000)]
address: Correctly subtract IPv4 addresses
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:27:11 +0000 (11:27 +0000)]
network-list: Cap prefix length based on family
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:12:17 +0000 (11:12 +0000)]
bogons: Refactor algorithms
This changes that we won't compare one network with the previous one,
but instead we will look for gaps starting from the first possible to
the last possible IP address.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 11:07:55 +0000 (11:07 +0000)]
addresses: Implement subtraction for IPv4
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Mon, 7 Mar 2022 10:01:23 +0000 (10:01 +0000)]
network: Implement bit length function for IPv4
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Sun, 6 Mar 2022 15:08:47 +0000 (15:08 +0000)]
network: Allow creating any valid networks
Formerly, we did not allow creating special networks like ::1/128, ::/0,
127.0.0.0/8, and so on.
In order to represent all bogons, we will have to allow this.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Sun, 6 Mar 2022 15:06:17 +0000 (15:06 +0000)]
network-list: Rewrite summarize algorithm
The former algorithm did a lot of trial and error which is slow and
probably returned wrong results.
This one determines the correct prefix size quickly.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Sun, 6 Mar 2022 15:05:17 +0000 (15:05 +0000)]
network: Drop functions moved in an earlier commit
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Michael Tremer [Sun, 6 Mar 2022 14:28:26 +0000 (14:28 +0000)]
network: Add function that counts the bit length of an addres
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>