Skip to content
Open
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions bfd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ pub enum AddPeerError {
#[cfg(test)]
mod test {
use super::*;
use mg_common::eprintln_nopipe;
use pretty_assertions::assert_eq;
use slog::Drain;
use std::net::IpAddr;
Expand Down Expand Up @@ -311,11 +312,11 @@ mod test {
tx.send((addr, msg)).unwrap();
}
None => {
eprintln!("no egress for {}", addr);
eprintln_nopipe!("no egress for {}", addr);
}
},
Err(e) => {
eprintln!("recv: {}", e);
eprintln_nopipe!("recv: {}", e);
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion bgp/src/connection_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl std::fmt::Display for Network {
#[derive(Debug)]
struct Listener {
rx: Receiver<(SocketAddr, Endpoint<Message>)>,
addr: SocketAddr,
}

impl Listener {
Expand All @@ -98,6 +99,12 @@ impl Listener {
}
}

impl Drop for Listener {
fn drop(&mut self) {
NET.unbind(&self.addr);
}
}

// NOTE: this is not designed to be a full fidelity TCP/IP drop in. It gives
// us enough functionality to pass messages between BGP routers to test
// state machine transitions above TCP connection tracking. That's all we're
Expand All @@ -113,7 +120,12 @@ impl Network {
fn bind(&self, sa: SocketAddr) -> Listener {
let (tx, rx) = mpsc_channel();
lock!(self.endpoints).insert(sa, tx);
Listener { rx }
Listener { rx, addr: sa }
}

/// Remove a bound address from the network.
fn unbind(&self, addr: &SocketAddr) {
lock!(self.endpoints).remove(addr);
}

/// Send a copy of the provided endpoint to the endpoint identified by the
Expand Down
2 changes: 2 additions & 0 deletions bgp/src/connection_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ impl BgpConnectionTcp {
direction: ConnectionDirection,
config: &SessionInfo,
) -> Result<Self, Error> {
conn.set_nodelay(true)?;

let id = ConnectionId::new(source, peer);

let dropped = Arc::new(AtomicBool::new(false));
Expand Down
10 changes: 5 additions & 5 deletions bgp/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5949,7 +5949,7 @@ impl From<PathAttribute> for Option<PathAttributeV1> {
#[cfg(test)]
mod tests {
use super::*;
use mg_common::{cidr, ip, parse};
use mg_common::{cidr, ip, parse, println_nopipe};
use pretty_assertions::assert_eq;
use pretty_hex::*;
use std::net::{Ipv4Addr, Ipv6Addr};
Expand Down Expand Up @@ -6004,7 +6004,7 @@ mod tests {
};

let buf = h0.to_wire();
println!("buf: {}", buf.hex_dump());
println_nopipe!("buf: {}", buf.hex_dump());

assert_eq!(
buf,
Expand All @@ -6025,7 +6025,7 @@ mod tests {
let om0 = OpenMessage::new4(395849, 0x1234, 0xaabbccdd, false);

let buf = om0.to_wire().expect("open message to wire");
println!("buf: {}", buf.hex_dump());
println_nopipe!("buf: {}", buf.hex_dump());

let om1 = OpenMessage::from_wire(&buf).expect("open message from wire");
assert_eq!(om0, om1);
Expand All @@ -6036,7 +6036,7 @@ mod tests {
let om0 = OpenMessage::new4(395849, 0x1234, 0xaabbccdd, true);

let buf = om0.to_wire().expect("open message to wire");
println!("buf: {}", buf.hex_dump());
println_nopipe!("buf: {}", buf.hex_dump());

let om1 = OpenMessage::from_wire(&buf).expect("open message from wire");
assert_eq!(om0, om1);
Expand Down Expand Up @@ -6085,7 +6085,7 @@ mod tests {
};

let buf = um0.to_wire().expect("update message to wire");
println!("buf: {}", buf.hex_dump());
println_nopipe!("buf: {}", buf.hex_dump());

let um1 =
UpdateMessage::from_wire(&buf).expect("update message from wire");
Expand Down
7 changes: 4 additions & 3 deletions bgp/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,13 @@ pub fn new_rhai_engine() -> Engine {

#[cfg(debug_assertions)]
{
println!("Functions registered:");
use mg_common::println_nopipe;
println_nopipe!("Functions registered:");
engine
.gen_fn_signatures(false)
.into_iter()
.for_each(|func| println!("{func}"));
println!();
.for_each(|func| println_nopipe!("{func}"));
println_nopipe!();
}

engine
Expand Down
Loading