summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
AgeCommit message (Collapse)Author
2023-12-14Mostly straightforward conversion to imsg_get_fd() only the handlingClaudio Jeker
of the control socket needs a local variable since imsg_get_fd() can only be called once on an imsg. OK tb@
2023-11-07Rename struct imsgbuf *ibuf to *imsgbuf in all places.Claudio Jeker
ibuf should be reserved for struct ibuf * values. OK tb@
2023-11-07Alter imsg_move() to clear the full imsg buffer instead of just theClaudio Jeker
imsg->data field. This is needed for future imsg API changes. OK tb@
2023-11-04Use proper length in session_newmsg() for the RFC9072 case.Claudio Jeker
Right now OpenBGPD can not produce so many capabilities that this case is reached but still better to fix it now. OK tb@
2023-10-27Simplify the handling of optparamlen and RFC9072 support.Claudio Jeker
Use the ibuf_size() of the optional params (opb) when writing the various headers. Only use optparamlen to write the Opt Parm Len field of the OPEN message. Since there the size could be forced to 255 in case of a RFC9072 exended header. Also use size_t for optparamlen since the new ibuf API no longer depends on using the right sized type. OK tb@
2023-10-27The holdtime is added to the ibuf with ibuf_add_n16() so no need toClaudio Jeker
htons() the value before. OK tb@
2023-10-23Use xoff instead of *olen in the shift_right() call. xoff is the rightClaudio Jeker
value here since *olen is (conditionally) set a few lines later to the same value as xoff. Should fix the CodeQL warnings because *olen is dereferenced without proper NULL check. OK tb@
2023-10-19While the ibuf_add calls should not fail the way they are used itClaudio Jeker
is still better to check for error. OK tb@
2023-10-19Convert rtr_proto.c to use new ibuf API.Claudio Jeker
More yak shaving required which will follow. OK tb@
2023-10-19Convert the session engine to use the new ibuf API.Claudio Jeker
OK tb@
2023-10-17Neither sin_len nor sin6_len can be 0 so these checks are not needed.Claudio Jeker
Also reorder the RTF_HOST vs netmask check. RTF_HOST wins if both are set. Makes the code a bit neater. OK tb@
2023-10-17Remove bogus plen != 0xff checkClaudio Jeker
OK tb@
2023-10-16Improve IPv6 link-local address handlingClaudio Jeker
When a session is established determine the possible interface scope of that session. The scope is only set when the remote address is directly connected. This interface scope is passed to the RDE that uses this information when link-local nexthops are received. Again checking that a link-local nexthop is actually acceptable. OK tb@
2023-10-14Rewrite log_peer_info() and log_peer_warn[x]()Claudio Jeker
Passing the peer description as part of the format string was a bad idea since the peer description may include some % signs (e.g. for link local IPv6 addresses). So instead of asprintf a new fmt string use vasprintf to get the message and then use logit("%s: %s", peer_info, msg). OK tb@
2023-10-13Add missing Ns in argument list of announce (IPv4|IPv6) ...Claudio Jeker
2023-10-12Before calling rde_generate_updates() with EVAL_ALL ensure that the newClaudio Jeker
path is actually eligible. If this is not the case pass NULL instead. This is an optimisation to bypass extra work if both old and new path were ineligible. OK tb@
2023-10-12In up_generate_addpath_all() ensure that the new prefix is valid.Claudio Jeker
This should fix a fatal error reported by Arend Brouwer (arend at eritap com) when "announce add-path send all" is used. As a workaround "announce add-path send best plus 500" can used. OK tb@
2023-10-11Bump version for -portable releaseClaudio Jeker
2023-10-10When rewriting community_writebuf() the handling of non-transitiveClaudio Jeker
ext-communities was put into the wrong place in the loop finding start, end and number of communities to dump. As a result the end pointer for regular communities can point at an ext-community and with that the COMMUNITY attribute written includes unexpected extra bytes. This in turn causes the peer to send a NOTIFICATION error and to terminate the session. Fix for -portable issue #64 reported by Pier Carlo Chiodi (pierky) OK tb@
2023-10-09Fix return value confusion of sa_cmp() by renaming the function sa_equal().Claudio Jeker
The code in get_alternate_addr() checked for sa_cmp() == 0 but actually sa_cmp() returned 1 for equal addrs. So rename the function to sa_equal() to make it clear that a true return value means equality. Found by Asa Yeamans (enigma2e at rivin net) OK tb@
2023-09-28Prep for OpenBGPD 8.2Claudio Jeker
2023-09-28Enforce NUL termination of the neighbor shutdown reason sent fromClaudio Jeker
bgpctl before calling strlcpy() with that string. OK tb@ some long time ago
2023-08-30Introduce CTL_RES_OPNOTSUPP as possible error response for bgpctl whichClaudio Jeker
can be used in -portable for features that are not available in the build. OK tb@
2023-08-16ASPAs are AFI-agnosticJob Snijders
OK claudio@
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-08-04Instead of forcing a NUL into struct ctl_neighbor descr adjust theClaudio Jeker
peer matching code to only match at maximum sizeof(n->descr) bytes using strncmp(). OK tb@
2023-07-20Use sizeof(destination) not sizeof(source) in strlcpy() calls.Claudio Jeker
OK tb@
2023-07-14Cleanup mrt message handling. Remove the DUMP_XYZ() macros and replaceClaudio Jeker
them with direct calls to for example ibuf_add_n16(). Further cleanup the error handling and use goto fail in most places. Remove many of the error messages and combine all the possible ibuf errors in one place. For this remove most warnings from internal functions (also mark all internal helper functions with static to make that more obvious). There are still some cases where an error will result in to warnings but those errors are unreachable in normal operations. OK tb@
2023-07-12Update OpenBGPD to use new ibuf API.Claudio Jeker
This replaces the old way of using a static buffer and a len to build UPDATEs with a pure ibuf solution. The result is much cleaner and a lot of almost duplicate code can be removed because often a version for ibufs and one for this static buffer was implemented (e.g. for mrt or bgpctl). With and OK tb@
2023-07-12In rde_attr_parse() if an attribute causes a parse error which results inClaudio Jeker
a treat-as-withdraw consume the full attribute by updating plen else the parser will fail parsing a possible next element which results in a session reset. Initial report by Ben Cox (ben at benjojo.co.uk) OK tb@
2023-07-11Bump version for -portable releaseClaudio Jeker
2023-06-17Fix 'ext-community * *' matching and with this set { ext-community delete * * }.Claudio Jeker
Problem reported by Moyaze Shivji OK tb@ job@
2023-06-12Use attr_writebuf() instead of hand rolling a more complicated versionClaudio Jeker
for IMSG_CTL_SHOW_RIB_ATTR. Also drop the attr_optlen() usage in imsg_create() since it is not stricly needed. With this attr_optlen follows the path of the dodo. OK tb@
2023-06-12Use data != NULL to be more explicit. No functional change.Claudio Jeker
OK tb@
2023-06-01Check the F_NEXTHOP flag on the right kroute6 object.Claudio Jeker
On multipath routes the check ended up checking the wrong route for the nexthop update. This resulted in a use-after-free in kroute_detach_nexthop(). This only affects IPv6 in the IPv4 code path the right object was already used. Thanks to sthen@ for providing the debug information to track this down. OK sthen@ tb@
2023-05-25In session_process_msg() recheck the validity of the rbuf before movingClaudio Jeker
the remaining data around. There is an improbable case where a NOTIFICATION is received while also reaching the MSG_PROCESS_LIMIT. In this case rbuf is NULL when breaking out of the for loop and hitting this code. sthen@ is the (un)lucky person to hit that improbable case OK tb@ sthen@
2023-05-09Properly handle references for nexthops and labels in filterset_copy()Claudio Jeker
Up until recently filterset_copy() was only used in the parent process where none of those references exist but by using filterset_copy() in the RDE to populate per-peer output filters the code needs to handle such references. Without this rules like 'match to any set nexthop X' will cause internal corruption on config reloads and session resets. Bug report from Marko Cupac (marko.cupac (at) mimar.rs) OK tb@
2023-05-05Pass ASPA objects in reverse since this is what aspa_add_set() expects.Claudio Jeker
OK tb@
2023-05-05Limit the socket buffer size to 64k for all sessions. Long time agoClaudio Jeker
setting the size to 64k was increasing the size but now auto-scaling could grow the buffer size much more. The origianl idea was that sessions without protection had a small window size to make window attacks harder. This problem was fixed long time ago and is no longer relevant. Limiting the buffer size to a reasonable size ensures that not too many updates end up queued in the TCP stack. OK benno@ (some time ago)
2023-05-01Bump to 8.0Claudio Jeker
2023-04-28Add explicit default labels in switch() statements with error handling.Claudio Jeker
Right now these are not reachable. Should also clear some gcc warnings. OK tb@
2023-04-26Add prototypes for geticmptypebyname() and geticmpcodebyname().Claudio Jeker
Needed for bison.
2023-04-23Add the same AID filter to prefix_flowspec_dump() like in the otherClaudio Jeker
prefix/rib dump functions. OK tb@
2023-04-21Adjust ext community handling to support the generic transitive communitiesClaudio Jeker
introduced with flowspec. OK tb@
2023-04-21Missing space noticed by Pablo Mendez HernandezClaudio Jeker
2023-04-21Sync common code with bgpctl with the version from there.Claudio Jeker
OK tb@
2023-04-20Rework the way transit provider AID masks are built and sent to the RDE.Claudio Jeker
ASPA provider AS sets can include optional limitations to inet/inet6 these limits are represented in the TAS_AID bit masks (2bits per AS). Introduce a TAS_AID_SIZE() makro that returns the size in bytes of this bit mask (rounded to the next uint32_t). Without this change aspa objects with AID specific elements trigger a fatal error condition when the config is loaded. OK tb@ job@
2023-04-20Implement IMSG_CTL_SHOW_FLOWSPEC and IMSG_FLOWSPEC_FLUSH and add bits forClaudio Jeker
IMSG_FLOWSPEC_ADD and IMSG_FLOWSPEC_REMOVE received from bgpctl via SE. OK tb@
2023-04-20Document flowspec in bgpd.conf.5Claudio Jeker
Input and OK jmc@ tb@
2023-04-19Reshuffle the flowrule yacc rules to be in a more logical and alphabeticalClaudio Jeker
order.