1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 07:27:59 -08:00
Commit Graph

2663 Commits

Author SHA1 Message Date
claudio
86da87d93e Bump version 2024-12-16 16:14:46 +00:00
claudio
0d4ceb4100 Prefix enum msg_type with MSG_ to prevent a duplicate symbol warning
for NOTIFICATION (which is also used in parse.y as token).
OK tb@ millert@ deraadt@
2024-12-16 16:10:10 +00:00
denis
5bfef6125a Fix wrong token name
OK claudio@
2024-12-14 21:24:31 +00:00
claudio
6c15f94398 Implement RFC 8538: Notification Message Support for BGP Graceful Restart
This is an extension to graceful restart and requires graceful restart to
be enabled to work. The NOTIFICATION bits are implemented as specified but
a much more strict stand was taken as to when send a graceful reset.

bgpd only sends graceful notifications for a few cease cases (same as in
the RFC) and for the holdtimer and sendholdtimer errors. Everything else
is a hard error because the other side is not trustworthy.

OK tb@
2024-12-13 19:21:03 +00:00
claudio
442a03204b Cache the Adj-RIB-Out for sessions that have not been down for more than
INTERVAL_SESSION_DOWN (3600) seconds.

Rebuilding the Adj-RIB-Out is a lot of work while keeping the RIB in sync
is reasonably trivial. So avoid the work for the case that a session
was just quickly reset. This only works if the same peer settings are
used in the old and new session.

For this introduce a IMSG_SESSION_DELETE that tells the RDE to remove the
peer and split peer_down into a part that takes the session down (and
clears the Adj-RIB-In) and a part the frees the peer (peer_delete).
The SE now sends an IMSG_SESSION_ADD command on first connect and skips
that imsg on later connects unless IMSG_SESSION_DELETE was called before.
During config reload the IMSG_SESSION_ADD calls only need to happen when
the RDE actually has that information.

OK tb@
2024-12-12 20:19:03 +00:00
claudio
f666252400 Introduce a peer_reaper() which asynchronously removes the Adj-RIB-Out
of a peer.

Once the peer is kind of done enqueue it onto the zombie list and then
the reaper will take care of the Adj-RIB-Out.
OK tb@
2024-12-11 09:19:44 +00:00
claudio
6df2f81829 In prefix_adjout_update() and prefix_adjout_withdraw() only link
prefixes to the update / withdraw queue if the peer is up.

For updates the Adj-RIB-Out is already updated and nothing more needs to happen.
For withdraws the prefix is unlinked and needs to be destroyed if the peer is
not up. For this to work correctly make the prefix as dead.

Right now this is a no-op since the functions are only called if the peer
is up.
OK tb@
2024-12-10 20:06:11 +00:00
claudio
6d701af4d6 A lot of space fixing and other minor consitency fixes that have no
effect on the code but reduce eyestrain.
OK tb@
2024-12-10 16:29:07 +00:00
claudio
1d44387dec Introduce a SessionDownTimer that is started when a session goes down
and is stopped when the session comes up (ESTABLISHED state).
Right now it is used to remove cloned sessions. For that the SessionDownTimer
is also started when a clone is created.
OK tb@
2024-12-10 14:34:51 +00:00
claudio
d31a879178 For ROUTE_REFRESH_REQUEST use peer_blast() since the Adj-RIB-Out is
already calculated. Saves a fair bit of work by skipping peer_dump().
OK tb@
2024-12-10 13:40:02 +00:00
claudio
fcf73b57ed Make the unknown AID case in pt_writebuf() a fatal error.
The pointer passed to pt_writebuf() is bad and there is no reason to limp
further. Someone else will trip over this at a later stage so better to
do it now.
OK tb@
2024-12-10 13:29:47 +00:00
claudio
c8208cf126 Refactor code around peer_dump.
Rename the upcall and done callbacks:
 - rde_up_adjout_force_upcall() to peer_blast_upcall() and same for done
 - rde_up_dump_upcall() to peer_dump_upcall() and same for done
