Drop packet if destination is unspecified (0.0.0.0/0) (#8321)

This commit is contained in:
Pankaj Garg
2020-02-18 16:14:20 -08:00
committed by GitHub
parent 73a278dc64
commit ac1d075d73
2 changed files with 30 additions and 18 deletions

View File

@ -85,8 +85,12 @@ pub fn to_packets_with_destination<T: Serialize>(
);
out.packets.resize(dests_and_data.len(), Packet::default());
for (dest_and_data, o) in dests_and_data.iter().zip(out.packets.iter_mut()) {
if let Err(e) = Packet::populate_packet(o, Some(&dest_and_data.0), &dest_and_data.1) {
error!("Couldn't write to packet {:?}. Data skipped.", e);
if !dest_and_data.0.ip().is_unspecified() && dest_and_data.0.port() != 0 {
if let Err(e) = Packet::populate_packet(o, Some(&dest_and_data.0), &dest_and_data.1) {
error!("Couldn't write to packet {:?}. Data skipped.", e);
}
} else {
trace!("Dropping packet, as destination is unknown");
}
}
out