Commit graph

35 commits

Author SHA1 Message Date
Sami Kerola
d25e7afa1c
analyze: bug fix shared networks counts
This also fixes backup state counts that were added to shared networks
twice, making the numbers to be much greater than they really where.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-12 15:12:16 +00:00
Sami Kerola
1875a13733
all files: replace global variables with runtime config state structure
Earlier variables magically appeared to scope of functions that took void as
argument.  One could figure out perhaps they were globals, but programs that
do that are unnessarily hard to follow.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-12 15:12:15 +00:00
Sami Kerola
1b35a16d95
analyze: use while() when for() is less fit to purpose
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-03 14:00:00 +01:00
Sami Kerola
4aff49ed80
correct return value FIXME items
Not all markups were quite right.  The output_* functions must return an
int.  The rest were as a matter of fact correct.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-28 21:03:38 +00:00
Sami Kerola
cfbd69c20b maint: remove unnecessary braces, spaces, update gnulib .gitignore
Improve code readability, and small maintenance.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-15 09:44:28 +00:00
Sami Kerola
e09f655a7b add appropriate sorting function for struct leases_t
The HASH_SORT in analyze needs this.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-08-09 19:28:23 +01:00
Sami Kerola
4392a5b917 reindent all files
And update the indent.pro to match with the style I like.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-20 18:05:00 +01:00
Sami Kerola
5189333c95 analyze: remove unnecessary function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-17 22:58:53 +01:00
Sami Kerola
51143b6b3c clean up: fix few indentation slips
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 23:28:58 +00:00
Sami Kerola
3471c91796 docs: add doxygen tags, configuration file, and autotooling
When ./configure --enable-doxygen is used one can browse internal api
documentation from docs/html directory.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 21:06:32 +00:00
Cheer Xiao
a57d399643 IPv6: add DHCPv6 support
The DHCP version is determined according to the first IP address that
appears in the configuration file.  Caveat; counters are of native long
type.  Since IPv6 address space has 2^128 addresses, they are subject to
overflow.

[Sami Kerola:  This commit also fixed a percent sorting bug, which has
been broken always.  See changes ret_percent() for the fix.]

CC: LI Zimu <lzm@cernet.edu.cn>
CC: Xing Li <xing@cernet.edu.cn>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Cheer Xiao <xiaqqaix@gmail.com>
2012-12-02 20:35:54 +00:00
Sami Kerola
6684772550 tools: add indent command configuration file
And reindent all files.

Reference: http://www.gnu.org/software/indent/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-28 19:57:19 +00:00
Sami Kerola
822ca33804 getdata & analyze: fix first_ip and last_ip arithmetics
There were too clever tricks done with first and last.  Earlier the aim
was to minimize '<=' and '>=' by fiddling with the numbers at the time
when they were saved.  While the program logic seemed to work there were
some off by one mistakes, resulting to a count error.  Even worse there
is not even that many of such comparisons, so that one cannot really even
justify added complexity.  I really hope this patch is last this kind fix
ever needed.

Reported-by: Cheer Xiao <xiaqqaix@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-21 21:50:09 +00:00
Cheer Xiao
88d989bbe2 Fix spelling mistakes. 2012-11-20 20:53:30 +00:00
Sami Kerola
6f4104acbc analyze: use gnulib
The gnulib is grippled without config.h in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-10 00:09:43 +00:00
Sami Kerola
5f59daa692 analyze, getdata: write functions in frequency order
According to test data free is seen most often in leases file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-09 22:20:04 +00:00
Sami Kerola
18f2835fd5 analyze: sort ranges before analysis
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>
2012-11-08 22:02:02 +00:00
Sami Kerola
7a86746710 analyze: use simpler comparison
In some cases the this can make run time to take 2.5% less time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-07 21:42:18 +00:00
Sami Kerola
b61c93b7a1 performance: add few restict and const key words
This should make the run to be couple percentages quicker.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-05 21:05:42 +00:00
Sami Kerola
b3e02ce0ba all: fix compiler warninings
Use compiler warnings from coreutils to check nothing complains, and
fix everything that did.

