1
0
mirror of https://github.com/bgp/stayrtr.git synced 2024-05-06 15:54:54 +00:00

322 Commits

Author SHA1 Message Date
caad9d419f Cleanup unused struct fields 2023-02-21 22:14:20 +00:00
6e4c533e8a Fix client.sendLoop possibly leaking/CPU burning
Basically, until now it was not possible for it to actually
exit since the break only breaks the for loop it's connected in
2023-02-21 22:11:43 +00:00
19ca7b27e9 Add BGPsec Router Key support to rtrdump
Tag: https://github.com/bgp/stayrtr/issues/57
2023-02-21 22:05:50 +00:00
513bda0e5f Implement BGPsec support
This imports and exports BGPsec router key data, and exports router
key data out over RTR to supporting clients (any version higher than 1)

Since it's obvious that at some point there will be clients that will
have issues seeing a RouterKey PDU for the first time ever, I've
included a -disable.bgpsec flag to prevent them from being sent.

That way if someone is caught off guard during an upgrade, they can
disable it and keep upgrading.

Tag: https://github.com/bgp/stayrtr/issues/57
2023-02-21 21:55:50 +00:00
b08f5383ac Convert lib.VRP to *lib.VRP
This allows the previous commit to be fully effecitve.

Since some tests showed potential for a nasty set of pointer
edge cases to appear, I will be running rtrmon between this and
a known "okay" version for a few hours to confirm I have not broken
anything.
2023-02-21 21:15:13 +00:00
925ac75c42 Move all []VRP's to []SendableData in prep to support non VRP things
This does a bunch of work (and it's not fully done, since VRP needs
to be converted into *VRP across the codebase to ensure that SetFlag()
works) to let what was the VRPManager diffing/dispatch system support
things that are not VRPs. We need to do this since we are looking
to support BGPsec Router Keys and ASPA objects soon. And a previous
attempt to write such support resulted in a unaccptable amount of
duplicate code.

Doing it this way will also make it a lot easier to extend StayRTR
to support whatever is after ASPA.
2023-02-21 20:40:00 +00:00
a9d36b4707 Fix BGPsec ROUTER_KEY encoding/decoding
Also add a test to ensure it keeps decoding correctly
2023-02-21 19:52:36 +00:00
f8b0c87ec8 Merge pull request #83 from bgp/pledge
On OpenBSD restrict access to system calls with pledge()
2023-02-06 11:15:30 +00:00
535becd0c3 Merge pull request #87 from bgp/remove_sessionid_modifier
Always automatically generate a RTR Session ID
2023-02-06 11:14:10 +00:00
bd5a54d54d Always automatically generate a RTR Session ID 2023-02-06 11:10:07 +00:00
1319beff75 Merge pull request #84 from bgp/send_error_to_desync_clients
Bugfix: don't echo the router's session_id back to the router, instead report an error
2023-02-03 21:44:50 +00:00
d5be6983b5 Bugfix: don't echo the router's session_id back to the router, instead report an error
Previously StayRTR would copy the client's Session ID back into the Cache
Response send to the router, even though the cache's internal Session ID
was something different.

The purpose of the Session ID is to help both router and cache understand
whether they are synchronized or not. There are two opportunities to fix
desyncs: if the cache recognises the router is desynced, the cache informs
the router (through an Error Report) to reconnect and send a Reset Query.
If the router recognises it is out of sync with the cache, the router can
send a Reset Query.

According to RFC 8210 section 5.1 the cache should send "Corrupt Data" when
a router sends a Serial Query with an unknown Session ID:

```
  Session ID:  A 16-bit unsigned integer.  When a cache server is
    started, it generates a Session ID to identify the instance of the
    cache and to bind it to the sequence of Serial Numbers that cache
    instance will generate.  This allows the router to restart a
    failed session knowing that the Serial Number it is using is
    commensurate with that of the cache.  If, at any time after the
    protocol version has been negotiated (Section 7), either the
    router or the cache finds that the value of the Session ID is not
    the same as the other's, the party which detects the mismatch MUST
    immediately terminate the session with an Error Report PDU with
    code 0 ("Corrupt Data"), and the router MUST flush all data
    learned from that cache.
```

