From 5dfe8af0b6186be335e8e48382c696655f0e8880 Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Mon, 11 Nov 2024 22:29:43 +0100 Subject: [PATCH] network: bridge: add support for host_interface_name option Fixes containers/netavark#24523 Signed-off-by: Michael Zimmermann --- src/network/bridge.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/network/bridge.rs b/src/network/bridge.rs index cc003f926..479c24bf6 100644 --- a/src/network/bridge.rs +++ b/src/network/bridge.rs @@ -38,6 +38,8 @@ const NO_BRIDGE_NAME_ERROR: &str = "no bridge interface name given"; struct InternalData { /// interface name of the veth pair inside the container netns container_interface_name: String, + /// interace name of the veth pair in the host netns + host_interface_name: String, /// interface name of the bridge for on the host bridge_interface_name: String, /// static mac address @@ -95,6 +97,13 @@ impl driver::NetworkDriver for Bridge<'_> { self.data = Some(InternalData { bridge_interface_name: bridge_name, container_interface_name: self.info.per_network_opts.interface_name.clone(), + host_interface_name: self + .info + .per_network_opts + .options + .get("host_interface_name") + .cloned() + .unwrap_or_else(|| "".to_string()), mac_address: static_mac, ipam, mtu, @@ -647,7 +656,8 @@ fn create_veth_pair<'fd>( let mut peer = LinkMessage::default(); netlink::parse_create_link_options(&mut peer, peer_opts); - let mut host_veth = netlink::CreateLinkOptions::new(String::from(""), InfoKind::Veth); + let mut host_veth = + netlink::CreateLinkOptions::new(data.host_interface_name.clone(), InfoKind::Veth); host_veth.mtu = data.mtu; host_veth.primary_index = primary_index; host_veth.info_data = Some(InfoData::Veth(InfoVeth::Peer(peer)));