CFLAGS='-Wall -W -Wformat-y2k -Wformat-security -Winit-self
-Wmissing-include-dirs -Wunused -Wunknown-pragmas -Wstrict-aliasing
-Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align
-Wwrite-strings -Wmissing-declarations -Wmissing-noreturn -Wpacked
-Winvalid-pch -Wvolatile-register-var -Wdisabled-optimization
-Woverlength-strings -Wbuiltin-macro-redefined -Wmudflap
-Wpacked-bitfield-compat -Wsync-nand -Wattributes -Wcoverage-mismatch
-Wabi -Wcpp -Wdeprecated -Wdeprecated-declarations -Wdiv-by-zero
-Wendif-labels -Wextra -Wformat-contains-nul -Wformat-extra-args
-Wformat-zero-length -Wformat=2 -Wmultichar -Wnormalized=nfc -Woverflow
-Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=noreturn
-Wtrampolines -Wno-sign-compare -Wno-unused-parameter
-Wsuggest-attribute=noreturn -Wno-format-nonliteral -Wno-logical-op
-fdiagnostics-show-option -funit-at-a-time'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-17 17:59:39 +02:00
Sami Kerola
8f3d8ceae7 analyze: a lot of IP counts being missed
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>
2012-06-13 21:44:24 +02:00
Enno Gröper
ae7747db87 analyse: critical bug in the counting code
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 Gröper <groepeen@cms.hu-berlin.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-02 19:57:45 +02:00
Sami Kerola
f9eb53a215 bug: use uint32_t for IP numbers
The commit 1e82461875 was
incomplete, and at the end was a cause of off by one miscount.
The reason was bsearch where long int needed to be unsigned.
Weird that the original had work while there where so many type
mismatches.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-09 23:32:25 +02:00
Sami Kerola
f51f2e9fe1 licensing: set placeholder properly
I should have done this at commit a31fd0d97a

sed -i 's/<COPYRIGHT HOLDER>/THE AUTHOR AND CONTRIBUTORS/'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-09 10:18:53 +02:00
Sami Kerola
76915512b2 maint: coding style fixes
Remove unnecessary type casting, move .gitignore file contents to
right location, reindent to use Linux coding style, fix few type
mismatches, clean up to help & version output and hint compiler
call to these functions will end program.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 21:41:35 +02:00
Sami Kerola
d29fd809c9 analyze: debugging leftover removed
My stupid mistake to leave statement hanging around while I where
wondering where the uninitialized memory came from.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 18:05:20 +02:00
Sami Kerola
26db4eafdc all: include-what-you-see fixes
After uint32_t fix from 1e82461875
it was good idea to check which headers where needed where. And
generally clean up the includes while doing the check.
2011-07-08 18:02:36 +02:00
Sami Kerola
12271887db analyze: use more logical variable names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 17:03:12 +02:00
Sami Kerola
1e82461875 bug: use uint32_t for IP numbers
There where long and unsigned long used for IPs in use which
caused occasional off by one errors. The word occasional should
be read: pretty much every one with large enough configuration
has been affected.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-08 16:28:22 +02:00
Sami Kerola
a31fd0d97a licensing: use FreeBSD license (was GNUv3)
This change will also remove getopt source code and headers,
which has GNU license that I cannot change.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-21 22:54:03 +02:00
Sami Kerola
e299e7fce2 headers: include-what-you-use fixes
Usage of includes are set up the way found to be in use, with a help of
magnificent utility.

http://code.google.com/p/include-what-you-use/

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-08 20:59:56 +02:00
Sami Kerola
17429ef85b Copyright notice change to GNU license 3
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-02-08 20:33:09 +01:00
Sami Kerola
849c8f5e73 Use what libc will provide
The eprintf removed and replaced with err & warn. Option parsing
no longer tries to find missing optargs, which are getopts should
notice. Few complier warnings got to be removed as well. Finally
the commments will no longer exceed standard terminal width.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-01-22 20:53:15 +01:00
Sami Kerola
ee35f8bb1f Arithmetic comparisons to be same way around
In writing arithmetic comparisons, use "<" and "<=" rather than
">" and ">=". For some justification, read this:

http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=4126

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-01-22 12:35:18 +01:00
Sami Kerola
74aef1c34e Import from release candidate 2.13.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-01-21 18:15:50 +01:00