This will allow nth_field function to begin from first field, and stop
immediately when it ends, which makes function much more simple and quite
a bit quicker.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
At the other day I where wondering why so much time was spent on analysis
function, when I realized regression. At the time uthash was introduced
to the project range sorting got to be dropped, which caused same leases
to be walked in analysis time after time.
Now when the regression is removed, and the test cases run about 28% over
all quicker. The rule of thumb is that the greater the data set the
bigger is the benefit having this fix. My largest test data is now
roughly 35% faster.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Add gnulib modules which make sense and remove few. The stuff gnulib
takes care can be dropped from configure.am.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This will mean better portability, and a good reason to get rid of
various portability autotools directives which where part of this
project.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
output.c:819:17: warning: comparison of integers of different signs:
'int' and ' unsigned int' [-Wsign-compare]
for (i = 0; i < num_ranges; i++) {
~ ^ ~~~~~~~~~~
output.c:832:17: warning: comparison of integers of different signs:
'int' and ' unsigned int' [-Wsign-compare]
for (i = 0; i < num_shared_networks; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~~
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Fix to a very severe bug. In cases when IP addresses in lease file had
a range of using highest bit, e.g. signed int minus, the sort caused
high ranges to be counted first and low ranges skipped. The usual case
when this happen was when ranges contained 10.0.0.0/8 addresses
together with addresses greater than 128.0.0.0/32.
Reported-by: Ryan Malek <rmalek@osage.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The problem is, that you simply count all lease occurrences in
dhcpd.leases, but only the last ones for each ip address are
valid. The lease file is more like a logfile of what has been
done, than a real database. To fix the counting issue, I'm using
a single hash (from uthash.h [1]) for the counting. This way
only the last lease entry for each IP gets into my counting
structure.
When you remove the duplicates in prepare_data(), you don't have
the information anymore, if the active lease entry or the free
lease entry came last. Simply deleting each ip from the touches
array, that is already in the leases array, gives you a big
chance to count wrong. Another way of fixing this would be to
not only store the ips in your arrays, but a structure containing
the ip and a global lease entry counter. Then you could delete
all entries except for the latest.
[1] http://uthash.sourceforge.net/
Reported-by: Huangy
Signed-off-by: Enno Grper <groepeen@cms.hu-berlin.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
[src/getdata.c:307]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:324]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:340]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:362]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:366]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:371]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:372]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:385]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When { is wrote together with a word, such as
pool{
range 10.0.0.100 100.0.0.200;
range ..
the parser ignored first range, resulting it to disappear from analysis.
Reported-by: Robert Viou <robert.viou@ndsu.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The script is not maintained, but perhaps nice to have a
reference how the IP sorting & range matching was done in demo
version. Actually more proper version number would have been 0.x
but it was not.
Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>