Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bc2a894c00c9
Choose a base ref
...
head repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bf916e68321a
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 24, 2017

  1. Copy the full SHA
    d9458c0 View commit details

Commits on Aug 25, 2017

  1. Make TCP packets not matching socket state return Error::Dropped.

    Error::Malformed is only for internally inconsistent packets,
    like SYN|FIN.
    whitequark committed Aug 25, 2017
    Copy the full SHA
    bf916e6 View commit details
Showing with 8 additions and 8 deletions.
  1. +1 −1 src/phy/sys/tap_interface.rs
  2. +7 −7 src/socket/tcp.rs
2 changes: 1 addition & 1 deletion src/phy/sys/tap_interface.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ pub struct TapInterfaceDesc {
impl TapInterfaceDesc {
pub fn new(name: &str) -> io::Result<TapInterfaceDesc> {
let lower = unsafe {
let lower = libc::open("/dev/net/tun".as_ptr() as *const libc::c_char,
let lower = libc::open("/dev/net/tun\0".as_ptr() as *const libc::c_char,
libc::O_RDWR);
if lower == -1 { return Err(io::Error::last_os_error()) }
lower
14 changes: 7 additions & 7 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -766,15 +766,15 @@ impl<'a> TcpSocket<'a> {
net_debug!("[{}]{}:{}: unacceptable RST (expecting RST|ACK) \
in response to initial SYN",
self.debug_id, self.local_endpoint, self.remote_endpoint);
return Err(Error::Malformed)
return Err(Error::Dropped)
}
(State::SynSent, TcpRepr {
control: TcpControl::Rst, ack_number: Some(ack_number), ..
}) => {
if ack_number != self.local_seq_no + 1 {
net_debug!("[{}]{}:{}: unacceptable RST|ACK in response to initial SYN",
self.debug_id, self.local_endpoint, self.remote_endpoint);
return Err(Error::Malformed)
return Err(Error::Dropped)
}
}
// Any other RST need only have a valid sequence number.
@@ -787,7 +787,7 @@ impl<'a> TcpSocket<'a> {
(_, TcpRepr { ack_number: None, .. }) => {
net_debug!("[{}]{}:{}: expecting an ACK",
self.debug_id, self.local_endpoint, self.remote_endpoint);
return Err(Error::Malformed)
return Err(Error::Dropped)
}
// Every acknowledgement must be for transmitted but unacknowledged data.
(_, TcpRepr { ack_number: Some(ack_number), .. }) => {
@@ -1023,7 +1023,7 @@ impl<'a> TcpSocket<'a> {
_ => {
net_debug!("[{}]{}:{}: unexpected packet {}",
self.debug_id, self.local_endpoint, self.remote_endpoint, repr);
return Err(Error::Malformed)
return Err(Error::Dropped)
}
}

@@ -1793,7 +1793,7 @@ mod test {
seq_number: REMOTE_SEQ,
ack_number: None,
..SEND_TEMPL
}, Err(Error::Malformed));
}, Err(Error::Dropped));
assert_eq!(s.state, State::SynSent);
}

@@ -1805,7 +1805,7 @@ mod test {
seq_number: REMOTE_SEQ,
ack_number: Some(TcpSeqNumber(1234)),
..SEND_TEMPL
}, Err(Error::Malformed));
}, Err(Error::Dropped));
assert_eq!(s.state, State::SynSent);
}

@@ -1919,7 +1919,7 @@ mod test {
seq_number: REMOTE_SEQ + 1,
ack_number: None,
..SEND_TEMPL
}, Err(Error::Malformed));
}, Err(Error::Dropped));
}

#[test]