summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2017-11-13lib: Pass the safi as a uint8_tDonald Sharp
The safi encode/decode is using 2 bytes, which may cause problems on some platforms. Let's assume that a safi is a uint8_t and work accordingly. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13lib, zebra: Modify zebra to use STREAM_GET for zapiDonald Sharp
This code modifies zebra to use the STREAM_GET functionality. This will allow zebra to continue functioning in the case of bad input data from higher level protocols instead of crashing. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13lib: Add STREAM_GETX functionsDonald Sharp
Currently when stream reads fail, for any reason, we assert. While a *great* debugging tool, Asserting on production code is not a good thing. So this is the start of a conversion over to a series of STREAM_GETX functions that do not assert and allow the developer a way to program this gracefully and still clean up. Current code is something like this( taken from redistribute.c because this is dead simple ): afi = stream_getc(client->ibuf); type = stream_getc(client->ibuf); instance = stream_getw(client->ibuf); This code has several issues: 1) There is no failure mode for the stream read other than assert. if afi fails to be read the code stops. 2) stream_getX functions cannot be converted to a failure mode because it is impossible to tell a failure from good data with this api. So this new code will convert to this: STREAM_GETC(client->ibuf, afi); STREAM_GETC(client->ibuf, type); STREAM_GETW(client->ibuf, instance); .... stream_failure: return; We've created a stream_getc2( which does not assert ), but we need a way to allow clean failure mode handling. This is done by macro'ing stream_getX2 functions with the equivalent all uppercase STREAM_GETX functions that include a goto. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13Merge pull request #1436 from rtrlib/rpkiDonald Sharp
bgpd: Add RPKI/RTR support
2017-11-12lib: Fix command `copy running-config startup-config` to alias `write file`pogojotz
Fixes: #1412 Signed-off-by: Juergen Werner <pogojotz@gmx.net>
2017-11-10Merge pull request #1426 from donaldsharp/prefixlistafiJafar Al-Gharaibeh
lib: Only apply prefix's to the same family
2017-11-10bgpd: Add RPKI/RTR supportMarcel Röthke
This commit adds support for the RTR protocol to receive ROA information from a RPKI cache server. That information can than be used to validate the BGP origin AS of IP prefixes. Both features are implemented using [rtrlib](http://rtrlib.realmv6.org/). Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
2017-11-07lib: Only apply prefix's to the same familyDonald Sharp
When we have a v4 or v6 prefix list, only apply it via a match when the address families are the same. Fixes: #1339 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-06lib: Fix nexthop reading to work betterDonald Sharp
Fixes: #1404 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-31Merge pull request #1363 from donaldsharp/z_improvementsRuss White
Z improvements
2017-10-31Merge pull request #1366 from ↵Lou Berger
donaldsharp/bgp_non_integrated_zebra_redistribution Bgp non integrated zebra redistribution
2017-10-27Merge pull request #1174 from opensourcerouting/show_route_defpyDonald Sharp
Refactor the 'show ip route' commands using DEFPY
2017-10-25lib: Fix non-integrated config error displayDonald Sharp
When using a non-integrated config and starting up of a protocol daemon, we were not properly handling all possible cases and as such when an user hit an actual error they were getting (null) listed for the message string. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25lib: Remove strange lineDonald Sharp
Remove a line that only has a semi-colon on it. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25lib, ospf6d, ospfd, zebra: Add ZEBRA_STRDonald Sharp
Allow us to use a ZEBRA_STR for commands Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-24lib: optimize sockunion_connect()Renato Westphal
This function is only called with non-blocking sockets [1], so there's no need to worry about setting O_NONBLOCK and unsetting it later if the given fd was a blocking socket. This saves us 4 syscalls per connect, which is not much but is something. Also, remove an outdated comment about the return values of this function. It returns a 'connect_result' enum now, whose values are self-explanatory (connect_error, connect_success and connect_in_progress). This also fixes a coverity scan warning where we weren't checking the return value of the fcntl() syscall. [1] bgp_connect() and pim_msdp_sock_connect(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24*: fix coverity warnings - resource leaksRenato Westphal
These are mostly trivial fixes for leaks in the error path of some functions. The changes in bgpd/bgp_mpath.c deserves a bit of explanation though. In the bgp_info_mpath_aggregate_update() function, we were allocating memory for the lcomm variable but doing nothing with it. Since the code for communities, extended communities and large communities is pretty much the same in this function, it's clear that this was a copy and paste error where most of the ext. community code was copied but not all of it as it should have been. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24*: add missing \n in some help stringsRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24lib: fix coverity warnings introduced by the iface rb-tree conversionRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24zebra: unify the ipv4/ipv6 'show ip route' commands - part 1/2Renato Westphal
Note: I had to remove one assert in clidef.py in order to fix a build error when using a preprocessor string (FRR_IP_REDIST_STR_ZEBRA) inside a DEFPY command. This should be revisited later. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-23*: Modify zclient_init to require privs dataDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-23lib: Cleanup some missed reformatDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-18Merge pull request #1331 from donaldsharp/hash_speedupRenato Westphal
lib: Allow hash_get to sidestep expensive hash key generation in some…
2017-10-17Merge pull request #1333 from donaldsharp/command_py_leakJafar Al-Gharaibeh
lib: Fix small memory leak when using command_py.c
2017-10-17lib: Display unsigned instead of signedDonald Sharp
When displaying thread cpu data, display unsigned instead of signed data when we get really really really large numbers of invocations. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-17lib: Fix small memory leak when using command_py.cDonald Sharp
When free'ing memory associated with the wgraph, also free memory malloced during the initialization. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-16lib: No need to call apply_mask 2 timesDonald Sharp
route_node_set is only called by route_node_get which calls apply_mask. There is no need to do this again. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-16lib: Allow hash_get to sidestep expensive hash key generation in some casesDonald Sharp
There is no need to generate a hash key *if* the hash_alloc_function is NULL and the hash is empty. This changed showed a measurable increase in performance for table hash lookup for tables that were meant to be empty in bgp( the distance commands ). Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-16Merge pull request #1298 from opensourcerouting/iface-rb-treeDonald Sharp
Use rb-trees to store interfaces instead of linked-lists
2017-10-11lib: Free workqueue memory leak on freeDonald Sharp
When free'ing the workqueue if you have items on the workqueue you should free the memory associated with it. Additionally move the work_queue_item_remove function to allow for static to be awesome Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-10lib: Add some documentation about argv_findDonald Sharp
We expect that the index value passed in for argv_find should be initially set to 0. This way if the cli ever changes there is no need to modify the initial value. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-10lib: Fix missing va_endDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-10*: use the FOR_ALL_INTERFACES abstraction from babeldRenato Westphal
This improves code readability and also future-proofs our codebase against new changes in the data structure used to store interfaces. The FOR_ALL_INTERFACES_ADDRESSES macro was also moved to lib/ but for now only babeld is using it. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10lib: fix bug in if_cmp_name_func()Renato Westphal
If the p1 and p2 arguments pointed to identical strings ending with a non-numeric character (e.g. "lo"), this function would return -1 instead of 0 as one would expect. This inconsistency didn't matter for sorted linked-lists but for red-black trees it's a major source of problems. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10*: introduce new rb-tree to optimize interface lookup by ifindexRenato Westphal
Performance tests showed that, when running on a system with a large number of interfaces, some daemons would spend a considerable amount of time in the if_lookup_by_index() function. Introduce a new rb-tree to solve this problem. With this change, we need to use the if_set_index() function whenever we want to change the ifindex of an interface. This is necessary to ensure that the 'ifaces_by_index' rb-tree is updated accordingly. The return value of all insert/remove operations in the interface rb-trees is checked to ensure that an error is logged if a corruption is detected. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10*: eliminate IFINDEX_DELETED in favor of IFINDEX_INTERNALRenato Westphal
IFINDEX_DELETED is not necessary anymore as we moved from a global list of interfaces to a list of interfaces per VRF. This reverts commit 84361d615. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10*: use rb-trees to store interfaces instead of sorted linked-listsRenato Westphal
This is an important optimization for users running FRR on systems with a large number of interfaces (e.g. thousands of tunnels). Red-black trees scale much better than sorted linked-lists and also store the elements in an ordered way (contrary to hash tables). This is a big patch but the interesting bits are all in lib/if.[ch]. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10lib: register 'if_var_handlers' only onceRenato Westphal
There's no need to register 'if_var_handlers' for every VRF, we need to do it only once. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10lib: nuke the if_*_by_name_len() functionsRenato Westphal
Make use of strnlen() and strlcpy() so we can get rid of these convoluted if_*_by_name_len() functions. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-09Merge pull request #1310 from vjardin6WIND/null_referencesDonald Sharp
lib: linklist avoid access NULL->data
2017-10-09lib: fix wrong warning from clangVincent JARDIN
The compiler cannot guess that rise() will not return here. One should help. Warning: Access to field 'file' results in a dereference of a null pointer (loaded from variable 'error') aka error->file while error is NULL. Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09lib: csv unit testsVincent JARDIN
Fix csv unit tests. To be run using, gcc -o csv csv.c -DTEST_CSV ./csv Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09lib: fix NULL->field_len accessVincent JARDIN
Currenlty, this function is used only by: - unit test of csv.c (see its main() section) - ptm_lib.c In case of ptm, it is safe to return NULL because: csv_encode_record() -> return NULL _ptm_lib_encode_header() -> return NULL the only consumer of the return value is: ptm_lib_init_msg() that checks the NULL return. Warning: Access to field 'field_len' results in a dereference of a null pointer (loaded from variable 'fld') Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09lib: fix a64448ba, invalid NULL->num_labelsVincent JARDIN
We should assume match OK only when neither nhl1 and neither nhl2 are NULL. If both are NULL, it means match NOK. Clang Warning: Access to field 'num_labels' results in a dereference of a null pointer (loaded from variable 'nhl1') Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09lib: linklist avoid access NULL->dataVincent JARDIN
Let's assert(NULL) if the datastructure is not set. The code assumes that the pointer is always non NULL. So, let's enforce this semantic. Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-08lib: fix clang warningVincent JARDIN
Properly initialize to avoid "Branch condition evaluates to a garbage value" warning. Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-05lib, ldpd: fix "argument cannot be negative" coverity warningsRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-05*: Convert list_free usage to list_deleteDonald Sharp
list_free is occassionally being used to delete the list and accidently not deleting all the nodes. We keep running across this usage pattern. Let's remove the temptation and only allow list_delete to handle list deletion. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05*: Convert list_delete(struct list *) to ** to allow nullingDonald Sharp
Convert the list_delete(struct list *) function to use struct list **. This is to allow the list pointer to be nulled. I keep running into uses of this list_delete function where we forget to set the returned pointer to NULL and attempt to use it and then experience a crash, usually after the developer has long since left the building. Let's make the api explicit in it setting the list pointer to null. Cynical Prediction: This code will expose a attempt to use the NULL'ed list pointer in some obscure bit of code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-03lib: Fix memset usageDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>