Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1778: Double mdns recv_buffer to 4096 bytes #1779

Merged
merged 2 commits into from
Oct 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions protocols/mdns/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use dns_parser::{Packet, RData};
use either::Either::{Left, Right};
use futures::{future, prelude::*};
use libp2p_core::{multiaddr::{Multiaddr, Protocol}, PeerId};
use log::warn;
use std::{convert::TryFrom as _, fmt, io, net::Ipv4Addr, net::SocketAddr, str, time::{Duration, Instant}};
use wasm_timer::Interval;
use lazy_static::lazy_static;
Expand Down Expand Up @@ -122,7 +123,12 @@ pub struct $service_name {
/// regularly to recover from errors. Otherwise we could simply use an `Option<Interval>`.
silent: bool,
/// Buffer used for receiving data from the main socket.
recv_buffer: [u8; 2048],
/// RFC6762 discourages packets larger than the interface MTU, but allows sizes of up to 9000
/// bytes, if it can be ensured that all participating devices can handle such large packets.
/// For computers with several interfaces and IP addresses responses can easily reach sizes in
/// the range of 3000 bytes, so 4096 seems sensible for now. For more information see
/// [rfc6762](https://tools.ietf.org/html/rfc6762#page-46).
recv_buffer: [u8; 4096],
/// Buffers pending to send on the main socket.
send_buffers: Vec<Vec<u8>>,
/// Buffers pending to send on the query socket.
Expand Down Expand Up @@ -173,7 +179,7 @@ impl $service_name {
query_socket,
query_interval: Interval::new_at(Instant::now(), Duration::from_secs(20)),
silent,
recv_buffer: [0; 2048],
recv_buffer: [0; 4096],
send_buffers: Vec::new(),
query_send_buffers: Vec::new(),
})
Expand Down Expand Up @@ -346,7 +352,8 @@ impl MdnsPacket {
return Some(resp);
}
}
Err(_) => {
Err(err) => {
warn!("Parsing mdns packet failed: {:?}", err);
return None;
}
}
Expand Down