summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
AgeCommit message (Collapse)Author
2022-09-01Switch the rde_peer hashtable and peer list to a single RB tree.Claudio Jeker
Only the RDE used a hashtable for lookups while the session engine switched from a list to RB tree some time ago. Use peer_foreach() in the mrt code instead of passing the peer list as an argument. OK benno@ tb@
2022-09-01This code no longer needs siphash.h and also cleanup some leftoverClaudio Jeker
prototypes and members that were not removed in the previous RB tree conversions. OK benno@ tb@
2022-08-31Remove IMSG_CTL_SHOW_RIB_HASH and struct rde_hashstats which are noClaudio Jeker
longer used. Also cleanup some hash sizes which are also no longer used. OK tb@
2022-08-31Switch the generic attribute cache to an RB tree.Claudio Jeker
OK benno@ tb@
2022-08-31Make sure that only one roa softreconfig runner is run at any time.Claudio Jeker
If a run takes to long drop the current update and wait for the next update. OK benno@
2022-08-30Switch nexthop hash to a RB tree.Claudio Jeker
OK benno@
2022-08-30Add missing #include <sys/queue.h>Claudio Jeker
2022-08-30Reshuffle and cleanup the includes a little bit.Claudio Jeker
2022-08-29Instead of a global aspath cache copy the aspath attribute per rde_aspathClaudio Jeker
struct. It uses a bit more memory but improves performance a lot on really big systems because aspath_get() becomes a very hot function. OK tb@
2022-08-29Use fatal("%s", __func__); instead of fatal("function_name");Claudio Jeker
OK tb@
2022-08-29Switch the DB of communities collections to a RB tree instead of anClaudio Jeker
undersized hash table. OK tb@
2022-08-29Switch rde_aspath to a RB tree instead of a hash table.Claudio Jeker
OK tb@
2022-08-29Export pending update and withdraw as part of struct peer_stats.Claudio Jeker
OK tb@
2022-08-26Handle IMSG_SESSION_* messages immediatly when received and do not putClaudio Jeker
them on the per peer imsg queue. This is mainly for IMSG_SESSION_DOWN. Delaying the session down can race against IMSG_SESSION_ADD which is handled immediatly and as a result an establised connection may be removed in the RDE because of it. The various graceful restart imsgs need similar treatment for similar reasons. In the end when a session is reset/closed the RDE needs to stop all work and flush the per peer imsg queue. With this only update and route refresh messages are handled via the imsg queue. OK tb@
2022-08-25Connected routes use the BGP exit nexthop while other routes need to useClaudio Jeker
the nexthop from the covering route. Move this logic from RDE to the kroute code so it is all in one place. OK tb@
2022-08-24Put the 'connection from non-peer' log message behind a verbose logging check.Claudio Jeker
In many cases the message is just flooding the logs. In some cases it may help to identify a missing neighbor for those cases log verbose can be used. OK deraadt@ denis@
2022-08-19Fix nexthop lookup for connected routes.Claudio Jeker
In knexthop_true_nexthop() connected routes need to be handled specially. If a nexthop is directly reachable the gateway needs to remain the same. There is no nexthop set for F_CONNECTED kroutes. A very similar trick is used in rde_rib.c::nexthop_update() but was forgotten here. Regression noticed by Daniel Jakots (danj at chown.me). OK tb@
2022-08-18In kroute_insert() fix the check for multipath routes. Use a helper variableClaudio Jeker
since krm is only set for IPv4 routes but not for IPv6 ones. OK tb@
2022-08-18There is no need to pass the fd to send_rtmsg(), the fd is always theClaudio Jeker
one from kr_state and removing this argument helps portability. OK tb@
2022-08-17Convert bzero() to memset(), bcmp() to memcmp() and bcopy() to memcpy().Claudio Jeker
The memory regions passed to memcpy() can not overlap so no need for memmove(). OK tb@ deraadt@
2022-08-17Just use struct kif and kill struct kif_node. No need for this extraClaudio Jeker
struct. OK tb@
2022-08-17Just 2 newline changes.Claudio Jeker
2022-08-17Add default case to switch to silence a warning seen with gcc.Claudio Jeker
2022-08-16Do not send kroutes from the RDE to the FIB with the true_nexthop butClaudio Jeker
instead use exit_nexthop (the nexthop from BGP). The FIB code can then do the lookup and replace the nexthop in the FIB. This solves an issue when multiple nexthops change concurrently. In the RDE the decision process handles these changes ansynchronously which resulted in bad true_nexthops to be sent to the FIB. The exit_nethop is stable so the data sent to the FIB is always correct. Fix a bug in netxhop tracking introduced in 1.280. On RTM_CHANGE when the nexthop of a kroute changes a knexthop_send_update() must be sent but knexthop_track() does not do that because the kroute did not change. Introduce a knexthop_update() function for this case instead. OK tb@
2022-08-10Reverse NULL check in krVPN6_change()Theo Buehler
This matches the VPN4 code and avoids a NULL deref in the else branch. ok claudio
2022-08-10More kroute_nexthop cleanup. Mainly use direct assignment instead ofClaudio Jeker
memcpy(). Additionally replace a bzero() with memset() and remove to superfluous bzero calls. OK tb@
2022-08-10Fix logic in network_dump_upcall()Claudio Jeker
The nexthop can be valid but still a NULL pointer. In that case just set the aid like it is done for invalid nexthops. If the nexthop is set by explicitly specifying one then include the exit_nexthop, that is the nexthop that is relevant for BGP. Further cleanup the function as usual. OK tb@
2022-08-03Add comment that NEXTHOP_FLAPPED is only set on oldstate of a nexthop.Claudio Jeker
2022-08-03Fix a modify after free error in kroute_remove()Claudio Jeker
knexthop_validate() will modify the kroute the nexthop points to. Because of this knexthop_validate() needs to be called before the to be removed kroute is freed. Move the code into kroute_remove[46] so the order is correct. Problem found and fix tested by sthen@. OK sthen@ tb@
2022-08-03Fix possible NULL dereference in knexthop_validate().Claudio Jeker
kroute_match() may return NULL so setting kn->ifindex should only be done if the kroute is valid. Also set the ifindex to 0 in kroute_detach_nexthop(). Based on a bigger diff which is OK tb@ and sthen@
2022-07-28Rework kroute_remove(), it uses a struct kroute_full and does most ofClaudio Jeker
the work internally. Removes a bunch of duplicated code and simplifies code further. Input and OK tb@
2022-07-28whitespace found during a read-thru; ok claudioTheo de Raadt
2022-07-28Remove F_DOWN, it is no longer used and reshuffle the other flags a bitClaudio Jeker
to group them a bit better. OK tb@
2022-07-27There is no need to track both F_BGPD and F_KERNEL anymore.Claudio Jeker
Remove F_KERNEL and replace the checks using the F_BGPD flag. Also do not convert the priority in kr_tofull() instead provide kr_priority() which does this and is used by the bgpctl imsg commands. Also in dispatch_rtmsg_addr() convert to RTP_MINE if the priority is equal to the configured priority. OK tb@
2022-07-26No need to check RB_REMOVE() return value if kif is not NULL.Claudio Jeker
Therefor check that in the IFAN_DEPARTURE case the interface was found before calling kif_remove. Idea and OK tb@
2022-07-26Missing indirection. This version compiles.Claudio Jeker
2022-07-26Refactor nexthop tracking and remove all the kif_kr code. There is noClaudio Jeker
need to track directly connected routes per kif. The only use case was for nexthop validation but that can be done by storing the ifindex in struct knexthop. OK tb@
2022-07-25Properly handle nexthop state changes in the decision processClaudio Jeker
In rev 1.90 of rde_decide.c the re->active cache of the best prefix was replaced with a call to prefix_best(). This introduced a bug because the nexthop state at that time may have changed already. As a result when a nexthop became unreachable prefix_evaluate() had oldbest = NULL and newbest = NULL and did not withdraw the prefix from FIB and Adj-RIB-Out. To fix this store the nexthop state per prefix and introduce prefix_evaluate_nexthop() which removes the prefix from the decision list, updates the nexthop state of the prefix and reinserts the prefix. Doing this ensures that prefix_best() always reports the same result once the decison process is done. prefix_best() and prefix_eligible() only depend on data stored on the prefix itself. OK tb@
2022-07-23Refactor and rename bgpd_filternexthop() to bgpd_oknexthop()Claudio Jeker
Simplify the logic and adjust kroute_match() which makes the code easier to understand. OK tb@
2022-07-23There is no need to set kf.flags to F_KERNEL here.Claudio Jeker
From a previous diff that was reverted because of a different issue. was OK tb@
2022-07-22Revert previous commit. The RTP_MINE checks on struct kroute_full areClaudio Jeker
not correct because kr_tofull() replaces RTP_MINE with the real priority. Noticed because of incorrect nexthop selection.
2022-07-22Retire the F_KERNEL flag, it got superseded by route priority and RTP_MINE.Claudio Jeker
Only problem is when route(8) is used to modify/delete a bgpd owned route. Exact behaviour for that is still a bit unclear but F_KERNEL does not help in this case either. In the kr_fib_delete/change remove F_BGPD_INSERTED in that case as a first step. OK tb@
2022-07-21Relax the config of add-path send and rde evaluate allClaudio Jeker
add-path send is kind of like rde evaluate all (at least if plus is used) and so it kind of implies 'rde evaluate all' in that case. Removing the check in neighbor_consistent() allows to setup sessions so that 'either or' are used. This makes sense since peers may opt out of add-path by disabling the capability on their side. Based on report from Pier Carlo Chiodi OK tb@ cvs: ----------------------------------------------------------------------
2022-07-21Make kr_redistribute() and kroute_insert() AID independent and useClaudio Jeker
struct kroute_full. This removes some of the duplicated code. OK tb@
2022-07-20Cleanup and fix the network code.Claudio Jeker
- introduce network_free() to properly free a network struct including the possible rtlabel reference. - change expand_networks() and the reload code to not only expand the main network config but also the network configs inside L3VPN sections. - adjust reload logic to properly match any kind of network struct. Up until now rtlabel and priority network statememnts were not correctly reloaded. OK tb@
2022-07-19Do a minimal check that the passed in option is inside the ASPATH segment.Claudio Jeker
Check both for negative pos and for pos bigger or equal to the segment length With and OK tb@
2022-07-19Use kf for all struct kroute_full variables. Makes code more consistent.Claudio Jeker
OK tb@
2022-07-18use syntax which more acceptable to older compilersTheo de Raadt
discussed with tb
2022-07-18Remove warning messages that add nothing in the situation they occure.Claudio Jeker
If the RDE dies this is logged before but the error messages from imsg_rde() may be called a couple of times before the SE has a chance to exit. OK tb@
2022-07-18Do not fatalx() when calculating the dmetric and the result is negative.Claudio Jeker
The list of invalid prefixes is not properly sorted and when those prefixes all become valid the list is not properly sorted until the nexthop update pass is done. Found the hard way by myself. OK tb@ benno@