Commit Graph

296 Commits

Author SHA1 Message Date
Lee Smet ec5ef0be1d Add abstraction for ip pubkey mapping
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 17:12:41 +02:00
Lee Smet 0e6681161e Add IP Trie dependency
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 15:19:34 +02:00
Lee Smet 89a5935e2c Add update filter to limit subnet size
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 14:41:39 +02:00
Lee Smet aed423ba34 Rework RoutingTable retain to remove_peer
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 12:59:42 +02:00
Lee Smet 36e69c105d Remove obsolete peer_by_ip and RouteEntry next_hop
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 11:46:39 +02:00
Lee Smet b4ff95577a Extract Peer from RouteEntry when sending
Also when removing routes in the routing table

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 11:44:20 +02:00
Lee Smet 97570c49e2 Add Peer in RouteKey instad of overlay IP
The babel spec mentions overlay IP, however we have a designated type
for this, so it's better to outright use that and avoid some hassle in
lookiing up the proper Peer later on

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 11:30:49 +02:00
Lee Smet dd9ad18ec4 Add network method to Subnet
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-19 10:25:01 +02:00
Lee Smet d9f1ae306d Conditionally enable linux only dependencies
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-18 15:31:11 +02:00
Lee Smet 3bb14e9a4a Cleaner transfer of tun read result
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-18 15:16:45 +02:00
Lee Smet 289fdff937 Rework Router to tkae a subnet for tun address
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-18 12:04:47 +02:00
Lee Smet b1584f4aea Use RoutintTable lookup method in router
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-18 12:04:17 +02:00
Lee Smet 0603ef4861 Add method to find route in routing table for IP
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-18 12:02:29 +02:00
Lee Smet f4dea15307 Add method to check if IP is contained in a subnet
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-18 12:01:42 +02:00
Lee Smet 094d0c57ef Close #24: use subnet filter for incoming updates
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-13 16:36:38 +02:00
Lee Smet c40a550f62 Add basic RouteUpdateFilter implementation
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-13 16:14:33 +02:00
Lee Smet 6a44994877 Add contains_subnet method for Subnet
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-13 16:10:59 +02:00
Lee Smet f3551f1428 Lower MTU to avoid physical nic MTU overflow
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-12 16:27:32 +02:00
Lee Smet 1a2b7994ba Add test flow for encryption and decryption flow
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-12 14:31:25 +02:00
Lee Smet b635484d64 Retain PacketBuffer allocation if it isn't used
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-12 12:57:26 +02:00
Lee Smet fb1e1efa2f Avoid reallocation in decrypt flow
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-12 11:13:46 +02:00
Lee Smet d18f8de813 Close #22: Avoid reallocations in encrypt flow
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-11 18:03:31 +02:00
Lee Smet 1dffc61206 Use dedicated RouterId type in existing code
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-11 14:55:46 +02:00
Lee Smet f6232ba034 Add dedicated RouterId type
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-11 14:55:29 +02:00
Lee Smet 22f307d57e Elide RoutingTable::iter lifetime bounds
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-11 10:28:41 +02:00
Lee Smet d06bd6e120 Make RoutingTable field private
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-11 10:25:25 +02:00
Lee Smet e09f1d7f49 Remove obsolete ControlStruct type
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-08 15:18:26 +02:00
Lee Smet e429f04625 Improve control packet handling
- Pass actual packet to handler function instead of wrapper enum.
- Pass the peer who sent the control packet instead of extracting the IP
  from the control packet and doing a lookup in the router.
- Rework PeerInner to only contain data, move the actual stream
  management task to the parent Peer.
- Inject a clone of the peer in the channel with the control packet.

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-08 14:59:00 +02:00
Lee Smet d07b6f86a6 Remove legacy commented code
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-08 14:10:46 +02:00
Lee Smet 0c8638a7ce Remove unused router function
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-08 14:09:46 +02:00
Lee Smet 6332946d08 Update dependencies to latest versions
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-08 14:09:25 +02:00
Lee Smet 0e932795ea Remove explicit rand and getrandom dependencies
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 16:08:43 +02:00
Lee Smet 8fcb8aaff3 Update x25519-dalek dependency to v2.0.0
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 16:07:03 +02:00
Lee Smet 5ec9ed8a58 Remove console-subscriber dependency
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 14:57:29 +02:00
Lee Smet 7d4cfd801f Remve leftover useless clone
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 14:29:35 +02:00
Lee Smet 97d073f918 Use synchronous routing method to send from TUN
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 14:02:33 +02:00
Lee Smet 40b5f9cd14 Refactor routing logic to a sync method as well
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 14:01:17 +02:00
Lee Smet 4c566957b3 Update tokio dependencies to latest version
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 11:56:16 +02:00
Lee Smet 06843b646a Remove commented line of code
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-07 11:38:47 +02:00
Lee Smet 2ec5274380 Clean up route priting
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-06 16:34:25 +02:00
Lee Smet 0b5d86835d Close #20: Implement dedicated subnet type
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-06 15:29:58 +02:00
Lee Smet 4ed14440f2 Implement a basic subnet module
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-06 15:27:28 +02:00
Lee Smet be06e5c0a0 Add IpNet dependency
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-06 13:20:32 +02:00
Lee Smet e1fadc1842 Disable Nagle's algorithm
Set TCP_NODELAY on TCP streams. By default, Nagle's algorithm is
enabled, which caused rather large latency spikes from time to time.
Making sure this is disabled leads to smooth latency graphs without
outliers

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-05 15:46:44 +02:00
Lee Smet 63aa5cd696 Change erronous return to continue
Leftover return after this was refactored from a closure to a while
loop, caused router exit in case invalid data was received.

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-01 16:49:06 +02:00
Lee Smet db2b99da04 Remove some useless clones
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-01 16:15:43 +02:00
Lee Smet fccb20ae6a Code cleanup
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-01 15:50:09 +02:00
Lee Smet bfa8e5d452 Rework code to avoid Sync requirement on router
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-09-01 15:47:08 +02:00
Lee Smet 4b36322a35 Switch router concurrency to left-right
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-08-31 18:35:36 +02:00
Lee Smet 3e27fbd484 Only wrap updates when sending
This avoids a needless match statement and allows proper type checking
for sending updates

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
2023-08-31 17:23:17 +02:00