Introduce peer_blast() which blasts out the Adj-RIB-Out including all
the route refresh messages (BEGIN_RR, EOR and END_RR) needed.
peer_dump() now always throttles the peer before starting the table walk to
fill the Adj-RIB-Out and calls peer_blast() in all cases (either directly or
via the peer_dump_done() call.
OK tb@
2024-12-10 12:23:42 +00:00
jmc
49f9fe9c73 increaded -> increased 2024-12-09 11:38:38 +00:00
claudio
25cbba3a33 Add support for extended messages (RFC8654)
This extends the maximum message size of BGP from 4096 to 65535.

This mostly follows rfc8654 with the following differences:
- NOTIFICATIONS are always truncated to fit in 4096 bytes.
- There is no message reduction using "attribute discard" in case of overflow.
- Large messages are only sent if both sides announced extended message support.
OK tb@
2024-12-09 10:51:46 +00:00
claudio
3a99c822f7 Only set the SO_RCVBUF and SO_SNDBUF on the socketpair to what we want.
Do not retry if that fails hoping for a different result.
OK tb@ kn@
2024-12-03 13:46:53 +00:00
claudio
ba04a0e746 Check in bgpctl show rib commands if the table / rib passed is
Adj-RIB-Out and in that case set F_CTL_ADJ_OUT on the request.
With this 'bgpctl show rib out' and 'bgpctl show rib table Adj-RIB-Out'
return the same results.
OK tb@
2024-12-02 16:31:51 +00:00
claudio
aaaf7e1f15 Remove the ASPA imsg size workaround now that imsg are large enough to
handle MAX_ASPA_SPAS_COUNT (10k) entries.
OK tb@
2024-12-02 15:13:57 +00:00
claudio
04e124822c Bump imsg size up to MAX_BGPD_IMSGSIZE (128k) to support extended messages
and more.
OK tb@
2024-12-02 15:03:17 +00:00
claudio
3417aeaedd Remove global queue_buf which is no longer used.
OK compiler
2024-12-02 13:46:11 +00:00
claudio
9509a1e638 Adjust the msgbuf parser callbacks in bgpd to the new API.
OK tb@
2024-11-26 13:59:54 +00:00
claudio
f1b790a573 Convert simple stuff in usr.sbin over to new imsgbuf_init behaviour
OK tb@
2024-11-21 13:38:14 +00:00
claudio
6a3db2bab8 Convert session.c to use the new msgbuf reader API.
OK tb@
2024-11-21 13:34:30 +00:00
claudio
eaff30a2cd Teach mrt_dump_bgp_msg() to use ibufs
OK tb@
2024-11-21 13:34:01 +00:00
claudio
c9c4d4e441 Pass the message to bgp_fsm as argument instead of stashing it in rptr.
This fixes many XXX in the parser functions since we now pass ibufs around.

OK tb@
2024-11-21 13:33:41 +00:00
claudio
9e5228dde3 Kill the bgp_msg struct and instead pass the type to session_sendmsg()
OK tb@
2024-11-21 13:33:14 +00:00
claudio
22b46a1fed Convert rtr_proto to use new msgbuf reader API.
OK tb@
2024-11-21 13:32:50 +00:00
claudio
98435822fc Replace imsgbuf_read_nofd() hack with the new imsgbuf API.
OK tb@
2024-11-21 13:31:37 +00:00
claudio
05453d673c Adjust bgpd to the new msgbuf API
The tricky bit here is the fact that the peer wbuf needs to be allocated
and freed in the right places (when a peer is setup and when it is freed).
During lifetime we just flush the msgbuf with msgbuf_clear().
mrt has a similar issue. I think that freeing the msgbuf in mrt_clean is right.

OK tb@
2024-11-21 13:29:52 +00:00
claudio
bb5614127f Adjust bgpd to the new msgbuf_write / ibuf_write API
OK tb@
2024-11-21 13:28:34 +00:00
claudio
cfaf74104d Do not abuse struct ibuf_read instead define local struct with the same fields.
All of this will die in the end. This is just a step towards that.
OK tb@
2024-11-21 13:27:40 +00:00
claudio
fa353a8f9b s/ibuf_add_buf/ibuf_add_ibuf/
OK tb@
2024-11-21 13:26:49 +00:00
claudio
16b0c81bb5 bgpd and smtpd include their own imsgbuf_read_nofd() implementation.
Adjust that one as well apart from that the conversion to the new
imsgbuf_read read behaviour is trivial.

OK tb@
2024-11-21 13:22:21 +00:00
claudio
31be28ca73 Use imsgbuf_queuelen() instead of accessing the w.queue member.
OK tb@
2024-11-21 13:18:37 +00:00
claudio
9cbf9e90b0 Use imsgbuf_clear() where appropriate instead of msgbuf_clear().
OK tb@
2024-11-21 13:17:56 +00:00
claudio
dd7efffe3c Rename imsg_init, imsg_clear, imsg_read, imsg_write and imsg_flush to
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-21 13:17:01 +00:00
claudio
c1aa9554a3 Convert imsg_write() callers to the new simplified return logic.
OK tb@
2024-11-21 13:16:06 +00:00
claudio
4fb4351109 Convert ibuf_write() callers to new simplified return logic.
OK tb@
2024-11-21 13:13:37 +00:00
claudio
e4dbe30d1e Use ibuf_write() to send BGP messages to peers instead of msgbuf_write().
This code does not need to pass fds so there is no need to call msgbuf_write.

OK tb@
2024-11-21 13:11:33 +00:00
claudio
ce33693d52 Introduce imsg_write() and use it instead of msgbuf_write().
imsg_write() is just a thin wrapper around msgbuf_write(). So this is
mostly search and replace.

OK tb@
2024-11-21 13:10:18 +00:00
claudio
674395a05a ibuf_get_string() was added to the ibuf API, remove local version
OK tb@
2024-11-21 13:05:23 +00:00
job
64468f86ca Reference SendHoldTimer RFC in bgpd(8)
OK claudio@
2024-11-06 12:01:39 +00:00
claudio
baad1f5d65 Fix logic to return CTL_RES_NOSUCHPEER. The RB_EMPTY check needs to be
reversed since no error should be printed if there are no neighbors
configured (yet).
OK tb@
2024-10-29 12:35:37 +00:00
claudio
8045fa89e1 Remove two fatalx calls in pt_fill since they are wrong.
L3VPN withdraws don't carry a labelstack (see util.c::nlri_get_vpn4()).
OK tb@
2024-10-28 12:05:00 +00:00
claudio
a2dc744ed1 Make it possible to configure tcp md5 and ipsec on rtr as well
Single out the auth_config yacc rules. Even though this requires an
extra merge_auth_conf() function to handle manual IPsec setups but
even with that this seems like a net gain.

There is no rtr cache that does tcp md5 on OpenBSD so those bits remain
untested for now.
OK tb@
2024-10-09 10:01:29 +00:00
claudio
cd16358eb0 Extend the socket handover from parent to rtr process to also include teardown
This is needed to support tcp md5sum and ipsec auth for rtr.
OK tb@
2024-10-08 12:28:09 +00:00
claudio
69319e3ad6 No need to check as->established before calling pfkey_remove().
Remove the extra checks in the caller and simplify some code because of that.
OK tb@
2024-10-02 09:45:29 +00:00
claudio
63c2b4966a Explicitly set peer.auth_conf.method, the auth_state value is never
initialized in the SE so bgpctl did always see 0, auth_conf.method
is on the other hand properly shared.
OK tb@
2024-10-01 18:31:10 +00:00
claudio
8f5501c15d In merge_peers also copy over the auth_conf from the new peer to the old
since that one is kept.
OK tb@
2024-10-01 18:29:34 +00:00
claudio
14a2db8031 Fix typo in comment
OK tb@
2024-10-01 18:28:17 +00:00
claudio
d762911438 Rework the pfkey and tcp md5 API to not depend on struct peer.
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-10-01 11:49:24 +00:00