Skip to main content

create_veth_pair

Function create_veth_pair 

Source
pub async fn create_veth_pair(
    host_name: &str,
    peer_name: &str,
) -> Result<(), NetlinkError>
Expand description

Create a veth pair with the two ends named host_name and peer_name.

Both ends start in the current network namespace. The caller is responsible for moving the peer end into the container netns (see move_link_into_netns_and_rename) and bringing the host end up (see set_link_up_by_name).

Replaces the shell-out: ip link add <host_name> type veth peer name <peer_name>

§Errors

Returns NetlinkError::Netlink if RTNETLINK fails for any reason. EEXIST / “File exists” is surfaced verbatim so the caller can distinguish a leaked endpoint (typically a sign the orphan sweeper missed something) from a permission or interface-name problem.