summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2016-12-20build: rename (1 of ?): configure.ac + preprocDavid Lamparter
This replaces Quagga -> FRR in most configure.ac settings as well as a handful of preprocessor macros in the source code. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-08lib: fix prefix2str return value and assertChristian Franke
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-12-08*: always set SO_SNDBUF and SO_RCVBUF using a best effort approachRenato Westphal
If we fail to set any socket's buffer size, try again with a smaller value and keep going until it succeeds. This is better than just giving up or, even worse, abort the creation of a socket (ospf6d and ripd). Fix broken ospf6d on FreeBSD. Signed-off-by: Renato Westphal <renato@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-05lib: remove unused NS_BITMAP MTYPEDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-05Merge branch '-rip' into stable/2.0David Lamparter
This fixes up a lot of RIP/RIPng compliance tests that were still flagged up. Tested-by: Martin Winter <mwinter@opensourcerouting.org>
2016-12-05Merge branch '-renato' into stable/2.0David Lamparter
This contains bgp memory leak fixes as well as cleanups to VRF/namespace handling and has been run through extended testing in Cumulus' testbed: Tested-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-05lib, zebra: Minimize display of link-params sub dataDonald Sharp
When link-params is configured it auto starts displaying 6000-02# conf t dell-s6000-02(config)# int swp1 dell-s6000-02(config-if)# link-params dell-s6000-02(config-link-params)# admin-grp 0x12345678 dell-s6000-02(config-link-params)# end dell-s6000-02# show run interface swp1 link-params enable metric 0 <----Remove the bw lines max-bw 1.25e+06 max-rsv-bw 1.25e+06 unrsv-bw 0 1.25e+06 unrsv-bw 1 1.25e+06 unrsv-bw 2 1.25e+06 unrsv-bw 3 1.25e+06 unrsv-bw 4 1.25e+06 unrsv-bw 5 1.25e+06 unrsv-bw 6 1.25e+06 unrsv-bw 7 1.25e+06 admin-grp 305419896 exit-link-params ! I'd like to reduce this to: interface enp0s3 ip igmp ip pim sm link-params enable admin-grp 0x12345678 <----- Fix this to be what we entered exit-link-params ! Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01lib: replace MIT license with ISCDavid Lamparter
Since other parts (e.g. ldpd) use the ISC license, and the ISC license is just a simplified form of the MIT license, just move things over and reduce the number of different licenses we have in use here. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28zebra/lib: remove redundant fields from zebra_vrfRenato Westphal
There's no need to duplicate the 'vrf_id' and 'name' fields from the 'vrf' structure into the 'zebra_vrf' structure. Instead of that, add a back pointer in 'zebra_vrf' that should point to the associated 'vrf' structure. Additionally, modify the vrf callbacks to pass the whole vrf structure as a parameter. This allow us to make further simplifications in the code. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28lib/zebra: put vrf_get() on a dietRenato Westphal
Also, for some reason we had two functions to search a VRF by its name: zebra_vrf_lookup_by_name() and zebra_vrf_list_lookup_by_name(). The first one would loop through vrf_table and the other one through vrf_list. This is not necessary anymore, so remove zebra_vrf_lookup_by_name() and rename zebra_vrf_list_lookup_by_name() to zebra_vrf_lookup_by_name(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28zebra: order VRFs by name on user outputRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28lib/zebra: convert vrf_list to a red-black treeRenato Westphal
Since we're already using a red-black tree to store VRFs sorted by their vrf_id's, create a new tree to store VRFs sorted by their names. The biggest advantage of doing this is that we reduce the time complexity of vrf_list_lookup_by_name() from O(n) to O(log n). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28*: rename two vrf functionsRenato Westphal
Since VRFs can be searched by vrf_id or name, make this explicit in the helper functions. s/vrf_lookup/vrf_lookup_by_id/ s/zebra_vrf_lookup/zebra_vrf_lookup_by_id/ Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28lib: convert vrf code to use red-black trees as wellRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28lib: convert namespace code to use red-black treesRenato Westphal
We definitely need to stop abusing the route table data structure when it's not necessary. Convert the namespace code to use red-black trees instead. This greatly improves code readability. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28lib: fix creation of pre-provisioned VRFsRenato Westphal
If we configure a VRF that doesn't match any device in the kernel, we'll fall in the first case of the vrf_get() function. In this function, a vrf structure is callocated and it's vrf_id is never set explicitly, which means it's set to zero (the vrf-id of the default VRF). When this happens, commands like "router-id A.B.C.D vrf ..." will act on the default VRF and not on the pre-provisioned VRF. To fix this, always set the vrf_id of pre-provisioned VRFs to VRF_UNKNOWN. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28zebra/lib: move some code aroundRenato Westphal
* move netlink code from zebra_nc.c to kernel_netlink.c; * move vrf CLI commands from if.c/interface.c to vrf.c/zebra_vrf.c; * move declaration of the 'ns' structure to a header file. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28lib: remove unused ns codeRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28zebra/lib: plug several memleaksRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28Merge remote-tracking branch 'cmaster-next' into cmaster-next-relengDavid Lamparter
2016-11-25*: create a helper function to set the IP_MULTICAST_LOOP sockoptionRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-25ripd: fix the "neighbor" command.Renato Westphal
We can't use if_lookup_prefix() in rip_update_process() because this function uses prefix_cmp() internally to try matching an interface address to a static neighbor's address. Since prefix_cmp() tries to match exact prefixes, if_lookup_prefix() was always returning NULL. What we really need here is to use prefix_match(), which checks if one prefix includes the other (e.g. one /24 interface including a /32 static neighbor's address). The fix then is to replace the call to if_lookup_prefix() and use if_lookup_address() instead, which uses prefix_match() internally. Fixes IxANVL RIP test 17.1 Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-24lib: Fix nexthop strings to coincide with enumvivek
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-11-19Merge remote-tracking branch 'cmaster-next' into cmaster-next-relengDavid Lamparter
2016-11-18*: Fix up licensing to be rightDonald Sharp
These files were submitted by Cumulus but did not properly setup the licensing of them. This fixes that issue. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-11-15lib: replace strlcpy & strlcat with glibc versionsDavid Lamparter
It seems these two were at some point copied in from rsync; replace with more recent versions that will hopefully become available in glibc as well. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15build: massively remove needless checksDavid Lamparter
Since we have autoconf results from a wide swath of target platforms, we can go remove checks that have the same result on all systems. This also removes several "fallback" implementations of functions that, at some point in the history, weren't available on all target platforms. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15build: don't use deprecation warning on ICCDavid Lamparter
icc doesn't do the pragma warning push/pop thing to selectively disable the warning. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15build: fix -Wmaybe-uninitialized warningsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-10lib: add minimal no-config VTY modeDavid Lamparter
This silences the following warning from watchquagga: "Can't save to configuration file, using vtysh." which otherwise appears when doing a "write file" in vtysh when no integrated-config is in use. Also make "show memory" available in watchquagga. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-09watchquagga: add "write integrated"David Lamparter
This new command - available for internal use by vtysh and explicit usage by users - calls "vtysh -w" from watchquagga. This ensures vtysh is run with privileges to actually write the integrated-config file. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-09watchquagga: add ZLOG_WATCHQUAGGADavid Lamparter
watchquagga logs as "NONE", which will also become visible in vtysh for error messages. Add "WATCHQUAGGA" log target. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-09lib: privs: always look up VTY groupDavid Lamparter
Even if we're running without user switch, we should still try to honor the VTY group. This applies both to watchquagga (which always runs as root) as well as "no-userswitch" configurations for other daemons. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-09lib: add and use set_cloexec()David Lamparter
watchquagga is already leaking an open file descriptor on its pid file on fork+exec() invocations; next up is adding vtysh support with even more fds. Mark things CLOEXEC before going there. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-24lib: Fix race condition in shutdown of routemapDonald Sharp
When shutting down a daemon that uses an update timer to handle route map processing, there exists a race condition where if you change a route map and then immediately shutdown quagga before the update timer for the routemap runs, you will be placed in a infinite loop. This condition happens because this commit introduces route map memory free'ing but never tests to see if the to_be_processed flag has happened or not before deleting: commit 289d25016b79ed7908a29af7ba35e18f1ec6ed0a Author: Lou Berger <lberger@labn.net> Date: Wed Apr 10 12:30:04 2013 -0700 bgpd, lib: memory cleanups for valgrind, plus debug changes Modify route_map_finish to explicitly turn off the to_be_processed field. As that we know we are going away if route_map_finish is called. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-10-20lib: Fix for int64 and json on some systemsDonald Sharp
When compiling json on systems with json/json.h that don't have json_object_new_int64, just use json_object_new_int instead and accept we might truncate data. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-20bgpd: 'show ip bgp summary json' shows large negative value for "peerUptimeMsec"Daniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Ticket: CM-13239
2016-10-19lib: keep hash of node's commands to detect duplicate installsPaul Jakma
* command.h: (struct cmd_node) Add a hash, so duplicate installs of a cmd_element to a command node can be detected. To help catch strays from the VIEW/ENABLE node consolidation particularly (installs to VIEW automatically install to ENABLE too now). * command.c: (cmd_hash_{key,cmp}) helpers for the hash - just directly on the pointer value is sufficient to catch the main problem. (install_node) setup the hash for the command node. (install_element) check for duplicate installs. The assert on the cmd_parse_format seems misplaced. (install_default_basic) separate the basic, VIEW, node default commands to here. (cmd_init) get rid of dupes, given consolidation. (cmd_terminate) clean up the node command hash. Not done: The (struct cmd_node)'s vector could be replaced with the cmd hash, however much of the command parser depends heavily on the vector and it's a lot of work to change. A vector_lookup_value could also work, particularly if vector could be backed by a hash. The duplicate check could be disabled in releases - but useful in development. It's a little extra overhead at startup. The command initialisation overhead is already something that bites in micro-benchmarks - makes it easy for other implementations to show how much faster they are with benchmarks where other load is low enough that startup time is a factor.
2016-10-19lib: Fix redist memory free'ingDonald Sharp
When shutting down, properly free memory associated with zclient. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-19lib: Add cleanup for routemapsDonald Sharp
Some new routemap hash data structures were not being properly cleaned up. Add the hash_free code in. This code does not fix the variety of daemons that don't actually call route_map_finish. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-19*: Consolidate routemap initializationDonald Sharp
Consolidate the routemap initialization into one function. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-10-18bgpd, lib: memory cleanups for valgrind, plus debug changesLou Berger
Description: We use valgrind memcheck quite a bit to spot leaks in our work with bgpd. In order to eliminate false positives, we added code in the exit path to release the remaining allocated memory. Bgpd startup log message now includes pid. Some little tweaks by Paul Jakma <paul.jakma@hpe.com>: * bgp_mplsvpn.c: (str2prefix_rd) do the cleanup in common code at the end and goto it. [DL: dropped several chunks from original commit which are obsolete by now on this tree.]
2016-10-18lib/zebra: remove code duplication in redist_del_instance()Renato Westphal
Change redist_check_instance() to return a pointer instead of returning 1 on success. This way this function can be reused in redist_del_instance() instead of duplicating the same logic there. Also, remove unnecessary call to redist_check_instance() in zebra_redistribute_delete(). While here, remove unnecessary cast from void* in redist_add_instance(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-10-18zebra/ldpd: introduce ZEBRA_ROUTE_ALL wildcard route typeRenato Westphal
The ZEBRA_ROUTE_ALL route type can be used by a client to request all routes from zebra. The main motivation for introducing this is to allow ldpd to get routes from all OSPF instances, not only from the default one. Without ZEBRA_ROUTE_ALL, ldpd would need to send a ZEBRA_REDISTRIBUTE_ADD message for each possible OSPF instance (65k), which doesn't scale very well. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-10-18lib: add event_counterChristian Franke
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-10-18lib: add api method to read current config pathChristian Franke
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-10-12lib/vtysh: fix duplicate installation of some vty commandsRenato Westphal
This is a followup to commits 735e62 and 0b1442, where we forgot to apply the same VIEW/ENABLE consolidation logic to vtysh. Also, we can't call install_default() for the ENABLE node because some of the vty commands installed by this function were already installed in the VIEW node before. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-10-07*: Consolidate all double VIEW_NODE and ENABLE_NODE'sDonald Sharp
If a command is put into the VIEW_NODE, it is going into the ENABLE_NODE as well. This is especially true for show commands. As such if a command is in both consolidate it down to VIEW_NODE. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07lib: Consolidate VIEW_NODE to be ENABLE_NODE as wellDonald Sharp
If you are in VIEW_NODE, the command should exist in ENABLE_NODE as well. This is being done to reduce chances of code being added to one but not the other NODE. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07bgpd, lib: Remove RESTRICTED_NODE from code baseDonald Sharp
The RESTRICTED_NODE command is not used, introduces code complexity and provides no additional levels of security. The only way to get into RESTRICTED_NODE is to add, under vty configuration the command 'anonymous restricted', and then telnet to a daemon, provide a password, then type 'enable' and fail to enter the password three times. Then the user can enter a very limited set of commands to monitor bgp and only bgp behavior. This commit removes both the RESTRICTED_NODE usage as well as the lib/* usage of the code Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>