Skip to content

Commit cdfec82

Browse files
committed
linux-specific fixes to IpPacketRouter
1 parent 888a3d8 commit cdfec82

File tree

5 files changed

+13
-25
lines changed

5 files changed

+13
-25
lines changed

common/wireguard-private-metadata/server/src/http/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
// Copyright 2025 - Nym Technologies SA <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4+
use nym_wireguard::WgApiWrapper;
45
use std::sync::Arc;
5-
66
use tokio::task::JoinHandle;
7-
use tokio_util::sync::CancellationToken;
8-
9-
use nym_wireguard::WgApiWrapper;
107

118
pub(crate) mod openapi;
129
pub(crate) mod router;
@@ -20,7 +17,6 @@ pub(crate) mod state;
2017
/// AFTER you have shut down BG tasks (or past their grace period).
2118
#[allow(unused)]
2219
pub struct ShutdownHandles {
23-
axum_shutdown_button: CancellationToken,
2420
/// Tokio JoinHandle for axum server's task
2521
axum_join_handle: AxumJoinHandle,
2622
/// Wireguard API for kernel interactions
@@ -30,13 +26,8 @@ pub struct ShutdownHandles {
3026
impl ShutdownHandles {
3127
/// Cancellation token is given to Axum server constructor. When the token
3228
/// receives a shutdown signal, Axum server will shut down gracefully.
33-
pub fn new(
34-
axum_join_handle: AxumJoinHandle,
35-
wg_api: Arc<WgApiWrapper>,
36-
axum_shutdown_button: CancellationToken,
37-
) -> Self {
29+
pub fn new(axum_join_handle: AxumJoinHandle, wg_api: Arc<WgApiWrapper>) -> Self {
3830
Self {
39-
axum_shutdown_button,
4031
axum_join_handle,
4132
wg_api,
4233
}

gateway/src/node/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,13 @@ impl GatewayTasksBuilder {
508508
ecash_manager,
509509
self.metrics.clone(),
510510
all_peers,
511-
self.shutdown_tracker.clone(),
511+
self.shutdown_tracker.clone_shutdown_token(),
512512
wireguard_data,
513513
)
514514
.await?;
515515

516516
let server = router.build_server(&bind_address).await?;
517-
let cancel_token = self.shutdown_tracker.clone();
517+
let cancel_token = self.shutdown_tracker.clone_shutdown_token();
518518
let server_handle = tokio::spawn(async move {
519519
{
520520
info!("Started Wireguard Axum HTTP V2 server on {bind_address}");
@@ -524,11 +524,8 @@ impl GatewayTasksBuilder {
524524
}
525525
});
526526

527-
let shutdown_handles = nym_wireguard_private_metadata_server::ShutdownHandles::new(
528-
server_handle,
529-
wg_handle,
530-
cancel_token,
531-
);
527+
let shutdown_handles =
528+
nym_wireguard_private_metadata_server::ShutdownHandles::new(server_handle, wg_handle);
532529

533530
Ok(shutdown_handles)
534531
}

service-providers/ip-packet-router/src/cli/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) async fn execute(args: &Run) -> Result<(), IpPacketRouterError> {
2828
log::debug!("Using config: {config:#?}");
2929

3030
log::info!("Starting ip packet router service provider");
31-
let mut shutdown_manager = ShutdownManager::build_new_default?;
31+
let mut shutdown_manager = ShutdownManager::build_new_default()?;
3232
let mut server = nym_ip_packet_router::IpPacketRouter::new(
3333
config,
3434
shutdown_manager.shutdown_tracker_owned(),

service-providers/ip-packet-router/src/ip_packet_router.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl IpPacketRouter {
155155

156156
let tun_listener = TunListener {
157157
tun_reader,
158-
task_client: task_handle.get_handle(),
158+
shutdown_token: self.shutdown.clone_shutdown_token(),
159159
connected_clients: connected_clients_rx,
160160
};
161161
tun_listener.start();
@@ -168,7 +168,7 @@ impl IpPacketRouter {
168168
request_filter: request_filter.clone(),
169169
tun_writer,
170170
mixnet_client,
171-
shutdown_token: task_handle,
171+
shutdown_token: self.shutdown.clone_shutdown_token(),
172172
connected_clients,
173173
};
174174

service-providers/ip-packet-router/src/tun_listener.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
use std::collections::HashMap;
55
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
66

7+
use crate::clients::{ConnectEvent, ConnectedClientEvent, DisconnectEvent};
8+
use crate::{error::Result, util::parse_ip::parse_dst_addr};
79
use nym_ip_packet_requests::IpPair;
10+
use nym_task::ShutdownToken;
811
#[cfg(target_os = "linux")]
912
use tokio::io::AsyncReadExt;
1013
use tokio::sync::mpsc;
1114

12-
use crate::clients::{ConnectEvent, ConnectedClientEvent, DisconnectEvent};
13-
use crate::{error::Result, util::parse_ip::parse_dst_addr};
14-
1515
// The TUN listener keeps a local map of the connected clients that has its state updated by the
1616
// mixnet listener. Basically it's just so that we don't have to have mutexes around shared state.
1717
// It's even ok if this is slightly out of date
@@ -78,7 +78,7 @@ impl ConnectedClientsListener {
7878
#[cfg(target_os = "linux")]
7979
pub(crate) struct TunListener {
8080
pub(crate) tun_reader: tokio::io::ReadHalf<tokio_tun::Tun>,
81-
pub(crate) task_client: TaskClient,
81+
pub(crate) shutdown_token: ShutdownToken,
8282
pub(crate) connected_clients: ConnectedClientsListener,
8383
}
8484

0 commit comments

Comments
 (0)