Skip to content

Commit

Permalink
network: bridge: add support for host_interface_name option
Browse files Browse the repository at this point in the history
Fixes containers/netavark#24523

Signed-off-by: Michael Zimmermann <[email protected]>
  • Loading branch information
M1cha committed Nov 11, 2024
1 parent dfcbea6 commit 5dfe8af
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/network/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)));
Expand Down

0 comments on commit 5dfe8af

Please sign in to comment.