summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
AgeCommit message (Collapse)Author
2022-11-07Fix a memory leak in the error path of rde_dump_ctx_new.Moritz Buhl
ctx is leaked in case of an allocation in prefix_dump_new, prefix_dump_subtree, rib_dump_new, or rib_dump_subtree fails. Found by CodeChecker. OK claudio@
2022-11-07Fix theoretical access to garbage stack memory in pfkey_reply forMoritz Buhl
bgpd and ldpd. Found by CodeChecker. OK claudio@
2022-11-07Fix some spelling errors.Moritz Buhl
OK claudio@
2022-10-18Initalize last_updown in init_peer() so that it is reported correctlyClaudio Jeker
for peers that never managed to establish a connection. OK tb@
2022-10-18Fix some spelling errorsJob Snijders
Thanks Marco D'Itri for spotting them OK claudio@
2022-10-12use correct type with sizeofJonathan Gray
ok miod@ claudio@ tb@
2022-09-24OpenBGPD 7.7Claudio Jeker
2022-09-23Don't depend on RTLABEL_LEN but instead define our own ROUTELABEL_LEN.Claudio Jeker
With this bgpd.h no longer depends on net/route.h OK tb@
2022-09-23Implement a special update generator for add-path send all.Claudio Jeker
The generic add-path code up_generate_addpath() reevaluates everything since this is the simplest way to select the announced paths. For add-path all this is overkill since there is no dependency between prefixes and so individual prefixes can be handled more efficently. Extend rde_generate_updates() to pass the current newbest and oldbest prefixes (for the selected best path) but now also include newpath and oldpath (which is the prefix that is added/removed/modified). If newpath or oldpath is set then a single prefix was altered and up_generate_addpath_all() can just remove or add this prefix. If newpath and oldpath are NULL than the full list based on newbest needs to be inserted and any old path/prefix removed in the process. This improves update generation performance on big route collectors using add-path all substantially. OK tb@
2022-09-21The values for fib_priority are OS dependent. To help portability moveClaudio Jeker
the RTP_BGP and similar defines all into kroute.c and export them via kr_default_prio() and kr_check_prio(). OK tb@
2022-09-21Adjust pathid_assign() to be much faster in the common case.Claudio Jeker
Use a per peer path_id_tx to assign to paths received from none add-path enabled peers. This skips two extra walks of the RIB prefix list and is a big speed-up when there are many regular sessions. If the session uses add-path recv then the old way of assigning random path_ids needs to be used. With input and OK tb@
2022-09-15Make kroute_matchgw() also work with connected routes.Claudio Jeker
Connected routes have no gateway set but only have ifindex set. When an interface is deconfigured this makes sure the right route is removed. OK tb@
2022-09-12Bump version for upcoming -portable releaseClaudio Jeker
2022-09-12Introduce tree walkers that only walk a subtree of the RIB.Claudio Jeker
In some cases only a "small" part of the RIB needs to be looked at. Like bgpctl show rib 10/8 or-longer that only needs to travers nodes under 10/8 all other RIB entries do not matter. By setting the start node to the RB_NFIND(10/8) the all nodes below this point can be skipped. Using prefix_compare() while walking the tree with RB_NEXT() the walker know when it steps outside of the 10/8 subtree and stops. With this the or-longer commands become a lot faster. Looks good to tb@
2022-09-09Implement the F_SHORTER filter by doing explicit lookups for each possibleClaudio Jeker
prefixlen. Even for IPv6 this is much faster than a full table walk. OK tb@
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@