Age | Commit message (Collapse) | Author |
|
nonwithstanding any desire for optimisation, these versions are shorter
and more concise. reading the comments, they might even be easier to
understand.
I've tested them on i686 and x86_64, and checked that correct assembler
code is emitted for ARM, MIPS and PowerPC.
IPv6 is left as an exercise for another day, none of the ideas I had led
to a "yes, this is the one to go with" solution.
Signed-off-by: David Lamparter <equinox@diac24.net>
|
|
This reverts commit d171bf58ef12ace43d48565e6870722dece1e6ed.
There are multiple reasons for this revert, including bug #720, but also
quite simply the unreadability of having 2000 lines of an autogenerated
table in the middle of a source file.
Signed-off-by: David Lamparter <equinox@diac24.net>
Reported-by: Martin Winter <mwinter@opensourcerouting.org>
|
|
While defining two "maskbytes" arrays for the respective endiannesses,
the code was unconditionally using one that only worked on little endian
systems.
Use preprocessor macros to avoid the somewhat expensive
htonl/ntohl macros.
From: Renato Westphal <renatowestphal@gmail.com>
Signed-off-by: David Lamparter <equinox@diac24.net>
|
|
|
|
* (general) Move functions in headers into files, to be compiled into
shared object files. Remove inline qualifier from functions. Let the
compiler do the work.
|
|
IPV4_ADDR_SAME() wasn't passed the right union member, this could cause
a bug due to strict-aliasing. IPV6_ADDR_SAME() case got its fix before
the error could be created by macro upgrade.
|
|
ip_masklen() was likely to return incorrect results after being compiled
with -fstrict-aliasing (-O2, -O3, -Os)
|
|
The new implementation makes use of a 64KB mapping table, which makes it
possible to compute masklen faster and with constant execution time. The
map also allows for additional version of the function, which can detect
errors in input argument.
The previous implementation had a variable cost of execution, which
depended on masklen in a non-linear manner, and at its worst (/31) was
4 times slower, than the new implementation. The only case of old
function just slightly outperforming the new one is /0, which is of
little practical interest.
|
|
Experience with IPv4 counterpart of this function suggests, that
this way of type-punning is likely to cause errors.
|
|
|
|
|
|
|
|
|
|
|
|
prefix2sockunion converts a struct prefix* to a union sockunion *;
prefix_common_bits counts the number of common bits in the prefix's
address part.
|
|
* lib/prefix.c: (prefix_match) nano-optimisation, let it return early
without copying pointers.
|
|
* bgpd/bgp_attr.c, bgpd/bgp_open.h, bgpd/bgp_route.c, lib/prefix.c,
lib/prefix.h: Various integer types were being used where, if we
had strict type checking, afi_t and safi_t would be required.
Signed-off-by: G.Balaji <balajig81@gmail.com>
(cherry picked from commit c8af35ffa2dc79ff7d7ff00b1b61f1f50a100ab6)
|
|
* isisd/isis_pdu.c
* maskbit: this pre-initialized array is not modified
* lib/prefix.c
* maskbit: idem
* lib/command.c
* facility_map: idem
* itoa64: idem
* default_motd: make local var static
* facility_name(): update local var accordingly
* facility_match(): idem
|
|
* prefix.c: (str2prefix_ipv6) inet_pton succesful return is presumed to be
1, rather than the "not zero" the man page describes - seemed fragile.
|
|
* prefix.c: (prefix_ipv4_new, prefix_ipv6_new): Call prefix_new
to allocate the memory to make sure that all struct prefix pointers
point to objects of the same length (avoids memory overruns
on struct prefix assignments).
(prefix_ipv4_free, prefix_ipv6_free): Simply call prefix_free.
It is interesting to note that these functions are never actually
called anywhere in the code. Instead prefix_free was already
being called directly, despite the previous MTYPE incompatibility.
[backport candidate]
|
|
* prefix.c: (ip_masklen) While loop should test that 'pnt' pointer is
in range before dereferencing it.
[backport candidate]
|
|
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
|
|
inet_ntoa alike.
* ripngd.[hc], ripng_interface.c, ripng_peer.c: inet6_ntoa() takes
argument now by value.
|
|
ripngd/ripngd.c (inet6_ntop).
* ripngd.[hc]: Remove inet6_ntop() and any usage of it. inet6_ntoa()
from lib is used now.
* ripng_interface.c: inet6_ntop() -> inet6_ntoa().
* ripng_peer.c: inet6_ntop() -> inet6_ntoa().
|
|
* prefix.c: (prefix_copy) Error message before abort should
have severity LOG_ERR, not LOG_INFO.
* memory.c: (mtype_log) Log level should be LOG_DEBUG, not LOG_INFO.
|
|
ripd might need some more testing though.
|
|
adding FIXME's.
|
|
address/netmask pairs, and clarify the two comparison functions.
|
|
|