summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/bgpd.c
AgeCommit message (Collapse)Author
2024-12-03Only set the SO_RCVBUF and SO_SNDBUF on the socketpair to what we want.Claudio Jeker
Do not retry if that fails hoping for a different result. OK tb@ kn@
2024-12-02Remove the ASPA imsg size workaround now that imsg are large enough toClaudio Jeker
handle MAX_ASPA_SPAS_COUNT (10k) entries. OK tb@
2024-12-02Bump imsg size up to MAX_BGPD_IMSGSIZE (128k) to support extended messagesClaudio Jeker
and more. OK tb@
2024-11-21Convert simple stuff in usr.sbin over to new imsgbuf_init behaviourClaudio Jeker
OK tb@
2024-11-21bgpd and smtpd include their own imsgbuf_read_nofd() implementation.Claudio Jeker
Adjust that one as well apart from that the conversion to the new imsgbuf_read read behaviour is trivial. OK tb@
2024-11-21Use imsgbuf_queuelen() instead of accessing the w.queue member.Claudio Jeker
OK tb@
2024-11-21Use imsgbuf_clear() where appropriate instead of msgbuf_clear().Claudio Jeker
OK tb@
2024-11-21Rename imsg_init, imsg_clear, imsg_read, imsg_write and imsg_flush toClaudio Jeker
imsgbuf_init, imsgbuf_clear, imsgbuf_read, imsgbuf_write and imsgbuf_flush. This separates the imsgbuf API from the per-imsg API. OK tb@
2024-11-21Convert imsg_write() callers to the new simplified return logic.Claudio Jeker
OK tb@
2024-11-21Introduce imsg_write() and use it instead of msgbuf_write().Claudio Jeker
imsg_write() is just a thin wrapper around msgbuf_write(). So this is mostly search and replace. OK tb@
2024-10-08Extend the socket handover from parent to rtr process to also include teardownClaudio Jeker
This is needed to support tcp md5sum and ipsec auth for rtr. OK tb@
2024-10-01Rework the pfkey and tcp md5 API to not depend on struct peer.Claudio Jeker
Instead use struct auth_config and struct auth_state in the pfkey calls and those tcp_md5 calls where it matters. This is preparation work to allow RTR to use TCP MD5 as well. OK tb@
2024-09-30In bgpd_rtr_connect() do the setsockopt dance for IP_TOS and TCP_NODELAYClaudio Jeker
before calling connect(). This way it happens for sure and on top the TOS is already set on the initial SYN. OK tb@
2024-09-04Qualifying nexthops via BGP does not properly work since nexthops needClaudio Jeker
to be rechecked when a BGP route is added (or changed). We need to revalidate nexthops on inserts (kroute_insert) and on change (krX_change but only for AID_INET and AID_INET6 -- no nexthops in the other tables) the nexthop needs to be updated. Only validate nexthops if 'nexthop qualify via bgp' is enabled. For route changes the code can depend on the F_NEXTHOP flag. Fix for: https://github.com/openbgpd-portable/openbgpd-portable/issues/81 OK tb@
2024-09-04Call pfkey_remove() only after the Session Engine finished reloading itsClaudio Jeker
configuration. Doing so before could result in some messages being sent out without proper TCP-MD5 signature. Fix for: https://github.com/openbgpd-portable/openbgpd-portable/issues/82 OK tb@
2024-08-12Add 'min-version' RTR config option and default to RTR version 1 by default.Claudio Jeker
The min-version pins a minimal required version for rtr session. This is needed if specific PDUs are required and it ensures that the session is not suddenly downgraded. This is important for ASPA where a minimum version of 2 is required. Only then the ASPA PDUs are transmitted. By default a RTR version of 1 is used but setting min-version to 2 will enable draft-ietf-sidrops-8210bis-14 support and enforce it at the same time. Right now defaulting to version 2 is not possible since draft-ietf-sidrops-8210bis failed to progress for a too long time resulting in split eco system with various incompatible RTR version 2 implementations. OK tb@
2024-05-15Mark RTR and IPv6 BGP packets with DSCP CS6 (network control)Job Snijders
Additionally, set TCP_NODELAY on the RTR socket, there is no need to queue up messages towards the RTR server. OK claudio@
2024-04-09Check that the ASPA tas array fits in an IMSG before sending the ASPAClaudio Jeker
record over to RTR or the RDE. The long term goal is to increase the IMSG size considerably but that requires some additional API changes to the imsg API. OK tb@
2024-01-09Convert the parent process imsg handling over to the new imsg API.Claudio Jeker
This simplifies the code a fair bit and removes direct unchecked memory access to imsg.data. OK tb@
2024-01-04Rename argument roa of imsg_send_sockets() to rtr since the imsgbuf isClaudio Jeker
for PROC_RTR.
2023-11-07Rename struct imsgbuf *ibuf to *imsgbuf in all places.Claudio Jeker
ibuf should be reserved for struct ibuf * values. OK tb@
2023-08-16Remove per-AFI ASPA handling in bgpd internalsClaudio Jeker
With draft-ietf-sidrops-aspa-profile-16 and draft-ietf-sidrops-aspa-verification-15 the AFI dependence of ASPA records was dropped. So remove this complication form the code. This only removes the AFI handling internally in bgpd but still allows the old syntax in aspa-set tables. The optional address family is just ignored and records are merged together. For RTR sessions draft-ietf-sidrops-8210bis has not yet been updated so right now we still handle RTR sessions as specified there. The IPv4 and IPv6 ASPA entries are handled in two trees and merged together into one AFI independent tree. This is the best we can do for now until IETF updates draft-ietf-sidrops-8210bis. OK tb@ job@
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@