summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
AgeCommit message (Collapse)Author
2021-04-08The path with the *highest* local weight is selectedDaniel Jakots
ok kn
2021-03-08When introducing prefix_eligible() I botched up one if statement.Claudio Jeker
For nexthops it is fine if they point to NULL. This is used in local announcements. Only if they point to a real struct the state must be NEXTHOP_REACH. Bug reported by and OK florian@
2021-03-02Introduce 'rde evaluate all' a mode to work around path hiding in IXPClaudio Jeker
route-server environments. By default only the best path is sent to peers and if that path is filtered then the path is hidden for that peer. On route-servers this is sometimes not desried. For this 'rde evaluate all' will cause the evaluation process to fall back to alternate routes and will redistribute the first non-filtered path to the peer. This is very similar to per-peer RIBs but accomplishes the same effect without the massive increase in memory usage. Compared to the default mode this requires more CPU resources but it is probably less than what per-peer RIBs would require. 'rde evaluate all' can be set and reset globally, on groups and on idividual neighbors. It is not limited to route-server configs but route loops are possible if not properly used. OK benno@
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-02-02Properly implement 'rde med compare strict' and make sure that the orderClaudio Jeker
of prefixes is always correct. The strict RFC4271 way of checking MED is requires to check the neighbor AS and only do the check if the AS are equal. Because of this it is possible that inserting or removing a route reshuffles the total order. prefix_cmp() was extended to return the location where the decision happened: - 0 if the decision was before the MED comparison or med compare always is set - 1 if the decision happened after the MED comparison - 2 if the MED made caused the decision With this the new functions prefix_insert() and prefix_remove() are able to decide if more prefixes need to be evaluated (testall was not 0.) and if prefixes need to be re-evaluated after this one was put (testall = 2). There is a local redo list where prefixes where the MED resulted in a reshuffle are put on. After the new prefix is inserted all prefixes on the redo list are reinserted. Because now all affected MED routes get reevaluated the order is always correct.
2021-02-01update the pathname for the control socket path; from daniel jakotsJason McIntyre
clean up FILES while here ok claudio for the former
2021-01-27spelling fixes;Jason McIntyre
2021-01-25RFC6472 discourages the use of AS_SET segements in ASPATH attributes.Claudio Jeker
The main reason is that AS_SET does not play nice with RPKI ROA. Introduce a per neighbor and global config option 'reject as-set yes' and 'reject as-set no' If set to yes received UPDATES with AS_SET segements are rejected. This is done the same way other ASPATH soft-errors are handled. The UPDATE is marked invalid and all prefixes are treated as withdraws. `bgpctl show rib in error` can be used to show prefixes that where denied and treated as withdraws because of errors. By default this feature is off. OK benno@
2021-01-18Change struct bgpd_addr VPN encoding. Instead of including two almostClaudio Jeker
equal versions put the RD and lable stack right into struct bgpd_addr. For non-VPN addresses these extra fields are ignored. Since VPN and non-VPN addresses encode the prefix in the same way now some code can be simplified. In most cases a fallthrough or reuse of encoding functions is now possible. It should also reduce the size of struct bgpd_addr a bit. OK denis@
2021-01-16aspath_neighbor() needs to return the local system AS for empty AS pathsClaudio Jeker
but also for AS paths starting with an AS_SET segment. RFC4271 wants this and it also makes sense for all the cases where aspath_neighbor() is used in bgpd. OK denis@ job@
2021-01-14Cleanup prefix_cmp() a bit. Make sure that the return value can not overflowClaudio Jeker
the int type by doing calculations on bigger types. Instead just do a > and < check. Also improve the remote_addr test by using the same address comparison as in other places. OK benno@
2021-01-13Extend prefix_evaluate() to also be used when withdrawing a prefix.Claudio Jeker
Doing the LIST_REMOVE() outside of prefix_evalute() is no longer valid. As a benefit it is now simply possible to re-evaluate a prefix by passing it to prefix_evaluate() for both removal and insertion. prefix_evaluate() will then take care to ensure that a update is sent out if necessary. Also move rde_send_kroute() call to rde_generate_updates() to make it a bit easier to plug this module into a regress test. OK denis@
2021-01-09Move peer related checks from up_test_update() to rde_generate_updates()Claudio Jeker
both the export check and the address family check should be done as early as possible since these peers will not need any kind of updates to happen. Also remove the non-standard ORIGINATOR_ID check. With this up_test_update() becomes a simple true/false function which makes the rest of the code a bit simpler. OK benno@
2021-01-05It is safe to call addr2sa with a bgpd_addr NULL pointerClaudio Jeker
2021-01-05Revert part of the last addr2sa change. When addr is NULL or AID_UNSPECClaudio Jeker
addr2sa needs to return NULL. Without this connection establishment fails because bind is called with a bad sockaddr.
2021-01-05Add AID_VPN_IPv[46] support to addr2sa. It only converts the address partClaudio Jeker
of the VPN address into a sockaddr but it allows to use log_sockaddr for all cases of log_addr now. OK florian@
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@
2021-01-04Rework roa_cmp() so that the result does not depend on the endianess ofClaudio Jeker
the system. While at use memcmp in prefixset_cmp() as well for address checks. OK florian@
2021-01-04Use log_sockaddr() in log_addr() to print a struct bgpd_addr. This wayClaudio Jeker
IPv6 scoped addresses will print correctly. OK tb@ florian@
2020-12-30Implement IMSG_CTL_SHOW_SET to get information about roa-set, as-sets andClaudio Jeker
prefix-sets loaded into the RDE. For now only the number of prefixes or asnumbers are shown plus the time since the last change was done to the table. OK benno@
2020-12-30Use correct IMSG type in fatal message. Also reformat some not so long lines.Claudio Jeker
Bad IMSg name noticed by proctor@
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-12-29getifaddrs() can return entries where ifa_addr is NULL. Check for thisClaudio Jeker
before accessing anything in ifa_addr. OK florian@
2020-12-29Only skip routes with a loopback gateway for network static and connected.Claudio Jeker
For network rtlabel and priority skip this check since there the operator may actually want to distribute this network explicitly (even though it is probably a reject or blackhole route). Requested by dlg@ OK benno@
2020-12-23BGP uses KEEPALIVE packets and the HOLD timer to detect stalled sessions.Claudio Jeker
The problem is that this timer only looks at the receive side of the TCP session. If for some reason the send side stalls the system fully depends on the remote BGP peer to reset the session. As seen in an ever growing OutQ and as a result important changes can get stalled and cause routing troubles. This change introduces a SEND HOLD timer. The timer is reset whenever the session engine was able to write data to the TCP socket. If the send hold timer expires bgpd was not able to send any data to that neighbor for at least 90 seconds and therefor the session is forcefully closed with a hold timer expired notification. The send hold timer acts as a last resort to detect faulty peers. On an idle session it can take a long time until this timer triggers but the main goal here is to reset a stuck session at some point which did not happen before. With and OK job@
2020-12-11Make the timer code independent of struct peer this way it can be usedClaudio Jeker
in other places as well. ok procter@
2020-12-04Reference count prefixes added to a pftable. This allows to exportClaudio Jeker
prefixes from multiple sessions into the same table. Before a prefix was removed from the table on the first withdraw (even though there was an alternative around). Requested by, tested and OK dlg@
2020-12-03rework the overflow checks for the various relative metric adjustments.Claudio Jeker
This test no longer depends on specific overflow behaviour. OK millert@
2020-11-05Mark some common symbols of RDE and SE as static so that linkingClaudio Jeker
with -fno-common does not fail. OK bcook@
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-11-05Refactor the filterset handling of nexthops. Instead of depending onClaudio Jeker
bgpd_process and changing the behaviour that way add a new filterset type ACTION_SET_NEXTHOP_REF which is used when the nexthop reference of the union is used. Adjust the RDE to convert ACTION_SET_NEXTHOP to ACTION_SET_NEXTHOP_REF when receiving the filtersets. OK benno@
2020-11-05Refactor the control code to be more like a module.Claudio Jeker
Change control_dispatch_msg() to return the change of control connection count since the return value was not used before. Add control_fill_pfds() to replace the TAILQ_FOREACH loop in session.c. This allows to move the ctl_conns symbol to control.c (from session.h where it caused issues when compiled with -fno-common). OK benno@
2020-11-05Fix comment to better reflect realityClaudio Jeker
2020-10-27Do not allow configuration of the same neighbor multiple times. For thisClaudio Jeker
the parser needs to check if the remote address is already in the RB tree. Additionally fixup get_id to also compare the remote_masklen and fix some memory leaks on parser failures. Fixes a bgpd fatal on reload reported by Pascal Mathis. OK benno@
2020-10-26Fix a memory leak when parsing roa-set lists. If the prefixset_item isClaudio Jeker
already in the RB tree free the item we tried to add since the item form the RB tree is used. Memory leak found and fix provided by Felix Maurer ( felix at felix-maurer.de)
2020-10-21rde_update_dispatch() was switched to void some time ago. There is noClaudio Jeker
need to use or set error anymore. OK deraadt@
2020-10-21Move tmp16 declaration into the #ifdef __KAME__ block to remove a compilerClaudio Jeker
warning on non __KAME__ systems. OK deraadt@
2020-10-21For portability include sys/types.h instead of sys/cdefs.h.Claudio Jeker
cdefs.h may not exist on some systems and the portable framework uses sys/types.h to define __dead. OK deraadt@
2020-06-27Replace TAILQ concatenation loop with TAILQ_CONCATbket
OK claudio@
2020-06-05Remove redundant codedenis
Reported by Prof. Dr. Steffen Wendzel <wendzel @ hs-worms . de>, thanks! OK martijn@ sthen@
2020-05-16list example files in FILES with a short description: generally, "ExampleJason McIntyre
configuration file.", but occasionally something else fit better; at the same time, try to make the format for FILES more consistent; original diff from clematis
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
2020-05-08Do not use string litterals in the grammar ("{") it is not POSIX compliantClaudio Jeker
and also not needed. This just needs a char lookup ('{') like it is done in all the other rules with '{'. With this parse.y can be compiled with bison. OK otto@ benno@
2020-05-02The warning "bad AGGREGATOR, AS 0 not allowed ..." is not very helpful.Claudio Jeker
Make it a log_debug() instead to reduce the noise seen on most full feeds. The DFZ is currently not clean enough to properly drop AS 0 in that case. OK job@ deraadt@
2020-04-23 ce examples of "Ar arg Ar arg" with "Ar arg arg" and stop the spread;Jason McIntyre
2020-04-23replace examples of "Ic arg Ic arg" with "Ic arg arg" and stop the spread;Jason McIntyre
2020-04-23Try to document 'no local-address'Claudio Jeker
2020-04-23Store local-address by address family. This allows to configure bothClaudio Jeker
an IPv4 and IPv6 local-address on a group and the neighbors bind to the right local-address. Also implement 'no local-address' to reset a previously set local address back to zero. This should help with IBGP and multihop session config and hopefully reduce repetition in bgpd configs. OK sthen@ benno@