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 @@ -217,6 +217,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 @@ -277,11 +278,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 @@ -560,6 +560,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 @@ -2534,7 +2534,7 @@ impl Display for MessageParseError {
mod tests {
use super::*;
use mg_api_types::rdb::prefix::Prefix;
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 @@ -2589,7 +2589,7 @@ mod tests {
};

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

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

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

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

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

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

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

let um1 =
update_message_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 @@ -248,12 +248,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