mirror of
https://github.com/jmcorgan/fips.git
synced 2026-10-05 19:18:25 +00:00
Give the connected-socket test helper one home
Carrying the in-line decrypt tests up brought a second copy of install_connected_udp with them: netmon's tests already had one, and the two differed only in which local address they bound. Both now call one helper alongside make_node, on the netmon copy's wildcard bind, so the suite that was already passing keeps the socket it was passing with.
This commit is contained in:
@@ -107,36 +107,6 @@ fn far_side_frame(session: &mut NoiseSession, receiver_idx: SessionIndex) -> Vec
|
|||||||
build_encrypted(&header, &ciphertext)
|
build_encrypted(&header, &ciphertext)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Install a real `connect()`-ed UDP socket on a peer, the way the
|
|
||||||
/// tick-driven activation in `dataplane::connected_udp` does.
|
|
||||||
///
|
|
||||||
/// The socket is opened against the loopback discard port: nothing is
|
|
||||||
/// ever sent through it, and the tests only care whether the handle is
|
|
||||||
/// still installed afterwards.
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
|
||||||
fn install_connected_udp(node: &mut Node, addr: &NodeAddr, transport_id: TransportId) {
|
|
||||||
let local: std::net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
|
||||||
let peer_sa: std::net::SocketAddr = "127.0.0.1:9".parse().unwrap();
|
|
||||||
|
|
||||||
let owned = crate::transport::udp::open_connected_fd(local, peer_sa, 65_536, 65_536)
|
|
||||||
.expect("open a connected UDP socket");
|
|
||||||
let socket = std::sync::Arc::new(crate::transport::udp::ConnectedPeerSocket::from_fd(
|
|
||||||
owned, peer_sa, local,
|
|
||||||
));
|
|
||||||
let (packet_tx, _packet_rx) = packet_channel(8);
|
|
||||||
let drain = crate::transport::udp::PeerRecvDrain::spawn(
|
|
||||||
socket.clone(),
|
|
||||||
transport_id,
|
|
||||||
peer_sa,
|
|
||||||
packet_tx,
|
|
||||||
)
|
|
||||||
.expect("spawn the peer recv drain");
|
|
||||||
|
|
||||||
node.get_peer_mut(addr)
|
|
||||||
.expect("peer present")
|
|
||||||
.set_connected_udp(socket, drain);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// **The defect.**
|
/// **The defect.**
|
||||||
///
|
///
|
||||||
/// The in-line decrypt path called `set_current_addr` as a bare
|
/// The in-line decrypt path called `set_current_addr` as a bare
|
||||||
|
|||||||
@@ -59,6 +59,39 @@ pub(super) fn make_node_with(config: Config) -> Node {
|
|||||||
Node::new(config).unwrap()
|
Node::new(config).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Install a real `connect()`-ed UDP socket on a peer, the way the tick-driven
|
||||||
|
/// activation in `dataplane::connected_udp` does.
|
||||||
|
///
|
||||||
|
/// The socket is opened against the loopback discard port: nothing is ever sent
|
||||||
|
/// through it, and the callers only care whether the handle is still installed
|
||||||
|
/// afterwards.
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
|
pub(super) fn install_connected_udp(
|
||||||
|
node: &mut Node,
|
||||||
|
addr: &NodeAddr,
|
||||||
|
transport_id: crate::transport::TransportId,
|
||||||
|
) {
|
||||||
|
let local: std::net::SocketAddr = "0.0.0.0:0".parse().unwrap();
|
||||||
|
let peer_sa: std::net::SocketAddr = "127.0.0.1:9".parse().unwrap();
|
||||||
|
|
||||||
|
let owned = crate::transport::udp::open_connected_fd(local, peer_sa, 65_536, 65_536)
|
||||||
|
.expect("open a connected UDP socket");
|
||||||
|
let bound = crate::transport::udp::ConnectedPeerSocket::from_fd(owned, peer_sa, local);
|
||||||
|
let socket = std::sync::Arc::new(bound);
|
||||||
|
let (packet_tx, _packet_rx) = packet_channel(8);
|
||||||
|
let drain = crate::transport::udp::PeerRecvDrain::spawn(
|
||||||
|
socket.clone(),
|
||||||
|
transport_id,
|
||||||
|
peer_sa,
|
||||||
|
packet_tx,
|
||||||
|
)
|
||||||
|
.expect("spawn the peer recv drain");
|
||||||
|
|
||||||
|
node.get_peer_mut(addr)
|
||||||
|
.expect("peer present")
|
||||||
|
.set_connected_udp(socket, drain);
|
||||||
|
}
|
||||||
|
|
||||||
/// Build a test node with an explicit `max_peers` limit (replaces the removed
|
/// Build a test node with an explicit `max_peers` limit (replaces the removed
|
||||||
/// `set_max_peers` setter; resource limits are immutable post-construction).
|
/// `set_max_peers` setter; resource limits are immutable post-construction).
|
||||||
pub(super) fn make_node_with_max_peers(max_peers: usize) -> Node {
|
pub(super) fn make_node_with_max_peers(max_peers: usize) -> Node {
|
||||||
|
|||||||
@@ -31,35 +31,6 @@ fn identity_of(nodes: &[TestNode], j: usize) -> PeerIdentity {
|
|||||||
PeerIdentity::from_pubkey_full(nodes[j].node.identity().pubkey_full())
|
PeerIdentity::from_pubkey_full(nodes[j].node.identity().pubkey_full())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Install a real `connect()`-ed UDP socket on a peer, the way the tick-driven
|
|
||||||
/// activation does.
|
|
||||||
///
|
|
||||||
/// The socket is opened against a discard port on loopback: nothing is ever
|
|
||||||
/// sent through it, and the test only cares whether the handle survives a
|
|
||||||
/// medium change.
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
|
||||||
fn install_connected_udp(node: &mut Node, addr: &NodeAddr, transport_id: TransportId) {
|
|
||||||
let local: std::net::SocketAddr = "0.0.0.0:0".parse().unwrap();
|
|
||||||
let peer_sa: std::net::SocketAddr = "127.0.0.1:9".parse().unwrap();
|
|
||||||
|
|
||||||
let owned = crate::transport::udp::open_connected_fd(local, peer_sa, 65_536, 65_536)
|
|
||||||
.expect("open a connected UDP socket");
|
|
||||||
let bound = crate::transport::udp::ConnectedPeerSocket::from_fd(owned, peer_sa, local);
|
|
||||||
let socket = std::sync::Arc::new(bound);
|
|
||||||
let (packet_tx, _packet_rx) = crate::transport::packet_channel(8);
|
|
||||||
let drain = crate::transport::udp::PeerRecvDrain::spawn(
|
|
||||||
socket.clone(),
|
|
||||||
transport_id,
|
|
||||||
peer_sa,
|
|
||||||
packet_tx,
|
|
||||||
)
|
|
||||||
.expect("spawn the peer recv drain");
|
|
||||||
|
|
||||||
node.get_peer_mut(addr)
|
|
||||||
.expect("peer present")
|
|
||||||
.set_connected_udp(socket, drain);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// **The defect this feature exists for.**
|
/// **The defect this feature exists for.**
|
||||||
///
|
///
|
||||||
/// Established UDP peers get a per-peer `connect()`-ed socket. `open_connected_fd`
|
/// Established UDP peers get a per-peer `connect()`-ed socket. `open_connected_fd`
|
||||||
|
|||||||
Reference in New Issue
Block a user