Skip to content

Commit

Permalink
Completely reset the socket on MismatchedSrcIp
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKoch committed Aug 1, 2024
1 parent 1bdf544 commit 8d6bdde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/iface/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl Interface {

enum EgressError {
Exhausted,
MismatchingSrcIp,
MismatchedSrcIp,
Dispatch,
}

Expand All @@ -593,7 +593,7 @@ impl Interface {

if !inner.has_ip_addr(response.ip_repr().src_addr()) {
net_debug!("failed to transmit IP: mismatched src addr");
return Err(EgressError::MismatchingSrcIp);
return Err(EgressError::MismatchedSrcIp);
}

let t = device.transmit(inner.now).ok_or_else(|| {
Expand Down Expand Up @@ -652,9 +652,10 @@ impl Interface {
Packet::new(ip, IpPayload::Tcp(tcp)),
)
}) {
Err(EgressError::MismatchingSrcIp) => {
socket.close();
Err(EgressError::MismatchingSrcIp)
Err(EgressError::MismatchedSrcIp) => {
// FIXME: Should this be `close()` or `abort()`?
socket.reset();
Err(EgressError::MismatchedSrcIp)
}
r => r,
},
Expand Down Expand Up @@ -690,7 +691,7 @@ impl Interface {
neighbor_addr.expect("non-IP response packet"),
);
}
Err(EgressError::MismatchingSrcIp) => {}
Err(EgressError::MismatchedSrcIp) => {},
Ok(()) => {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ impl<'a> Socket<'a> {
self.state
}

fn reset(&mut self) {
pub fn reset(&mut self) {
let rx_cap_log2 =
mem::size_of::<usize>() * 8 - self.rx_buffer.capacity().leading_zeros() as usize;

Expand Down

0 comments on commit 8d6bdde

Please sign in to comment.