summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/bgpd.c
AgeCommit message (Collapse)Author
2023-04-19Implement code to pass the flowspec config over to the RDE. The parentClaudio Jeker
process tracks which prefixes are added / removed and issues the corresponding imsg calls. Right now the RDE does nothing with the received information. OK tb@
2023-02-14No longer wait for the RTR process to finish the config reload beforeClaudio Jeker
sending the IMSG_RECONF_DONE message to the RDE. The RDE does not depend on the RTR config reload (in contrast to the SE). The ROA / ASPA reload is async from the RDE config reload. OK tb@
2023-01-20comma space not space commaClaudio Jeker
2022-11-18Add plumbing for ASPA support. This implements the parser and part of theClaudio Jeker
logic in the rtr process. It does not implement the new RTR messages yet but it is possible to specify an aspa-set in the config. Also the validation code in the RDE is missing so this does not do anything. With this in it will be possible to extend rpki-client to publish an aspa-set as part of the openbgpd config file. 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-07-28whitespace found during a read-thru; ok claudioTheo de Raadt
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-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-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-06-23Move struct kif from bgpd.h to kroute.cClaudio Jeker
The only user of struct kif was the session engine for the 'depend on' feature. Switch the imsg exchange to a new struct session_dependon and rename the IMSG as well. OK tb@
2022-06-22Use struct kroute_full in bgpd_filternexthop() so this code becomes a lotClaudio Jeker
simpler. OK tb@
2022-06-15Rename F_BGPD_INSERTED to F_BGPD and use F_BGPD_INSERTED as a flag thatClaudio Jeker
indicates that the route was successfully added to the FIB. Filter out dynamic routes, like it is already done for ARP and ND routes) and kill F_DYNAMIC. Also remove the protect_lo() bits. Adding dummy kroute entries does no longer prevent bad routes to hit the FIB. Also loopback IPs are checked in a few other places to prevent bad routes to be installed into the FIB. OK tb@
2022-06-09Remove the rdomain / rtableid passed to some kroute functions.Claudio Jeker
kr_nexthop_add() and kr_nexthop_delete() only operate on the main table so just pass in the right rdomain id. kr_shutdown() and kr_dispatch_msg() don't really need the rdomain passed. The was done for kif_remove(), since that function needs to remove connected routes from the rdomain table. Connected routes can only exists in the interfaces rdomain so just use kif->k.rdomain. If such routes exist that table exists as well. If the table does not exists there are also no connected routes to track. OK tb@
2022-06-05Rework how fib_priority is handled.Claudio Jeker
Instead of passing it around all the time put the fib_priority into the kroute state. It is only needed in send_rtmsg() in the end. Additionally insert F_BGP_INSERTED routes with a special RTP_MINE priority. This makes changing the fib_priority at runtime simpler because there is no need to alter the kroute table anymore. OK tb@ deraadt@
2022-06-02Adjust some warning messages to be a bit more accurate. ktable_update()Claudio Jeker
actually loads a routing table and not really an rdomain.
2022-02-06Switch from u_intX_t types to stdint.h uintX_t. Mostly mechanical withClaudio Jeker
a few reindents. OK florian@ tb@
2022-01-23On poll() failure we want to skip pollfd related action but the signalClaudio Jeker
delivery checks at the end still need to happen. So that on EINTR bgpd processes reconfigure or mrt files ASAP. Fix for mrt integration tests. Reported by and ok anton@
2022-01-20Make sure that all poll loops properly restart the poll loop on EINTR.Claudio Jeker
Also either fail hard or restart after other errors. In anycase do not look at pollfds after an error. OK benno@
2021-07-20Add -V to usage. Reported by Pier Carlo Chiodi.Claudio Jeker
2021-06-16Add command line option to show the versionjob
OK claudio@
2021-05-17Limit the number of concurrent RTR connects to 32.Claudio Jeker
If the limit is hit the request will be dropped and the rtr process will retry the connect after the retry timeout. Hopefully by then the number of connections is down again. OK deraadt@ benno@
2021-05-11Use non-blocking connect() to setup the RTR socket. connect() can hang forClaudio Jeker
a long time if the IP is not reachable and would block the main process while doing so. Problem noticed by Pier Carlo Chiodi OK benno@
2021-05-03Like in the session engine do not inline the addr2sa call into connect andClaudio Jeker
bind. The len argument is modified by addr2sa but is also used as argument in the call and it is undefined if the value of len in connect is set to the value "returned" by addr2sa(). Should fix connect issues seen on Linux system. OK denis@
2021-02-16Add RTR support to OpenBGPD. Add basic support for the protocol.Claudio Jeker
The RTR client runs in a new process where the protocol handling is done and when new data is available all sources are merged into one ROA set which is then loaded into the RDE. The roa-set from the config is also handled by the new RTR engine. Tested by and ok job@
2021-01-04Rename PFD_PIPE_ROUTE to PFD_PIPE_RDE which is a more obvious name.Claudio Jeker
Also change the startup code to use enum bgpd_process to select which process needs to be run. Makes the code in my opinion easier to understand. OK denis@
2020-12-30RB_REMOVE from the correct tree. Dumb copy paste bug introduced by last commit.Claudio Jeker
Noticed by procter@
2020-12-29In preparation for RTR support change the representation of the roa-setClaudio Jeker
in the parent to a simple RB tree based on struct roa. With this overlapping ROAs (same prefix & source-as but different maxlen) are now merged in the RDE when the lookup trie is constructed. OK benno@
2020-11-05Kill bgpd_process, nothing uses it anymore. Instead pass the processClaudio Jeker
type directly to log init. One less common in bgpd. OK benno@
2020-05-11There is no reason to limit the string length of log_reason() to REASON_LENClaudio Jeker
charactars. Also fix a long line. OK benno@ deraadt@
2020-05-10In bgpctl argument parser, re-arrange 'reason' parsing ('nei action [reason]')Theo de Raadt
to be more generic, then change 'reload' to take take a '[reason]' also, which will be logged by bgpd. ok kn claudio
2019-10-02In IMSG_PFKEY_RELOAD do not warn about unknown peers. When a peer isClaudio Jeker
removed the session engine will issue a IMSG_PFKEY_RELOAD call after the parent has removed the peer which is no problem and so no need to fill the log with this. OK benno@
2019-10-01For portable kr_init() returns an fd of -1 which now would end up in anClaudio Jeker
immediate exit of bgpd. Instead pass the fd via pointer arg. OK benno@
2019-08-08Parse the config file early on startup before bgpd is daemonized.Claudio Jeker
This way config errors will be directly user visible on startup. To do this split out send_config() out of reconfigure() which is sending the config to the SE and RDE. OK sthen@
2019-08-05Cleanup config reload in the RDE. Use the bgpd_conf struct to store setsClaudio Jeker
and l3vpns instead of temporary globals. Also rework rde_reload_done to free filters and sets earlier. The soft-reconfiguration process no longer needs the previous filters / sets to do its work since there is a full Adj-RIB-Out. OK benno@
2019-08-05Change the order how filtersets are passed during config reloads. InsteadClaudio Jeker
of sending them after e.g. the filter rule send them before. The benefit is that the filterset is present when a rule is added and so the filter rule is complete at that moment. OK benno@
2019-07-24mrt.h only needs to be included by mrt.cSebastian Benoit
ok claudio@
2019-07-23Clean up RIB related kroute code. Introduce a way to flush a FIB tableClaudio Jeker
from the RDE. Make sure that all nexthops don't get removed in the FIB when a FIB table is removed. This should only happen for the main FIB. Remove F_RIB_HASNOFIB which is just confusing since there is already F_RIB_NOFIB and F_RIB_NOFIBSYNC. OK benno@
2019-07-19When allocating socketpair() increase their send and receive buffers toClaudio Jeker
4 times the read size. This helps to increase the efficency of poll() since now most of the time the read and write call can operate on full buffers. OK benno@ phessler@
2019-05-29Rework pfkey handling a bit. The old remove then add way of inserting md5sigClaudio Jeker
hit a race frequently where a session ended up with no key/SPI in the kernel. Since there is no way to do atomic updates of SADB_X_SATYPE_TCPSIGNATURE the code is adding a new one then removing the old one. Also make sure keys are correctly cleared when peers are deconfigured. May not be perfect but a lot better than what was there before. Tested by and OK sthen@
2019-05-27Switch the peer TAILQ to a RB tree indexed by the peer id. This wayClaudio Jeker
getpeerbyid() gets a lot quicker at finding the peer when many peers are configured. In my test case the difference is around 20% runtime. OK denis@
2019-05-08when passing objects to imsg use the for 'obj, sizeof(*obj)' instead ofClaudio Jeker
'obj, sizeof(struct object)' OK benno@
2019-05-08Rework the TCP md5sig and IKE handling. Move the pfkey socket to the parentClaudio Jeker
process in this process. The refreshing of the keys is done whenever the session state is changes to state IDLE or ACTIVE. This should behave better when reloading configs with auth changes. OK benno@
2019-03-31Move the struct peer into bgpd_config and switch it to a TAILQ instead ofClaudio Jeker
the hand-rolled list. This changes the way peers are reloaded since now both parent and session engine are now merging the lists. OK denis@
2019-03-31Avoid calling dup2(oldd, newd) when oldd == newd. In that case theYASUOKA Masahiko
descriptor keeps CLOEXEC flag then it will be closed unexpectedly by exec(). ok tedu florian
2019-03-07Do a better job at cleaning up the config on shutdown. Remove bits thatClaudio Jeker
were missed before (e.g. network related objects). This helps to detect memory leaks. Start using new_config() and free_config() in all places where bgpd_config structure are used. This way the struct is properly initialised and cleaned up. Introduce copy_config() to only copy the values into the other struct leaving the pointers as they were. Looks good to benno@
2019-02-14mrt_timeout() can send out imsgs so better call it before doing the set_pollfdClaudio Jeker
this ensures that the imsgs go actually out right away.
2019-02-14mrt_timeout should just return -1 when there is no timeout set insteadClaudio Jeker
of some strange maximum. The poll loop in bgpd.c already limits the maximum wait time so there is no need to double it. While there switch to using time_t for the calculation. OK phessler@
2019-02-14Revert part of last commit, this stuff is unrelated.Claudio Jeker
2019-02-14Use -1 instead of the less portable INFTIM for the poll timeout.Claudio Jeker
Result is the same.