Reformat with gofmt from Ties
2023-02-03 21:37:30 +00:00
d9b3679d0a On OpenBSD restrict access to system calls with pledge() 2023-01-30 21:25:21 +00:00
3bc6c95061 Upgrade CodeQL to v2 2023-01-30 21:24:39 +00:00
f257f675ec Upgrade CodeQL to v2 2023-01-30 21:18:53 +00:00
949f7c457c Merge pull request #81 from hellt/nokia-examples
Added Nokia SR OS example configuration
2023-01-26 17:59:21 +01:00
cbf19feca3 added nokia sros examples 2023-01-26 17:45:42 +01:00
fa1f95967e update readme 2023-01-26 13:13:24 +00:00
b7159cae72 Add blurp about sponsors 2023-01-26 09:23:15 +00:00
ba724ad290 Make slurm and vrp-json updates happen in parallel
Tag: https://github.com/bgp/stayrtr/issues/53
v0.4.0
2023-01-25 23:57:38 +00:00
52a52e1895 Update loop now updates on a predictable basis
Previously if you had a very slow backend, the refresh timer for a reload
would only start after the current refresh has finished.

Now the timer will run after the timer fires for the last one.

This helps avoid the client being torpedod by very slow backends

Tag: https://github.com/bgp/stayrtr/issues/53
2023-01-25 12:06:42 +00:00
13659dd27e Filter VRPs if they have expired. Prevent stale JSON files from lingering
First, VRPs that have expiry times are now checked, and they are
filtered out at import time.

Second, If a VRP JSON file is too old, and the "current state"
(in the case of a update) is too old, the state will empty to avoid
routing on old data.

Third, Every time a refresh cycle now happens, the file is reprocessed
to check for expiry, if the resulting VRPs from that procesing changes
then a new update+serial is pushed

Tag: https://github.com/bgp/stayrtr/issues/15
2023-01-24 17:50:15 +00:00
7944d8f2d5 Auto start stayrtr on debian flavors, create missing directories
Now you can actually install stayrtr from the deb/rpm's made by
the Makefile, and they work!

Tag: https://github.com/bgp/stayrtr/issues/58
2023-01-23 14:58:00 +00:00
0e541d3cec Drop GoReleaser
We right now have two different ways of packaging stuff up, one
involves a Makefile and one involves https://goreleaser.com/

I was having issues with goreleaser outputing binaries in /usr/local/bin
rather than /usr/bin (To the best of my understanding, /usr/local/
is for stuff outside of the package managers remit, however we are
producing things that /are/ inside that)

Rather than fight with goreleaser, it's better to look at we have
two different ways, and the Makefile is a lot more approchable than
goreleaser (at least, strongly likely to the average person just
wanting to build the thing ™️)

Right now CI produces deb's and rpm's, and pushes a docker image to
https://hub.docker.com/r/rpki/stayrtr

I think that is likely good enough ™️ for now.
2023-01-23 14:43:01 +00:00
8198b3a2ec Fix RPM packages not being put in the artifact directories
Seemingly a FPM bug? I poked around in FPM for a while and /could
not/ get it to actually use --package at all, nor it's little -P.

So a quite move back into place should solve it instead.

Mildly Related Tag: https://github.com/bgp/stayrtr/issues/58
2023-01-23 14:42:56 +00:00
b165bfeac8 Correct packaged systemd service not starting stayrtr correctly
The package installs in /usr/bin/ but the systemd unit starts
a binary (that wont exist) in /usr/local/bin

