Skip to content

Commit

Permalink
fixup! Fix bridge ip logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Serock3 committed Jan 8, 2025
1 parent 4fcae68 commit b7a3697
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/test-manager/src/vm/network/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ pub(crate) fn find_vm_bridge(guest_ip: &Ipv4Addr) -> Result<(String, Ipv4Addr)>
.and_then(|addr| addr.as_sockaddr_in())
.map(|addr| SocketAddrV4::from(*addr).ip())
};
let address = SocketAddrV4::from(*address).ip();
let Some(netmask) = addr.netmask.as_ref().and_then(|addr| addr.as_sockaddr_in()) else {
continue;
if let (Some(address), Some(netmask)) =
(to_sock_addr(addr.address), to_sock_addr(addr.netmask))
{
if let Ok(ip_v4_network) = ipnetwork::Ipv4Network::with_netmask(*address, *netmask) {
if ip_v4_network.contains(*guest_ip) {
return Ok((addr.interface_name.to_owned(), *address));
}
};
};
let netmask = SocketAddrV4::from(*netmask).ip();
let Ok(ip_v4_network) = ipnetwork::Ipv4Network::with_netmask(address, netmask) else {
Expand Down

0 comments on commit b7a3697

Please sign in to comment.