Skip to content

Commit

Permalink
use retry
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Aug 26, 2024
1 parent 149481e commit 3669f10
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub fn spawn_server_multi(
#[allow(clippy::too_many_arguments)]
async fn run_server(
name: &'static str,
incoming: Vec<Endpoint>,
endpoints: Vec<Endpoint>,
packet_sender: Sender<PacketBatch>,
exit: Arc<AtomicBool>,
max_connections_per_peer: usize,
Expand Down Expand Up @@ -268,7 +268,7 @@ async fn run_server(
));
stats
.quic_endpoints_count
.store(incoming.len(), Ordering::Relaxed);
.store(endpoints.len(), Ordering::Relaxed);
let staked_connection_table: Arc<Mutex<ConnectionTable>> =
Arc::new(Mutex::new(ConnectionTable::new()));
let (sender, receiver) = async_unbounded();
Expand All @@ -280,7 +280,7 @@ async fn run_server(
coalesce,
));

let mut accepts = incoming
let mut accepts = endpoints
.iter()
.enumerate()
.map(|(i, incoming)| {
Expand All @@ -296,7 +296,7 @@ async fn run_server(
if let Some((connecting, i)) = ready {
accepts.push(
Box::pin(EndpointAccept {
accept: incoming[i].accept(),
accept: endpoints[i].accept(),
endpoint: i,
}
));
Expand Down Expand Up @@ -354,6 +354,14 @@ async fn run_server(
continue;
}

// Use retry to make it harder to have stateless initial packet attack.
if !incoming.remote_address_validated() {
// The unwrap below is safe as we can only have error when the remote
// address is already validated.
incoming.retry().unwrap();
continue;
}

stats
.outstanding_incoming_connection_attempts
.fetch_add(1, Ordering::Relaxed);
Expand Down

0 comments on commit 3669f10

Please sign in to comment.