Sinec this service file is only ever mentioned in the Makefile
for packaging, I belive this is a bug fix that has no other side
effects.
v0.001 v0.01
2023-01-20 16:44:20 +00:00
634ed94184 Merge pull request #75 from bgp/bencc-cleanups
Small codebase refactors / cleanups
2023-01-19 17:25:53 +00:00
d7dfb7cf43 Merge pull request #74 from bgp/make-means-build
Tweak Makefile to vet and build stayrtr and friends by default
2023-01-19 17:25:43 +00:00
13186622bd Improve internal error messaging to match standard convention 2023-01-19 12:17:23 +00:00
15503e8347 Use IP.Equal rather than bytes.compare
IP.Equal handles some edge cases inside how IP addresses are represented
rather than just flat out comparing some byte arrays blindly.
2023-01-19 12:15:41 +00:00
c90daccd3f Refactor convoluted ways to recieve a message from a single channel
Plus remove a pointless fmt.sprintf()
2023-01-19 12:12:44 +00:00
029060a6a1 Replace redudant errors.new(fmt.sprintf with fmt.errorf(
They serve the same function, but it's more understandable what
is going on. go-static-check raises this as a warning
2023-01-19 12:11:02 +00:00
17b7e94876 Fix possible crash when it cannot create output files 2023-01-19 12:08:29 +00:00
411d2b262b Remove redundant runtime.GOMAXPROCS() setting
The default value of runtime.GOMAXPROCS is the number of CPUs. So
there is no need for this line to exist.
2023-01-19 11:50:23 +00:00
49dafacf1f Tweak Makefile to vet and build stayrtr and friends by default
In general I belive it's accepted that the default action of
Make is to build. This change does exactly that.
2023-01-19 11:45:16 +00:00
ad3ed83abe Merge pull request #72 from erikrozendaal/detect-disappearing-vrps
Avoid false positives in rtrmon when VRPs are removed
2022-10-18 11:27:43 +02:00
88719fec73 Rename variable for clarity 2022-10-18 11:18:48 +02:00
3aff120fc4 Document why we keep FirstSeen in case of visible VRP 2022-10-18 11:18:28 +02:00
e2bcc18e4d Update inGracePeriod metric even when data source was not modified
Time still passes so VRPs may be dropped due to the expiration of the
grace period.
2022-10-18 11:11:06 +02:00
5a841b3c71 Go fmt 2022-10-18 11:01:19 +02:00
60e9818750 Ensure grace period is at least same as highest visibility threshold 2022-10-18 10:26:07 +02:00
a1a2e32281 Clone updated VRPs to avoid mutating shared state 2022-10-18 10:04:35 +02:00
2854ce3130 Re-run comparison even when both sides have no updates
However, time does change so we need to account for the new thresholds
and grace period.
2022-10-18 09:10:59 +02:00
0f047b25b2 Track visibility of VRPs to avoid false positivies when a VRP disappears 2022-10-17 16:14:33 +02:00
33ae5d9ec5 Merge pull request #71 from marenamat/fix-ssh-auth
Fixed SSH client key validation
2022-10-03 14:08:49 +02:00
4bd02cc8f3 Fixed SSH client key validation
The strings.HasPrefix() call was used with flipped argument order,
allowing incomplete rows in the authorized_keys file to any key matching
that prefix. In worst case, a line like

  ecdsa-sha2-nistp256

with no key at all would match all keys of that type.

On the other hand, when the key was followed by a comment as is common
in authorized_keys files, it wasn't matched at all.
2022-10-03 13:55:14 +02:00
8d18a41821 Merge pull request #70 from ties/feature/grace-period-for-diff
Grace period for diff
2022-07-12 14:57:40 +02:00
8e9b738548 fix linter nit 2022-07-12 14:41:19 +02:00
8e57e8e6e0 Add tests for rtrmon expiry logic 2022-07-12 14:40:22 +02:00
6149d5f25d Add metric for number of VRPs in grace period 2022-07-11 17:41:40 +02:00